public static SchemaDetailsDto FromSchema(ISchemaEntity schema) { var response = new SchemaDetailsDto { Properties = new SchemaPropertiesDto() }; SimpleMapper.Map(schema, response); SimpleMapper.Map(schema.SchemaDef, response); SimpleMapper.Map(schema.SchemaDef.Properties, response.Properties); response.Fields = new List <FieldDto>(); foreach (var field in schema.SchemaDef.Fields) { var fieldPropertiesDto = FieldPropertiesDtoFactory.Create(field.RawProperties); var fieldInstanceDto = SimpleMapper.Map(field, new FieldDto { FieldId = field.Id, Properties = fieldPropertiesDto, Partitioning = field.Partitioning.Key }); response.Fields.Add(fieldInstanceDto); } return(response); }
public static SchemaDetailsDto FromSchemaWithDetails(ISchemaEntity schema, ApiController controller, string app) { var result = new SchemaDetailsDto(); SimpleMapper.Map(schema, result); SimpleMapper.Map(schema.SchemaDef, result); SimpleMapper.Map(schema.SchemaDef.Scripts, result.Scripts); SimpleMapper.Map(schema.SchemaDef.Properties, result.Properties); if (schema.SchemaDef.PreviewUrls.Count > 0) { result.PreviewUrls = new Dictionary <string, string>(schema.SchemaDef.PreviewUrls); } result.Fields = new List <FieldDto>(); foreach (var field in schema.SchemaDef.Fields) { result.Fields.Add(FieldDto.FromField(field)); } result.CreateLinks(controller, app); return(result); }
public static SchemaDetailsDto FromSchemaWithDetails(ISchemaEntity schema, Resources resources) { var result = new SchemaDetailsDto(); SimpleMapper.Map(schema, result); SimpleMapper.Map(schema.SchemaDef, result); SimpleMapper.Map(schema.SchemaDef.Scripts, result.Scripts); SimpleMapper.Map(schema.SchemaDef.Properties, result.Properties); result.FieldsInLists = schema.SchemaDef.FieldsInLists.ToList(); result.FieldsInReferences = schema.SchemaDef.FieldsInReferences.ToList(); result.FieldRules = schema.SchemaDef.FieldRules.Select(FieldRuleDto.FromFieldRule).ToList(); if (schema.SchemaDef.PreviewUrls.Count > 0) { result.PreviewUrls = new Dictionary <string, string>(schema.SchemaDef.PreviewUrls); } result.Fields = new List <FieldDto>(); foreach (var field in schema.SchemaDef.Fields) { result.Fields.Add(FieldDto.FromField(field)); } result.CreateLinks(resources); return(result); }
public static SchemaDetailsDto FromSchemaWithDetails(ISchemaEntity schema, ApiController controller, string app) { var result = new SchemaDetailsDto(); SimpleMapper.Map(schema, result); SimpleMapper.Map(schema.SchemaDef, result); SimpleMapper.Map(schema.SchemaDef.Scripts, result.Scripts); SimpleMapper.Map(schema.SchemaDef.Properties, result.Properties); if (schema.SchemaDef.PreviewUrls.Count > 0) { result.PreviewUrls = new Dictionary <string, string>(schema.SchemaDef.PreviewUrls); } result.Fields = new List <FieldDto>(); foreach (var field in schema.SchemaDef.Fields) { var fieldPropertiesDto = FieldPropertiesDtoFactory.Create(field.RawProperties); var fieldDto = SimpleMapper.Map(field, new FieldDto { FieldId = field.Id, Properties = fieldPropertiesDto, Partitioning = field.Partitioning.Key }); if (field is IArrayField arrayField) { fieldDto.Nested = new List <NestedFieldDto>(); foreach (var nestedField in arrayField.Fields) { var nestedFieldPropertiesDto = FieldPropertiesDtoFactory.Create(nestedField.RawProperties); var nestedFieldDto = SimpleMapper.Map(nestedField, new NestedFieldDto { FieldId = nestedField.Id, Properties = nestedFieldPropertiesDto }); fieldDto.Nested.Add(nestedFieldDto); } } result.Fields.Add(fieldDto); } result.CreateLinks(controller, app); return(result); }