diff --git a/src/models/common/decorators/fieldConfig/fieldConfig.decorator.ts b/src/models/common/decorators/fieldConfig/fieldConfig.decorator.ts index 0b1bbcf..237593c 100644 --- a/src/models/common/decorators/fieldConfig/fieldConfig.decorator.ts +++ b/src/models/common/decorators/fieldConfig/fieldConfig.decorator.ts @@ -39,6 +39,7 @@ export interface IFieldConfigInfo { infoMsgCode?: string[]; validation?: IValidationConfigInfo[]; default?: string | number; + shapeFileMapping?: string; } export interface IPropFieldConfigInfo extends IFieldConfigInfo { diff --git a/src/models/index.ts b/src/models/index.ts index 1f2af25..5262b51 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -5,3 +5,4 @@ export * from './discreteIngestion/index'; export * from './pycsw/index'; export * from './rasterCatalog/index'; export * from './3dCatalog/index'; +export * from './polygonParts/index'; diff --git a/src/models/layerMetadata/bestMetadata.ts b/src/models/layerMetadata/bestMetadata.ts index 9d8a0b6..42a1024 100644 --- a/src/models/layerMetadata/bestMetadata.ts +++ b/src/models/layerMetadata/bestMetadata.ts @@ -11,9 +11,9 @@ import { import { RecordType } from '../pycsw/coreEnums'; import { IMetadataCommonModel } from './interfaces/metadataCommonModel'; import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/property/csw.decorator'; -import { getInputDataMapping, IDataMapping, DataFileType, inputDataMapping } from './decorators/property/shp.decorator'; +import { getInputDataMapping, IDataMapping, DataFileType, inputDataMapping, IPropSHPMapping } from './decorators/property/shp.decorator'; import { getCatalogDBMapping, ICatalogDBMapping, catalogDB } from './decorators/property/catalogDB.decorator'; -import { getTsTypesMapping, ITsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; +import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { ProductType } from './enums'; import { DiscreteOrder } from './discreteOrder'; @@ -24,9 +24,6 @@ export interface IBestMetadata { scale: number | undefined; discretes: DiscreteOrder[] | undefined; } -export interface IPropSHPMapping extends IDataMapping, ITsTypesMapping { - prop: string; -} export interface IPropPYCSWMapping extends IPYCSWMapping { prop: string; diff --git a/src/models/layerMetadata/decorators/property/shp.decorator.ts b/src/models/layerMetadata/decorators/property/shp.decorator.ts index 4133cac..7aa8c0f 100644 --- a/src/models/layerMetadata/decorators/property/shp.decorator.ts +++ b/src/models/layerMetadata/decorators/property/shp.decorator.ts @@ -1,4 +1,5 @@ import 'reflect-metadata'; +import { ITsTypesMapping } from './tsTypes.decorator'; const inputDataMappingMetadataKey = Symbol('inputDataMapping'); @@ -15,6 +16,10 @@ export enum DataFileType { TFW = 'TFW', } +export interface IPropSHPMapping extends IDataMapping, ITsTypesMapping { + prop: string; +} + export function inputDataMapping(dataMapping: IDataMapping): PropertyDecorator { return Reflect.metadata(inputDataMappingMetadataKey, dataMapping); } diff --git a/src/models/layerMetadata/layerMetadata.ts b/src/models/layerMetadata/layerMetadata.ts index ac4889c..e48e779 100644 --- a/src/models/layerMetadata/layerMetadata.ts +++ b/src/models/layerMetadata/layerMetadata.ts @@ -12,9 +12,9 @@ import { import { RecordType } from '../pycsw/coreEnums'; import { IMetadataCommonModel } from './interfaces/metadataCommonModel'; import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/property/csw.decorator'; -import { getInputDataMapping, IDataMapping, DataFileType, inputDataMapping } from './decorators/property/shp.decorator'; +import { getInputDataMapping, IDataMapping, DataFileType, inputDataMapping, IPropSHPMapping } from './decorators/property/shp.decorator'; import { getCatalogDBMapping, ICatalogDBMapping, catalogDB, ORMColumnType } from './decorators/property/catalogDB.decorator'; -import { getTsTypesMapping, ITsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; +import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { ProductType, Transparency, TileOutputFormat } from './enums'; export interface ILayerMetadata { @@ -29,9 +29,6 @@ export interface ILayerMetadata { region: string[] | undefined; sensors: string[] | undefined; } -export interface IPropSHPMapping extends IDataMapping, ITsTypesMapping { - prop: string; -} export interface IPropPYCSWMapping extends IPYCSWMapping { prop: string; diff --git a/src/models/layerMetadata/pycsw3DCatalogRecord.ts b/src/models/layerMetadata/pycsw3DCatalogRecord.ts index 1983cf0..41d32d0 100644 --- a/src/models/layerMetadata/pycsw3DCatalogRecord.ts +++ b/src/models/layerMetadata/pycsw3DCatalogRecord.ts @@ -11,6 +11,7 @@ import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } f import { getPyCSWMapping, pycsw } from './decorators/property/csw.decorator'; import { Layer3DMetadata, IPropPYCSWMapping } from './layer3DMetadata'; import { Link } from './link'; +import { IPropSHPMapping } from './decorators/property/shp.decorator'; @catalogDBEntity({ table: 'records', @@ -286,6 +287,10 @@ export class Pycsw3DCatalogRecord extends Layer3DMetadata implements IPycswCoreM return ret; } + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + return []; + } + public getORMCatalogMappings(): IPropCatalogDBMapping[] { const ret = []; diff --git a/src/models/layerMetadata/pycswBestCatalogRecord.ts b/src/models/layerMetadata/pycswBestCatalogRecord.ts index 39ec96c..1876885 100644 --- a/src/models/layerMetadata/pycswBestCatalogRecord.ts +++ b/src/models/layerMetadata/pycswBestCatalogRecord.ts @@ -11,6 +11,7 @@ import { getTsTypesMapping, TsTypes, tsTypes } from './decorators/property/tsTyp import { IPropPYCSWMapping, BestMetadata } from './bestMetadata'; import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } from './decorators/class/catalogDBEntity.decorator'; import { getPyCSWMapping, pycsw } from './decorators/property/csw.decorator'; +import { IPropSHPMapping } from './decorators/property/shp.decorator'; @catalogDBEntity({ table: 'records', @@ -272,6 +273,10 @@ export class PycswBestCatalogRecord extends BestMetadata implements IPycswCoreMo return ret as IPropFieldConfigInfo[]; } + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + return []; + } + public getORMCatalogMappings(): IPropCatalogDBMapping[] { const ret = []; diff --git a/src/models/layerMetadata/pycswDEMCatalogRecord.ts b/src/models/layerMetadata/pycswDEMCatalogRecord.ts index c727b2a..32f4c27 100644 --- a/src/models/layerMetadata/pycswDEMCatalogRecord.ts +++ b/src/models/layerMetadata/pycswDEMCatalogRecord.ts @@ -11,6 +11,7 @@ import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } f import { getPyCSWMapping, pycsw } from './decorators/property/csw.decorator'; import { LayerDemMetadata, IPropPYCSWMapping } from './layerDEMMetadata'; import { Link } from './link'; +import { IPropSHPMapping } from './decorators/property/shp.decorator'; @catalogDBEntity({ table: 'records', @@ -283,6 +284,10 @@ export class PycswDemCatalogRecord extends LayerDemMetadata implements IPycswCor return ret; } + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + return []; + } + public getORMCatalogMappings(): IPropCatalogDBMapping[] { const ret = []; diff --git a/src/models/layerMetadata/pycswLayerCatalogRecord.ts b/src/models/layerMetadata/pycswLayerCatalogRecord.ts index 2e548fe..c87f216 100644 --- a/src/models/layerMetadata/pycswLayerCatalogRecord.ts +++ b/src/models/layerMetadata/pycswLayerCatalogRecord.ts @@ -11,6 +11,7 @@ import { getTsTypesMapping, TsTypes, tsTypes } from './decorators/property/tsTyp import { IPropPYCSWMapping, LayerMetadata } from './layerMetadata'; import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } from './decorators/class/catalogDBEntity.decorator'; import { getPyCSWMapping, pycsw } from './decorators/property/csw.decorator'; +import { IPropSHPMapping } from './decorators/property/shp.decorator'; @catalogDBEntity({ table: 'records', @@ -245,6 +246,10 @@ export class PycswLayerCatalogRecord extends LayerMetadata implements IPycswCore return ret as IPropFieldConfigInfo[]; } + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + return []; + } + public getORMCatalogMappings(): IPropCatalogDBMapping[] { const ret = []; diff --git a/src/models/layerMetadata/pycswQuantizedMeshBestCatalogRecord.ts b/src/models/layerMetadata/pycswQuantizedMeshBestCatalogRecord.ts index aea22cf..7a6598d 100644 --- a/src/models/layerMetadata/pycswQuantizedMeshBestCatalogRecord.ts +++ b/src/models/layerMetadata/pycswQuantizedMeshBestCatalogRecord.ts @@ -11,6 +11,7 @@ import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } f import { getPyCSWMapping, pycsw } from './decorators/property/csw.decorator'; import { QuantizedMeshBestMetadata, IPropPYCSWMapping } from './quantizedMeshBestMetadata'; import { Link } from './link'; +import { IPropSHPMapping } from './decorators/property/shp.decorator'; @catalogDBEntity({ table: 'records', @@ -276,6 +277,10 @@ export class PycswQuantizedMeshBestCatalogRecord extends QuantizedMeshBestMetada return ret; } + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + return []; + } + public getORMCatalogMappings(): IPropCatalogDBMapping[] { const ret = []; diff --git a/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts b/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts index 2cbf4c2..fb7cbc6 100644 --- a/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts +++ b/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts @@ -11,6 +11,7 @@ import { getTsTypesMapping, TsTypes, tsTypes } from './decorators/property/tsTyp import { IPropPYCSWMapping, VectorBestMetadata } from './vectorBestMetadata'; import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } from './decorators/class/catalogDBEntity.decorator'; import { getPyCSWMapping, pycsw } from './decorators/property/csw.decorator'; +import { IPropSHPMapping } from './decorators/property/shp.decorator'; @catalogDBEntity({ table: 'records', @@ -272,6 +273,10 @@ export class PycswVectorBestCatalogRecord extends VectorBestMetadata implements return ret as IPropFieldConfigInfo[]; } + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + return []; + } + public getORMCatalogMappings(): IPropCatalogDBMapping[] { const ret = []; diff --git a/src/models/layerMetadata/quantizedMeshBestMetadata.ts b/src/models/layerMetadata/quantizedMeshBestMetadata.ts index dbc7979..b339800 100644 --- a/src/models/layerMetadata/quantizedMeshBestMetadata.ts +++ b/src/models/layerMetadata/quantizedMeshBestMetadata.ts @@ -14,6 +14,7 @@ import { catalogDB, getCatalogDBMapping, ICatalogDBMapping, ORMColumnType } from import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { IMetadataCommonModel } from './interfaces/metadataCommonModel'; import { ProductType, RecordStatus } from './enums'; +import { IPropSHPMapping } from './decorators/property/shp.decorator'; export interface IQuantizedMeshBestMetadata { // Based on 3D Entity fields @@ -994,6 +995,10 @@ export class QuantizedMeshBestMetadata implements IQuantizedMeshBestMetadata, IM return ret; } + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + return []; + } + public static getFieldConfigs(): IPropFieldConfigInfo[] { const ret = []; const layer = new QuantizedMeshBestMetadata(); diff --git a/src/models/layerMetadata/vectorBestMetadata.ts b/src/models/layerMetadata/vectorBestMetadata.ts index 9eba45e..fea259b 100644 --- a/src/models/layerMetadata/vectorBestMetadata.ts +++ b/src/models/layerMetadata/vectorBestMetadata.ts @@ -13,6 +13,7 @@ import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/property/csw import { getCatalogDBMapping, ICatalogDBMapping, catalogDB } from './decorators/property/catalogDB.decorator'; import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { ProductType } from './enums'; +import { IPropSHPMapping } from './decorators/property/shp.decorator'; export interface IVectorBestMetadata { productVersion: string | undefined; @@ -575,4 +576,8 @@ export class VectorBestMetadata implements IVectorBestMetadata { } return ret; } + + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + return []; + } } diff --git a/src/models/polygonParts/index.ts b/src/models/polygonParts/index.ts new file mode 100644 index 0000000..cc8a4f5 --- /dev/null +++ b/src/models/polygonParts/index.ts @@ -0,0 +1 @@ +export * from './polygonPartRecord'; diff --git a/src/models/polygonParts/polygonPart.ts b/src/models/polygonParts/polygonPart.ts new file mode 100644 index 0000000..6c6d80e --- /dev/null +++ b/src/models/polygonParts/polygonPart.ts @@ -0,0 +1,501 @@ +import { GeoJSON } from 'geojson'; +import { IPropCatalogDBMapping } from '../common/interfaces/propCatalogDBMapping.interface'; +import { graphql } from '../common/decorators/graphQL/graphql.decorator'; +import { + FieldCategory, + fieldConfig, + getFieldConfig, + IFieldConfigInfo, + IPropFieldConfigInfo, +} from '../common/decorators/fieldConfig/fieldConfig.decorator'; +import { + getInputDataMapping, + IDataMapping, + DataFileType, + inputDataMapping, + IPropSHPMapping, +} from '../layerMetadata/decorators/property/shp.decorator'; +import { getCatalogDBMapping, ICatalogDBMapping, catalogDB } from '../layerMetadata/decorators/property/catalogDB.decorator'; +import { getTsTypesMapping, tsTypes, TsTypes } from '../layerMetadata/decorators/property/tsTypes.decorator'; +import { IPYCSWMapping } from '../layerMetadata/decorators/property/csw.decorator'; + +export interface IPolygonPart { + id: string | undefined; + classification: string | undefined; + name: string | undefined; + description: string | undefined; + resolutionDegree: number | undefined; + resolutionMeter: number | undefined; + horizontalAccuracyCE90: number | undefined; + countries: string[] | undefined; + cities: string[] | undefined; + sensors: string[] | undefined; + imagingTimeBeginUTC: Date | undefined; + imagingTimeEndUTC: Date | undefined; + geometry: GeoJSON | undefined; +} + +export interface IPropPYCSWMapping extends IPYCSWMapping { + prop: string; +} + +export class PolygonPart implements IPolygonPart { + //#region METADATA: id + @catalogDB({ + column: { + name: 'id', + type: 'text', + nullable: true, + }, + }) + @inputDataMapping({ + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.Source', + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + }) + //#endregion + public id: string | undefined = undefined; + + //#region METADATA: classification + @catalogDB({ + column: { + name: 'classification', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + lookupTable: 'classification', + }) + //#endregion + public classification: string | undefined = undefined; + + //#region METADATA: name + @catalogDB({ + column: { + name: 'name', + type: 'text', + nullable: true, + }, + }) + @inputDataMapping({ + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.SourceName', + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + }) + //#endregion + public name: string | undefined = undefined; + + //#region METADATA: description + @catalogDB({ + column: { + name: 'description', + type: 'text', + nullable: true, + }, + }) + @inputDataMapping({ + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.Dsc', + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public description: string | undefined = undefined; + + //#region METADATA: imagingTimeBeginUTC + @catalogDB({ + column: { + name: 'imagingTimeBeginUTC', + type: 'timestamp with time zone', + nullable: false, + }, + }) + @inputDataMapping({ + isCustomLogic: false, + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.UpdateDate', + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.GENERAL, + infoMsgCode: ['info-general-tooltip.required', 'info-field-tooltip.sourceDateStart.max'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.sourceDateStart.max', + valueType: 'field', + max: 'imagingTimeEndUTC', + }, + ], + isLifecycleEnvolved: true, + }) + //#endregion + public imagingTimeBeginUTC: Date | undefined = undefined; + + //#region METADATA: imagingTimeEndUTC + @catalogDB({ + column: { + name: 'imagingTimeEndUTC', + type: 'timestamp without time zone', + nullable: false, + }, + }) + @inputDataMapping({ + isCustomLogic: false, + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.UpdateDate', + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.GENERAL, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + isLifecycleEnvolved: true, + }) + //#endregion + public imagingTimeEndUTC: Date | undefined = undefined; + + //#region METADATA: horizontalAccuracyCE90 + @catalogDB({ + column: { + name: 'horizontalAccuracyCE90', + type: 'real', + }, + }) + @inputDataMapping({ + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.Ep90', + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.minHorizontalAccuracyCE90.min', + valueType: 'value', + min: 0.01, + }, + { + errorMsgCode: 'validation-field.minHorizontalAccuracyCE90.max', + valueType: 'value', + max: 4000, + }, + ], + isLifecycleEnvolved: true, + }) + //#endregion + public horizontalAccuracyCE90: number | undefined = undefined; + + //#region METADATA: sensors + @catalogDB({ + column: { + name: 'sensors', + type: 'text', + }, + field: { + overrideType: TsTypes.STRING, + }, + }) + @inputDataMapping({ + isCustomLogic: false, + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.SensorType', + }) + @tsTypes({ + mappingType: TsTypes.STRING_ARRAY, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.GENERAL, + isLifecycleEnvolved: true, + infoMsgCode: ['info-field-tooltip.sensors.tooltip', 'info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public sensors: string[] | undefined = undefined; + + //#region METADATA: countries + @catalogDB({ + column: { + name: 'countries', + type: 'text', + nullable: true, + }, + field: { + overrideType: TsTypes.STRING, + }, + }) + @inputDataMapping({ + isCustomLogic: false, + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.Countries', + }) + @tsTypes({ + mappingType: TsTypes.STRING_ARRAY, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + infoMsgCode: ['info-field-tooltip.region.tooltip'], + }) + //#endregion + public countries: string[] | undefined = undefined; + + //#region **TO_VERIFY_CITIES?** METADATA: cities + @catalogDB({ + column: { + name: 'cities', + type: 'text', + nullable: true, + }, + field: { + overrideType: TsTypes.STRING, + }, + }) + @inputDataMapping({ + isCustomLogic: false, + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.Cities', + }) + @tsTypes({ + mappingType: TsTypes.STRING_ARRAY, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public cities: string[] | undefined = undefined; + + //#region METADATA: resolutionDegree + @catalogDB({ + column: { + name: 'resolutionDegree', + type: 'numeric', + }, + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: [ + 'info-field-tooltip.maxResolutionDeg.tooltip', + 'info-general-tooltip.required', + 'info-field-tooltip.maxResolutionDeg.min', + 'info-field-tooltip.maxResolutionDeg.max', + ], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.maxResolutionDeg.min', + valueType: 'value', + min: 0.00000009, + }, + { + errorMsgCode: 'validation-field.maxResolutionDeg.max', + valueType: 'value', + max: 0.072, + }, + ], + }) + //#endregion + public resolutionDegree: number | undefined = undefined; + + //#region METADATA: resolutionMeter + @catalogDB({ + column: { + name: 'resolutionMeter', + type: 'numeric', + }, + }) + @inputDataMapping({ + dataFile: DataFileType.SHAPE_METADATA, + valuePath: 'properties.Resolution', + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: ['info-general-tooltip.required', 'info-field-tooltip.maxResolutionMeter.min', 'info-field-tooltip.maxResolutionMeter.max'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.maxResolutionMeter.min', + valueType: 'value', + min: 0.01, + }, + { + errorMsgCode: 'validation-field.maxResolutionMeter.max', + valueType: 'value', + max: 8000, + }, + ], + }) + //#endregion + public resolutionMeter: number | undefined = undefined; + + //#region METADATA: geometry + @catalogDB({ + column: { + name: 'geometry', + type: 'text', + }, + }) + @inputDataMapping({ + dataFile: DataFileType.PRODUCT, + valuePath: 'geometry', + }) + @tsTypes({ + mappingType: TsTypes.OBJECT, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.footprint.json', + json: true, + }, + ], + }) + //#endregion + public geometry: GeoJSON | undefined = undefined; + + public static getShpMapping(prop: string): IDataMapping | undefined { + return getInputDataMapping(new PolygonPart(), prop); + } + + public static getCatalogDBMapping(prop: string): ICatalogDBMapping | undefined { + return getCatalogDBMapping(new PolygonPart(), prop); + } + + public static getFieldConfig(prop: string): IFieldConfigInfo | undefined { + return getFieldConfig(new PolygonPart(), prop); + } + + public static getPyCSWMappings(): IPropPYCSWMapping[] { + return []; + } + + public static getCatalogDBMappings(): IPropCatalogDBMapping[] { + const ret = []; + const layer = new PolygonPart(); + for (const prop in layer) { + const catalogDbMap = getCatalogDBMapping(layer, prop); + const tsTypesMap = getTsTypesMapping(layer, prop); + if (catalogDbMap && tsTypesMap) { + ret.push({ + prop: prop, + ...catalogDbMap, + ...tsTypesMap, + }); + } + } + return ret; + } + + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + const ret = []; + const layer = new PolygonPart(); + for (const prop in layer) { + const shpMap = getInputDataMapping(layer, prop); + const tsTypesMap = getTsTypesMapping(layer, prop); + if (shpMap && tsTypesMap && (includeCustomLogic || shpMap.isCustomLogic === undefined || !shpMap.isCustomLogic)) { + ret.push({ + prop: prop, + ...shpMap, + ...tsTypesMap, + }); + } + } + return ret; + } + + public static getFieldConfigs(): IPropFieldConfigInfo[] { + const ret = []; + const layer = new PolygonPart(); + for (const prop in layer) { + const fieldConfigMap = getFieldConfig(layer, prop); + if (fieldConfigMap) { + ret.push({ + prop: prop, + ...fieldConfigMap, + }); + } + } + return ret; + } +} diff --git a/src/models/polygonParts/polygonPartRecord.ts b/src/models/polygonParts/polygonPartRecord.ts new file mode 100644 index 0000000..b3e6d96 --- /dev/null +++ b/src/models/polygonParts/polygonPartRecord.ts @@ -0,0 +1,186 @@ +import { IPycswCoreModel } from '../pycsw/interfaces/pycswCoreModel'; +import { IPropCatalogDBMapping } from '../common/interfaces/propCatalogDBMapping.interface'; +import { IOrmCatalog } from '../common/interfaces/ormCatalog.interface'; +import { graphql } from '../common/decorators/graphQL/graphql.decorator'; +import { graphqlClass } from '../common/decorators/graphQL/classGraphql.decorator'; +import { FieldCategory, fieldConfig, getFieldConfig, IPropFieldConfigInfo } from '../common/decorators/fieldConfig/fieldConfig.decorator'; +import { getFieldConfigClassInfo } from '../common/decorators/fieldConfig/classFieldConfig.decorator'; +import { catalogDB, getCatalogDBMapping } from '../layerMetadata/decorators/property/catalogDB.decorator'; +import { getTsTypesMapping, TsTypes, tsTypes } from '../layerMetadata/decorators/property/tsTypes.decorator'; +import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } from '../layerMetadata/decorators/class/catalogDBEntity.decorator'; +import { getInputDataMapping, IPropSHPMapping } from '../layerMetadata/decorators/property/shp.decorator'; +import { IPropPYCSWMapping, PolygonPart } from './polygonPart'; + +@catalogDBEntity({ + table: 'records', + className: 'RecordEntity', +}) +@graphqlClass({ alias: 'PolygonPartRecord' }) +export class PolygonPartRecord extends PolygonPart implements IOrmCatalog { + //#region RECORD: internalId_partId + @catalogDB({ + column: { + name: 'internalId_partId', + type: 'number', + nullable: false, + primary: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + // eslint-disable-next-line @typescript-eslint/naming-convention + public internalId_partId: number | undefined; + + //#region RECORD: partId + @catalogDB({ + column: { + name: 'partId', + type: 'number', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public partId: number | undefined; + + //#region RECORD: recordId + @catalogDB({ + column: { + name: 'recordId', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public recordId: string | undefined = 'UNKNOWN'; + + //#region RECORD: version + @catalogDB({ + column: { + name: 'version', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: ['info-field-tooltip.productVersion.pattern'], + validation: [ + { + errorMsgCode: 'validation-field.productVersion.pattern', + valueType: 'value', + pattern: '^[1-9]\\d{0,2}(\\.(0|[1-9]\\d?))?$', + }, + ], + }) + //#endregion + public version: string | undefined = undefined; + + //#region RECORD: ingestionDateUTC + @catalogDB({ + column: { + name: 'ingestionDateUTC', + type: 'timestamp with time zone', + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public ingestionDateUTC: Date | undefined = undefined; + + public constructor() { + super(); + } + + public static getPyCSWMappings(): IPropPYCSWMapping[] { + return []; + } + + public static getFieldConfigs(): IPropFieldConfigInfo[] { + const ret = []; + const layer = new PolygonPartRecord(); + for (const prop in layer) { + const fieldConfigMap = getFieldConfig(layer, prop); + if (fieldConfigMap) { + const fieldConfig = { prop: prop, ...fieldConfigMap }; + if (fieldConfigMap.complexType) { + fieldConfig.subFields = getFieldConfigClassInfo(fieldConfigMap.complexType.value); + } + ret.push(fieldConfig); + } + } + return ret as IPropFieldConfigInfo[]; + } + + public static getShpMappings(includeCustomLogic = false): IPropSHPMapping[] { + const ret = []; + const layer = new PolygonPart(); + for (const prop in layer) { + const shpMap = getInputDataMapping(layer, prop); + const tsTypesMap = getTsTypesMapping(layer, prop); + if (shpMap && tsTypesMap && (includeCustomLogic || shpMap.isCustomLogic === undefined || !shpMap.isCustomLogic)) { + ret.push({ + prop: prop, + ...shpMap, + ...tsTypesMap, + }); + } + } + return ret; + } + + public getORMCatalogMappings(): IPropCatalogDBMapping[] { + const ret = []; + + for (const prop in this) { + const catalogDbMap = getCatalogDBMapping(this, prop); + const tsTypesMap = getTsTypesMapping(this, prop); + if (catalogDbMap && tsTypesMap) { + ret.push({ + prop: prop, + ...catalogDbMap, + ...tsTypesMap, + }); + } + } + return ret; + } + + public getORMCatalogEntityMappings(): ICatalogDBEntityMapping { + return getCatalogDBEntityMapping(PolygonPartRecord); + } +} diff --git a/tests/unit/layerMetadata.spec.ts b/tests/unit/layerMetadata.spec.ts index 68b86de..e39cf70 100644 --- a/tests/unit/layerMetadata.spec.ts +++ b/tests/unit/layerMetadata.spec.ts @@ -1,5 +1,6 @@ -import { LayerMetadata, IPYCSWMapping, IDataMapping, IPropPYCSWMapping, IPropSHPMapping, Pycsw3DCatalogRecord } from '../../src/models'; +import { LayerMetadata, IPYCSWMapping, IDataMapping, IPropPYCSWMapping, Pycsw3DCatalogRecord } from '../../src/models'; import { ICatalogDBMapping } from '../../src/models/layerMetadata/decorators/property/catalogDB.decorator'; +import { IPropSHPMapping } from '../../src/models/layerMetadata/decorators/property/shp.decorator'; import { PycswLayerCatalogRecord } from '../../src/models/layerMetadata/pycswLayerCatalogRecord'; describe('LayerMetadata class static methods', () => {