From 5cfc676c1d58fbfd1f8b8890038d023237e72cd4 Mon Sep 17 00:00:00 2001 From: NicoleNG18 Date: Tue, 17 Mar 2026 23:30:57 +0200 Subject: [PATCH] regenerate module to remove dao folder --- codbex-uoms/codbex-uoms.gen | 60 ++- .../api/Settings/DimensionController.ts | 4 +- .../codbex-uoms/api/Settings/UoMController.ts | 4 +- .../dao/Settings/Dimension.extensionpoint | 4 - .../dao/Settings/DimensionRepository.ts | 261 -------------- .../dao/Settings/UoM.extensionpoint | 4 - .../codbex-uoms/dao/Settings/UoMRepository.ts | 341 ------------------ .../gen/codbex-uoms/dao/utils/EntityUtils.ts | 20 - .../data/Settings/DimensionRepository.ts | 2 +- .../data/Settings/UoMRepository.ts | 2 +- .../Dimension/dialog-window/index.html | 14 +- .../ui/Settings/UoM/dialog-window/index.html | 31 +- .../translations/en-US/codbex-uoms.model.json | 5 +- 13 files changed, 77 insertions(+), 675 deletions(-) delete mode 100644 codbex-uoms/gen/codbex-uoms/dao/Settings/Dimension.extensionpoint delete mode 100644 codbex-uoms/gen/codbex-uoms/dao/Settings/DimensionRepository.ts delete mode 100644 codbex-uoms/gen/codbex-uoms/dao/Settings/UoM.extensionpoint delete mode 100644 codbex-uoms/gen/codbex-uoms/dao/Settings/UoMRepository.ts delete mode 100644 codbex-uoms/gen/codbex-uoms/dao/utils/EntityUtils.ts diff --git a/codbex-uoms/codbex-uoms.gen b/codbex-uoms/codbex-uoms.gen index 2ef0e21..53e6cd2 100644 --- a/codbex-uoms/codbex-uoms.gen +++ b/codbex-uoms/codbex-uoms.gen @@ -2,28 +2,15 @@ "tablePrefix": "CODBEX_", "brand": "codbex", "brandUrl": "https://www.codbex.com/", - "title": "UOMs Management Module", - "description": "Managing UOMs Data", - "fileName": "codbex-uoms", - "genFolderName": "codbex-uoms", - "dataSource": "DefaultDB", - "roles": [ - { - "entityName": "Dimension", - "roleRead": "codbex-uoms.Dimensions.DimensionReadOnly", - "roleWrite": "codbex-uoms.Dimensions.DimensionFullAccess" - }, - { - "entityName": "UoM", - "roleRead": "codbex-uoms.UnitsOfMeasures.UoMReadOnly", - "roleWrite": "codbex-uoms.UnitsOfMeasures.UoMFullAccess" - } - ], - "tprefix": "codbex-uoms-model", + "title": "Uoms Management Module", + "description": "Managing Uoms Data", "projectName": "codbex-uoms", "workspaceName": "workspace", "filePath": "codbex-uoms.model", "templateId": "template-application-angular-v2/template/template.js", + "fileName": "codbex-uoms", + "genFolderName": "codbex-uoms", + "dataSource": "DefaultDB", "perspectives": { "Settings": { "views": [ @@ -39,10 +26,24 @@ "role": "" } }, + "roles": [ + { + "entityName": "Dimension", + "roleRead": "codbex-uoms.Dimensions.DimensionReadOnly", + "roleWrite": "codbex-uoms.Dimensions.DimensionFullAccess" + }, + { + "entityName": "UoM", + "roleRead": "codbex-uoms.UnitsOfMeasures.UoMReadOnly", + "roleWrite": "codbex-uoms.UnitsOfMeasures.UoMFullAccess" + } + ], + "tprefix": "codbex-uoms-model", "models": [ { "properties": [ { + "auditType": "NONE", "dataAutoIncrement": true, "dataName": "DIMENSION_ID", "dataNullable": true, @@ -59,6 +60,7 @@ "dataUnique": false, "isRequiredProperty": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Id", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -67,6 +69,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataLength": "100", "dataName": "DIMENSION_NAME", "dataNullable": false, @@ -84,6 +87,7 @@ "dataAutoIncrement": false, "dataPrimaryKey": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Name", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -94,6 +98,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataLength": "20", "dataName": "DIMENSION_SAP", "dataNullable": true, @@ -111,6 +116,7 @@ "dataPrimaryKey": false, "isRequiredProperty": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "SAP", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -157,6 +163,7 @@ { "properties": [ { + "auditType": "NONE", "dataAutoIncrement": true, "dataName": "UOM_ID", "dataNullable": true, @@ -173,6 +180,7 @@ "dataUnique": false, "isRequiredProperty": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Id", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -181,6 +189,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataLength": "100", "dataName": "UOM_NAME", "dataNullable": false, @@ -198,6 +207,7 @@ "dataAutoIncrement": false, "dataPrimaryKey": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Name", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -208,6 +218,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataLength": "20", "dataName": "UOM_ISO", "dataNullable": false, @@ -225,6 +236,7 @@ "dataAutoIncrement": false, "dataPrimaryKey": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "ISO", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -235,6 +247,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataName": "UOM_DIMENSION", "dataNullable": false, "dataType": "INTEGER", @@ -257,6 +270,7 @@ "dataPrimaryKey": false, "dataUnique": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Dimension", "widgetDropdownUrl": "/services/ts/codbex-uoms/gen/codbex-uoms/api/Settings/DimensionService.ts", "widgetDropdownControllerUrl": "/services/ts/codbex-uoms/gen/codbex-uoms/api/Settings/DimensionController.ts", @@ -265,6 +279,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataLength": "20", "dataName": "UOM_SAP", "dataNullable": true, @@ -286,6 +301,7 @@ "dataPrimaryKey": false, "isRequiredProperty": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "SAP", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -296,6 +312,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataName": "UOM_NUMERATOR", "dataNullable": false, "dataType": "BIGINT", @@ -312,6 +329,7 @@ "dataPrimaryKey": false, "dataUnique": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Numerator", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -320,6 +338,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataName": "UOM_DENOMINATOR", "dataNullable": false, "dataType": "BIGINT", @@ -336,6 +355,7 @@ "dataPrimaryKey": false, "dataUnique": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Denominator", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -344,6 +364,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataDefaultValue": "0", "dataName": "UOM_ROUNDING", "dataNullable": false, @@ -361,6 +382,7 @@ "dataPrimaryKey": false, "dataUnique": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Rounding", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", @@ -369,6 +391,7 @@ "inputRule": "" }, { + "auditType": "NONE", "dataDefaultValue": "false", "dataName": "UOM_BASE", "dataNullable": false, @@ -386,6 +409,7 @@ "dataUnique": false, "isRequiredProperty": false, "isCalculatedProperty": false, + "isReadOnlyProperty": false, "widgetLabel": "Base", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", diff --git a/codbex-uoms/gen/codbex-uoms/api/Settings/DimensionController.ts b/codbex-uoms/gen/codbex-uoms/api/Settings/DimensionController.ts index 3627fee..bac4bfb 100644 --- a/codbex-uoms/gen/codbex-uoms/api/Settings/DimensionController.ts +++ b/codbex-uoms/gen/codbex-uoms/api/Settings/DimensionController.ts @@ -27,7 +27,7 @@ class DimensionController { const options: Options = { limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : 20, offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : 0, - language: request.getLocale().slice(0, 2) + language: request.getLocale().split("_")[0] }; return this.repository.findAll(options); @@ -96,7 +96,7 @@ class DimensionController { this.checkPermissions('read'); const id = parseInt(ctx.pathParameters.id); const options: Options = { - language: request.getLocale().slice(0, 2) + language: request.getLocale().split("_")[0] }; const entity = this.repository.findById(id, options); if (entity) { diff --git a/codbex-uoms/gen/codbex-uoms/api/Settings/UoMController.ts b/codbex-uoms/gen/codbex-uoms/api/Settings/UoMController.ts index 712c4e0..05f5379 100644 --- a/codbex-uoms/gen/codbex-uoms/api/Settings/UoMController.ts +++ b/codbex-uoms/gen/codbex-uoms/api/Settings/UoMController.ts @@ -27,7 +27,7 @@ class UoMController { const options: Options = { limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : 20, offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : 0, - language: request.getLocale().slice(0, 2) + language: request.getLocale().split("_")[0] }; return this.repository.findAll(options); @@ -96,7 +96,7 @@ class UoMController { this.checkPermissions('read'); const id = parseInt(ctx.pathParameters.id); const options: Options = { - language: request.getLocale().slice(0, 2) + language: request.getLocale().split("_")[0] }; const entity = this.repository.findById(id, options); if (entity) { diff --git a/codbex-uoms/gen/codbex-uoms/dao/Settings/Dimension.extensionpoint b/codbex-uoms/gen/codbex-uoms/dao/Settings/Dimension.extensionpoint deleted file mode 100644 index 78ace43..0000000 --- a/codbex-uoms/gen/codbex-uoms/dao/Settings/Dimension.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-uoms-Settings-Dimension", - "description": "Extension Point for the codbex-uoms-Settings-Dimension entity" -} \ No newline at end of file diff --git a/codbex-uoms/gen/codbex-uoms/dao/Settings/DimensionRepository.ts b/codbex-uoms/gen/codbex-uoms/dao/Settings/DimensionRepository.ts deleted file mode 100644 index 351dfa3..0000000 --- a/codbex-uoms/gen/codbex-uoms/dao/Settings/DimensionRepository.ts +++ /dev/null @@ -1,261 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; - -export interface DimensionEntity { - readonly Id: number; - Name: string; - SAP?: string; -} - -export interface DimensionCreateEntity { - readonly Name: string; - readonly SAP?: string; -} - -export interface DimensionUpdateEntity extends DimensionCreateEntity { - readonly Id: number; -} - -export interface DimensionEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Name?: string | string[]; - SAP?: string | string[]; - }; - notEquals?: { - Id?: number | number[]; - Name?: string | string[]; - SAP?: string | string[]; - }; - contains?: { - Id?: number; - Name?: string; - SAP?: string; - }; - greaterThan?: { - Id?: number; - Name?: string; - SAP?: string; - }; - greaterThanOrEqual?: { - Id?: number; - Name?: string; - SAP?: string; - }; - lessThan?: { - Id?: number; - Name?: string; - SAP?: string; - }; - lessThanOrEqual?: { - Id?: number; - Name?: string; - SAP?: string; - }; - }, - $select?: (keyof DimensionEntity)[], - $sort?: string | (keyof DimensionEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface DimensionEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface DimensionUpdateEntityEvent extends DimensionEntityEvent { - readonly previousEntity: DimensionEntity; -} - -export class DimensionRepository { - - private static readonly DEFINITION = { - table: "CODBEX_DIMENSION", - properties: [ - { - name: "Id", - column: "DIMENSION_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Name", - column: "DIMENSION_NAME", - type: "VARCHAR", - required: true - }, - { - name: "SAP", - column: "DIMENSION_SAP", - type: "VARCHAR", - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(DimensionRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: DimensionEntityOptions = {}): DimensionEntity[] { - let list = this.dao.list(options); - try { - let script = sql.getDialect().select().column("*").from('"' + DimensionRepository.DEFINITION.table + '_LANG"').where('Language = ?').build(); - const resultSet = query.execute(script, [options.$language]); - if (resultSet !== null && resultSet[0] !== null) { - let translatedProperties = Object.getOwnPropertyNames(resultSet[0]); - let maps = []; - for (let i = 0; i < translatedProperties.length - 2; i++) { - maps[i] = {}; - } - resultSet.forEach((r) => { - for (let i = 0; i < translatedProperties.length - 2; i++) { - maps[i][r[translatedProperties[0]]] = r[translatedProperties[i + 1]]; - } - }); - list.forEach((r) => { - for (let i = 0; i < translatedProperties.length - 2; i++) { - if (maps[i][r[translatedProperties[0]]]) { - r[translatedProperties[i + 1]] = maps[i][r[translatedProperties[0]]]; - } - } - - }); - } - } catch (Error) { - console.error("Entity is marked as language dependent, but no language table present: " + DimensionRepository.DEFINITION.table); - } - return list; - } - - public findById(id: number, options: DimensionEntityOptions = {}): DimensionEntity | undefined { - const entity = this.dao.find(id); - if (entity) { - try { - let script = sql.getDialect().select().column("*").from('"' + DimensionRepository.DEFINITION.table + '_LANG"').where('Language = ?').where('Id = ?').build(); - const resultSet = query.execute(script, [options.$language, id]); - let translatedProperties = Object.getOwnPropertyNames(resultSet[0]); - let maps = []; - for (let i = 0; i < translatedProperties.length - 2; i++) { - maps[i] = {}; - } - resultSet.forEach((r) => { - for (let i = 0; i < translatedProperties.length - 2; i++) { - maps[i][r[translatedProperties[0]]] = r[translatedProperties[i + 1]]; - } - }); - for (let i = 0; i < translatedProperties.length - 2; i++) { - if (maps[i][entity[translatedProperties[0]]]) { - entity[translatedProperties[i + 1]] = maps[i][entity[translatedProperties[0]]]; - } - } - } catch (Error) { - console.error("Entity is marked as language dependent, but no language table present: " + DimensionRepository.DEFINITION.table); - } - } - return entity ?? undefined; - } - - public create(entity: DimensionCreateEntity): number { - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_DIMENSION", - entity: entity, - key: { - name: "Id", - column: "DIMENSION_ID", - value: id - } - }); - return id; - } - - public update(entity: DimensionUpdateEntity): void { - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_DIMENSION", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "DIMENSION_ID", - value: entity.Id - } - }); - } - - public upsert(entity: DimensionCreateEntity | DimensionUpdateEntity): number { - const id = (entity as DimensionUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as DimensionUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_DIMENSION", - entity: entity, - key: { - name: "Id", - column: "DIMENSION_ID", - value: id - } - }); - } - - public count(options?: DimensionEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX__DIMENSION"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: DimensionEntityEvent | DimensionUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-uoms-Settings-Dimension", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-uoms-Settings-Dimension").send(JSON.stringify(data)); - } -} diff --git a/codbex-uoms/gen/codbex-uoms/dao/Settings/UoM.extensionpoint b/codbex-uoms/gen/codbex-uoms/dao/Settings/UoM.extensionpoint deleted file mode 100644 index d1a4785..0000000 --- a/codbex-uoms/gen/codbex-uoms/dao/Settings/UoM.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-uoms-Settings-UoM", - "description": "Extension Point for the codbex-uoms-Settings-UoM entity" -} \ No newline at end of file diff --git a/codbex-uoms/gen/codbex-uoms/dao/Settings/UoMRepository.ts b/codbex-uoms/gen/codbex-uoms/dao/Settings/UoMRepository.ts deleted file mode 100644 index ea129a7..0000000 --- a/codbex-uoms/gen/codbex-uoms/dao/Settings/UoMRepository.ts +++ /dev/null @@ -1,341 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; -import { EntityUtils } from "../utils/EntityUtils"; - -export interface UoMEntity { - readonly Id: number; - Name: string; - ISO: string; - Dimension: number; - SAP?: string; - Numerator: number; - Denominator: number; - Rounding: number; - Base: boolean; -} - -export interface UoMCreateEntity { - readonly Name: string; - readonly ISO: string; - readonly Dimension: number; - readonly SAP?: string; - readonly Numerator: number; - readonly Denominator: number; - readonly Rounding: number; - readonly Base: boolean; -} - -export interface UoMUpdateEntity extends UoMCreateEntity { - readonly Id: number; -} - -export interface UoMEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Name?: string | string[]; - ISO?: string | string[]; - Dimension?: number | number[]; - SAP?: string | string[]; - Numerator?: number | number[]; - Denominator?: number | number[]; - Rounding?: number | number[]; - Base?: boolean | boolean[]; - }; - notEquals?: { - Id?: number | number[]; - Name?: string | string[]; - ISO?: string | string[]; - Dimension?: number | number[]; - SAP?: string | string[]; - Numerator?: number | number[]; - Denominator?: number | number[]; - Rounding?: number | number[]; - Base?: boolean | boolean[]; - }; - contains?: { - Id?: number; - Name?: string; - ISO?: string; - Dimension?: number; - SAP?: string; - Numerator?: number; - Denominator?: number; - Rounding?: number; - Base?: boolean; - }; - greaterThan?: { - Id?: number; - Name?: string; - ISO?: string; - Dimension?: number; - SAP?: string; - Numerator?: number; - Denominator?: number; - Rounding?: number; - Base?: boolean; - }; - greaterThanOrEqual?: { - Id?: number; - Name?: string; - ISO?: string; - Dimension?: number; - SAP?: string; - Numerator?: number; - Denominator?: number; - Rounding?: number; - Base?: boolean; - }; - lessThan?: { - Id?: number; - Name?: string; - ISO?: string; - Dimension?: number; - SAP?: string; - Numerator?: number; - Denominator?: number; - Rounding?: number; - Base?: boolean; - }; - lessThanOrEqual?: { - Id?: number; - Name?: string; - ISO?: string; - Dimension?: number; - SAP?: string; - Numerator?: number; - Denominator?: number; - Rounding?: number; - Base?: boolean; - }; - }, - $select?: (keyof UoMEntity)[], - $sort?: string | (keyof UoMEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface UoMEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface UoMUpdateEntityEvent extends UoMEntityEvent { - readonly previousEntity: UoMEntity; -} - -export class UoMRepository { - - private static readonly DEFINITION = { - table: "CODBEX_UOM", - properties: [ - { - name: "Id", - column: "UOM_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Name", - column: "UOM_NAME", - type: "VARCHAR", - required: true - }, - { - name: "ISO", - column: "UOM_ISO", - type: "VARCHAR", - required: true - }, - { - name: "Dimension", - column: "UOM_DIMENSION", - type: "INTEGER", - required: true - }, - { - name: "SAP", - column: "UOM_SAP", - type: "VARCHAR", - }, - { - name: "Numerator", - column: "UOM_NUMERATOR", - type: "BIGINT", - required: true - }, - { - name: "Denominator", - column: "UOM_DENOMINATOR", - type: "BIGINT", - required: true - }, - { - name: "Rounding", - column: "UOM_ROUNDING", - type: "INTEGER", - required: true - }, - { - name: "Base", - column: "UOM_BASE", - type: "BOOLEAN", - required: true - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(UoMRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: UoMEntityOptions = {}): UoMEntity[] { - let list = this.dao.list(options).map((e: UoMEntity) => { - EntityUtils.setBoolean(e, "Base"); - return e; - }); - try { - let script = sql.getDialect().select().column("*").from('"' + UoMRepository.DEFINITION.table + '_LANG"').where('Language = ?').build(); - const resultSet = query.execute(script, [options.$language]); - if (resultSet !== null && resultSet[0] !== null) { - let translatedProperties = Object.getOwnPropertyNames(resultSet[0]); - let maps = []; - for (let i = 0; i < translatedProperties.length - 2; i++) { - maps[i] = {}; - } - resultSet.forEach((r) => { - for (let i = 0; i < translatedProperties.length - 2; i++) { - maps[i][r[translatedProperties[0]]] = r[translatedProperties[i + 1]]; - } - }); - list.forEach((r) => { - for (let i = 0; i < translatedProperties.length - 2; i++) { - if (maps[i][r[translatedProperties[0]]]) { - r[translatedProperties[i + 1]] = maps[i][r[translatedProperties[0]]]; - } - } - - }); - } - } catch (Error) { - console.error("Entity is marked as language dependent, but no language table present: " + UoMRepository.DEFINITION.table); - } - return list; - } - - public findById(id: number, options: UoMEntityOptions = {}): UoMEntity | undefined { - const entity = this.dao.find(id); - EntityUtils.setBoolean(entity, "Base"); - return entity ?? undefined; - } - - public create(entity: UoMCreateEntity): number { - EntityUtils.setBoolean(entity, "Base"); - if (entity.Rounding === undefined || entity.Rounding === null) { - (entity as UoMEntity).Rounding = 0; - } - if (entity.Base === undefined || entity.Base === null) { - (entity as UoMEntity).Base = false; - } - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_UOM", - entity: entity, - key: { - name: "Id", - column: "UOM_ID", - value: id - } - }); - return id; - } - - public update(entity: UoMUpdateEntity): void { - EntityUtils.setBoolean(entity, "Base"); - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_UOM", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "UOM_ID", - value: entity.Id - } - }); - } - - public upsert(entity: UoMCreateEntity | UoMUpdateEntity): number { - const id = (entity as UoMUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as UoMUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_UOM", - entity: entity, - key: { - name: "Id", - column: "UOM_ID", - value: id - } - }); - } - - public count(options?: UoMEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX__UOM"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: UoMEntityEvent | UoMUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-uoms-Settings-UoM", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-uoms-Settings-UoM").send(JSON.stringify(data)); - } -} diff --git a/codbex-uoms/gen/codbex-uoms/dao/utils/EntityUtils.ts b/codbex-uoms/gen/codbex-uoms/dao/utils/EntityUtils.ts deleted file mode 100644 index 0f8815d..0000000 --- a/codbex-uoms/gen/codbex-uoms/dao/utils/EntityUtils.ts +++ /dev/null @@ -1,20 +0,0 @@ -export class EntityUtils { - - public static setDate(obj: any, property: string): void { - if (obj && obj[property]) { - obj[property] = new Date(obj[property]).getTime(); - } - } - - public static setLocalDate(obj: any, property: string): void { - if (obj && obj[property]) { - obj[property] = new Date(new Date(obj[property]).setHours(-(new Date().getTimezoneOffset() / 60), 0, 0, 0)).toISOString(); - } - } - - public static setBoolean(obj: any, property: string): void { - if (obj && obj[property] !== undefined) { - obj[property] = obj[property] ? true : false; - } - } -} \ No newline at end of file diff --git a/codbex-uoms/gen/codbex-uoms/data/Settings/DimensionRepository.ts b/codbex-uoms/gen/codbex-uoms/data/Settings/DimensionRepository.ts index ec5ed37..5d66224 100644 --- a/codbex-uoms/gen/codbex-uoms/data/Settings/DimensionRepository.ts +++ b/codbex-uoms/gen/codbex-uoms/data/Settings/DimensionRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' diff --git a/codbex-uoms/gen/codbex-uoms/data/Settings/UoMRepository.ts b/codbex-uoms/gen/codbex-uoms/data/Settings/UoMRepository.ts index f05d45e..0f38122 100644 --- a/codbex-uoms/gen/codbex-uoms/data/Settings/UoMRepository.ts +++ b/codbex-uoms/gen/codbex-uoms/data/Settings/UoMRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' diff --git a/codbex-uoms/gen/codbex-uoms/ui/Settings/Dimension/dialog-window/index.html b/codbex-uoms/gen/codbex-uoms/ui/Settings/Dimension/dialog-window/index.html index 21d692d..ddaab0e 100644 --- a/codbex-uoms/gen/codbex-uoms/ui/Settings/Dimension/dialog-window/index.html +++ b/codbex-uoms/gen/codbex-uoms/ui/Settings/Dimension/dialog-window/index.html @@ -23,15 +23,16 @@ {{ 'codbex-uoms:codbex-uoms-model.t.DIMENSION_NAME' | t }}
- + @@ -43,15 +44,16 @@ {{ 'codbex-uoms:codbex-uoms-model.t.DIMENSION_SAP' | t }}
- + diff --git a/codbex-uoms/gen/codbex-uoms/ui/Settings/UoM/dialog-window/index.html b/codbex-uoms/gen/codbex-uoms/ui/Settings/UoM/dialog-window/index.html index f860774..df196df 100644 --- a/codbex-uoms/gen/codbex-uoms/ui/Settings/UoM/dialog-window/index.html +++ b/codbex-uoms/gen/codbex-uoms/ui/Settings/UoM/dialog-window/index.html @@ -23,15 +23,16 @@ {{ 'codbex-uoms:codbex-uoms-model.t.UOM_NAME' | t }}
- + @@ -43,15 +44,16 @@ {{ 'codbex-uoms:codbex-uoms-model.t.UOM_ISO' | t }}
- + @@ -68,7 +70,7 @@ state="{{ forms.details['Dimension'].$valid ? '' : 'error' }}" ng-required="true" ng-model="entity.Dimension" - is-readonly="true" + is-readonly="action === 'select'" dropdown-items="optionsDimension" placeholder="{{ 'codbex-uoms:codbex-uoms-model.messages.inputSearch' | t:{'name':'$t(codbex-uoms:codbex-uoms-model.t.UOM_DIMENSION)'} }}" btn-aria-label="{{ 'codbex-uoms:codbex-uoms-model.aria.showHide' | t:{'name':'Dimension'} }}" list-aria-label="{{ 'codbex-uoms:codbex-uoms-model.aria.options' | t:{'name':'Dimension'} }}"> @@ -80,15 +82,16 @@ {{ 'codbex-uoms:codbex-uoms-model.t.UOM_SAP' | t }}
- + @@ -105,7 +108,7 @@ state="{{ forms.details['Numerator'].$valid ? '' : 'error' }}" ng-required="true" ng-model="entity.Numerator" - is-readonly="true" + is-readonly="action === 'select'" placeholder="{{ 'codbex-uoms:codbex-uoms-model.messages.inputEnter' | t:{'name':'$t(codbex-uoms:codbex-uoms-model.t.UOM_NUMERATOR)'} }}">
@@ -120,7 +123,7 @@ state="{{ forms.details['Denominator'].$valid ? '' : 'error' }}" ng-required="true" ng-model="entity.Denominator" - is-readonly="true" + is-readonly="action === 'select'" placeholder="{{ 'codbex-uoms:codbex-uoms-model.messages.inputEnter' | t:{'name':'$t(codbex-uoms:codbex-uoms-model.t.UOM_DENOMINATOR)'} }}"> @@ -135,7 +138,7 @@ state="{{ forms.details['Rounding'].$valid ? '' : 'error' }}" ng-required="true" ng-model="entity.Rounding" - is-readonly="true" + is-readonly="action === 'select'" placeholder="{{ 'codbex-uoms:codbex-uoms-model.messages.inputEnter' | t:{'name':'$t(codbex-uoms:codbex-uoms-model.t.UOM_ROUNDING)'} }}"> @@ -146,7 +149,7 @@ {{ 'codbex-uoms:codbex-uoms-model.t.UOM_BASE' | t }} diff --git a/codbex-uoms/translations/en-US/codbex-uoms.model.json b/codbex-uoms/translations/en-US/codbex-uoms.model.json index 6dff440..311342b 100644 --- a/codbex-uoms/translations/en-US/codbex-uoms.model.json +++ b/codbex-uoms/translations/en-US/codbex-uoms.model.json @@ -24,7 +24,10 @@ "unableToLoad": "Unable to load data: '{{message}}'", "unableToLF": "Unable to list/filter {{name}}: '{{message}}'", "unableToCount": "Unable to count {{name}}: '{{message}}'", - "pattern": "The value doesn't match the required pattern: {{rule}}" + "pattern": "The value doesn't match the required pattern: {{rule}}", + "lengthMinMax": "Value must be between {{min}} and {{max}} characters long", + "lengthMin": "Value must not be less than {{min}} characters", + "lengthMax": "Value must not be more than {{max}} characters" }, "propertySuccessfullyCreated": "{{name}} successfully created", "propertySuccessfullyUpdated": "{{name}} successfully updated",