From 51593009fcacf2da87535a326cdc9d3eccd0a859 Mon Sep 17 00:00:00 2001 From: Alex Lebinson Date: Thu, 18 Nov 2021 13:25:22 +0200 Subject: [PATCH] fix: common profile sync (#103) * fix: commom profile sync * fix: insert-date treatment --- src/models/layerMetadata/bestMetadata.ts | 36 +++++++++++-- .../interfaces/metadataCommonModel.ts | 12 ++--- src/models/layerMetadata/layer3DMetadata.ts | 54 +++++++++++-------- src/models/layerMetadata/layerMetadata.ts | 10 ++-- .../layerMetadata/pycswBestCatalogRecord.ts | 10 ++++ .../layerMetadata/pycswLayerCatalogRecord.ts | 10 ++++ 6 files changed, 93 insertions(+), 39 deletions(-) diff --git a/src/models/layerMetadata/bestMetadata.ts b/src/models/layerMetadata/bestMetadata.ts index 8353f9d..9b201ae 100644 --- a/src/models/layerMetadata/bestMetadata.ts +++ b/src/models/layerMetadata/bestMetadata.ts @@ -19,9 +19,7 @@ import { DiscreteOrder } from './discreteOrder'; export interface IBestMetadata { productVersion: string | undefined; - productType: ProductType | undefined; resolution: number | undefined; - srsName: string | undefined; rms: number | undefined; scale: string | undefined; discretes: DiscreteOrder[] | undefined; @@ -241,9 +239,6 @@ export class BestMetadata implements IBestMetadata, IMetadataCommonModel { @graphql({ nullable: true, }) - @fieldConfig({ - category: FieldCategory.GENERAL, - }) //#endregion public ingestionDate: Date | undefined = undefined; @@ -431,6 +426,37 @@ export class BestMetadata implements IBestMetadata, IMetadataCommonModel { }) //#endregion public region: string | undefined = undefined; + + //#region COMMON: productId + @pycsw({ + profile: 'mc_raster', + xmlElement: 'mc:productId', + queryableField: 'mc:productId', + pycswField: 'pycsw:ProductId', + }) + @catalogDB({ + column: { + name: 'product_id', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public productId: string | undefined = 'UNKNOWN'; //#endregion //#region BEST SPECIFIC FIELDS diff --git a/src/models/layerMetadata/interfaces/metadataCommonModel.ts b/src/models/layerMetadata/interfaces/metadataCommonModel.ts index aca6f7e..e57cc66 100644 --- a/src/models/layerMetadata/interfaces/metadataCommonModel.ts +++ b/src/models/layerMetadata/interfaces/metadataCommonModel.ts @@ -1,22 +1,22 @@ import { GeoJSON } from 'geojson'; -import { SensorType } from '../enums'; +import { ProductType, SensorType } from '../enums'; import { RecordType } from '../../pycsw/coreEnums'; export interface IMetadataCommonModel { // PROFILES COMMON FIELDS type: RecordType | undefined; classification: string | undefined; - productName: string | undefined; //title + productName: string | undefined; description: string | undefined; srsId: string | undefined; - producerName: string | undefined; //not in spec but present in profile (probably 3D only) - creationDate: Date | undefined; - ingestionDate: Date | undefined; + srsName: string | undefined; + producerName: string | undefined; updateDate: Date | undefined; sourceDateStart: Date | undefined; sourceDateEnd: Date | undefined; - accuracyCE90: number | undefined; sensorType: SensorType[] | undefined; //sensors region: string | undefined; footprint: GeoJSON | undefined; + productId: string | undefined; + productType: ProductType | undefined; } diff --git a/src/models/layerMetadata/layer3DMetadata.ts b/src/models/layerMetadata/layer3DMetadata.ts index 8009fff..6067302 100644 --- a/src/models/layerMetadata/layer3DMetadata.ts +++ b/src/models/layerMetadata/layer3DMetadata.ts @@ -12,18 +12,11 @@ import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/property/csw import { tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { ProductType, SensorType } from './enums'; import { catalogDB } from './decorators/property/catalogDB.decorator'; +import { IMetadataCommonModel } from './interfaces/metadataCommonModel'; export interface ILayer3DMetadata { - type: RecordType | undefined; - - productId: string | undefined; - productName: string | undefined; - productVersion: number | undefined; - productType: ProductType | undefined; - description: string | undefined; + productVersion: string | undefined; creationDate: Date | undefined; - sourceDateStart: Date | undefined; - sourceDateEnd: Date | undefined; minResolutionMeter: number | undefined; maxResolutionMeter: number | undefined; nominalResolution: number | undefined; @@ -32,18 +25,11 @@ export interface ILayer3DMetadata { accuracySE90: number | undefined; relativeAccuracyLEP90: number | undefined; visualAccuracy: number | undefined; - sensors: SensorType[] | undefined; - footprint: GeoJSON | undefined; heightRangeFrom: number | undefined; heightRangeTo: number | undefined; - srsId: number | undefined; - srsName: string | undefined; srsOrigin: string | undefined; - region: string | undefined; - classification: string | undefined; productionSystem: string | undefined; productionSystemVer: string | undefined; - producerName: string | undefined; productionMethod: string | undefined; minFlightAlt: number | undefined; maxFlightAlt: number | undefined; @@ -55,7 +41,7 @@ export interface IPropPYCSWMapping extends IPYCSWMapping { prop: string; } -export class Layer3DMetadata implements ILayer3DMetadata { +export class Layer3DMetadata implements ILayer3DMetadata, IMetadataCommonModel { //#region 3D SPECIFIC FIELDS //#region 3D: type @pycsw({ @@ -168,7 +154,7 @@ export class Layer3DMetadata implements ILayer3DMetadata { isAutoGenerated: true, }) //#endregion - public productVersion: number | undefined = undefined; + public productVersion: string | undefined = undefined; //#region 3D: productType @pycsw({ @@ -254,6 +240,32 @@ export class Layer3DMetadata implements ILayer3DMetadata { //#endregion public creationDate: Date | undefined = undefined; + //#region COMMON: updateDate + @pycsw({ + profile: 'mc_raster', + xmlElement: 'mc:updateDateUTC', + queryableField: 'mc:updateDateUTC', + pycswField: 'pycsw:UpdateDate', + }) + @catalogDB({ + column: { + name: 'update_date', + type: 'timestamp without time zone', + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public updateDate: Date | undefined = undefined; + //#region 3D: sourceDateStart @pycsw({ profile: 'mc3d', @@ -628,7 +640,7 @@ export class Layer3DMetadata implements ILayer3DMetadata { //#endregion public visualAccuracy: number | undefined = undefined; - //#region 3D: sensors + //#region 3D: sensorsType @pycsw({ profile: 'mc3d', xmlElement: 'mc:sensors', @@ -661,7 +673,7 @@ export class Layer3DMetadata implements ILayer3DMetadata { ], }) //#endregion - public sensors: SensorType[] | undefined = undefined; + public sensorType: SensorType[] | undefined = undefined; //#region 3D: footprint @pycsw({ @@ -772,7 +784,7 @@ export class Layer3DMetadata implements ILayer3DMetadata { category: FieldCategory.GEO_INFO, }) //#endregion - public srsId: number | undefined = undefined; + public srsId: string | undefined = undefined; //#region 3D: srsName @pycsw({ diff --git a/src/models/layerMetadata/layerMetadata.ts b/src/models/layerMetadata/layerMetadata.ts index 3341872..2d5d2bb 100644 --- a/src/models/layerMetadata/layerMetadata.ts +++ b/src/models/layerMetadata/layerMetadata.ts @@ -17,14 +17,14 @@ import { getTsTypesMapping, ITsTypesMapping, tsTypes, TsTypes } from './decorato import { ProductType, SensorType } from './enums'; export interface ILayerMetadata { - productId: string | undefined; productVersion: string | undefined; - productType: ProductType | undefined; resolution: number | undefined; - srsName: string | undefined; rms: number | undefined; scale: string | undefined; includedInBests: string[] | undefined; + creationDate: Date | undefined; + ingestionDate: Date | undefined; + accuracyCE90: number | undefined; } export interface IPropSHPMapping extends IDataMapping, ITsTypesMapping { prop: string; @@ -251,10 +251,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { @graphql({ nullable: true, }) - @fieldConfig({ - category: FieldCategory.GENERAL, - isAutoGenerated: true, - }) //#endregion public ingestionDate: Date | undefined = undefined; diff --git a/src/models/layerMetadata/pycswBestCatalogRecord.ts b/src/models/layerMetadata/pycswBestCatalogRecord.ts index c6691c7..39ec96c 100644 --- a/src/models/layerMetadata/pycswBestCatalogRecord.ts +++ b/src/models/layerMetadata/pycswBestCatalogRecord.ts @@ -110,6 +110,12 @@ export class PycswBestCatalogRecord extends BestMetadata implements IPycswCoreMo public anyText: string | undefined = undefined; //#region CORE: insertDate + @pycsw({ + profile: 'mc_raster', + xmlElement: 'mc:insertDate', + queryableField: 'mc:insertDate', + pycswField: 'pycsw:InsertDate', + }) @catalogDB({ column: { name: 'insert_date', @@ -123,6 +129,10 @@ export class PycswBestCatalogRecord extends BestMetadata implements IPycswCoreMo @graphql({ nullable: true, }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isAutoGenerated: true, + }) //#endregion public insertDate: Date | undefined = undefined; diff --git a/src/models/layerMetadata/pycswLayerCatalogRecord.ts b/src/models/layerMetadata/pycswLayerCatalogRecord.ts index cf36700..fc278d5 100644 --- a/src/models/layerMetadata/pycswLayerCatalogRecord.ts +++ b/src/models/layerMetadata/pycswLayerCatalogRecord.ts @@ -109,6 +109,12 @@ export class PycswLayerCatalogRecord extends LayerMetadata implements IPycswCore public anyText: string | undefined = undefined; //#region CORE: insertDate + @pycsw({ + profile: 'mc_raster', + xmlElement: 'mc:insertDate', + queryableField: 'mc:insertDate', + pycswField: 'pycsw:InsertDate', + }) @catalogDB({ column: { name: 'insert_date', @@ -122,6 +128,10 @@ export class PycswLayerCatalogRecord extends LayerMetadata implements IPycswCore @graphql({ nullable: true, }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isAutoGenerated: true, + }) //#endregion public insertDate: Date | undefined = undefined;