From 26afe132a48d63fe5f88b38c4e4a9704ec660309 Mon Sep 17 00:00:00 2001 From: NicoleNG18 Date: Tue, 9 Jun 2026 15:05:24 +0300 Subject: [PATCH 1/2] regenerate module with new Java template --- codbex-accounts/codbex-accounts.gen | 51 +++-- .../JournalEntry/JournalEntryController.ts | 181 ------------------ .../api/Settings/AccountController.ts | 181 ------------------ .../JournalEntryDirectionController.ts | 159 --------------- .../data/JournalEntry/JournalEntryEntity.ts | 80 -------- .../JournalEntry/JournalEntryRepository.ts | 45 ----- .../data/Settings/AccountEntity.ts | 42 ---- .../data/Settings/AccountRepository.ts | 25 --- .../Settings/JournalEntryDirectionEntity.ts | 35 ---- .../JournalEntryDirectionRepository.ts | 25 --- .../odata/codbex-accounts.odata | 4 - .../JournalEntry/JournalEntry/controller.js | 14 +- .../JournalEntry/dialog-filter/controller.js | 8 +- .../JournalEntry/dialog-window/controller.js | 18 +- .../JournalEntry/main-details/controller.js | 18 +- .../ui/Settings/Account/controller.js | 2 +- .../Account/dialog-window/controller.js | 2 +- .../JournalEntryDirection/controller.js | 2 +- .../dialog-window/controller.js | 2 +- .../journalentry/JournalEntryController.java | 173 +++++++++++++++++ .../api/settings/AccountController.java | 173 +++++++++++++++++ .../JournalEntryDirectionController.java | 153 +++++++++++++++ .../journalentry}/JournalEntry.extensionpoint | 2 +- .../data/journalentry/JournalEntryEntity.java | 58 ++++++ .../journalentry/JournalEntryRepository.java | 12 ++ .../data/settings}/Account.extensionpoint | 2 +- .../data/settings/AccountEntity.java | 38 ++++ .../data/settings/AccountRepository.java | 12 ++ .../JournalEntryDirection.extensionpoint | 2 +- .../settings/JournalEntryDirectionEntity.java | 34 ++++ .../JournalEntryDirectionRepository.java | 12 ++ .../roles/default-roles.roles | 2 +- 32 files changed, 741 insertions(+), 826 deletions(-) delete mode 100644 codbex-accounts/gen/codbex-accounts/api/JournalEntry/JournalEntryController.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntryEntity.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntryRepository.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/data/Settings/AccountEntity.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/data/Settings/AccountRepository.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirectionEntity.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirectionRepository.ts delete mode 100644 codbex-accounts/gen/codbex-accounts/odata/codbex-accounts.odata create mode 100644 codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController.java create mode 100644 codbex-accounts/gen/codbex_accounts/api/settings/AccountController.java create mode 100644 codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController.java rename codbex-accounts/gen/{codbex-accounts/data/JournalEntry => codbex_accounts/data/journalentry}/JournalEntry.extensionpoint (98%) create mode 100644 codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryEntity.java create mode 100644 codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryRepository.java rename codbex-accounts/gen/{codbex-accounts/data/Settings => codbex_accounts/data/settings}/Account.extensionpoint (98%) create mode 100644 codbex-accounts/gen/codbex_accounts/data/settings/AccountEntity.java create mode 100644 codbex-accounts/gen/codbex_accounts/data/settings/AccountRepository.java rename codbex-accounts/gen/{codbex-accounts/data/Settings => codbex_accounts/data/settings}/JournalEntryDirection.extensionpoint (98%) create mode 100644 codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionEntity.java create mode 100644 codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionRepository.java rename codbex-accounts/gen/{codbex-accounts => codbex_accounts}/roles/default-roles.roles (99%) diff --git a/codbex-accounts/codbex-accounts.gen b/codbex-accounts/codbex-accounts.gen index ab4d92d..d517298 100644 --- a/codbex-accounts/codbex-accounts.gen +++ b/codbex-accounts/codbex-accounts.gen @@ -1,15 +1,17 @@ { "tablePrefix": "CODBEX_", "brand": "codbex", - "brandUrl": "https://www.codbex.com", - "title": "Account Management Application", - "description": "Managing account data", + "brandUrl": "https://www.codbex.com/", + "title": "Accounts Management Module", + "description": "Managing Accounts Data", "projectName": "codbex-accounts", "workspaceName": "workspace", "filePath": "codbex-accounts.model", - "templateId": "template-application-angular-v2/template/template.js", + "templateId": "template-application-angular-java/template/template.js", "fileName": "codbex-accounts", "genFolderName": "codbex-accounts", + "javaRuntime": true, + "javaGenFolderName": "codbex_accounts", "dataSource": "DefaultDB", "perspectives": { "Settings": { @@ -97,6 +99,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" }, { @@ -124,6 +127,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", "minLength": 0, "maxLength": 20, "inputRule": "" @@ -152,6 +156,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" }, { @@ -178,6 +183,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "boolean", "dataTypeTypescript": "boolean", + "dataTypeJavaClass": "Boolean", "inputRule": "" } ], @@ -206,6 +212,7 @@ "tooltip": "Account", "type": "SETTING", "dataSource": "DefaultDB", + "javaPerspectiveName": "settings", "referencedProjections": [], "primaryKeys": [ "Id" @@ -238,6 +245,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" }, { @@ -264,6 +272,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "date", "dataTypeTypescript": "Date", + "dataTypeJavaClass": "java.time.LocalDate", "isDateType": true, "inputRule": "" }, @@ -293,10 +302,11 @@ "isCalculatedProperty": false, "isReadOnlyProperty": false, "widgetLabel": "Account", - "widgetDropdownUrl": "/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountService.ts", - "widgetDropdownControllerUrl": "/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts", + "widgetDropdownUrl": "/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController", + "widgetDropdownControllerUrl": "/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" }, { @@ -325,10 +335,11 @@ "isCalculatedProperty": false, "isReadOnlyProperty": false, "widgetLabel": "Direction", - "widgetDropdownUrl": "/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionService.ts", - "widgetDropdownControllerUrl": "/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts", + "widgetDropdownUrl": "/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController", + "widgetDropdownControllerUrl": "/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" }, { @@ -355,6 +366,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "timestamp", "dataTypeTypescript": "Date", + "dataTypeJavaClass": "java.time.Instant", "isDateType": true, "inputRule": "" }, @@ -383,6 +395,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", "minLength": 0, "maxLength": 20, "inputRule": "" @@ -411,6 +424,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "timestamp", "dataTypeTypescript": "Date", + "dataTypeJavaClass": "java.time.Instant", "isDateType": true, "inputRule": "" }, @@ -439,6 +453,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", "minLength": 0, "maxLength": 20, "inputRule": "" @@ -471,6 +486,7 @@ "tooltip": "JournalEntry", "type": "PRIMARY", "dataSource": "DefaultDB", + "javaPerspectiveName": "journalentry", "referencedProjections": [], "primaryKeys": [ "Id" @@ -501,6 +517,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "date", "dataTypeTypescript": "Date", + "dataTypeJavaClass": "java.time.LocalDate", "isDateType": true, "inputRule": "" }, @@ -531,10 +548,11 @@ "isCalculatedProperty": false, "isReadOnlyProperty": false, "widgetLabel": "Account", - "widgetDropdownUrl": "/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountService.ts", - "widgetDropdownControllerUrl": "/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts", + "widgetDropdownUrl": "/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController", + "widgetDropdownControllerUrl": "/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" }, { @@ -563,10 +581,11 @@ "isCalculatedProperty": false, "isReadOnlyProperty": false, "widgetLabel": "Direction", - "widgetDropdownUrl": "/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionService.ts", - "widgetDropdownControllerUrl": "/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts", + "widgetDropdownUrl": "/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController", + "widgetDropdownControllerUrl": "/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" }, { @@ -593,6 +612,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "timestamp", "dataTypeTypescript": "Date", + "dataTypeJavaClass": "java.time.Instant", "isDateType": true, "inputRule": "" }, @@ -621,6 +641,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", "minLength": 0, "maxLength": 20, "inputRule": "" @@ -649,6 +670,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "timestamp", "dataTypeTypescript": "Date", + "dataTypeJavaClass": "java.time.Instant", "isDateType": true, "inputRule": "" }, @@ -677,6 +699,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", "minLength": 0, "maxLength": 20, "inputRule": "" @@ -712,6 +735,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" }, { @@ -739,6 +763,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", "minLength": 0, "maxLength": 20, "inputRule": "" @@ -767,6 +792,7 @@ "widgetDropdownControllerUrl": "", "dataTypeJava": "int", "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", "inputRule": "" } ], @@ -793,6 +819,7 @@ "tooltip": "JournalEntryDirection", "type": "SETTING", "dataSource": "DefaultDB", + "javaPerspectiveName": "settings", "referencedProjections": [], "primaryKeys": [ "Id" diff --git a/codbex-accounts/gen/codbex-accounts/api/JournalEntry/JournalEntryController.ts b/codbex-accounts/gen/codbex-accounts/api/JournalEntry/JournalEntryController.ts deleted file mode 100644 index 16bc985..0000000 --- a/codbex-accounts/gen/codbex-accounts/api/JournalEntry/JournalEntryController.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { Controller, Get, Post, Put, Delete, Documentation, request, response } from '@aerokit/sdk/http' -import { HttpUtils } from "@aerokit/sdk/http/utils"; -import { ValidationError } from '@aerokit/sdk/http/errors' -import { ForbiddenError } from '@aerokit/sdk/http/errors' -import { user } from '@aerokit/sdk/security' -import { Options } from '@aerokit/sdk/db' -import { Extensions } from "@aerokit/sdk/extensions" -import { Injected, Inject } from '@aerokit/sdk/component' -import { JournalEntryRepository } from '../../data/JournalEntry/JournalEntryRepository' -import { JournalEntryEntity } from '../../data/JournalEntry/JournalEntryEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-accounts-JournalEntry-JournalEntry', ['validate']); - -@Controller -@Documentation('codbex-accounts - JournalEntry Controller') -@Injected() -class JournalEntryController { - - @Inject('JournalEntryRepository') - private readonly repository!: JournalEntryRepository; - - @Get('/') - @Documentation('Get All JournalEntry') - public getAll(_: any, ctx: any): JournalEntryEntity[] { - try { - this.checkPermissions('read'); - const options: Options = { - limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : 20, - offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : 0, - language: request.getLocale()?.split("_")[0] - }; - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/') - @Documentation('Create JournalEntry') - public create(entity: JournalEntryEntity): JournalEntryEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-accounts/gen/codbex-accounts/api/JournalEntry/JournalEntryController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count JournalEntry') - public count(): { count: number } { - try { - this.checkPermissions('read'); - return { count: this.repository.count() }; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/count') - @Documentation('Count JournalEntry with filter') - public countWithFilter(filter: any): { count: number } { - try { - this.checkPermissions('read'); - return { count: this.repository.count(filter) }; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/search') - @Documentation('Search JournalEntry') - public search(filter: any): JournalEntryEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get JournalEntry by id') - public getById(_: any, ctx: any): JournalEntryEntity { - try { - this.checkPermissions('read'); - const id = parseInt(ctx.pathParameters.id); - const options: Options = { - language: request.getLocale()?.split("_")[0] - }; - const entity = this.repository.findById(id, options); - if (entity) { - return entity; - } else { - HttpUtils.sendResponseNotFound('JournalEntry not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update JournalEntry by id') - public update(entity: JournalEntryEntity, ctx: any): JournalEntryEntity { - try { - this.checkPermissions('write'); - const id = parseInt(ctx.pathParameters.id); - entity.Id = id; - this.validateEntity(entity); - this.repository.update(entity); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Delete('/:id') - @Documentation('Delete JournalEntry by id') - public deleteById(_: any, ctx: any): void { - try { - this.checkPermissions('write'); - const id = parseInt(ctx.pathParameters.id); - const entity = this.repository.findById(id); - if (entity) { - this.repository.deleteById(id); - HttpUtils.sendResponseNoContent(); - } else { - HttpUtils.sendResponseNotFound('JournalEntry not found'); - } - } catch (error: any) { - this.handleError(error); - } - } - - private handleError(error: any) { - if (error.name === 'ForbiddenError') { - HttpUtils.sendForbiddenRequest(error.message); - } else if (error.name === 'ValidationError') { - HttpUtils.sendResponseBadRequest(error.message); - } else { - HttpUtils.sendInternalServerError(error.message); - } - } - - private checkPermissions(operationType: string) { - if (operationType === 'read' && !(user.isInRole('codbex-accounts.JournalEntry.JournalEntryReadOnly') || user.isInRole('codbex-accounts.JournalEntry.JournalEntryFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-accounts.JournalEntry.JournalEntryFullAccess')) { - throw new ForbiddenError(); - } - } - - private validateEntity(entity: any): void { - if (entity.Account === null || entity.Account === undefined) { - throw new ValidationError(`The 'Account' property is required, provide a valid value`); - } - if (entity.CreatedBy?.length > 20) { - throw new ValidationError(`The 'CreatedBy' exceeds the maximum length of [20] characters`); - } - if (entity.UpdatedBy?.length > 20) { - throw new ValidationError(`The 'UpdatedBy' exceeds the maximum length of [20] characters`); - } - for (const next of validationModules) { - next.validate(entity); - } - } - -} diff --git a/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts b/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts deleted file mode 100644 index 66cdb07..0000000 --- a/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { Controller, Get, Post, Put, Delete, Documentation, request, response } from '@aerokit/sdk/http' -import { HttpUtils } from "@aerokit/sdk/http/utils"; -import { ValidationError } from '@aerokit/sdk/http/errors' -import { ForbiddenError } from '@aerokit/sdk/http/errors' -import { user } from '@aerokit/sdk/security' -import { Options } from '@aerokit/sdk/db' -import { Extensions } from "@aerokit/sdk/extensions" -import { Injected, Inject } from '@aerokit/sdk/component' -import { AccountRepository } from '../../data/Settings/AccountRepository' -import { AccountEntity } from '../../data/Settings/AccountEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-accounts-Settings-Account', ['validate']); - -@Controller -@Documentation('codbex-accounts - Account Controller') -@Injected() -class AccountController { - - @Inject('AccountRepository') - private readonly repository!: AccountRepository; - - @Get('/') - @Documentation('Get All Account') - public getAll(_: any, ctx: any): AccountEntity[] { - try { - this.checkPermissions('read'); - const options: Options = { - limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : 20, - offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : 0, - language: request.getLocale()?.split("_")[0] - }; - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/') - @Documentation('Create Account') - public create(entity: AccountEntity): AccountEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count Account') - public count(): { count: number } { - try { - this.checkPermissions('read'); - return { count: this.repository.count() }; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/count') - @Documentation('Count Account with filter') - public countWithFilter(filter: any): { count: number } { - try { - this.checkPermissions('read'); - return { count: this.repository.count(filter) }; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/search') - @Documentation('Search Account') - public search(filter: any): AccountEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get Account by id') - public getById(_: any, ctx: any): AccountEntity { - try { - this.checkPermissions('read'); - const id = parseInt(ctx.pathParameters.id); - const options: Options = { - language: request.getLocale()?.split("_")[0] - }; - const entity = this.repository.findById(id, options); - if (entity) { - return entity; - } else { - HttpUtils.sendResponseNotFound('Account not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update Account by id') - public update(entity: AccountEntity, ctx: any): AccountEntity { - try { - this.checkPermissions('write'); - const id = parseInt(ctx.pathParameters.id); - entity.Id = id; - this.validateEntity(entity); - this.repository.update(entity); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Delete('/:id') - @Documentation('Delete Account by id') - public deleteById(_: any, ctx: any): void { - try { - this.checkPermissions('write'); - const id = parseInt(ctx.pathParameters.id); - const entity = this.repository.findById(id); - if (entity) { - this.repository.deleteById(id); - HttpUtils.sendResponseNoContent(); - } else { - HttpUtils.sendResponseNotFound('Account not found'); - } - } catch (error: any) { - this.handleError(error); - } - } - - private handleError(error: any) { - if (error.name === 'ForbiddenError') { - HttpUtils.sendForbiddenRequest(error.message); - } else if (error.name === 'ValidationError') { - HttpUtils.sendResponseBadRequest(error.message); - } else { - HttpUtils.sendInternalServerError(error.message); - } - } - - private checkPermissions(operationType: string) { - if (operationType === 'read' && !(user.isInRole('codbex-accounts.Accounts.AccountReadOnly') || user.isInRole('codbex-accounts.Accounts.AccountFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-accounts.Accounts.AccountFullAccess')) { - throw new ForbiddenError(); - } - } - - private validateEntity(entity: any): void { - if (entity.Name === null || entity.Name === undefined) { - throw new ValidationError(`The 'Name' property is required, provide a valid value`); - } - if (entity.Name?.length > 200) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [200] characters`); - } - if (entity.Code === null || entity.Code === undefined) { - throw new ValidationError(`The 'Code' property is required, provide a valid value`); - } - for (const next of validationModules) { - next.validate(entity); - } - } - -} diff --git a/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts b/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts deleted file mode 100644 index 2f07e87..0000000 --- a/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { Controller, Get, Post, Put, Delete, Documentation, request, response } from '@aerokit/sdk/http' -import { HttpUtils } from "@aerokit/sdk/http/utils"; -import { ValidationError } from '@aerokit/sdk/http/errors' -import { Options } from '@aerokit/sdk/db' -import { Extensions } from "@aerokit/sdk/extensions" -import { Injected, Inject } from '@aerokit/sdk/component' -import { JournalEntryDirectionRepository } from '../../data/Settings/JournalEntryDirectionRepository' -import { JournalEntryDirectionEntity } from '../../data/Settings/JournalEntryDirectionEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-accounts-Settings-JournalEntryDirection', ['validate']); - -@Controller -@Documentation('codbex-accounts - JournalEntryDirection Controller') -@Injected() -class JournalEntryDirectionController { - - @Inject('JournalEntryDirectionRepository') - private readonly repository!: JournalEntryDirectionRepository; - - @Get('/') - @Documentation('Get All JournalEntryDirection') - public getAll(_: any, ctx: any): JournalEntryDirectionEntity[] { - try { - const options: Options = { - limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : 20, - offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : 0, - language: request.getLocale()?.split("_")[0] - }; - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/') - @Documentation('Create JournalEntryDirection') - public create(entity: JournalEntryDirectionEntity): JournalEntryDirectionEntity { - try { - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count JournalEntryDirection') - public count(): { count: number } { - try { - return { count: this.repository.count() }; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/count') - @Documentation('Count JournalEntryDirection with filter') - public countWithFilter(filter: any): { count: number } { - try { - return { count: this.repository.count(filter) }; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/search') - @Documentation('Search JournalEntryDirection') - public search(filter: any): JournalEntryDirectionEntity[] { - try { - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get JournalEntryDirection by id') - public getById(_: any, ctx: any): JournalEntryDirectionEntity { - try { - const id = parseInt(ctx.pathParameters.id); - const options: Options = { - language: request.getLocale()?.split("_")[0] - }; - const entity = this.repository.findById(id, options); - if (entity) { - return entity; - } else { - HttpUtils.sendResponseNotFound('JournalEntryDirection not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update JournalEntryDirection by id') - public update(entity: JournalEntryDirectionEntity, ctx: any): JournalEntryDirectionEntity { - try { - const id = parseInt(ctx.pathParameters.id); - entity.Id = id; - this.validateEntity(entity); - this.repository.update(entity); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Delete('/:id') - @Documentation('Delete JournalEntryDirection by id') - public deleteById(_: any, ctx: any): void { - try { - const id = parseInt(ctx.pathParameters.id); - const entity = this.repository.findById(id); - if (entity) { - this.repository.deleteById(id); - HttpUtils.sendResponseNoContent(); - } else { - HttpUtils.sendResponseNotFound('JournalEntryDirection not found'); - } - } catch (error: any) { - this.handleError(error); - } - } - - private handleError(error: any) { - if (error.name === 'ForbiddenError') { - HttpUtils.sendForbiddenRequest(error.message); - } else if (error.name === 'ValidationError') { - HttpUtils.sendResponseBadRequest(error.message); - } else { - HttpUtils.sendInternalServerError(error.message); - } - } - - private validateEntity(entity: any): void { - if (entity.Name === null || entity.Name === undefined) { - throw new ValidationError(`The 'Name' property is required, provide a valid value`); - } - if (entity.Name?.length > 20) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [20] characters`); - } - for (const next of validationModules) { - next.validate(entity); - } - } - -} diff --git a/codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntryEntity.ts b/codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntryEntity.ts deleted file mode 100644 index 68fb241..0000000 --- a/codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntryEntity.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('JournalEntryEntity') -@Table('CODBEX_JOURNALENTRY') -@Documentation('JournalEntry entity mapping') -export class JournalEntryEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'JOURNALENTRY_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Date') - @Column({ - name: 'JOURNALENTRY_DATE', - type: 'date', - nullable: true, - }) - public Date?: Date; - - @Documentation('Account') - @Column({ - name: 'JOURNALENTRY_ACCOUNT', - type: 'integer', - }) - public Account!: number; - - @Documentation('Direction') - @Column({ - name: 'JOURNALENTRY_DIRECTION', - type: 'integer', - nullable: true, - }) - public Direction?: number; - - @Documentation('CreatedAt') - @Column({ - name: 'JOURNALENTRY_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'JOURNALENTRY_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - - @Documentation('UpdatedAt') - @Column({ - name: 'JOURNALENTRY_UPDATEDAT', - type: 'timestamp', - nullable: true, - }) - @UpdatedAt() - public UpdatedAt?: Date; - - @Documentation('UpdatedBy') - @Column({ - name: 'JOURNALENTRY_UPDATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @UpdatedBy() - public UpdatedBy?: string; - -} - -(new JournalEntryEntity()); diff --git a/codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntryRepository.ts b/codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntryRepository.ts deleted file mode 100644 index 15f31cc..0000000 --- a/codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntryRepository.ts +++ /dev/null @@ -1,45 +0,0 @@ -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' -import { JournalEntryEntity } from './JournalEntryEntity' - -@Component('JournalEntryRepository') -export class JournalEntryRepository extends Repository { - - constructor() { - super((JournalEntryEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): JournalEntryEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - entity.Date = entity.Date ? new Date(entity.Date) : undefined; - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - entity.UpdatedAt = entity.UpdatedAt ? new Date(entity.UpdatedAt) : undefined; - } - return entity; - } - - public override findAll(options?: Options): JournalEntryEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - entity.Date = entity.Date ? new Date(entity.Date) : undefined; - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - entity.UpdatedAt = entity.UpdatedAt ? new Date(entity.UpdatedAt) : undefined; - }); - return entities; - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-accounts-JournalEntry-JournalEntry', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-accounts-JournalEntry-JournalEntry').send(JSON.stringify(data)); - } -} diff --git a/codbex-accounts/gen/codbex-accounts/data/Settings/AccountEntity.ts b/codbex-accounts/gen/codbex-accounts/data/Settings/AccountEntity.ts deleted file mode 100644 index 75f5b10..0000000 --- a/codbex-accounts/gen/codbex-accounts/data/Settings/AccountEntity.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('AccountEntity') -@Table('CODBEX_ACCOUNT') -@Documentation('Account entity mapping') -export class AccountEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'ACCOUNT_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Name') - @Column({ - name: 'ACCOUNT_NAME', - type: 'string', - length: 200, - }) - public Name!: string; - - @Documentation('Code') - @Column({ - name: 'ACCOUNT_CODE', - type: 'integer', - }) - public Code!: number; - - @Documentation('Active') - @Column({ - name: 'ACCOUNT_ACTIVE', - type: 'boolean', - nullable: true, - }) - public Active?: boolean; - -} - -(new AccountEntity()); diff --git a/codbex-accounts/gen/codbex-accounts/data/Settings/AccountRepository.ts b/codbex-accounts/gen/codbex-accounts/data/Settings/AccountRepository.ts deleted file mode 100644 index b806e92..0000000 --- a/codbex-accounts/gen/codbex-accounts/data/Settings/AccountRepository.ts +++ /dev/null @@ -1,25 +0,0 @@ -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' -import { AccountEntity } from './AccountEntity' - -@Component('AccountRepository') -export class AccountRepository extends Repository { - - constructor() { - super((AccountEntity as EntityConstructor)); - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-accounts-Settings-Account', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-accounts-Settings-Account').send(JSON.stringify(data)); - } -} diff --git a/codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirectionEntity.ts b/codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirectionEntity.ts deleted file mode 100644 index a30917b..0000000 --- a/codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirectionEntity.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('JournalEntryDirectionEntity') -@Table('CODBEX_JOURNALENTRYDIRECTION') -@Documentation('JournalEntryDirection entity mapping') -export class JournalEntryDirectionEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'JOURNALENTRYDIRECTION_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Name') - @Column({ - name: 'JOURNALENTRYDIRECTION_NAME', - type: 'string', - length: 20, - }) - public Name!: string; - - @Documentation('Direction') - @Column({ - name: 'JOURNALENTRYDIRECTION_DIRECTION', - type: 'integer', - nullable: true, - }) - public Direction?: number; - -} - -(new JournalEntryDirectionEntity()); diff --git a/codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirectionRepository.ts b/codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirectionRepository.ts deleted file mode 100644 index 7fa618d..0000000 --- a/codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirectionRepository.ts +++ /dev/null @@ -1,25 +0,0 @@ -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' -import { JournalEntryDirectionEntity } from './JournalEntryDirectionEntity' - -@Component('JournalEntryDirectionRepository') -export class JournalEntryDirectionRepository extends Repository { - - constructor() { - super((JournalEntryDirectionEntity as EntityConstructor)); - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-accounts-Settings-JournalEntryDirection', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-accounts-Settings-JournalEntryDirection').send(JSON.stringify(data)); - } -} diff --git a/codbex-accounts/gen/codbex-accounts/odata/codbex-accounts.odata b/codbex-accounts/gen/codbex-accounts/odata/codbex-accounts.odata deleted file mode 100644 index f149140..0000000 --- a/codbex-accounts/gen/codbex-accounts/odata/codbex-accounts.odata +++ /dev/null @@ -1,4 +0,0 @@ -{ - "namespace": "", - "entities": [] -} diff --git a/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/controller.js b/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/controller.js index bcd67f3..6d00af7 100644 --- a/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/controller.js +++ b/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-accounts/gen/codbex-accounts/api/JournalEntry/JournalEntryController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController'; }]) .controller('PageController', ($scope, $http, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); @@ -105,7 +105,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer if (optionsAccountHasMore) { const optionsAccountSearchValues = Array.from(new Set(response.data.map(e => e.Account))); if (optionsAccountSearchValues.length > 0) { - $http.post('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts/search', { + $http.post('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController/search', { conditions: [ { propertyName: 'Id', operator: 'IN', value: optionsAccountSearchValues } ] @@ -128,7 +128,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer if (optionsDirectionHasMore) { const optionsDirectionSearchValues = Array.from(new Set(response.data.map(e => e.Direction))); if (optionsDirectionSearchValues.length > 0) { - $http.post('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts/search', { + $http.post('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController/search', { conditions: [ { propertyName: 'Id', operator: 'IN', value: optionsDirectionSearchValues } ] @@ -263,9 +263,9 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer let optionsAccountHasMore = true; - $http.get('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts/count').then((response) => { + $http.get('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController/count').then((response) => { const optionsAccountCount = response.data.count; - $http.get('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts').then((response) => { + $http.get('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController').then((response) => { $scope.optionsAccount = response.data.map(e => ({ value: e.Id, text: e.Name @@ -291,9 +291,9 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer }); let optionsDirectionHasMore = true; - $http.get('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts/count').then((response) => { + $http.get('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController/count').then((response) => { const optionsDirectionCount = response.data.count; - $http.get('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts').then((response) => { + $http.get('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController').then((response) => { $scope.optionsDirection = response.data.map(e => ({ value: e.Id, text: e.Name diff --git a/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/dialog-filter/controller.js b/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/dialog-filter/controller.js index 8ecf778..fb7e04e 100644 --- a/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/dialog-filter/controller.js +++ b/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/dialog-filter/controller.js @@ -124,7 +124,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle $scope.loadMoreOptionsAccount = () => { const limit = 20; $scope.optionsAccountLoading = true; - $http.get(`/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts?$limit=${limit}&$offset=${++loadMoreOptionsAccountCounter * limit}`) + $http.get(`/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController?$limit=${limit}&$offset=${++loadMoreOptionsAccountCounter * limit}`) .then((response) => { const optionValues = allValuesAccount.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -174,7 +174,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle } }) if (!cacheHit) { - $http.post('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts/search', { + $http.post('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] @@ -213,7 +213,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle $scope.loadMoreOptionsDirection = () => { const limit = 20; $scope.optionsDirectionLoading = true; - $http.get(`/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts?$limit=${limit}&$offset=${++loadMoreOptionsDirectionCounter * limit}`) + $http.get(`/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController?$limit=${limit}&$offset=${++loadMoreOptionsDirectionCounter * limit}`) .then((response) => { const optionValues = allValuesDirection.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -263,7 +263,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle } }) if (!cacheHit) { - $http.post('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts/search', { + $http.post('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] diff --git a/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/dialog-window/controller.js b/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/dialog-window/controller.js index b9b5fb0..acb4fd9 100644 --- a/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/dialog-window/controller.js +++ b/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-accounts/gen/codbex-accounts/api/JournalEntry/JournalEntryController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); @@ -92,11 +92,11 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer }); }; - $scope.serviceAccount = '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts'; + $scope.serviceAccount = '/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController'; $scope.optionsAccount = []; - $http.get('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts').then((response) => { + $http.get('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController').then((response) => { $scope.optionsAccount = response.data.map(e => ({ value: e.Id, text: e.Name @@ -120,7 +120,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.loadMoreOptionsAccount = () => { const limit = 20; $scope.optionsAccountLoading = true; - $http.get(`/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts?$limit=${limit}&$offset=${++loadMoreOptionsAccountCounter * limit}`) + $http.get(`/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController?$limit=${limit}&$offset=${++loadMoreOptionsAccountCounter * limit}`) .then((response) => { const optionValues = allValuesAccount.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -170,7 +170,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } }) if (!cacheHit) { - $http.post('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts/search', { + $http.post('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] @@ -199,11 +199,11 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } } }; - $scope.serviceDirection = '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts'; + $scope.serviceDirection = '/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController'; $scope.optionsDirection = []; - $http.get('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts').then((response) => { + $http.get('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController').then((response) => { $scope.optionsDirection = response.data.map(e => ({ value: e.Id, text: e.Name @@ -227,7 +227,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.loadMoreOptionsDirection = () => { const limit = 20; $scope.optionsDirectionLoading = true; - $http.get(`/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts?$limit=${limit}&$offset=${++loadMoreOptionsDirectionCounter * limit}`) + $http.get(`/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController?$limit=${limit}&$offset=${++loadMoreOptionsDirectionCounter * limit}`) .then((response) => { const optionValues = allValuesDirection.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -277,7 +277,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } }) if (!cacheHit) { - $http.post('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts/search', { + $http.post('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] diff --git a/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/main-details/controller.js b/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/main-details/controller.js index 5c5910c..cf05cc9 100644 --- a/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/main-details/controller.js +++ b/codbex-accounts/gen/codbex-accounts/ui/JournalEntry/JournalEntry/main-details/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(["EntityServiceProvider", (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-accounts/gen/codbex-accounts/api/JournalEntry/JournalEntryController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController'; }]) .controller('PageController', ($scope, $http, Extensions, LocaleService, EntityService) => { const Dialogs = new DialogHub(); @@ -98,8 +98,8 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer }); }}); - $scope.serviceAccount = '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts'; - $scope.serviceDirection = '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts'; + $scope.serviceAccount = '/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController'; + $scope.serviceDirection = '/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController'; //-----------------Events-------------------// @@ -193,7 +193,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.loadMoreOptionsAccount = () => { const limit = 20; $scope.optionsAccountLoading = true; - $http.get(`/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts?$limit=${limit}&$offset=${++loadMoreOptionsAccountCounter * limit}`) + $http.get(`/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController?$limit=${limit}&$offset=${++loadMoreOptionsAccountCounter * limit}`) .then((response) => { const optionValues = allValuesAccount.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -243,7 +243,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } }) if (!cacheHit) { - $http.post('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts/search', { + $http.post('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] @@ -275,7 +275,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.refreshAccount = () => { $scope.optionsAccount = []; - $http.get('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts').then((response) => { + $http.get('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController').then((response) => { $scope.optionsAccount = response.data.map(e => ({ value: e.Id, text: e.Name @@ -300,7 +300,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.loadMoreOptionsDirection = () => { const limit = 20; $scope.optionsDirectionLoading = true; - $http.get(`/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts?$limit=${limit}&$offset=${++loadMoreOptionsDirectionCounter * limit}`) + $http.get(`/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController?$limit=${limit}&$offset=${++loadMoreOptionsDirectionCounter * limit}`) .then((response) => { const optionValues = allValuesDirection.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -350,7 +350,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } }) if (!cacheHit) { - $http.post('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts/search', { + $http.post('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] @@ -382,7 +382,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.refreshDirection = () => { $scope.optionsDirection = []; - $http.get('/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts').then((response) => { + $http.get('/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController').then((response) => { $scope.optionsDirection = response.data.map(e => ({ value: e.Id, text: e.Name diff --git a/codbex-accounts/gen/codbex-accounts/ui/Settings/Account/controller.js b/codbex-accounts/gen/codbex-accounts/ui/Settings/Account/controller.js index 8951631..11fa26d 100644 --- a/codbex-accounts/gen/codbex-accounts/ui/Settings/Account/controller.js +++ b/codbex-accounts/gen/codbex-accounts/ui/Settings/Account/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-accounts/gen/codbex-accounts/ui/Settings/Account/dialog-window/controller.js b/codbex-accounts/gen/codbex-accounts/ui/Settings/Account/dialog-window/controller.js index 011127c..bfab853 100644 --- a/codbex-accounts/gen/codbex-accounts/ui/Settings/Account/dialog-window/controller.js +++ b/codbex-accounts/gen/codbex-accounts/ui/Settings/Account/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/AccountController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-accounts/gen/codbex_accounts/api/settings/AccountController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-accounts/gen/codbex-accounts/ui/Settings/JournalEntryDirection/controller.js b/codbex-accounts/gen/codbex-accounts/ui/Settings/JournalEntryDirection/controller.js index 8355486..8530cb4 100644 --- a/codbex-accounts/gen/codbex-accounts/ui/Settings/JournalEntryDirection/controller.js +++ b/codbex-accounts/gen/codbex-accounts/ui/Settings/JournalEntryDirection/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-accounts/gen/codbex-accounts/ui/Settings/JournalEntryDirection/dialog-window/controller.js b/codbex-accounts/gen/codbex-accounts/ui/Settings/JournalEntryDirection/dialog-window/controller.js index 6fff04c..cff22e4 100644 --- a/codbex-accounts/gen/codbex-accounts/ui/Settings/JournalEntryDirection/dialog-window/controller.js +++ b/codbex-accounts/gen/codbex-accounts/ui/Settings/JournalEntryDirection/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-accounts/gen/codbex-accounts/api/Settings/JournalEntryDirectionController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController.java b/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController.java new file mode 100644 index 0000000..9064140 --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController.java @@ -0,0 +1,173 @@ +package gen.codbex_accounts.api.journalentry; + +import gen.codbex_accounts.data.journalentry.JournalEntryEntity; +import gen.codbex_accounts.data.journalentry.JournalEntryRepository; + +import org.eclipse.dirigible.components.api.security.UserFacade; +import org.eclipse.dirigible.engine.java.annotations.Documentation; +import org.eclipse.dirigible.engine.java.annotations.Inject; +import org.eclipse.dirigible.engine.java.annotations.http.Body; +import org.eclipse.dirigible.engine.java.annotations.http.Controller; +import org.eclipse.dirigible.engine.java.annotations.http.Delete; +import org.eclipse.dirigible.engine.java.annotations.http.Get; +import org.eclipse.dirigible.engine.java.annotations.http.PathParam; +import org.eclipse.dirigible.engine.java.annotations.http.Post; +import org.eclipse.dirigible.engine.java.annotations.http.Put; +import org.eclipse.dirigible.engine.java.annotations.http.QueryParam; +import org.springframework.http.HttpStatus; +import org.springframework.web.server.ResponseStatusException; + +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +@Controller +@Documentation("codbex-accounts - JournalEntry Controller") +public class JournalEntryController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Date", "Account", "Direction", "CreatedAt", "CreatedBy", "UpdatedAt", "UpdatedBy"); + + @Inject + private JournalEntryRepository repository; + + @Get + @Documentation("List JournalEntry") + public List getAll(@QueryParam("$limit") Integer limit, + @QueryParam("$offset") Integer offset) { + checkPermissions("read"); + int actualLimit = limit != null ? limit.intValue() : 20; + int actualOffset = offset != null ? offset.intValue() : 0; + List result = repository.findAll(actualLimit, actualOffset); + return result; + } + + @Get("/count") + @Documentation("Count JournalEntry") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count JournalEntry with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search JournalEntry") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get JournalEntry by id") + public JournalEntryEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + JournalEntryEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "JournalEntry not found")); + return entity; + } + + @Post + @Documentation("Create JournalEntry") + public JournalEntryEntity create(@Body JournalEntryEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update JournalEntry by id") + public JournalEntryEntity update(@PathParam("id") Integer id, @Body JournalEntryEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete JournalEntry by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "JournalEntry not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from JournalEntryEntity e"); + Map params = new LinkedHashMap<>(); + boolean first = true; + if (filter != null && filter.get("equals") instanceof Map equals) { + for (Map.Entry entry : equals.entrySet()) { + String field = requireKnownField(String.valueOf(entry.getKey())); + String paramName = "p" + params.size(); + hql.append(first ? " where e." : " and e.").append(field).append(" = :").append(paramName); + params.put(paramName, entry.getValue()); + first = false; + } + } + if (filter != null && filter.get("conditions") instanceof List conditions) { + for (Object raw : conditions) { + if (!(raw instanceof Map condition)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid filter condition"); + } + String field = requireKnownField(String.valueOf(condition.get("propertyName"))); + String operator = String.valueOf(condition.get("operator")).toUpperCase(Locale.ROOT); + Object value = condition.get("value"); + String paramName = "p" + params.size(); + String clause = switch (operator) { + case "EQ" -> "e." + field + " = :" + paramName; + case "IN" -> { + if (!(value instanceof Collection)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "IN value must be a list for field: " + field); + } + yield "e." + field + " in (:" + paramName + ")"; + } + case "LIKE" -> "e." + field + " like :" + paramName; + default -> throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Unsupported operator: " + operator); + }; + hql.append(first ? " where " : " and ").append(clause); + params.put(paramName, value); + first = false; + } + } + return repository.query(hql.toString(), params); + } + + private static String requireKnownField(String field) { + if (!FILTER_FIELDS.contains(field)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Unknown filter field: " + field); + } + return field; + } + + private void checkPermissions(String op) { + if ("read".equals(op) && !(UserFacade.isInRole("codbex-accounts.JournalEntry.JournalEntryReadOnly") || UserFacade.isInRole("codbex-accounts.JournalEntry.JournalEntryFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-accounts.JournalEntry.JournalEntryFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(JournalEntryEntity entity) { + if (entity.Account == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Account' property is required"); + } + if (entity.CreatedBy != null && entity.CreatedBy.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'CreatedBy' exceeds the maximum length of 20"); + } + if (entity.UpdatedBy != null && entity.UpdatedBy.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'UpdatedBy' exceeds the maximum length of 20"); + } + } +} diff --git a/codbex-accounts/gen/codbex_accounts/api/settings/AccountController.java b/codbex-accounts/gen/codbex_accounts/api/settings/AccountController.java new file mode 100644 index 0000000..7031c62 --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/api/settings/AccountController.java @@ -0,0 +1,173 @@ +package gen.codbex_accounts.api.settings; + +import gen.codbex_accounts.data.settings.AccountEntity; +import gen.codbex_accounts.data.settings.AccountRepository; + +import org.eclipse.dirigible.components.api.security.UserFacade; +import org.eclipse.dirigible.engine.java.annotations.Documentation; +import org.eclipse.dirigible.engine.java.annotations.Inject; +import org.eclipse.dirigible.engine.java.annotations.http.Body; +import org.eclipse.dirigible.engine.java.annotations.http.Controller; +import org.eclipse.dirigible.engine.java.annotations.http.Delete; +import org.eclipse.dirigible.engine.java.annotations.http.Get; +import org.eclipse.dirigible.engine.java.annotations.http.PathParam; +import org.eclipse.dirigible.engine.java.annotations.http.Post; +import org.eclipse.dirigible.engine.java.annotations.http.Put; +import org.eclipse.dirigible.engine.java.annotations.http.QueryParam; +import org.springframework.http.HttpStatus; +import org.springframework.web.server.ResponseStatusException; + +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +@Controller +@Documentation("codbex-accounts - Account Controller") +public class AccountController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Name", "Code", "Active"); + + @Inject + private AccountRepository repository; + + @Get + @Documentation("List Account") + public List getAll(@QueryParam("$limit") Integer limit, + @QueryParam("$offset") Integer offset) { + checkPermissions("read"); + int actualLimit = limit != null ? limit.intValue() : 20; + int actualOffset = offset != null ? offset.intValue() : 0; + List result = repository.findAll(actualLimit, actualOffset); + return result; + } + + @Get("/count") + @Documentation("Count Account") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count Account with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search Account") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get Account by id") + public AccountEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + AccountEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Account not found")); + return entity; + } + + @Post + @Documentation("Create Account") + public AccountEntity create(@Body AccountEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update Account by id") + public AccountEntity update(@PathParam("id") Integer id, @Body AccountEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete Account by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Account not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from AccountEntity e"); + Map params = new LinkedHashMap<>(); + boolean first = true; + if (filter != null && filter.get("equals") instanceof Map equals) { + for (Map.Entry entry : equals.entrySet()) { + String field = requireKnownField(String.valueOf(entry.getKey())); + String paramName = "p" + params.size(); + hql.append(first ? " where e." : " and e.").append(field).append(" = :").append(paramName); + params.put(paramName, entry.getValue()); + first = false; + } + } + if (filter != null && filter.get("conditions") instanceof List conditions) { + for (Object raw : conditions) { + if (!(raw instanceof Map condition)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid filter condition"); + } + String field = requireKnownField(String.valueOf(condition.get("propertyName"))); + String operator = String.valueOf(condition.get("operator")).toUpperCase(Locale.ROOT); + Object value = condition.get("value"); + String paramName = "p" + params.size(); + String clause = switch (operator) { + case "EQ" -> "e." + field + " = :" + paramName; + case "IN" -> { + if (!(value instanceof Collection)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "IN value must be a list for field: " + field); + } + yield "e." + field + " in (:" + paramName + ")"; + } + case "LIKE" -> "e." + field + " like :" + paramName; + default -> throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Unsupported operator: " + operator); + }; + hql.append(first ? " where " : " and ").append(clause); + params.put(paramName, value); + first = false; + } + } + return repository.query(hql.toString(), params); + } + + private static String requireKnownField(String field) { + if (!FILTER_FIELDS.contains(field)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Unknown filter field: " + field); + } + return field; + } + + private void checkPermissions(String op) { + if ("read".equals(op) && !(UserFacade.isInRole("codbex-accounts.Accounts.AccountReadOnly") || UserFacade.isInRole("codbex-accounts.Accounts.AccountFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-accounts.Accounts.AccountFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(AccountEntity entity) { + if (entity.Name == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' property is required"); + } + if (entity.Name != null && entity.Name.length() > 200) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 200"); + } + if (entity.Code == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Code' property is required"); + } + } +} diff --git a/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController.java b/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController.java new file mode 100644 index 0000000..cf4477c --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController.java @@ -0,0 +1,153 @@ +package gen.codbex_accounts.api.settings; + +import gen.codbex_accounts.data.settings.JournalEntryDirectionEntity; +import gen.codbex_accounts.data.settings.JournalEntryDirectionRepository; + +import org.eclipse.dirigible.components.api.security.UserFacade; +import org.eclipse.dirigible.engine.java.annotations.Documentation; +import org.eclipse.dirigible.engine.java.annotations.Inject; +import org.eclipse.dirigible.engine.java.annotations.http.Body; +import org.eclipse.dirigible.engine.java.annotations.http.Controller; +import org.eclipse.dirigible.engine.java.annotations.http.Delete; +import org.eclipse.dirigible.engine.java.annotations.http.Get; +import org.eclipse.dirigible.engine.java.annotations.http.PathParam; +import org.eclipse.dirigible.engine.java.annotations.http.Post; +import org.eclipse.dirigible.engine.java.annotations.http.Put; +import org.eclipse.dirigible.engine.java.annotations.http.QueryParam; +import org.springframework.http.HttpStatus; +import org.springframework.web.server.ResponseStatusException; + +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +@Controller +@Documentation("codbex-accounts - JournalEntryDirection Controller") +public class JournalEntryDirectionController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Name", "Direction"); + + @Inject + private JournalEntryDirectionRepository repository; + + @Get + @Documentation("List JournalEntryDirection") + public List getAll(@QueryParam("$limit") Integer limit, + @QueryParam("$offset") Integer offset) { + int actualLimit = limit != null ? limit.intValue() : 20; + int actualOffset = offset != null ? offset.intValue() : 0; + List result = repository.findAll(actualLimit, actualOffset); + return result; + } + + @Get("/count") + @Documentation("Count JournalEntryDirection") + public Map count() { + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count JournalEntryDirection with filter") + public Map countWithFilter(@Body Map filter) { + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search JournalEntryDirection") + public List search(@Body Map filter) { + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get JournalEntryDirection by id") + public JournalEntryDirectionEntity getById(@PathParam("id") Integer id) { + JournalEntryDirectionEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "JournalEntryDirection not found")); + return entity; + } + + @Post + @Documentation("Create JournalEntryDirection") + public JournalEntryDirectionEntity create(@Body JournalEntryDirectionEntity entity) { + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update JournalEntryDirection by id") + public JournalEntryDirectionEntity update(@PathParam("id") Integer id, @Body JournalEntryDirectionEntity entity) { + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete JournalEntryDirection by id") + public void deleteById(@PathParam("id") Integer id) { + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "JournalEntryDirection not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from JournalEntryDirectionEntity e"); + Map params = new LinkedHashMap<>(); + boolean first = true; + if (filter != null && filter.get("equals") instanceof Map equals) { + for (Map.Entry entry : equals.entrySet()) { + String field = requireKnownField(String.valueOf(entry.getKey())); + String paramName = "p" + params.size(); + hql.append(first ? " where e." : " and e.").append(field).append(" = :").append(paramName); + params.put(paramName, entry.getValue()); + first = false; + } + } + if (filter != null && filter.get("conditions") instanceof List conditions) { + for (Object raw : conditions) { + if (!(raw instanceof Map condition)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid filter condition"); + } + String field = requireKnownField(String.valueOf(condition.get("propertyName"))); + String operator = String.valueOf(condition.get("operator")).toUpperCase(Locale.ROOT); + Object value = condition.get("value"); + String paramName = "p" + params.size(); + String clause = switch (operator) { + case "EQ" -> "e." + field + " = :" + paramName; + case "IN" -> { + if (!(value instanceof Collection)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "IN value must be a list for field: " + field); + } + yield "e." + field + " in (:" + paramName + ")"; + } + case "LIKE" -> "e." + field + " like :" + paramName; + default -> throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Unsupported operator: " + operator); + }; + hql.append(first ? " where " : " and ").append(clause); + params.put(paramName, value); + first = false; + } + } + return repository.query(hql.toString(), params); + } + + private static String requireKnownField(String field) { + if (!FILTER_FIELDS.contains(field)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Unknown filter field: " + field); + } + return field; + } + + private static void validate(JournalEntryDirectionEntity entity) { + if (entity.Name == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' property is required"); + } + if (entity.Name != null && entity.Name.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 20"); + } + } +} diff --git a/codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntry.extensionpoint b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntry.extensionpoint similarity index 98% rename from codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntry.extensionpoint rename to codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntry.extensionpoint index 741af38..35e43cf 100644 --- a/codbex-accounts/gen/codbex-accounts/data/JournalEntry/JournalEntry.extensionpoint +++ b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntry.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-accounts-JournalEntry-JournalEntry", "description": "Extension Point for the codbex-accounts-JournalEntry-JournalEntry entity" -} \ No newline at end of file +} diff --git a/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryEntity.java b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryEntity.java new file mode 100644 index 0000000..95cecd2 --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryEntity.java @@ -0,0 +1,58 @@ +package gen.codbex_accounts.data.journalentry; + +import org.eclipse.dirigible.engine.java.annotations.Column; +import org.eclipse.dirigible.engine.java.annotations.CreatedAt; +import org.eclipse.dirigible.engine.java.annotations.CreatedBy; +import org.eclipse.dirigible.engine.java.annotations.Documentation; +import org.eclipse.dirigible.engine.java.annotations.Entity; +import org.eclipse.dirigible.engine.java.annotations.GeneratedValue; +import org.eclipse.dirigible.engine.java.annotations.GenerationType; +import org.eclipse.dirigible.engine.java.annotations.Id; +import org.eclipse.dirigible.engine.java.annotations.Table; +import org.eclipse.dirigible.engine.java.annotations.UpdatedAt; +import org.eclipse.dirigible.engine.java.annotations.UpdatedBy; + +@Entity +@Table(name = "CODBEX_JOURNALENTRY") +@Documentation("JournalEntry entity mapping") +public class JournalEntryEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "JOURNALENTRY_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "JOURNALENTRY_DATE", nullable = true) + @Documentation("Date") + public java.time.LocalDate Date; + + @Column(name = "JOURNALENTRY_ACCOUNT", nullable = false) + @Documentation("Account") + public Integer Account; + + @Column(name = "JOURNALENTRY_DIRECTION", nullable = true) + @Documentation("Direction") + public Integer Direction; + + @CreatedAt + @Column(name = "JOURNALENTRY_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "JOURNALENTRY_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + + @UpdatedAt + @Column(name = "JOURNALENTRY_UPDATEDAT", nullable = true) + @Documentation("UpdatedAt") + public java.time.Instant UpdatedAt; + + @UpdatedBy + @Column(name = "JOURNALENTRY_UPDATEDBY", length = 20, nullable = true) + @Documentation("UpdatedBy") + public String UpdatedBy; + +} diff --git a/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryRepository.java b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryRepository.java new file mode 100644 index 0000000..03bd4d7 --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_accounts.data.journalentry; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.engine.java.annotations.Repository; + +@Repository +public class JournalEntryRepository extends JavaRepository { + + public JournalEntryRepository() { + super(JournalEntryEntity.class); + } +} diff --git a/codbex-accounts/gen/codbex-accounts/data/Settings/Account.extensionpoint b/codbex-accounts/gen/codbex_accounts/data/settings/Account.extensionpoint similarity index 98% rename from codbex-accounts/gen/codbex-accounts/data/Settings/Account.extensionpoint rename to codbex-accounts/gen/codbex_accounts/data/settings/Account.extensionpoint index 39a199b..fb5c37f 100644 --- a/codbex-accounts/gen/codbex-accounts/data/Settings/Account.extensionpoint +++ b/codbex-accounts/gen/codbex_accounts/data/settings/Account.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-accounts-Settings-Account", "description": "Extension Point for the codbex-accounts-Settings-Account entity" -} \ No newline at end of file +} diff --git a/codbex-accounts/gen/codbex_accounts/data/settings/AccountEntity.java b/codbex-accounts/gen/codbex_accounts/data/settings/AccountEntity.java new file mode 100644 index 0000000..240e11f --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/data/settings/AccountEntity.java @@ -0,0 +1,38 @@ +package gen.codbex_accounts.data.settings; + +import org.eclipse.dirigible.engine.java.annotations.Column; +import org.eclipse.dirigible.engine.java.annotations.CreatedAt; +import org.eclipse.dirigible.engine.java.annotations.CreatedBy; +import org.eclipse.dirigible.engine.java.annotations.Documentation; +import org.eclipse.dirigible.engine.java.annotations.Entity; +import org.eclipse.dirigible.engine.java.annotations.GeneratedValue; +import org.eclipse.dirigible.engine.java.annotations.GenerationType; +import org.eclipse.dirigible.engine.java.annotations.Id; +import org.eclipse.dirigible.engine.java.annotations.Table; +import org.eclipse.dirigible.engine.java.annotations.UpdatedAt; +import org.eclipse.dirigible.engine.java.annotations.UpdatedBy; + +@Entity +@Table(name = "CODBEX_ACCOUNT") +@Documentation("Account entity mapping") +public class AccountEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ACCOUNT_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "ACCOUNT_NAME", length = 200, nullable = false, unique = true) + @Documentation("Name") + public String Name; + + @Column(name = "ACCOUNT_CODE", nullable = false, unique = true) + @Documentation("Code") + public Integer Code; + + @Column(name = "ACCOUNT_ACTIVE", nullable = true) + @Documentation("Active") + public Boolean Active; + +} diff --git a/codbex-accounts/gen/codbex_accounts/data/settings/AccountRepository.java b/codbex-accounts/gen/codbex_accounts/data/settings/AccountRepository.java new file mode 100644 index 0000000..791fd5d --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/data/settings/AccountRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_accounts.data.settings; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.engine.java.annotations.Repository; + +@Repository +public class AccountRepository extends JavaRepository { + + public AccountRepository() { + super(AccountEntity.class); + } +} diff --git a/codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirection.extensionpoint b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirection.extensionpoint similarity index 98% rename from codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirection.extensionpoint rename to codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirection.extensionpoint index 7ac1b13..e3c478e 100644 --- a/codbex-accounts/gen/codbex-accounts/data/Settings/JournalEntryDirection.extensionpoint +++ b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirection.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-accounts-Settings-JournalEntryDirection", "description": "Extension Point for the codbex-accounts-Settings-JournalEntryDirection entity" -} \ No newline at end of file +} diff --git a/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionEntity.java b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionEntity.java new file mode 100644 index 0000000..5307339 --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionEntity.java @@ -0,0 +1,34 @@ +package gen.codbex_accounts.data.settings; + +import org.eclipse.dirigible.engine.java.annotations.Column; +import org.eclipse.dirigible.engine.java.annotations.CreatedAt; +import org.eclipse.dirigible.engine.java.annotations.CreatedBy; +import org.eclipse.dirigible.engine.java.annotations.Documentation; +import org.eclipse.dirigible.engine.java.annotations.Entity; +import org.eclipse.dirigible.engine.java.annotations.GeneratedValue; +import org.eclipse.dirigible.engine.java.annotations.GenerationType; +import org.eclipse.dirigible.engine.java.annotations.Id; +import org.eclipse.dirigible.engine.java.annotations.Table; +import org.eclipse.dirigible.engine.java.annotations.UpdatedAt; +import org.eclipse.dirigible.engine.java.annotations.UpdatedBy; + +@Entity +@Table(name = "CODBEX_JOURNALENTRYDIRECTION") +@Documentation("JournalEntryDirection entity mapping") +public class JournalEntryDirectionEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "JOURNALENTRYDIRECTION_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "JOURNALENTRYDIRECTION_NAME", length = 20, nullable = false, unique = true) + @Documentation("Name") + public String Name; + + @Column(name = "JOURNALENTRYDIRECTION_DIRECTION", nullable = true) + @Documentation("Direction") + public Integer Direction; + +} diff --git a/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionRepository.java b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionRepository.java new file mode 100644 index 0000000..18e6568 --- /dev/null +++ b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_accounts.data.settings; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.engine.java.annotations.Repository; + +@Repository +public class JournalEntryDirectionRepository extends JavaRepository { + + public JournalEntryDirectionRepository() { + super(JournalEntryDirectionEntity.class); + } +} diff --git a/codbex-accounts/gen/codbex-accounts/roles/default-roles.roles b/codbex-accounts/gen/codbex_accounts/roles/default-roles.roles similarity index 99% rename from codbex-accounts/gen/codbex-accounts/roles/default-roles.roles rename to codbex-accounts/gen/codbex_accounts/roles/default-roles.roles index 302ba66..8ae5e01 100644 --- a/codbex-accounts/gen/codbex-accounts/roles/default-roles.roles +++ b/codbex-accounts/gen/codbex_accounts/roles/default-roles.roles @@ -15,4 +15,4 @@ "name": "codbex-accounts.JournalEntry.JournalEntryFullAccess", "description": "A role that grants full access for JournalEntry." } -] \ No newline at end of file +] From c543403a13681370d09c385c3638264156d394e1 Mon Sep 17 00:00:00 2001 From: NicoleNG18 Date: Fri, 3 Jul 2026 16:31:57 +0300 Subject: [PATCH 2/2] regenerate module with the latest hava template --- codbex-accounts/codbex-accounts.gen | 9 ++++ .../journalentry/JournalEntryController.java | 26 ++++++----- .../api/settings/AccountController.java | 26 ++++++----- .../JournalEntryDirectionController.java | 26 ++++++----- .../data/journalentry/JournalEntryEntity.java | 22 ++++----- .../journalentry/JournalEntryRepository.java | 46 ++++++++++++++++++- .../data/settings/AccountEntity.java | 22 ++++----- .../data/settings/AccountRepository.java | 46 ++++++++++++++++++- .../settings/JournalEntryDirectionEntity.java | 22 ++++----- .../JournalEntryDirectionRepository.java | 46 ++++++++++++++++++- 10 files changed, 219 insertions(+), 72 deletions(-) diff --git a/codbex-accounts/codbex-accounts.gen b/codbex-accounts/codbex-accounts.gen index d517298..1db10f0 100644 --- a/codbex-accounts/codbex-accounts.gen +++ b/codbex-accounts/codbex-accounts.gen @@ -100,6 +100,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" }, { @@ -157,6 +158,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" }, { @@ -246,6 +248,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" }, { @@ -307,6 +310,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" }, { @@ -340,6 +344,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" }, { @@ -553,6 +558,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" }, { @@ -586,6 +592,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" }, { @@ -736,6 +743,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" }, { @@ -793,6 +801,7 @@ "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", + "isNumberType": true, "inputRule": "" } ], diff --git a/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController.java b/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController.java index 9064140..dbcd5ed 100644 --- a/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController.java +++ b/codbex-accounts/gen/codbex_accounts/api/journalentry/JournalEntryController.java @@ -4,16 +4,15 @@ import gen.codbex_accounts.data.journalentry.JournalEntryRepository; import org.eclipse.dirigible.components.api.security.UserFacade; -import org.eclipse.dirigible.engine.java.annotations.Documentation; -import org.eclipse.dirigible.engine.java.annotations.Inject; -import org.eclipse.dirigible.engine.java.annotations.http.Body; -import org.eclipse.dirigible.engine.java.annotations.http.Controller; -import org.eclipse.dirigible.engine.java.annotations.http.Delete; -import org.eclipse.dirigible.engine.java.annotations.http.Get; -import org.eclipse.dirigible.engine.java.annotations.http.PathParam; -import org.eclipse.dirigible.engine.java.annotations.http.Post; -import org.eclipse.dirigible.engine.java.annotations.http.Put; -import org.eclipse.dirigible.engine.java.annotations.http.QueryParam; +import org.eclipse.dirigible.sdk.platform.Documentation; +import org.eclipse.dirigible.sdk.http.Body; +import org.eclipse.dirigible.sdk.http.Controller; +import org.eclipse.dirigible.sdk.http.Delete; +import org.eclipse.dirigible.sdk.http.Get; +import org.eclipse.dirigible.sdk.http.PathParam; +import org.eclipse.dirigible.sdk.http.Post; +import org.eclipse.dirigible.sdk.http.Put; +import org.eclipse.dirigible.sdk.http.QueryParam; import org.springframework.http.HttpStatus; import org.springframework.web.server.ResponseStatusException; @@ -30,8 +29,11 @@ public class JournalEntryController { private static final Set FILTER_FIELDS = Set.of("Id", "Date", "Account", "Direction", "CreatedAt", "CreatedBy", "UpdatedAt", "UpdatedBy"); - @Inject - private JournalEntryRepository repository; + private final JournalEntryRepository repository; + + public JournalEntryController(JournalEntryRepository repository) { + this.repository = repository; + } @Get @Documentation("List JournalEntry") diff --git a/codbex-accounts/gen/codbex_accounts/api/settings/AccountController.java b/codbex-accounts/gen/codbex_accounts/api/settings/AccountController.java index 7031c62..4dc5f88 100644 --- a/codbex-accounts/gen/codbex_accounts/api/settings/AccountController.java +++ b/codbex-accounts/gen/codbex_accounts/api/settings/AccountController.java @@ -4,16 +4,15 @@ import gen.codbex_accounts.data.settings.AccountRepository; import org.eclipse.dirigible.components.api.security.UserFacade; -import org.eclipse.dirigible.engine.java.annotations.Documentation; -import org.eclipse.dirigible.engine.java.annotations.Inject; -import org.eclipse.dirigible.engine.java.annotations.http.Body; -import org.eclipse.dirigible.engine.java.annotations.http.Controller; -import org.eclipse.dirigible.engine.java.annotations.http.Delete; -import org.eclipse.dirigible.engine.java.annotations.http.Get; -import org.eclipse.dirigible.engine.java.annotations.http.PathParam; -import org.eclipse.dirigible.engine.java.annotations.http.Post; -import org.eclipse.dirigible.engine.java.annotations.http.Put; -import org.eclipse.dirigible.engine.java.annotations.http.QueryParam; +import org.eclipse.dirigible.sdk.platform.Documentation; +import org.eclipse.dirigible.sdk.http.Body; +import org.eclipse.dirigible.sdk.http.Controller; +import org.eclipse.dirigible.sdk.http.Delete; +import org.eclipse.dirigible.sdk.http.Get; +import org.eclipse.dirigible.sdk.http.PathParam; +import org.eclipse.dirigible.sdk.http.Post; +import org.eclipse.dirigible.sdk.http.Put; +import org.eclipse.dirigible.sdk.http.QueryParam; import org.springframework.http.HttpStatus; import org.springframework.web.server.ResponseStatusException; @@ -30,8 +29,11 @@ public class AccountController { private static final Set FILTER_FIELDS = Set.of("Id", "Name", "Code", "Active"); - @Inject - private AccountRepository repository; + private final AccountRepository repository; + + public AccountController(AccountRepository repository) { + this.repository = repository; + } @Get @Documentation("List Account") diff --git a/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController.java b/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController.java index cf4477c..a1f0f21 100644 --- a/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController.java +++ b/codbex-accounts/gen/codbex_accounts/api/settings/JournalEntryDirectionController.java @@ -4,16 +4,15 @@ import gen.codbex_accounts.data.settings.JournalEntryDirectionRepository; import org.eclipse.dirigible.components.api.security.UserFacade; -import org.eclipse.dirigible.engine.java.annotations.Documentation; -import org.eclipse.dirigible.engine.java.annotations.Inject; -import org.eclipse.dirigible.engine.java.annotations.http.Body; -import org.eclipse.dirigible.engine.java.annotations.http.Controller; -import org.eclipse.dirigible.engine.java.annotations.http.Delete; -import org.eclipse.dirigible.engine.java.annotations.http.Get; -import org.eclipse.dirigible.engine.java.annotations.http.PathParam; -import org.eclipse.dirigible.engine.java.annotations.http.Post; -import org.eclipse.dirigible.engine.java.annotations.http.Put; -import org.eclipse.dirigible.engine.java.annotations.http.QueryParam; +import org.eclipse.dirigible.sdk.platform.Documentation; +import org.eclipse.dirigible.sdk.http.Body; +import org.eclipse.dirigible.sdk.http.Controller; +import org.eclipse.dirigible.sdk.http.Delete; +import org.eclipse.dirigible.sdk.http.Get; +import org.eclipse.dirigible.sdk.http.PathParam; +import org.eclipse.dirigible.sdk.http.Post; +import org.eclipse.dirigible.sdk.http.Put; +import org.eclipse.dirigible.sdk.http.QueryParam; import org.springframework.http.HttpStatus; import org.springframework.web.server.ResponseStatusException; @@ -30,8 +29,11 @@ public class JournalEntryDirectionController { private static final Set FILTER_FIELDS = Set.of("Id", "Name", "Direction"); - @Inject - private JournalEntryDirectionRepository repository; + private final JournalEntryDirectionRepository repository; + + public JournalEntryDirectionController(JournalEntryDirectionRepository repository) { + this.repository = repository; + } @Get @Documentation("List JournalEntryDirection") diff --git a/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryEntity.java b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryEntity.java index 95cecd2..e56020c 100644 --- a/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryEntity.java +++ b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryEntity.java @@ -1,16 +1,16 @@ package gen.codbex_accounts.data.journalentry; -import org.eclipse.dirigible.engine.java.annotations.Column; -import org.eclipse.dirigible.engine.java.annotations.CreatedAt; -import org.eclipse.dirigible.engine.java.annotations.CreatedBy; -import org.eclipse.dirigible.engine.java.annotations.Documentation; -import org.eclipse.dirigible.engine.java.annotations.Entity; -import org.eclipse.dirigible.engine.java.annotations.GeneratedValue; -import org.eclipse.dirigible.engine.java.annotations.GenerationType; -import org.eclipse.dirigible.engine.java.annotations.Id; -import org.eclipse.dirigible.engine.java.annotations.Table; -import org.eclipse.dirigible.engine.java.annotations.UpdatedAt; -import org.eclipse.dirigible.engine.java.annotations.UpdatedBy; +import org.eclipse.dirigible.sdk.db.Column; +import org.eclipse.dirigible.sdk.db.CreatedAt; +import org.eclipse.dirigible.sdk.db.CreatedBy; +import org.eclipse.dirigible.sdk.platform.Documentation; +import org.eclipse.dirigible.sdk.db.Entity; +import org.eclipse.dirigible.sdk.db.GeneratedValue; +import org.eclipse.dirigible.sdk.db.GenerationType; +import org.eclipse.dirigible.sdk.db.Id; +import org.eclipse.dirigible.sdk.db.Table; +import org.eclipse.dirigible.sdk.db.UpdatedAt; +import org.eclipse.dirigible.sdk.db.UpdatedBy; @Entity @Table(name = "CODBEX_JOURNALENTRY") diff --git a/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryRepository.java b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryRepository.java index 03bd4d7..9d83de6 100644 --- a/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryRepository.java +++ b/codbex-accounts/gen/codbex_accounts/data/journalentry/JournalEntryRepository.java @@ -1,7 +1,9 @@ package gen.codbex_accounts.data.journalentry; import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; -import org.eclipse.dirigible.engine.java.annotations.Repository; +import org.eclipse.dirigible.sdk.component.Repository; +import org.eclipse.dirigible.sdk.messaging.Producer; +import org.eclipse.dirigible.sdk.utils.Json; @Repository public class JournalEntryRepository extends JavaRepository { @@ -9,4 +11,46 @@ public class JournalEntryRepository extends JavaRepository { public JournalEntryRepository() { super(JournalEntryEntity.class); } + + @Override + public JournalEntryEntity save(JournalEntryEntity entity) { + JournalEntryEntity saved = super.save(entity); + // Publish the create event so listeners (e.g. intent process triggers / reactions under gen/events) can react. + Producer.sendToTopic("codbex-accounts-JournalEntry-JournalEntry", Json.stringify(saved)); + return saved; + } + + @Override + public JournalEntryEntity update(JournalEntryEntity entity) { + JournalEntryEntity updated = super.update(entity); + // Publish the update event (suffixed topic) so intent reactions under gen/events can react. + Producer.sendToTopic("codbex-accounts-JournalEntry-JournalEntry-updated", Json.stringify(updated)); + return updated; + } + + /** + * Persists changes WITHOUT publishing the "-updated" event. Intended for system-managed + * back-references — e.g. an intent process trigger writing ProcessId back onto the entity that + * started it. Going through {@link #update} would re-publish "JournalEntry-updated" and spuriously + * re-fire onUpdate reactions (notifications, roll-ups, integrations) for a change the user never made. + */ + public JournalEntryEntity updateWithoutEvent(JournalEntryEntity entity) { + return super.update(entity); + } + + @Override + public void delete(JournalEntryEntity entity) { + super.delete(entity); + // Publish the delete event (suffixed topic) so intent reactions under gen/events can react. + Producer.sendToTopic("codbex-accounts-JournalEntry-JournalEntry-deleted", Json.stringify(entity)); + } + + @Override + public void deleteById(Object id) { + JournalEntryEntity entity = findById(id); + super.deleteById(id); + if (entity != null) { + Producer.sendToTopic("codbex-accounts-JournalEntry-JournalEntry-deleted", Json.stringify(entity)); + } + } } diff --git a/codbex-accounts/gen/codbex_accounts/data/settings/AccountEntity.java b/codbex-accounts/gen/codbex_accounts/data/settings/AccountEntity.java index 240e11f..8bb2102 100644 --- a/codbex-accounts/gen/codbex_accounts/data/settings/AccountEntity.java +++ b/codbex-accounts/gen/codbex_accounts/data/settings/AccountEntity.java @@ -1,16 +1,16 @@ package gen.codbex_accounts.data.settings; -import org.eclipse.dirigible.engine.java.annotations.Column; -import org.eclipse.dirigible.engine.java.annotations.CreatedAt; -import org.eclipse.dirigible.engine.java.annotations.CreatedBy; -import org.eclipse.dirigible.engine.java.annotations.Documentation; -import org.eclipse.dirigible.engine.java.annotations.Entity; -import org.eclipse.dirigible.engine.java.annotations.GeneratedValue; -import org.eclipse.dirigible.engine.java.annotations.GenerationType; -import org.eclipse.dirigible.engine.java.annotations.Id; -import org.eclipse.dirigible.engine.java.annotations.Table; -import org.eclipse.dirigible.engine.java.annotations.UpdatedAt; -import org.eclipse.dirigible.engine.java.annotations.UpdatedBy; +import org.eclipse.dirigible.sdk.db.Column; +import org.eclipse.dirigible.sdk.db.CreatedAt; +import org.eclipse.dirigible.sdk.db.CreatedBy; +import org.eclipse.dirigible.sdk.platform.Documentation; +import org.eclipse.dirigible.sdk.db.Entity; +import org.eclipse.dirigible.sdk.db.GeneratedValue; +import org.eclipse.dirigible.sdk.db.GenerationType; +import org.eclipse.dirigible.sdk.db.Id; +import org.eclipse.dirigible.sdk.db.Table; +import org.eclipse.dirigible.sdk.db.UpdatedAt; +import org.eclipse.dirigible.sdk.db.UpdatedBy; @Entity @Table(name = "CODBEX_ACCOUNT") diff --git a/codbex-accounts/gen/codbex_accounts/data/settings/AccountRepository.java b/codbex-accounts/gen/codbex_accounts/data/settings/AccountRepository.java index 791fd5d..df7c108 100644 --- a/codbex-accounts/gen/codbex_accounts/data/settings/AccountRepository.java +++ b/codbex-accounts/gen/codbex_accounts/data/settings/AccountRepository.java @@ -1,7 +1,9 @@ package gen.codbex_accounts.data.settings; import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; -import org.eclipse.dirigible.engine.java.annotations.Repository; +import org.eclipse.dirigible.sdk.component.Repository; +import org.eclipse.dirigible.sdk.messaging.Producer; +import org.eclipse.dirigible.sdk.utils.Json; @Repository public class AccountRepository extends JavaRepository { @@ -9,4 +11,46 @@ public class AccountRepository extends JavaRepository { public AccountRepository() { super(AccountEntity.class); } + + @Override + public AccountEntity save(AccountEntity entity) { + AccountEntity saved = super.save(entity); + // Publish the create event so listeners (e.g. intent process triggers / reactions under gen/events) can react. + Producer.sendToTopic("codbex-accounts-Settings-Account", Json.stringify(saved)); + return saved; + } + + @Override + public AccountEntity update(AccountEntity entity) { + AccountEntity updated = super.update(entity); + // Publish the update event (suffixed topic) so intent reactions under gen/events can react. + Producer.sendToTopic("codbex-accounts-Settings-Account-updated", Json.stringify(updated)); + return updated; + } + + /** + * Persists changes WITHOUT publishing the "-updated" event. Intended for system-managed + * back-references — e.g. an intent process trigger writing ProcessId back onto the entity that + * started it. Going through {@link #update} would re-publish "Account-updated" and spuriously + * re-fire onUpdate reactions (notifications, roll-ups, integrations) for a change the user never made. + */ + public AccountEntity updateWithoutEvent(AccountEntity entity) { + return super.update(entity); + } + + @Override + public void delete(AccountEntity entity) { + super.delete(entity); + // Publish the delete event (suffixed topic) so intent reactions under gen/events can react. + Producer.sendToTopic("codbex-accounts-Settings-Account-deleted", Json.stringify(entity)); + } + + @Override + public void deleteById(Object id) { + AccountEntity entity = findById(id); + super.deleteById(id); + if (entity != null) { + Producer.sendToTopic("codbex-accounts-Settings-Account-deleted", Json.stringify(entity)); + } + } } diff --git a/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionEntity.java b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionEntity.java index 5307339..02cff4b 100644 --- a/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionEntity.java +++ b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionEntity.java @@ -1,16 +1,16 @@ package gen.codbex_accounts.data.settings; -import org.eclipse.dirigible.engine.java.annotations.Column; -import org.eclipse.dirigible.engine.java.annotations.CreatedAt; -import org.eclipse.dirigible.engine.java.annotations.CreatedBy; -import org.eclipse.dirigible.engine.java.annotations.Documentation; -import org.eclipse.dirigible.engine.java.annotations.Entity; -import org.eclipse.dirigible.engine.java.annotations.GeneratedValue; -import org.eclipse.dirigible.engine.java.annotations.GenerationType; -import org.eclipse.dirigible.engine.java.annotations.Id; -import org.eclipse.dirigible.engine.java.annotations.Table; -import org.eclipse.dirigible.engine.java.annotations.UpdatedAt; -import org.eclipse.dirigible.engine.java.annotations.UpdatedBy; +import org.eclipse.dirigible.sdk.db.Column; +import org.eclipse.dirigible.sdk.db.CreatedAt; +import org.eclipse.dirigible.sdk.db.CreatedBy; +import org.eclipse.dirigible.sdk.platform.Documentation; +import org.eclipse.dirigible.sdk.db.Entity; +import org.eclipse.dirigible.sdk.db.GeneratedValue; +import org.eclipse.dirigible.sdk.db.GenerationType; +import org.eclipse.dirigible.sdk.db.Id; +import org.eclipse.dirigible.sdk.db.Table; +import org.eclipse.dirigible.sdk.db.UpdatedAt; +import org.eclipse.dirigible.sdk.db.UpdatedBy; @Entity @Table(name = "CODBEX_JOURNALENTRYDIRECTION") diff --git a/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionRepository.java b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionRepository.java index 18e6568..1d692e4 100644 --- a/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionRepository.java +++ b/codbex-accounts/gen/codbex_accounts/data/settings/JournalEntryDirectionRepository.java @@ -1,7 +1,9 @@ package gen.codbex_accounts.data.settings; import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; -import org.eclipse.dirigible.engine.java.annotations.Repository; +import org.eclipse.dirigible.sdk.component.Repository; +import org.eclipse.dirigible.sdk.messaging.Producer; +import org.eclipse.dirigible.sdk.utils.Json; @Repository public class JournalEntryDirectionRepository extends JavaRepository { @@ -9,4 +11,46 @@ public class JournalEntryDirectionRepository extends JavaRepository