From 23fc3e9c4bfcba82ad73d144070dc6a51c0d5977 Mon Sep 17 00:00:00 2001 From: alebinson Date: Thu, 6 Jan 2022 08:34:22 +0200 Subject: [PATCH] feat: new vecto-best-entity --- src/models/layerMetadata/index.ts | 1 + .../pycswVectorBestCatalogRecord.ts | 295 +++++++++ .../layerMetadata/vectorBestMetadata.ts | 573 ++++++++++++++++++ 3 files changed, 869 insertions(+) create mode 100644 src/models/layerMetadata/pycswVectorBestCatalogRecord.ts create mode 100644 src/models/layerMetadata/vectorBestMetadata.ts diff --git a/src/models/layerMetadata/index.ts b/src/models/layerMetadata/index.ts index 7e45c30..def34ce 100644 --- a/src/models/layerMetadata/index.ts +++ b/src/models/layerMetadata/index.ts @@ -12,5 +12,6 @@ export * from './pycswLayerCatalogRecord'; export * from './pycsw3DCatalogRecord'; export * from './pycswBestCatalogRecord'; export * from './pycswDEMCatalogRecord'; +export * from './pycswVectorBestCatalogRecord'; export * from './enums'; diff --git a/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts b/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts new file mode 100644 index 0000000..2cbf4c2 --- /dev/null +++ b/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts @@ -0,0 +1,295 @@ +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 { Link } from './link'; +import { catalogDB, getCatalogDBMapping } from './decorators/property/catalogDB.decorator'; +import { getTsTypesMapping, TsTypes, tsTypes } from './decorators/property/tsTypes.decorator'; +import { IPropPYCSWMapping, VectorBestMetadata } from './vectorBestMetadata'; +import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } from './decorators/class/catalogDBEntity.decorator'; +import { getPyCSWMapping, pycsw } from './decorators/property/csw.decorator'; + +@catalogDBEntity({ + table: 'records', + className: 'VectorBestEntity', +}) +@graphqlClass({ alias: 'VectorBestRecord' }) +export class PycswVectorBestCatalogRecord extends VectorBestMetadata implements IPycswCoreModel, IOrmCatalog { + //#region CORE: id + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:id', + queryableField: 'mc:id', + pycswField: 'pycsw:Identifier', + }) + @catalogDB({ + column: { + name: 'identifier', + type: 'text', + nullable: false, + primary: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public id: string | undefined = undefined; + + //#region CORE: typename + @catalogDB({ + column: { + name: 'typename', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public typeName = 'mc_MCVectorBestRecord'; + + //#region CORE: schema + @catalogDB({ + column: { + name: 'schema', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public schema: string | undefined = 'mc_vector_best'; + + //#region CORE: mdsource + @catalogDB({ + column: { + name: 'mdsource', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public mdSource: string | undefined = ''; + + //#region CORE: xml + @catalogDB({ + column: { + name: 'xml', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public xml: string | undefined = ''; + + //#region CORE: anytext + @catalogDB({ + column: { + name: 'anytext', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public anyText: string | undefined = undefined; + + //#region CORE: insertDate + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:insertDate', + queryableField: 'mc:insertDate', + pycswField: 'pycsw:InsertDate', + }) + @catalogDB({ + column: { + name: 'insert_date', + type: 'timestamp without time zone', + default: 'CURRENT_TIMESTAMP', + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isAutoGenerated: true, + }) + //#endregion + public insertDate: Date | undefined = undefined; + + //#region CORE: wktGeometry + @catalogDB({ + column: { + name: 'wkt_geometry', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public wktGeometry: string | undefined = undefined; + + //#region CORE: wkbGeometry (DD trigger populated) + @catalogDB({ + column: { + name: 'wkb_geometry', + type: 'geometry', + spatialFeatureType: 'Geometry', + srid: 4326, + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public wkbGeometry: string | undefined = undefined; + + //#region CORE: keywords + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:keywords', + queryableField: 'mc:keywords', + pycswField: 'pycsw:Keywords', + }) + @catalogDB({ + column: { + name: 'keywords', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isManuallyEditable: true, + }) + //#endregion + public keywords: string | undefined = undefined; + + //#region CORE: anyTextTsvector + @catalogDB({ + column: { + name: 'anytext_tsvector', + type: 'tsvector', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public anyTextTsvector: string | undefined = undefined; + + //#region CORE: links + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:links', + queryableField: 'mc:links', + pycswField: 'pycsw:Links', + }) + @catalogDB({ + column: { + name: 'links', + type: 'text', + nullable: true, + }, + field: { + overrideType: TsTypes.STRING, + }, + }) + @tsTypes({ + mappingType: TsTypes.LINKS, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + complexType: TsTypes.LINKS, + isAutoGenerated: true, + }) + //#endregion + public links: Link[] | undefined = undefined; + + public constructor() { + super(); + } + + public static getPyCSWMappings(): IPropPYCSWMapping[] { + const ret = []; + const layer = new PycswVectorBestCatalogRecord(); + for (const prop in layer) { + const pycswMap = getPyCSWMapping(layer, prop); + if (pycswMap) { + ret.push({ + prop: prop, + ...pycswMap, + }); + } + } + return ret; + } + + public static getFieldConfigs(): IPropFieldConfigInfo[] { + const ret = []; + const layer = new PycswVectorBestCatalogRecord(); + 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 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(PycswVectorBestCatalogRecord); + } +} diff --git a/src/models/layerMetadata/vectorBestMetadata.ts b/src/models/layerMetadata/vectorBestMetadata.ts new file mode 100644 index 0000000..996f29b --- /dev/null +++ b/src/models/layerMetadata/vectorBestMetadata.ts @@ -0,0 +1,573 @@ +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 { RecordType } from '../pycsw/coreEnums'; +import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/property/csw.decorator'; +import { getCatalogDBMapping, ICatalogDBMapping, catalogDB } from './decorators/property/catalogDB.decorator'; +import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; +import { ProductType } from './enums'; + +export interface IVectorBestMetadata { + productVersion: string | undefined; + // resolution: number | undefined; + // rms: number | undefined; + scale: number | undefined; + + // PROFILES COMMON FIELDS + type: RecordType | undefined; + classification: string | undefined; + productName: string | undefined; + description: string | undefined; + srsId: string | undefined; + srsName: string | undefined; + producerName: string | undefined; + updateDate: Date | undefined; + // sourceDateStart: Date | undefined; + // sourceDateEnd: Date | undefined; + // sensorType: SensorType[] | undefined; //sensors + region: string | undefined; + footprint: GeoJSON | undefined; + // productId: string | undefined; + productType: ProductType | undefined; + creationDate: Date | undefined; + ingestionDate: Date | undefined; +} + +export interface IPropPYCSWMapping extends IPYCSWMapping { + prop: string; +} + +export class VectorBestMetadata implements IVectorBestMetadata { + //#region COMMON FIELDS + //#region COMMON: type + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:type', + queryableField: 'mc:type', + pycswField: 'pycsw:Type', + }) + @catalogDB({ + column: { + name: 'type', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.RECORDTYPE, + }) + @graphql({ + nullable: true, + }) + //#endregion + public type: RecordType | undefined = RecordType.RECORD_RASTER; + + //#region COMMON: classification + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:classification', + queryableField: 'mc:classification', + pycswField: 'pycsw:Classification', + }) + @catalogDB({ + column: { + name: 'classification', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isAutoGenerated: false, + isManuallyEditable: true, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public classification: string | undefined = undefined; + + //#region COMMON: productName + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:productName', + queryableField: 'mc:productName', + pycswField: 'pycsw:Title', + }) + @catalogDB({ + column: { + name: 'product_name', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isManuallyEditable: true, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public productName: string | undefined = undefined; + + //#region COMMON: description + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:description', + queryableField: 'mc:description', + pycswField: 'pycsw:Abstract', + }) + @catalogDB({ + column: { + name: 'description', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isManuallyEditable: true, + }) + //#endregion + public description: string | undefined = undefined; + + //#region COMMON: srsId + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:SRS', + queryableField: 'mc:SRS', + pycswField: 'pycsw:CRS', + }) + @catalogDB({ + column: { + name: 'srs', + type: 'text', + nullable: false, + default: '4326', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + isAutoGenerated: true, + }) + //#endregion + public srsId: string | undefined = undefined; + + //#region COMMON: producerName + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:producerName', + queryableField: 'mc:producerName', + pycswField: 'pycsw:Creator', + }) + @catalogDB({ + column: { + name: 'producer_name', + type: 'text', + default: 'IDFMU', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isManuallyEditable: true, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public producerName: string | undefined = 'IDFMU'; + + //#region COMMON: creationDate + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:creationDate', + queryableField: 'mc:creationDate', + pycswField: 'pycsw:CreationDate', + }) + @catalogDB({ + column: { + name: 'creation_date', + type: 'timestamp without time zone', + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isAutoGenerated: true, + }) + //#endregion + public creationDate: Date | undefined = undefined; + + //#region COMMON: ingestionDate + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:ingestionDate', + queryableField: 'mc:ingestionDate', + pycswField: 'pycsw:IngestionDate', + }) + @catalogDB({ + column: { + name: 'ingestion_date', + type: 'timestamp without time zone', + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isAutoGenerated: true, + }) + //#endregion + public ingestionDate: Date | undefined = undefined; + + //#region COMMON: updateDate + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:updateDate', + queryableField: 'mc:updateDate', + 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 COMMON: region + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:region', + queryableField: 'mc:region', + pycswField: 'pycsw:Region', + }) + @catalogDB({ + column: { + name: 'region', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public region: string | undefined = undefined; + //#endregion + + //#region VECTOR_BEST SPECIFIC FIELDS + //#region VECTOR_BEST: productVersion + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:productVersion', + queryableField: 'mc:productVersion', + pycswField: 'pycsw:ProductVersion', + }) + @catalogDB({ + column: { + name: 'product_version', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public productVersion: string | undefined = undefined; + + //#region VECTOR_BEST: productType + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:productType', + queryableField: 'mc:productType', + pycswField: 'pycsw:ProductType', + }) + @catalogDB({ + column: { + name: 'product_type', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.PRODUCTTYPE, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public productType: ProductType | undefined = ProductType.RASTER_VECTOR_BEST; + + //#region VECTOR_BEST: srsName + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:SRSName', + queryableField: 'mc:SRSName', + pycswField: 'pycsw:CRSName', + }) + @catalogDB({ + column: { + name: 'srs_name', + type: 'text', + nullable: false, + default: 'WGS84GEO', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public srsName: string | undefined = undefined; + + //#region VECTOR_BEST: scale + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:scale', + queryableField: 'mc:scale', + pycswField: 'pycsw:Scale', + }) + @catalogDB({ + column: { + name: 'scale', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: [ + 'info-field-tooltip.scale.tooltip', + 'info-general-tooltip.required', + 'info-field-tooltip.scale.min', + 'info-field-tooltip.scale.max', + ], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.scale.min', + valueType: 'value', + min: 0, + }, + { + errorMsgCode: 'validation-field.scale.max', + valueType: 'value', + max: 100000000, + }, + ], + }) + //#endregion + public scale: number | undefined = undefined; + + //#region VECTOR_BEST: footprint + @pycsw({ + profile: 'mc_vector_best', + xmlElement: 'mc:footprint', + queryableField: 'mc:footprint', + pycswField: 'pycsw:footprint', + }) + @catalogDB({ + column: { + name: 'footprint_geojson', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.OBJECT, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + isCreationEssential: true, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.footprint.json', + json: true, + }, + ], + }) + //#endregion + public footprint: GeoJSON | undefined = undefined; + //#endregion + + public static getPyCSWMapping(prop: string): IPYCSWMapping | undefined { + return getPyCSWMapping(new VectorBestMetadata(), prop); + } + + public static getCatalogDBMapping(prop: string): ICatalogDBMapping | undefined { + return getCatalogDBMapping(new VectorBestMetadata(), prop); + } + + public static getFieldConfig(prop: string): IFieldConfigInfo | undefined { + return getFieldConfig(new VectorBestMetadata(), prop); + } + + public static getPyCSWMappings(): IPropPYCSWMapping[] { + const ret = []; + const layer = new VectorBestMetadata(); + for (const prop in layer) { + const pycswMap = getPyCSWMapping(layer, prop); + if (pycswMap) { + ret.push({ + prop: prop, + ...pycswMap, + }); + } + } + return ret; + } + + public static getCatalogDBMappings(): IPropCatalogDBMapping[] { + const ret = []; + const layer = new VectorBestMetadata(); + 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 getFieldConfigs(): IPropFieldConfigInfo[] { + const ret = []; + const layer = new VectorBestMetadata(); + for (const prop in layer) { + const fieldConfigMap = getFieldConfig(layer, prop); + if (fieldConfigMap) { + ret.push({ + prop: prop, + ...fieldConfigMap, + }); + } + } + return ret; + } +}