protected override IEnumerable <MetadataMapping> CreateMappings() { Log.Info("Creating XSD Lookup to Json data mappings"); var typeNames = XmlMetadata.Select(x => x.Type).Distinct().Where(x => _lookupTypeRegex.IsMatch(x)); var mappings = typeNames.Select( x => new MetadataMapping { RootName = _lookupTypeRegex.Match(x).Groups["TypeName"].Value, SourceName = x, TargetName = $"edFi_{_lookupTypeRegex.Match(x).Groups["TypeName"].Value.ToCamelCase(CultureInfo.CurrentCulture)}" }).ToArray(); return(mappings); }
protected override IEnumerable <MetadataMapping> CreateMappings() { Log.Info("Creating XSD Resource to Json Identity data mappings"); var typeNames = XmlMetadata.Select(x => x.Type).Distinct().Where(x => _typeRegex.IsMatch(x)); var mappings = typeNames.Select( x => { var typeName = _typeRegex.Match(x).Groups["TypeName"].Value; return(new MetadataMapping { RootName = typeName, SourceName = x, //xml TargetName = Inflector.MakeInitialLowerCase(typeName) //json }); }).ToArray(); return(mappings); }
protected override IEnumerable <MetadataMapping> CreateMappings() { Log.Info("Creating XSD to Json data mappings"); var mappings = new List <MetadataMapping>(); var jsonModels = JsonMetadata.Select(x => x.Model).Distinct() .Where(x => !JsonMetadata.Select(y => y.Type).Contains(x) && !string.IsNullOrEmpty(x)) .ToArray(); var xmlModels = XmlMetadata.Select(x => x.Model).Distinct() .Where(x => !XmlMetadata.Select(y => y.Type).Contains(x)) .ToArray(); var maps = xmlModels.SelectMany( x => jsonModels.Select( j => new { x, j, m = x.PercentMatchTo(j) } )).OrderByDescending(o => o.m).ToList(); while (maps.Count > 0) { var map = maps.First(); // Useful if you want to only look at one mapping //if (map.x == "Account") //{ mappings.Add( new MetadataMapping { SourceName = map.x, TargetName = map.j, RootName = map.x }); //} maps.RemoveAll(x => x.x == map.x || x.j == map.j); } return(mappings); }