From fa3e29ae3029dec6af89822522d301a0813249cd Mon Sep 17 00:00:00 2001 From: NicoleNG18 Date: Fri, 13 Feb 2026 17:07:20 +0200 Subject: [PATCH] regenerate module using Application Full Stack - v2 template --- codbex-cities/codbex-cities.gen | 28 +- .../api/Settings/CityController.ts | 181 ++++++ .../codbex-cities/api/Settings/CityService.ts | 159 ----- .../codbex-cities/api/utils/ForbiddenError.ts | 8 - .../gen/codbex-cities/api/utils/HttpUtils.ts | 60 -- .../api/utils/ValidationError.ts | 8 - .../gen/codbex-cities/codbex-cities.openapi | 583 ------------------ .../data/Settings/City.extensionpoint | 4 + .../codbex-cities/data/Settings/CityEntity.ts | 34 + .../data/Settings/CityRepository.ts | 25 + .../ui/Settings/City/controller.js | 11 +- .../Settings/City/dialog-filter/controller.js | 29 +- .../Settings/City/dialog-window/controller.js | 6 +- 13 files changed, 279 insertions(+), 857 deletions(-) create mode 100644 codbex-cities/gen/codbex-cities/api/Settings/CityController.ts delete mode 100644 codbex-cities/gen/codbex-cities/api/Settings/CityService.ts delete mode 100644 codbex-cities/gen/codbex-cities/api/utils/ForbiddenError.ts delete mode 100644 codbex-cities/gen/codbex-cities/api/utils/HttpUtils.ts delete mode 100644 codbex-cities/gen/codbex-cities/api/utils/ValidationError.ts delete mode 100644 codbex-cities/gen/codbex-cities/codbex-cities.openapi create mode 100644 codbex-cities/gen/codbex-cities/data/Settings/City.extensionpoint create mode 100644 codbex-cities/gen/codbex-cities/data/Settings/CityEntity.ts create mode 100644 codbex-cities/gen/codbex-cities/data/Settings/CityRepository.ts diff --git a/codbex-cities/codbex-cities.gen b/codbex-cities/codbex-cities.gen index b311846..c5c7684 100644 --- a/codbex-cities/codbex-cities.gen +++ b/codbex-cities/codbex-cities.gen @@ -1,24 +1,16 @@ { "tablePrefix": "CODBEX_", "brand": "codbex", - "brandUrl": "https://codbex.com", + "brandUrl": "https://www.codbex.com/", "title": "Cities Management Module", - "description": "Managing cities data", - "dataSource": "DefaultDB", - "fileName": "codbex-cities", - "genFolderName": "codbex-cities", - "roles": [ - { - "entityName": "City", - "roleRead": "codbex-cities.Cities.CityReadOnly", - "roleWrite": "codbex-cities.Cities.CityFullAccess" - } - ], - "tprefix": "codbex-cities-model", + "description": "Managing Cities data", "projectName": "codbex-cities", "workspaceName": "workspace", "filePath": "codbex-cities.model", - "templateId": "template-application-angular/template/template.js", + "templateId": "template-application-angular-v2/template/template.js", + "fileName": "codbex-cities", + "genFolderName": "codbex-cities", + "dataSource": "DefaultDB", "perspectives": { "Settings": { "views": [ @@ -34,6 +26,14 @@ "role": "" } }, + "roles": [ + { + "entityName": "City", + "roleRead": "codbex-cities.Cities.CityReadOnly", + "roleWrite": "codbex-cities.Cities.CityFullAccess" + } + ], + "tprefix": "codbex-cities-model", "models": [ { "properties": [ diff --git a/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts b/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts new file mode 100644 index 0000000..5eb9cfb --- /dev/null +++ b/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts @@ -0,0 +1,181 @@ +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 { CityRepository } from '../../data/Settings/CityRepository' +import { CityEntity } from '../../data/Settings/CityEntity' + +const validationModules = await Extensions.loadExtensionModules('codbex-cities-Settings-City', ['validate']); + +@Controller +@Documentation('codbex-cities - City Controller') +@Injected() +class CityController { + + @Inject('CityRepository') + private readonly repository!: CityRepository; + + @Get('/') + @Documentation('Get All City') + public getAll(_: any, ctx: any): CityEntity[] { + 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().slice(0, 2) + }; + + return this.repository.findAll(options); + } catch (error: any) { + this.handleError(error); + } + return undefined as any; + } + + @Post('/') + @Documentation('Create City') + public create(entity: CityEntity): CityEntity { + try { + this.checkPermissions('write'); + this.validateEntity(entity); + entity.Id = this.repository.create(entity) as any; + response.setHeader('Content-Location', '/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts/' + entity.Id); + response.setStatus(response.CREATED); + return entity; + } catch (error: any) { + this.handleError(error); + } + return undefined as any; + } + + @Get('/count') + @Documentation('Count City') + 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 City 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 City') + public search(filter: any): CityEntity[] { + try { + this.checkPermissions('read'); + return this.repository.findAll(filter); + } catch (error: any) { + this.handleError(error); + } + return undefined as any; + } + + @Get('/:id') + @Documentation('Get City by id') + public getById(_: any, ctx: any): CityEntity { + try { + this.checkPermissions('read'); + const id = parseInt(ctx.pathParameters.id); + const options: Options = { + language: request.getLocale().slice(0, 2) + }; + const entity = this.repository.findById(id, options); + if (entity) { + return entity; + } else { + HttpUtils.sendResponseNotFound('City not found'); + } + } catch (error: any) { + this.handleError(error); + } + return undefined as any; + } + + @Put('/:id') + @Documentation('Update City by id') + public update(entity: CityEntity, ctx: any): CityEntity { + 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 City 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('City 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-cities.Cities.CityReadOnly') || user.isInRole('codbex-cities.Cities.CityFullAccess'))) { + throw new ForbiddenError(); + } + if (operationType === 'write' && !user.isInRole('codbex-cities.Cities.CityFullAccess')) { + 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 > 100) { + throw new ValidationError(`The 'Name' exceeds the maximum length of [100] characters`); + } + if (entity.Country === null || entity.Country === undefined) { + throw new ValidationError(`The 'Country' property is required, provide a valid value`); + } + for (const next of validationModules) { + next.validate(entity); + } + } + +} diff --git a/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts b/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts deleted file mode 100644 index 5b93609..0000000 --- a/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { Controller, Get, Post, Put, Delete, request, response } from "@aerokit/sdk/http" -import { Extensions } from "@aerokit/sdk/extensions" -import { CityRepository, CityEntityOptions } from "../../dao/Settings/CityRepository"; -import { user } from "@aerokit/sdk/security" -import { ForbiddenError } from "../utils/ForbiddenError"; -import { ValidationError } from "../utils/ValidationError"; -import { HttpUtils } from "../utils/HttpUtils"; - -const validationModules = await Extensions.loadExtensionModules("codbex-cities-Settings-City", ["validate"]); - -@Controller -class CityService { - - private readonly repository = new CityRepository(); - - @Get("/") - public getAll(_: any, ctx: any) { - try { - this.checkPermissions("read"); - const options: CityEntityOptions = { - $limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined, - $offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined, - $language: request.getLocale().slice(0, 2) - }; - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - } - - @Post("/") - public create(entity: any) { - try { - this.checkPermissions("write"); - this.validateEntity(entity); - entity.Id = this.repository.create(entity); - response.setHeader("Content-Location", "/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts/" + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - } - - @Get("/count") - public count() { - try { - this.checkPermissions("read"); - return { count: this.repository.count() }; - } catch (error: any) { - this.handleError(error); - } - } - - @Post("/count") - public countWithFilter(filter: any) { - try { - this.checkPermissions("read"); - return { count: this.repository.count(filter) }; - } catch (error: any) { - this.handleError(error); - } - } - - @Post("/search") - public search(filter: any) { - try { - this.checkPermissions("read"); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - } - - @Get("/:id") - public getById(_: any, ctx: any) { - try { - this.checkPermissions("read"); - const id = parseInt(ctx.pathParameters.id); - const options: CityEntityOptions = { - $language: request.getLocale().slice(0, 2) - }; - const entity = this.repository.findById(id, options); - if (entity) { - return entity; - } else { - HttpUtils.sendResponseNotFound("City not found"); - } - } catch (error: any) { - this.handleError(error); - } - } - - @Put("/:id") - public update(entity: any, ctx: any) { - try { - this.checkPermissions("write"); - entity.Id = ctx.pathParameters.id; - this.validateEntity(entity); - this.repository.update(entity); - return entity; - } catch (error: any) { - this.handleError(error); - } - } - - @Delete("/:id") - public deleteById(_: any, ctx: any) { - try { - this.checkPermissions("write"); - const id = ctx.pathParameters.id; - const entity = this.repository.findById(id); - if (entity) { - this.repository.deleteById(id); - HttpUtils.sendResponseNoContent(); - } else { - HttpUtils.sendResponseNotFound("City 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-cities.Cities.CityReadOnly") || user.isInRole("codbex-cities.Cities.CityFullAccess"))) { - throw new ForbiddenError(); - } - if (operationType === "write" && !user.isInRole("codbex-cities.Cities.CityFullAccess")) { - 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 > 100) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [100] characters`); - } - if (entity.Country === null || entity.Country === undefined) { - throw new ValidationError(`The 'Country' property is required, provide a valid value`); - } - for (const next of validationModules) { - next.validate(entity); - } - } - -} diff --git a/codbex-cities/gen/codbex-cities/api/utils/ForbiddenError.ts b/codbex-cities/gen/codbex-cities/api/utils/ForbiddenError.ts deleted file mode 100644 index 775ae84..0000000 --- a/codbex-cities/gen/codbex-cities/api/utils/ForbiddenError.ts +++ /dev/null @@ -1,8 +0,0 @@ -export class ForbiddenError extends Error { - readonly name = "ForbiddenError"; - readonly stack = (new Error()).stack; - - constructor(message: string = "You don't have permission to access this resource") { - super(message); - } -} \ No newline at end of file diff --git a/codbex-cities/gen/codbex-cities/api/utils/HttpUtils.ts b/codbex-cities/gen/codbex-cities/api/utils/HttpUtils.ts deleted file mode 100644 index 08fbd20..0000000 --- a/codbex-cities/gen/codbex-cities/api/utils/HttpUtils.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { response } from "@aerokit/sdk/http"; - -export class HttpUtils { - - // HTTP 200 - public static sendResponseOk(entity: any): void { - HttpUtils.sendResponse(200, entity); - } - - // HTTP 201 - public static sendResponseCreated(entity): void { - HttpUtils.sendResponse(201, entity); - } - - // HTTP 204 - public static sendResponseNoContent(): void { - HttpUtils.sendResponse(204); - } - - // HTTP 400 - public static sendResponseBadRequest(message): void { - HttpUtils.sendResponse(400, { - "code": 400, - "message": message - }); - } - - // HTTP 403 - public static sendForbiddenRequest(message): void { - HttpUtils.sendResponse(403, { - "code": 403, - "message": message - }); - } - - // HTTP 404 - public static sendResponseNotFound(message): void { - HttpUtils.sendResponse(404, { - "code": 404, - "message": message - }); - } - - // HTTP 500 - public static sendInternalServerError(message): void { - HttpUtils.sendResponse(500, { - "code": 500, - "message": message - }); - } - - // Generic - private static sendResponse(status: number, body?: any): void { - response.setContentType("application/json"); - response.setStatus(status); - if (body) { - response.println(JSON.stringify(body)); - } - } -} diff --git a/codbex-cities/gen/codbex-cities/api/utils/ValidationError.ts b/codbex-cities/gen/codbex-cities/api/utils/ValidationError.ts deleted file mode 100644 index 9b894fa..0000000 --- a/codbex-cities/gen/codbex-cities/api/utils/ValidationError.ts +++ /dev/null @@ -1,8 +0,0 @@ -export class ValidationError extends Error { - readonly name = "ValidationError"; - readonly stack = (new Error()).stack; - - constructor(message: string) { - super(message); - } -} \ No newline at end of file diff --git a/codbex-cities/gen/codbex-cities/codbex-cities.openapi b/codbex-cities/gen/codbex-cities/codbex-cities.openapi deleted file mode 100644 index 38c8444..0000000 --- a/codbex-cities/gen/codbex-cities/codbex-cities.openapi +++ /dev/null @@ -1,583 +0,0 @@ -openapi: 3.0.3 -info: - title: Cities Management Module - OpenAPI 3.0 - version: 1.0.0 - description: Managing cities data -externalDocs: - description: Find out more about Eclipse Dirigible - url: https://dirigible.io -servers: - - url: /services/ts -tags: - - name: Settings -paths: - /codbex-cities/gen/codbex-cities/api/Settings/CityService.ts: - get: - summary: List City - parameters: - - in: query - name: $limit - description: The number of records to be returned _(both `$limit` and `$offset` should be provided)_. - required: false - allowReserved: true - schema: - type: integer - allowEmptyValue: true - - in: query - name: $offset - description: The number of records to skip _(both `$limit` and `$offset` should be provided)_. - required: false - allowReserved: true - schema: - type: integer - allowEmptyValue: true - tags: - - Settings - responses: - 200: - description: Successful Request - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/City' - 400: - description: Bad Request Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 403: - description: Forbidden Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 500: - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - post: - summary: Create City - tags: - - Settings - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/City' - required: true - responses: - 201: - description: Successful Request - content: - application/json: - schema: - $ref: '#/components/schemas/City' - 400: - description: Bad Request Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 403: - description: Forbidden Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 500: - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /codbex-cities/gen/codbex-cities/api/Settings/CityService.ts/{id}: - get: - summary: Get City by Id - parameters: - - in: path - name: id - description: The Id of the entity. - required: true - schema: - type: string - tags: - - Settings - responses: - 200: - description: Successful Request - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/City' - 404: - description: Entity Not Found - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 403: - description: Forbidden Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 500: - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - put: - summary: Update City by Id - parameters: - - in: path - name: id - description: The Id of the entity. - required: true - schema: - type: string - tags: - - Settings - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/City' - required: true - responses: - 200: - description: Successful Request - content: - application/json: - schema: - $ref: '#/components/schemas/City' - 400: - description: Bad Request Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 404: - description: Entity Not Found - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 403: - description: Forbidden Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 500: - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - delete: - summary: Delete City by Id - parameters: - - in: path - name: id - description: The Id of the entity. - required: true - schema: - type: string - tags: - - Settings - responses: - 204: - description: Successful Request - 404: - description: Entity Not Found - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 403: - description: Forbidden Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 500: - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /codbex-cities/gen/codbex-cities/api/Settings/CityService.ts/count: - get: - summary: Count the number of City - tags: - - Settings - responses: - 200: - description: Successful Request - content: - application/json: - schema: - type: integer - example: 100 - 403: - description: Forbidden Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 500: - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - post: - summary: Count the number of City by CityFilterOptions - tags: - - Settings - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CityFilterOptions' - examples: - countWithMultipleCriteria: - summary: Count with multiple criteria - value: - $filter: - notEquals: - Id: 33 - contains: - Name: "abcd" - greaterThan: - Id: 0 - lessThanOrEqual: - Id: 100 - countWithEquals: - summary: Count with Equals - value: - $filter: - equals: - Id: 0 - countWithNotEquals: - summary: Count with Not Equals - value: - $filter: - notEquals: - Id: 0 - countWithContains: - summary: Count with Contains - value: - $filter: - contains: - Name: "abcd" - countWithGreaterThan: - summary: Count with Greater Than - value: - $filter: - greaterThan: - Id: 0 - countWithGreaterThanOrEqual: - summary: Count with Greater Than Or Equal - value: - $filter: - greaterThanOrEqual: - Id: 0 - countWithLessThan: - summary: Count with Less Than - value: - $filter: - lessThan: - Id: 0 - countWithLessThanOrEqual: - summary: Count with Less Than Or Equal - value: - $filter: - lessThanOrEqual: - Id: 0 - required: true - responses: - 200: - description: Successful Request - content: - application/json: - schema: - type: integer - example: 100 - 403: - description: Forbidden Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 500: - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /codbex-cities/gen/codbex-cities/api/Settings/CityService.ts/search: - post: - summary: Search City by CityFilterOptions - tags: - - Settings - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CityFilterOptions' - examples: - searchWithMultipleCriteria: - summary: Search with multiple criteria - value: - $filter: - notEquals: - Id: 33 - contains: - Name: "abcd" - greaterThan: - Id: 0 - lessThanOrEqual: - Id: 100 - searchWithEquals: - summary: Search with Equals - value: - $filter: - equals: - Id: 0 - searchWithNotEquals: - summary: Search with Not Equals - value: - $filter: - notEquals: - Id: 0 - searchWithContains: - summary: Search with Contains - value: - $filter: - contains: - Name: "abcd" - searchWithGreaterThan: - summary: Search with Greater Than - value: - $filter: - greaterThan: - Id: 0 - searchWithGreaterThanOrEqual: - summary: Search with Greater Than Or Equal - value: - $filter: - greaterThanOrEqual: - Id: 0 - searchWithLessThan: - summary: Search with Less Than - value: - $filter: - lessThan: - Id: 0 - searchWithLessThanOrEqual: - summary: Search with Less Than Or Equal - value: - $filter: - lessThanOrEqual: - Id: 0 - required: true - responses: - 200: - description: Successful Request - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/City' - 403: - description: Forbidden Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - 500: - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' -components: - schemas: - City: - type: object - required: - - Name - - Country - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 100 - Country: - type: integer - format: int32 - CityFilterOptions: - type: object - properties: - $filter: - type: object - properties: - equals: - type: object - properties: - Id: - oneOf: - - type: integer - format: int32 - - type: array - items: - type: integer - format: int32 - Name: - oneOf: - - type: string - minLength: 0 - maxLength: 100 - - type: array - items: - type: string - format: double - minLength: 0 - maxLength: 100 - Country: - oneOf: - - type: integer - format: int32 - - type: array - items: - type: integer - format: int32 - notEquals: - type: object - properties: - Id: - oneOf: - - type: integer - format: int32 - - type: array - items: - type: integer - format: int32 - Name: - oneOf: - - type: string - minLength: 0 - maxLength: 100 - - type: array - items: - type: string - format: double - minLength: 0 - maxLength: 100 - Country: - oneOf: - - type: integer - format: int32 - - type: array - items: - type: integer - format: int32 - contains: - type: object - properties: - Id: - Name: - type: string - minLength: 0 - maxLength: 100 - Country: - greaterThan: - type: object - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 100 - Country: - type: integer - format: int32 - greaterThanOrEqual: - type: object - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 100 - Country: - type: integer - format: int32 - lessThan: - type: object - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 100 - Country: - type: integer - format: int32 - lessThanOrEqual: - type: object - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 100 - Country: - type: integer - format: int32 - $select: - type: array - example: ["Id", "Name", "Country"] - items: - type: string - $sort: - - type: string - example: "Id,Name,Country" - $order: - type: string - enum: ["asc", "desc"] - example: "asc" - $offset: - type: integer - example: 0 - $limit: - type: integer - example: 10 - Error: - type: object - properties: - code: - type: integer - message: - type: string \ No newline at end of file diff --git a/codbex-cities/gen/codbex-cities/data/Settings/City.extensionpoint b/codbex-cities/gen/codbex-cities/data/Settings/City.extensionpoint new file mode 100644 index 0000000..d80896c --- /dev/null +++ b/codbex-cities/gen/codbex-cities/data/Settings/City.extensionpoint @@ -0,0 +1,4 @@ +{ + "name": "codbex-cities-Settings-City", + "description": "Extension Point for the codbex-cities-Settings-City entity" +} \ No newline at end of file diff --git a/codbex-cities/gen/codbex-cities/data/Settings/CityEntity.ts b/codbex-cities/gen/codbex-cities/data/Settings/CityEntity.ts new file mode 100644 index 0000000..ea00e68 --- /dev/null +++ b/codbex-cities/gen/codbex-cities/data/Settings/CityEntity.ts @@ -0,0 +1,34 @@ +import { Entity, Table, Id, Generated, Column, Documentation } from '@aerokit/sdk/db' + +@Entity('CityEntity') +@Table('CODBEX_CITY') +@Documentation('City entity mapping') +export class CityEntity { + + @Id() + @Generated('sequence') + @Documentation('Id') + @Column({ + name: 'CITY_ID', + type: 'integer', + }) + public Id?: number; + + @Documentation('Name') + @Column({ + name: 'CITY_NAME', + type: 'string', + length: 100, + }) + public Name!: string; + + @Documentation('Country') + @Column({ + name: 'CITY_COUNTRY', + type: 'integer', + }) + public Country!: number; + +} + +(new CityEntity()); diff --git a/codbex-cities/gen/codbex-cities/data/Settings/CityRepository.ts b/codbex-cities/gen/codbex-cities/data/Settings/CityRepository.ts new file mode 100644 index 0000000..e14146b --- /dev/null +++ b/codbex-cities/gen/codbex-cities/data/Settings/CityRepository.ts @@ -0,0 +1,25 @@ +import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Component } from '@aerokit/sdk/component' +import { Producer } from '@aerokit/sdk/messaging' +import { Extensions } from '@aerokit/sdk/extensions' +import { CityEntity } from './CityEntity' + +@Component('CityRepository') +export class CityRepository extends Repository { + + constructor() { + super((CityEntity as EntityConstructor)); + } + + protected override async triggerEvent(data: EntityEvent): Promise { + const triggerExtensions = await Extensions.loadExtensionModules('codbex-cities-Settings-City', ['trigger']); + triggerExtensions.forEach(triggerExtension => { + try { + triggerExtension.trigger(data); + } catch (error) { + console.error(error); + } + }); + Producer.topic('codbex-cities-Settings-City').send(JSON.stringify(data)); + } +} diff --git a/codbex-cities/gen/codbex-cities/ui/Settings/City/controller.js b/codbex-cities/gen/codbex-cities/ui/Settings/City/controller.js index 4564528..2deb99d 100644 --- a/codbex-cities/gen/codbex-cities/ui/Settings/City/controller.js +++ b/codbex-cities/gen/codbex-cities/ui/Settings/City/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts'; + EntityServiceProvider.baseUrl = '/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts'; }]) .controller('PageController', ($scope, $http, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); @@ -87,8 +87,11 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer let limit = $scope.dataLimit; let request; if (filter) { - filter.$offset = offset; - filter.$limit = limit; + if (!filter.$filter) { + filter.$filter = {}; + } + filter.$filter.offset = offset; + filter.$filter.limit = limit; request = EntityService.search(filter); } else { request = EntityService.list(offset, limit); @@ -204,7 +207,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.optionsCountry = []; - $http.get('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryService.ts').then((response) => { + $http.get('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts').then((response) => { $scope.optionsCountry = response.data.map(e => ({ value: e.Id, text: e.Name diff --git a/codbex-cities/gen/codbex-cities/ui/Settings/City/dialog-filter/controller.js b/codbex-cities/gen/codbex-cities/ui/Settings/City/dialog-filter/controller.js index 4e4f26e..13a3f93 100644 --- a/codbex-cities/gen/codbex-cities/ui/Settings/City/dialog-filter/controller.js +++ b/codbex-cities/gen/codbex-cities/ui/Settings/City/dialog-filter/controller.js @@ -22,30 +22,23 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle let entity = $scope.entity; const filter = { $filter: { - equals: { - }, - notEquals: { - }, - contains: { - }, - greaterThan: { - }, - greaterThanOrEqual: { - }, - lessThan: { - }, - lessThanOrEqual: { - } - }, + conditions: [], + sorts: [], + limit: 20, + offset: 0 + } }; if (entity.Id !== undefined) { - filter.$filter.equals.Id = entity.Id; + const condition = { propertyName: 'Id', operator: 'EQ', value: entity.Id }; + filter.$filter.conditions.push(condition); } if (entity.Name) { - filter.$filter.contains.Name = entity.Name; + const condition = { propertyName: 'Name', operator: 'LIKE', value: `%${entity.Name}%` }; + filter.$filter.conditions.push(condition); } if (entity.Country !== undefined) { - filter.$filter.equals.Country = entity.Country; + const condition = { propertyName: 'Country', operator: 'EQ', value: entity.Country }; + filter.$filter.conditions.push(condition); } Dialogs.postMessage({ topic: 'codbex-cities.Settings.City.entitySearch', data: { entity: entity, diff --git a/codbex-cities/gen/codbex-cities/ui/Settings/City/dialog-window/controller.js b/codbex-cities/gen/codbex-cities/ui/Settings/City/dialog-window/controller.js index 791166b..16823ce 100644 --- a/codbex-cities/gen/codbex-cities/ui/Settings/City/dialog-window/controller.js +++ b/codbex-cities/gen/codbex-cities/ui/Settings/City/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts'; + EntityServiceProvider.baseUrl = '/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); @@ -79,11 +79,11 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer }); }; - $scope.serviceCountry = '/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryService.ts'; + $scope.serviceCountry = '/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts'; $scope.optionsCountry = []; - $http.get('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryService.ts').then((response) => { + $http.get('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts').then((response) => { $scope.optionsCountry = response.data.map(e => ({ value: e.Id, text: e.Name