From 011b6c6939b6a4b2eefb2ab42e23410c90bb3774 Mon Sep 17 00:00:00 2001 From: Eliav Maimon Date: Sun, 16 Mar 2025 13:54:02 +0200 Subject: [PATCH 1/8] feat: update vector record --- .../common/decorators/wfs/wfs.decorator.ts | 16 +- .../decorators/property/tsTypes.decorator.ts | 17 +- src/models/layerMetadata/index.ts | 3 +- .../pycswVectorBestCatalogRecord.ts | 300 ----------- .../layerMetadata/vectorBestMetadata.ts | 502 ++++++------------ .../vectorFeatureTypeStructure.ts | 91 ++++ src/models/polygonParts/polygonPartRecord.ts | 95 +++- tests/unit/polygonParts.spec.ts | 3 +- 8 files changed, 348 insertions(+), 679 deletions(-) delete mode 100644 src/models/layerMetadata/pycswVectorBestCatalogRecord.ts create mode 100644 src/models/layerMetadata/vectorFeatureTypeStructure.ts diff --git a/src/models/common/decorators/wfs/wfs.decorator.ts b/src/models/common/decorators/wfs/wfs.decorator.ts index a1e299be..cbb2996b 100644 --- a/src/models/common/decorators/wfs/wfs.decorator.ts +++ b/src/models/common/decorators/wfs/wfs.decorator.ts @@ -13,14 +13,22 @@ export enum JAVA_BINDINGS { } export interface IWFSMapping { - binding: JAVA_BINDINGS; // java type 'java.util.UUID' - name?: string; // property name that will be exposed by WFS service - minOccurs?: number; - maxOccurs?: number; + geoserver?: { + binding: JAVA_BINDINGS; // java type 'java.util.UUID' + name?: string; // property name that will be exposed by WFS service + minOccurs?: number; + maxOccurs?: number; + }; + capabilitiesMapping?: { + xmlElement: string; + }; } export interface IPropWFSMapping extends IWFSMapping { prop: string; // prop name for convinience +} + +export interface IWFSGeoServerMapping extends IWFSMapping, IPropWFSMapping { source: string; // DB column name. IMPORTANT: Will be derived from catalogDB decorator metadata nillable: boolean; // is nullable by DB definitions } diff --git a/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts b/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts index c9a61b06..b6df5b34 100644 --- a/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts +++ b/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts @@ -16,6 +16,9 @@ export interface IDescribeTsType { importFromPackage?: string; } +//****** IMPORTANT: ALL external enums which in use MUST be proxied by mc-models. +//****** In other words, enums MUST be imported in generated code(graphQL) from MC_MODELS ONLY, +//****** in order to be compliant to types package which in use by MC-MODELS /* eslint-disable @typescript-eslint/naming-convention */ export const TsTypes = { STRING: { @@ -59,6 +62,14 @@ export const TsTypes = { value: 'Link', type: PropertiesTypes.ARRAY, }, + FEATURESTRUCTURE: { + value: 'VectorFeatureTypeStructure', + type: PropertiesTypes.CLASS, + }, + FIELDFEATURETYPES: { + value: 'FieldFeatureType', + type: PropertiesTypes.ARRAY, + }, RECORDTYPE: { value: 'RecordType', type: PropertiesTypes.ENUM, @@ -97,12 +108,12 @@ export const TsTypes = { PRODUCTTYPE: { value: 'ProductType', type: PropertiesTypes.ENUM, - importFromPackage: '@map-colonies/types', + importFromPackage: '@map-colonies/mc-model-types', }, TRANSPARENCY: { value: 'Transparency', type: PropertiesTypes.ENUM, - importFromPackage: '@map-colonies/types', + importFromPackage: '@map-colonies/mc-model-types', }, TILE_OUTPUT_FORMAT: { value: 'TileOutputFormat', @@ -112,7 +123,7 @@ export const TsTypes = { RECORD_STATUS: { value: 'RecordStatus', type: PropertiesTypes.ENUM, - importFromPackage: '@map-colonies/types', + importFromPackage: '@map-colonies/mc-model-types', }, } satisfies Record; diff --git a/src/models/layerMetadata/index.ts b/src/models/layerMetadata/index.ts index e6bf6435..6878226b 100644 --- a/src/models/layerMetadata/index.ts +++ b/src/models/layerMetadata/index.ts @@ -13,6 +13,7 @@ export { IOrmCatalog } from '../common/interfaces/ormCatalog.interface'; export * from './pycswLayerCatalogRecord'; export * from './pycsw3DCatalogRecord'; export * from './pycswDEMCatalogRecord'; -export * from './pycswVectorBestCatalogRecord'; +export * from './vectorBestMetadata'; export * from './pycswQuantizedMeshBestCatalogRecord'; +export * from './vectorFeatureTypeStructure'; export * from './enums'; diff --git a/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts b/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts deleted file mode 100644 index 329f3c21..00000000 --- a/src/models/layerMetadata/pycswVectorBestCatalogRecord.ts +++ /dev/null @@ -1,300 +0,0 @@ -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'; -import { IPropSHPMapping } from './decorators/property/shp.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 static getShpMappings(): IPropSHPMapping[] { - return []; - } - - 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 index 58e2107f..3fe1055a 100644 --- a/src/models/layerMetadata/vectorBestMetadata.ts +++ b/src/models/layerMetadata/vectorBestMetadata.ts @@ -1,6 +1,5 @@ import { GeoJSON } from 'geojson'; import { RecordType, ProductType } from '@map-colonies/types'; -import { IPropCatalogDBMapping } from '../common/interfaces/propCatalogDBMapping.interface'; import { graphql } from '../common/decorators/graphQL/graphql.decorator'; import { FieldCategory, @@ -9,57 +8,97 @@ import { IFieldConfigInfo, IPropFieldConfigInfo, } from '../common/decorators/fieldConfig/fieldConfig.decorator'; -import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/property/csw.decorator'; -import { getCatalogDBMapping, ICatalogDBMapping, catalogDB } from './decorators/property/catalogDB.decorator'; +// import { getCatalogDBMapping, ICatalogDBMapping } from './decorators/property/catalogDB.decorator'; import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { IPropSHPMapping } from './decorators/property/shp.decorator'; -export interface IVectorBestMetadata { - productVersion: string | undefined; - // resolution: number | undefined; - // rms: number | undefined; - scale: string | undefined; +import { getWFSMapping, graphqlClass, IPropWFSMapping, IWFSMapping, Link, wfs } from '../common'; +import { getFieldConfigClassInfo } from '../common/decorators/fieldConfig/classFieldConfig.decorator'; +import { IPropPYCSWMapping } from './layerRASTERMetadata'; +import { VectorFeatureTypeStructure } from './vectorFeatureTypeStructure'; - // PROFILES COMMON FIELDS - type: RecordType | undefined; - classification: string | undefined; - productName: string | undefined; +export interface IVectorBestMetadata { + id: string | undefined; // ** + keywords: string | undefined; + links: Link[] | undefined; // ** + type: RecordType | undefined; // ** + classification: string | undefined; //HardCoded 'Top secret' + 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; + srsId: string | undefined; // ** + srsName: string | undefined; // ** + producerName: string | undefined; //HardCoded 'Moria' + footprint: GeoJSON | undefined; // ** + productType: ProductType | undefined; // ** //vector best + featureStructure: VectorFeatureTypeStructure | undefined; } +@graphqlClass({ alias: 'VectorBestRecord' }) 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, + + //#region CORE: id + // @wfs({ + // capabilitiesMapping: { + // xmlElement: 'mc:id', + // } + // }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public id: string | undefined = undefined; + + //#region CORE: keywords + @wfs({ + capabilitiesMapping: { + xmlElement: 'keywords', }, }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isManuallyEditable: true, + }) + //#endregion + public keywords: string | undefined = undefined; + + //#region CORE: links + // @wfs({ + // capabilitiesMapping: { + // xmlElement: 'mc:links', + // } + // }) + @tsTypes({ + mappingType: TsTypes.LINKS, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + complexType: TsTypes.LINKS, + isAutoGenerated: true, + }) + //#endregion + public links: Link[] | undefined = undefined; + + //#region COMMON: type + // @wfs({ + // capabilitiesMapping: { + // xmlElement: 'type', + // } + // }) @tsTypes({ mappingType: TsTypes.RECORDTYPE, }) @@ -70,19 +109,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { 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, - }, - }) + // @wfs({ + // capabilitiesMapping: { + // xmlElement: 'classification', + // }, + // }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -106,17 +137,9 @@ export class VectorBestMetadata implements IVectorBestMetadata { 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, + @wfs({ + capabilitiesMapping: { + xmlElement: 'name.localPart', }, }) @tsTypes({ @@ -138,19 +161,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { 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, - }, - }) + // @wfs({ + // capabilitiesMapping: { + // xmlElement: 'description', + // } + // }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -165,18 +180,9 @@ export class VectorBestMetadata implements IVectorBestMetadata { 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', + @wfs({ + capabilitiesMapping: { + xmlElement: 'defaultCRS', }, }) @tsTypes({ @@ -194,18 +200,9 @@ export class VectorBestMetadata implements IVectorBestMetadata { 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, + @wfs({ + capabilitiesMapping: { + xmlElement: 'name.namespaceURI', }, }) @tsTypes({ @@ -229,164 +226,12 @@ export class VectorBestMetadata implements IVectorBestMetadata { //#endregion public producerName: string | undefined = undefined; - //#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.MAIN, - 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', - }, - field: { - overrideType: TsTypes.STRING, - }, - }) - @tsTypes({ - mappingType: TsTypes.STRING_ARRAY, - }) - @graphql({ - nullable: false, - }) - @fieldConfig({ - category: FieldCategory.GENERAL, - infoMsgCode: ['info-field-tooltip.region.tooltip', 'info-general-tooltip.required'], - isMultiSelection: true, - lookupTable: 'countries', - 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, - }, - }) + // @wfs({ + // capabilitiesMapping: { + // xmlElement: 'mc:productType', + // } + // }) @tsTypes({ mappingType: TsTypes.PRODUCTTYPE, }) @@ -399,18 +244,9 @@ export class VectorBestMetadata implements IVectorBestMetadata { 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', + @wfs({ + capabilitiesMapping: { + xmlElement: 'defaultCRS', }, }) @tsTypes({ @@ -433,76 +269,49 @@ export class VectorBestMetadata implements IVectorBestMetadata { //#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, + //#region VECTOR_BEST: footprint + @wfs({ + capabilitiesMapping: { + xmlElement: 'wgs84BoundingBox', }, }) @tsTypes({ - mappingType: TsTypes.NUMBER, + mappingType: TsTypes.OBJECT, }) @graphql({ - nullable: true, + nullable: false, }) @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', - ], + infoMsgCode: ['info-general-tooltip.required'], 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, + errorMsgCode: 'validation-field.footprint.json', + json: true, }, ], }) //#endregion - public scale: string | undefined = undefined; + public footprint: GeoJSON | 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, + //#region VECTOR_BEST: featureStructure + @wfs({ + capabilitiesMapping: { + xmlElement: 'metadataLink', }, }) @tsTypes({ - mappingType: TsTypes.OBJECT, + mappingType: TsTypes.FEATURESTRUCTURE, }) @graphql({ nullable: false, }) @fieldConfig({ - category: FieldCategory.GEO_INFO, + category: FieldCategory.MAIN, infoMsgCode: ['info-general-tooltip.required'], validation: [ { @@ -510,53 +319,57 @@ export class VectorBestMetadata implements IVectorBestMetadata { required: true, }, { - errorMsgCode: 'validation-field.footprint.json', + errorMsgCode: 'validation-field.featureStructure.json', json: true, }, ], }) //#endregion - public footprint: GeoJSON | undefined = undefined; + public featureStructure: VectorFeatureTypeStructure | 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 getWFSMapping(prop: string): IWFSMapping | undefined { + return getWFSMapping(new VectorBestMetadata(), prop); } public static getFieldConfig(prop: string): IFieldConfigInfo | undefined { return getFieldConfig(new VectorBestMetadata(), prop); } + // public static getWFSGeoServerMappings(): IPropWFSMapping[] { + // const ret = []; + // const layer = new VectorBestMetadata(); + // for (const prop in layer) { + // const wfsMap = getWFSMapping(layer, prop); + // if (wfsMap) { + // ret.push({ + // prop: prop, + // ...wfsMap, + // }); + // } + // } + // return ret; + // } + 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; + // return []; + //@ts-ignore + return this.getWFSCapabilitiesMappings(); } - public static getCatalogDBMappings(): IPropCatalogDBMapping[] { + public static getWFSGeoServerMappings(): IPropWFSMapping[] { + throw 'NOT IMPLEMENTED'; + } + + public static getWFSCapabilitiesMappings(): IPropWFSMapping[] { const ret = []; const layer = new VectorBestMetadata(); for (const prop in layer) { - const catalogDbMap = getCatalogDBMapping(layer, prop); - const tsTypesMap = getTsTypesMapping(layer, prop); - if (catalogDbMap && tsTypesMap) { + const wfsMap = getWFSMapping(layer, prop); + if (wfsMap) { ret.push({ prop: prop, - ...catalogDbMap, - ...tsTypesMap, + ...wfsMap.capabilitiesMapping, }); } } @@ -569,10 +382,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { for (const prop in layer) { const fieldConfigMap = getFieldConfig(layer, prop); if (fieldConfigMap) { - ret.push({ - prop: prop, - ...fieldConfigMap, - }); + const fieldConfig = { prop: prop, ...fieldConfigMap }; + if (fieldConfigMap.complexType) { + fieldConfig.subFields = getFieldConfigClassInfo(fieldConfigMap.complexType.value); + } + ret.push(fieldConfig); } } return ret; diff --git a/src/models/layerMetadata/vectorFeatureTypeStructure.ts b/src/models/layerMetadata/vectorFeatureTypeStructure.ts new file mode 100644 index 00000000..ea274560 --- /dev/null +++ b/src/models/layerMetadata/vectorFeatureTypeStructure.ts @@ -0,0 +1,91 @@ +import { graphqlClass } from '../common/decorators/graphQL/classGraphql.decorator'; +import { graphql } from '../common/decorators/graphQL/graphql.decorator'; +import { FieldCategory, fieldConfig } from '../common/decorators/fieldConfig/fieldConfig.decorator'; +import { fieldConfigClass } from '../common/decorators/fieldConfig/classFieldConfig.decorator'; +import { TsTypes, tsTypes } from './decorators/property/tsTypes.decorator'; + +@fieldConfigClass() +@graphqlClass() +export class FieldFeatureType { + //#region FIELD: fieldName + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public fieldName?: string = undefined; + + //#region FIELD: aliasFieldName + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public aliasFieldName?: string = undefined; + + //#region FIELD: type + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public type?: string = undefined; +} + +@fieldConfigClass() +@graphqlClass() +export class VectorFeatureTypeStructure { + //#region FIELD: layerName + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public layerName?: string = undefined; + + //#region FIELD: aliasLayerName + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public aliasLayerName?: string = undefined; + + //#region FIELD: fields + @tsTypes({ + mappingType: TsTypes.FIELDFEATURETYPES, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public fields?: FieldFeatureType[] = undefined; +} diff --git a/src/models/polygonParts/polygonPartRecord.ts b/src/models/polygonParts/polygonPartRecord.ts index e7d316f5..dc339622 100644 --- a/src/models/polygonParts/polygonPartRecord.ts +++ b/src/models/polygonParts/polygonPartRecord.ts @@ -13,7 +13,7 @@ import { import { catalogDB, getCatalogDBMapping, ORMColumnType } from '../layerMetadata/decorators/property/catalogDB.decorator'; import { getTsTypesMapping, tsTypes, TsTypes } from '../layerMetadata/decorators/property/tsTypes.decorator'; import { ICatalogDBEntityMapping, IOrmCatalog, IPYCSWMapping } from '../layerMetadata'; -import { getWFSMapping, graphqlClass, IPropCatalogDBMapping, IPropWFSMapping, JAVA_BINDINGS, wfs } from '../common'; +import { getWFSMapping, graphqlClass, IPropCatalogDBMapping, IWFSGeoServerMapping, JAVA_BINDINGS, wfs } from '../common'; import { VALIDATIONS } from '../raster/constants'; import { camelCaseToSnakeCase } from '../helpers/utils'; import { DBEntity, getDBEntityMapping } from '../layerMetadata/decorators/class/DBEntity.decorator'; @@ -43,7 +43,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @inputDataMapping([ { @@ -84,7 +86,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @inputDataMapping([ { @@ -131,7 +135,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: {}, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @inputDataMapping([ { @@ -196,7 +202,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: {}, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @tsTypes({ mappingType: TsTypes.PRODUCTTYPE, @@ -218,7 +226,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @inputDataMapping([ { @@ -259,7 +269,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: {}, }) @wfs({ - binding: JAVA_BINDINGS.TIMESTAMP, + geoserver: { + binding: JAVA_BINDINGS.TIMESTAMP, + }, }) @inputDataMapping([ { @@ -315,7 +327,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: {}, }) @wfs({ - binding: JAVA_BINDINGS.TIMESTAMP, + geoserver: { + binding: JAVA_BINDINGS.TIMESTAMP, + }, }) @inputDataMapping([ { @@ -365,7 +379,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.FLOAT, + geoserver: { + binding: JAVA_BINDINGS.FLOAT, + }, }) @inputDataMapping([ { @@ -424,7 +440,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @inputDataMapping([ { @@ -473,7 +491,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @inputDataMapping([ { @@ -517,7 +537,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @inputDataMapping([ { @@ -558,7 +580,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: {}, }) @wfs({ - binding: JAVA_BINDINGS.BIGDECIMAL, + geoserver: { + binding: JAVA_BINDINGS.BIGDECIMAL, + }, }) @tsTypes({ mappingType: TsTypes.NUMBER, @@ -599,7 +623,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: {}, }) @wfs({ - binding: JAVA_BINDINGS.BIGDECIMAL, + geoserver: { + binding: JAVA_BINDINGS.BIGDECIMAL, + }, }) @tsTypes({ mappingType: TsTypes.NUMBER, @@ -634,7 +660,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.BIGDECIMAL, + geoserver: { + binding: JAVA_BINDINGS.BIGDECIMAL, + }, }) @tsTypes({ mappingType: TsTypes.NUMBER, @@ -705,7 +733,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: { spatial: true }, }) @wfs({ - binding: JAVA_BINDINGS.POLYGON, + geoserver: { + binding: JAVA_BINDINGS.POLYGON, + }, }) @inputDataMapping([ { @@ -755,7 +785,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.UUID, + geoserver: { + binding: JAVA_BINDINGS.UUID, + }, }) @tsTypes({ mappingType: TsTypes.STRING, @@ -776,7 +808,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.UUID, + geoserver: { + binding: JAVA_BINDINGS.UUID, + }, }) @tsTypes({ mappingType: TsTypes.STRING, @@ -799,7 +833,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: {}, }) @wfs({ - binding: JAVA_BINDINGS.UUID, + geoserver: { + binding: JAVA_BINDINGS.UUID, + }, }) @tsTypes({ mappingType: TsTypes.STRING, @@ -821,7 +857,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }, }) @wfs({ - binding: JAVA_BINDINGS.STRING, + geoserver: { + binding: JAVA_BINDINGS.STRING, + }, }) @tsTypes({ mappingType: TsTypes.STRING, @@ -856,7 +894,9 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { index: {}, }) @wfs({ - binding: JAVA_BINDINGS.TIMESTAMP, + geoserver: { + binding: JAVA_BINDINGS.TIMESTAMP, + }, }) @tsTypes({ mappingType: TsTypes.DATE, @@ -872,20 +912,23 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { return []; } - public static getWFSMappings(): IPropWFSMapping[] { - const ret: IPropWFSMapping[] = []; + public static getWFSMappings(): IWFSGeoServerMapping[] { + const ret: IWFSGeoServerMapping[] = []; const layer = new PolygonPartRecord(); POLYGON_PARTS_SERVED_KEYS.forEach((prop) => { const catalogDbMap = getCatalogDBMapping(layer, prop); const wfsMap = getWFSMapping(layer, prop); if (catalogDbMap && wfsMap) { - const { name, ...rest } = wfsMap; + const { name, binding, ...rest } = wfsMap.geoserver ?? {}; ret.push({ prop: prop, - name: name ?? prop, source: catalogDbMap.column.name as string, nillable: catalogDbMap.column.nullable ?? false, - ...rest, + geoserver: { + name: name ?? prop, + binding: binding ?? JAVA_BINDINGS.STRING, + ...rest, + }, }); } }); diff --git a/tests/unit/polygonParts.spec.ts b/tests/unit/polygonParts.spec.ts index 4f764c32..68219571 100644 --- a/tests/unit/polygonParts.spec.ts +++ b/tests/unit/polygonParts.spec.ts @@ -13,8 +13,9 @@ describe('PolygonParts class static methods', () => { expect(ppGQLMappings?.fields.length).toBeGreaterThan(0); }); - it('getWFSMappings(): class property members HAS WFS mapped fields', () => { + fit('getWFSMappings(): class property members HAS WFS mapped fields', () => { const ppWFSMappings = PolygonPartRecord.getWFSMappings(); + console.log(ppWFSMappings); expect(ppWFSMappings.length).toBeGreaterThan(0); }); From 1de065625c81b5844534458f23660cc44a5f0e9c Mon Sep 17 00:00:00 2001 From: Eliav Maimon Date: Sun, 16 Mar 2025 16:41:19 +0200 Subject: [PATCH 2/8] fix: add footprint field to layerRASTERMetadata constructor --- src/models/layerMetadata/layerRASTERMetadata.ts | 2 ++ tests/unit/polygonParts.spec.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/layerMetadata/layerRASTERMetadata.ts b/src/models/layerMetadata/layerRASTERMetadata.ts index 05b198af..0b563058 100644 --- a/src/models/layerMetadata/layerRASTERMetadata.ts +++ b/src/models/layerMetadata/layerRASTERMetadata.ts @@ -1136,6 +1136,7 @@ export class LayerMetadata implements RasterLayerMetadata { const DUMMY_VALUE_TRANSPARENCY = Transparency.OPAQUE; const DUMMY_VALUE_TILE_OUTPUT_FORMAT = TileOutputFormat.JPEG; const DUMMY_VALUE_TILE_MIME_FORMAT = 'image/png'; + const DUMMY_VALUE_GEOJSON = { features: [], type: 'FeatureCollection' } as GeoJSON; this.classification = DUMMY_VALUE_STRING; this.id = DUMMY_VALUE_STRING; @@ -1151,6 +1152,7 @@ export class LayerMetadata implements RasterLayerMetadata { this.maxHorizontalAccuracyCE90 = DUMMY_VALUE_NUMBER; this.region = [DUMMY_VALUE_STRING]; this.sensors = [DUMMY_VALUE_STRING]; + this.footprint = DUMMY_VALUE_GEOJSON; this.imagingTimeBeginUTC = new Date(); this.imagingTimeEndUTC = new Date(); this.updateDateUTC = new Date(); diff --git a/tests/unit/polygonParts.spec.ts b/tests/unit/polygonParts.spec.ts index 68219571..30265761 100644 --- a/tests/unit/polygonParts.spec.ts +++ b/tests/unit/polygonParts.spec.ts @@ -13,7 +13,7 @@ describe('PolygonParts class static methods', () => { expect(ppGQLMappings?.fields.length).toBeGreaterThan(0); }); - fit('getWFSMappings(): class property members HAS WFS mapped fields', () => { + it('getWFSMappings(): class property members HAS WFS mapped fields', () => { const ppWFSMappings = PolygonPartRecord.getWFSMappings(); console.log(ppWFSMappings); From 1504829f049c976c6ea3e8c5d5b1230e7a5eff5d Mon Sep 17 00:00:00 2001 From: Eliav Maimon Date: Sun, 4 May 2025 14:47:59 +0300 Subject: [PATCH 3/8] fix: remove comments --- .../layerMetadata/vectorBestMetadata.ts | 113 +++++++----------- 1 file changed, 45 insertions(+), 68 deletions(-) diff --git a/src/models/layerMetadata/vectorBestMetadata.ts b/src/models/layerMetadata/vectorBestMetadata.ts index 3fe1055a..120bdf76 100644 --- a/src/models/layerMetadata/vectorBestMetadata.ts +++ b/src/models/layerMetadata/vectorBestMetadata.ts @@ -8,28 +8,26 @@ import { IFieldConfigInfo, IPropFieldConfigInfo, } from '../common/decorators/fieldConfig/fieldConfig.decorator'; -// import { getCatalogDBMapping, ICatalogDBMapping } from './decorators/property/catalogDB.decorator'; -import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; +import { tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { IPropSHPMapping } from './decorators/property/shp.decorator'; - import { getWFSMapping, graphqlClass, IPropWFSMapping, IWFSMapping, Link, wfs } from '../common'; import { getFieldConfigClassInfo } from '../common/decorators/fieldConfig/classFieldConfig.decorator'; import { IPropPYCSWMapping } from './layerRASTERMetadata'; import { VectorFeatureTypeStructure } from './vectorFeatureTypeStructure'; export interface IVectorBestMetadata { - id: string | undefined; // ** + id: string | undefined; keywords: string | undefined; - links: Link[] | undefined; // ** - type: RecordType | undefined; // ** - classification: string | undefined; //HardCoded 'Top secret' - productName: string | undefined; // ** + links: Link[] | undefined; + type: RecordType | undefined; + classification: string | undefined; + productName: string | undefined; description: string | undefined; - srsId: string | undefined; // ** - srsName: string | undefined; // ** - producerName: string | undefined; //HardCoded 'Moria' - footprint: GeoJSON | undefined; // ** - productType: ProductType | undefined; // ** //vector best + srsId: string | undefined; + srsName: string | undefined; + producerName: string | undefined; + footprint: GeoJSON | undefined; + productType: ProductType | undefined; featureStructure: VectorFeatureTypeStructure | undefined; } @@ -38,11 +36,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { //#region COMMON FIELDS //#region CORE: id - // @wfs({ - // capabilitiesMapping: { - // xmlElement: 'mc:id', - // } - // }) + @wfs({ + capabilitiesMapping: { + xmlElement: '', + }, + }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -74,11 +72,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { public keywords: string | undefined = undefined; //#region CORE: links - // @wfs({ - // capabilitiesMapping: { - // xmlElement: 'mc:links', - // } - // }) + @wfs({ + capabilitiesMapping: { + xmlElement: 'name', + }, + }) @tsTypes({ mappingType: TsTypes.LINKS, }) @@ -94,11 +92,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { public links: Link[] | undefined = undefined; //#region COMMON: type - // @wfs({ - // capabilitiesMapping: { - // xmlElement: 'type', - // } - // }) + @wfs({ + capabilitiesMapping: { + xmlElement: '', + }, + }) @tsTypes({ mappingType: TsTypes.RECORDTYPE, }) @@ -109,11 +107,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { public type: RecordType | undefined = RecordType.RECORD_RASTER; //#region COMMON: classification - // @wfs({ - // capabilitiesMapping: { - // xmlElement: 'classification', - // }, - // }) + @wfs({ + capabilitiesMapping: { + xmlElement: '', + }, + }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -161,11 +159,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { public productName: string | undefined = undefined; //#region COMMON: description - // @wfs({ - // capabilitiesMapping: { - // xmlElement: 'description', - // } - // }) + @wfs({ + capabilitiesMapping: { + xmlElement: '', + }, + }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -202,7 +200,7 @@ export class VectorBestMetadata implements IVectorBestMetadata { //#region COMMON: producerName @wfs({ capabilitiesMapping: { - xmlElement: 'name.namespaceURI', + xmlElement: 'name', }, }) @tsTypes({ @@ -227,11 +225,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { public producerName: string | undefined = undefined; //#region VECTOR_BEST: productType - // @wfs({ - // capabilitiesMapping: { - // xmlElement: 'mc:productType', - // } - // }) + @wfs({ + capabilitiesMapping: { + xmlElement: '', + }, + }) @tsTypes({ mappingType: TsTypes.PRODUCTTYPE, }) @@ -336,32 +334,11 @@ export class VectorBestMetadata implements IVectorBestMetadata { return getFieldConfig(new VectorBestMetadata(), prop); } - // public static getWFSGeoServerMappings(): IPropWFSMapping[] { - // const ret = []; - // const layer = new VectorBestMetadata(); - // for (const prop in layer) { - // const wfsMap = getWFSMapping(layer, prop); - // if (wfsMap) { - // ret.push({ - // prop: prop, - // ...wfsMap, - // }); - // } - // } - // return ret; - // } - public static getPyCSWMappings(): IPropPYCSWMapping[] { - // return []; - //@ts-ignore - return this.getWFSCapabilitiesMappings(); - } - - public static getWFSGeoServerMappings(): IPropWFSMapping[] { - throw 'NOT IMPLEMENTED'; + throw new Error('NOT IMPLEMENTED'); } - public static getWFSCapabilitiesMappings(): IPropWFSMapping[] { + public static getWFSMappings(): IPropWFSMapping[] { const ret = []; const layer = new VectorBestMetadata(); for (const prop in layer) { @@ -369,7 +346,7 @@ export class VectorBestMetadata implements IVectorBestMetadata { if (wfsMap) { ret.push({ prop: prop, - ...wfsMap.capabilitiesMapping, + ...wfsMap, }); } } From 91690982dda55b9e3f714eb90ac4b8e319fd097a Mon Sep 17 00:00:00 2001 From: Eliav Maimon Date: Mon, 5 May 2025 12:25:41 +0300 Subject: [PATCH 4/8] fix: eslint --- .../layerMetadata/vectorBestMetadata.ts | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/models/layerMetadata/vectorBestMetadata.ts b/src/models/layerMetadata/vectorBestMetadata.ts index 120bdf76..6970bab3 100644 --- a/src/models/layerMetadata/vectorBestMetadata.ts +++ b/src/models/layerMetadata/vectorBestMetadata.ts @@ -1,6 +1,7 @@ import { GeoJSON } from 'geojson'; import { RecordType, ProductType } from '@map-colonies/types'; import { graphql } from '../common/decorators/graphQL/graphql.decorator'; +import { getFieldConfigClassInfo } from '../common/decorators/fieldConfig/classFieldConfig.decorator'; import { FieldCategory, fieldConfig, @@ -8,29 +9,12 @@ import { IFieldConfigInfo, IPropFieldConfigInfo, } from '../common/decorators/fieldConfig/fieldConfig.decorator'; +import { getWFSMapping, graphqlClass, IPropWFSMapping, IWFSMapping, Link, wfs } from '../common'; import { tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { IPropSHPMapping } from './decorators/property/shp.decorator'; -import { getWFSMapping, graphqlClass, IPropWFSMapping, IWFSMapping, Link, wfs } from '../common'; -import { getFieldConfigClassInfo } from '../common/decorators/fieldConfig/classFieldConfig.decorator'; import { IPropPYCSWMapping } from './layerRASTERMetadata'; import { VectorFeatureTypeStructure } from './vectorFeatureTypeStructure'; -export interface IVectorBestMetadata { - id: string | undefined; - keywords: string | undefined; - links: Link[] | undefined; - type: RecordType | undefined; - classification: string | undefined; - productName: string | undefined; - description: string | undefined; - srsId: string | undefined; - srsName: string | undefined; - producerName: string | undefined; - footprint: GeoJSON | undefined; - productType: ProductType | undefined; - featureStructure: VectorFeatureTypeStructure | undefined; -} - @graphqlClass({ alias: 'VectorBestRecord' }) export class VectorBestMetadata implements IVectorBestMetadata { //#region COMMON FIELDS @@ -373,3 +357,19 @@ export class VectorBestMetadata implements IVectorBestMetadata { return []; } } + +export interface IVectorBestMetadata { + id: string | undefined; + keywords: string | undefined; + links: Link[] | undefined; + type: RecordType | undefined; + classification: string | undefined; + productName: string | undefined; + description: string | undefined; + srsId: string | undefined; + srsName: string | undefined; + producerName: string | undefined; + footprint: GeoJSON | undefined; + productType: ProductType | undefined; + featureStructure: VectorFeatureTypeStructure | undefined; +} From 30be150e1bd53f0460e22f9ecd3b801da36cd9fc Mon Sep 17 00:00:00 2001 From: Eliav Maimon Date: Mon, 5 May 2025 12:38:20 +0300 Subject: [PATCH 5/8] chore: bump types --- package-lock.json | 30 ++++++++++-------------------- package.json | 2 +- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9ab936e7..0f929a44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ }, "peerDependencies": { "@map-colonies/mc-utils": ">=1.8.0", - "@map-colonies/types": "1.6.0" + "@map-colonies/types": "1.6.1" } }, "node_modules/@ampproject/remapping": { @@ -1697,10 +1697,9 @@ } }, "node_modules/@map-colonies/types": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@map-colonies/types/-/types-1.6.0.tgz", - "integrity": "sha512-51bHTX0K5L+vsKTi8KA25ie2OShZzJSM9CG1D/JYe6fO+w8owJCxZOZOZsxDmCCBacBzGpsiAnsCcyW3QQFQag==", - "license": "ISC", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@map-colonies/types/-/types-1.6.1.tgz", + "integrity": "sha512-iXb04ps0vbD8bysy9EwOClkGC0cj52YGa6BzSTWbCU+7bKH7XMrgyyDuNn6W07H6g5nZcB+MNt2x6Z6yljgTSg==", "dependencies": { "@types/geojson": "^7946.0.16", "@types/mime-types": "^2.1.1", @@ -1873,7 +1872,6 @@ "version": "0.19.0", "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.19.0.tgz", "integrity": "sha512-Unz/WHmd4pGax91rdIKWi51wnVUW11QttMEPpBiBgIewnc9UQIX7UDLxr5vRlqeByXCwhkF6VabSsI0raWcyAQ==", - "license": "MIT", "dependencies": { "fast-glob": "^3.2.12", "minimatch": "^7.4.3", @@ -1885,7 +1883,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } @@ -1894,7 +1891,6 @@ "version": "7.4.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.6.tgz", "integrity": "sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==", - "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -1909,7 +1905,6 @@ "version": "2.1.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-2.1.6.tgz", "integrity": "sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==", - "license": "MIT", "bin": { "mkdirp": "dist/cjs/src/bin.js" }, @@ -3706,8 +3701,7 @@ "node_modules/@types/mime-types": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@types/mime-types/-/mime-types-2.1.4.tgz", - "integrity": "sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w==", - "license": "MIT" + "integrity": "sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w==" }, "node_modules/@types/minimatch": { "version": "3.0.5", @@ -5042,8 +5036,7 @@ "node_modules/code-block-writer": { "version": "12.0.0", "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-12.0.0.tgz", - "integrity": "sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==", - "license": "MIT" + "integrity": "sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==" }, "node_modules/collect-v8-coverage": { "version": "1.0.1", @@ -6465,7 +6458,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/epsg-index/-/epsg-index-1.3.0.tgz", "integrity": "sha512-pWJ7lkMbH0Au+MJyBV4GxiX+KmOknPc6c5FqDAYD61Ju3LblR60VGmOlteBhK9Dm3oy++Jxa2kUimONeSvsKRA==", - "license": "ISC", "engines": { "node": ">=8" } @@ -11067,8 +11059,7 @@ "node_modules/path-browserify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", - "license": "MIT" + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" }, "node_modules/path-exists": { "version": "4.0.0", @@ -13282,7 +13273,6 @@ "version": "18.0.0", "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-18.0.0.tgz", "integrity": "sha512-Kg5u0mk19PIIe4islUI/HWRvm9bC1lHejK4S0oh1zaZ77TMZAEmQC0sHQYiu2RgCQFZKXz1fMVi/7nOOeirznA==", - "license": "MIT", "dependencies": { "@ts-morph/common": "~0.19.0", "code-block-writer": "^12.0.0" @@ -15277,9 +15267,9 @@ } }, "@map-colonies/types": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@map-colonies/types/-/types-1.6.0.tgz", - "integrity": "sha512-51bHTX0K5L+vsKTi8KA25ie2OShZzJSM9CG1D/JYe6fO+w8owJCxZOZOZsxDmCCBacBzGpsiAnsCcyW3QQFQag==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@map-colonies/types/-/types-1.6.1.tgz", + "integrity": "sha512-iXb04ps0vbD8bysy9EwOClkGC0cj52YGa6BzSTWbCU+7bKH7XMrgyyDuNn6W07H6g5nZcB+MNt2x6Z6yljgTSg==", "requires": { "@types/geojson": "^7946.0.16", "@types/mime-types": "^2.1.1", diff --git a/package.json b/package.json index d635280e..68a0d18a 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ }, "peerDependencies": { "@map-colonies/mc-utils": ">=1.8.0", - "@map-colonies/types": "1.6.0" + "@map-colonies/types": "1.6.1" }, "devDependencies": { "@commitlint/cli": "^11.0.0", From ada61c9fa00cd958fbf9f9d862f3d698348e2b2a Mon Sep 17 00:00:00 2001 From: Eliav Maimon Date: Mon, 5 May 2025 14:38:58 +0300 Subject: [PATCH 6/8] fix: remove error throw --- src/models/layerMetadata/vectorBestMetadata.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/layerMetadata/vectorBestMetadata.ts b/src/models/layerMetadata/vectorBestMetadata.ts index 6970bab3..eeb2cf50 100644 --- a/src/models/layerMetadata/vectorBestMetadata.ts +++ b/src/models/layerMetadata/vectorBestMetadata.ts @@ -319,7 +319,7 @@ export class VectorBestMetadata implements IVectorBestMetadata { } public static getPyCSWMappings(): IPropPYCSWMapping[] { - throw new Error('NOT IMPLEMENTED'); + return []; } public static getWFSMappings(): IPropWFSMapping[] { From 68286a0236c7550c77219deafad0a94bb63cccb4 Mon Sep 17 00:00:00 2001 From: Eliav Maimon Date: Tue, 6 May 2025 11:16:58 +0300 Subject: [PATCH 7/8] fix: remove unnecessary footprint field --- src/models/layerMetadata/layerRASTERMetadata.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/models/layerMetadata/layerRASTERMetadata.ts b/src/models/layerMetadata/layerRASTERMetadata.ts index fbea9eca..38a9a990 100644 --- a/src/models/layerMetadata/layerRASTERMetadata.ts +++ b/src/models/layerMetadata/layerRASTERMetadata.ts @@ -1166,7 +1166,6 @@ export class LayerMetadata implements RasterLayerMetadata { const DUMMY_VALUE_TRANSPARENCY = Transparency.OPAQUE; const DUMMY_VALUE_TILE_OUTPUT_FORMAT = TileOutputFormat.JPEG; const DUMMY_VALUE_TILE_MIME_FORMAT = 'image/png'; - const DUMMY_VALUE_GEOJSON = { features: [], type: 'FeatureCollection' } as GeoJSON; this.classification = DUMMY_VALUE_STRING; this.id = DUMMY_VALUE_STRING; @@ -1182,7 +1181,6 @@ export class LayerMetadata implements RasterLayerMetadata { this.maxHorizontalAccuracyCE90 = DUMMY_VALUE_NUMBER; this.region = [DUMMY_VALUE_STRING]; this.sensors = [DUMMY_VALUE_STRING]; - this.footprint = DUMMY_VALUE_GEOJSON; this.imagingTimeBeginUTC = new Date(); this.imagingTimeEndUTC = new Date(); this.updateDateUTC = new Date(); From f786ffe43169d5d7e4338cc8794924ab5a2a1576 Mon Sep 17 00:00:00 2001 From: Eliav Maimon Date: Tue, 6 May 2025 11:18:33 +0300 Subject: [PATCH 8/8] fix: remove console log --- tests/unit/polygonParts.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/polygonParts.spec.ts b/tests/unit/polygonParts.spec.ts index 30265761..4f764c32 100644 --- a/tests/unit/polygonParts.spec.ts +++ b/tests/unit/polygonParts.spec.ts @@ -15,7 +15,6 @@ describe('PolygonParts class static methods', () => { it('getWFSMappings(): class property members HAS WFS mapped fields', () => { const ppWFSMappings = PolygonPartRecord.getWFSMappings(); - console.log(ppWFSMappings); expect(ppWFSMappings.length).toBeGreaterThan(0); });