@@ -12,11 +12,12 @@ import { SitePolygonLightDto } from "./dto/site-polygon.dto";
1212import { populateDto } from "@terramatch-microservices/common/dto/json-api-attributes" ;
1313import { ValidationDto } from "../validations/dto/validation.dto" ;
1414import { FeatureCollection } from "geojson" ;
15- import { Feature , CreateSitePolygonRequestDto , AttributeChangesDto } from "./dto/create-site-polygon-request.dto" ;
15+ import { Feature , CreateSitePolygonRequestDto } from "./dto/create-site-polygon-request.dto" ;
1616import { SitePolygon } from "@terramatch-microservices/database/entities" ;
1717import { Op } from "sequelize" ;
1818import { BadRequestException } from "@nestjs/common" ;
1919import { validateSitePolygonProperties } from "./utils/site-polygon-property-validator" ;
20+ import { convertPropertiesToAttributeChanges } from "./utils/attribute-changes-converter" ;
2021import { CriteriaId , ValidationType } from "@terramatch-microservices/database/constants" ;
2122
2223export interface GeometryUploadJobData {
@@ -247,7 +248,7 @@ export class GeometryUploadProcessor extends DelayedJobWorker<GeometryUploadJobD
247248 }
248249
249250 const validatedProperties = validateSitePolygonProperties ( allProperties ) ;
250- const attributeChanges = this . convertPropertiesToAttributeChanges ( validatedProperties ) ;
251+ const attributeChanges = convertPropertiesToAttributeChanges ( validatedProperties ) ;
251252
252253 const uploadedPolyName = attributeChanges . polyName ?? attributeChanges . poly_name ;
253254 const basePolyName = basePolygon . polyName ?? null ;
@@ -318,40 +319,4 @@ export class GeometryUploadProcessor extends DelayedJobWorker<GeometryUploadJobD
318319 payload : document
319320 } ;
320321 }
321-
322- private convertPropertiesToAttributeChanges ( properties : Partial < SitePolygon > ) : AttributeChangesDto {
323- const attributeChanges : AttributeChangesDto = { } ;
324-
325- if ( properties . polyName != null ) {
326- attributeChanges . polyName = properties . polyName ;
327- attributeChanges . poly_name = properties . polyName ;
328- }
329-
330- if ( properties . plantStart != null ) {
331- const plantStartString =
332- properties . plantStart instanceof Date ? properties . plantStart . toISOString ( ) : String ( properties . plantStart ) ;
333- attributeChanges . plantStart = plantStartString ;
334- attributeChanges . plantstart = plantStartString ;
335- }
336-
337- if ( properties . practice != null && properties . practice . length > 0 ) {
338- attributeChanges . practice = properties . practice ;
339- }
340-
341- if ( properties . targetSys != null ) {
342- attributeChanges . targetSys = properties . targetSys ;
343- attributeChanges . target_sys = properties . targetSys ;
344- }
345-
346- if ( properties . distr != null && properties . distr . length > 0 ) {
347- attributeChanges . distr = properties . distr ;
348- }
349-
350- if ( properties . numTrees != null ) {
351- attributeChanges . numTrees = properties . numTrees ;
352- attributeChanges . num_trees = properties . numTrees ;
353- }
354-
355- return attributeChanges ;
356- }
357322}
0 commit comments