示例#1
0
        public static FieldDto FromDomain(RootField field)
        {
            var properties = FieldPropertiesDtoFactory.Create(field.RawProperties);

            var result =
                SimpleMapper.Map(field,
                                 new FieldDto
            {
                FieldId      = field.Id,
                Properties   = properties,
                Partitioning = field.Partitioning.Key
            });

            if (field is IArrayField arrayField)
            {
                result.Nested = new List <NestedFieldDto>();

                foreach (var nestedField in arrayField.Fields)
                {
                    result.Nested.Add(FromDomain(nestedField));
                }
            }

            return(result);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        public static NestedFieldDto FromField(NestedField field)
        {
            var properties = FieldPropertiesDtoFactory.Create(field.RawProperties);

            var result =
                SimpleMapper.Map(field,
                                 new NestedFieldDto
            {
                Properties = properties
            });

            return(result);
        }