diff --git a/codbex-cities/codbex-cities.edm b/codbex-cities/codbex-cities.edm
index 67d311a..8d435a3 100644
--- a/codbex-cities/codbex-cities.edm
+++ b/codbex-cities/codbex-cities.edm
@@ -5,14 +5,14 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
@@ -20,5 +20,5 @@
-
+
\ No newline at end of file
diff --git a/codbex-cities/codbex-cities.gen b/codbex-cities/codbex-cities.gen
index 8bc82c0..ff7859b 100644
--- a/codbex-cities/codbex-cities.gen
+++ b/codbex-cities/codbex-cities.gen
@@ -4,21 +4,15 @@
"brandUrl": "https://www.codbex.com/",
"title": "Cities Management Module",
"description": "Managing Cities Data",
- "fileName": "codbex-cities",
- "genFolderName": "codbex-cities",
- "dataSource": "DefaultDB",
- "roles": [
- {
- "entityName": "City",
- "roleRead": "codbex-cities.Cities.CityReadOnly",
- "roleWrite": "codbex-cities.Cities.CityFullAccess"
- }
- ],
- "tprefix": "codbex-cities-model",
"projectName": "codbex-cities",
"workspaceName": "workspace",
"filePath": "codbex-cities.model",
- "templateId": "template-application-angular-v2/template/template.js",
+ "templateId": "template-application-angular-java/template/template.js",
+ "fileName": "codbex-cities",
+ "genFolderName": "codbex-cities",
+ "javaRuntime": true,
+ "javaGenFolderName": "codbex_cities",
+ "dataSource": "DefaultDB",
"perspectives": {
"Settings": {
"views": [
@@ -28,12 +22,20 @@
"name": "Settings",
"label": "Settings",
"header": "",
- "order": "100",
+ "order": "990",
"navId": "",
- "icon": "/services/web/resources/unicons/globe.svg",
+ "icon": "globe",
"role": ""
}
},
+ "roles": [
+ {
+ "entityName": "City",
+ "roleRead": "codbex-cities.Cities.CityReadOnly",
+ "roleWrite": "codbex-cities.Cities.CityFullAccess"
+ }
+ ],
+ "tprefix": "codbex-cities-model",
"models": [
{
"properties": [
@@ -61,6 +63,7 @@
"widgetDropdownControllerUrl": "",
"dataTypeJava": "int",
"dataTypeTypescript": "number",
+ "dataTypeJavaClass": "Integer",
"inputRule": ""
},
{
@@ -88,6 +91,7 @@
"widgetDropdownControllerUrl": "",
"dataTypeJava": "string",
"dataTypeTypescript": "string",
+ "dataTypeJavaClass": "String",
"minLength": 0,
"maxLength": 100,
"inputRule": ""
@@ -110,7 +114,7 @@
"relationshipName": "City_Country",
"relationshipEntityName": "Country",
"relationshipEntityPerspectiveName": "Settings",
- "relationshipEntityPerspectiveLabel": "Entities",
+ "relationshipEntityPerspectiveLabel": "Settings",
"dataNotNull": true,
"dataAutoIncrement": false,
"dataPrimaryKey": false,
@@ -118,10 +122,11 @@
"isCalculatedProperty": false,
"isReadOnlyProperty": false,
"widgetLabel": "Country",
- "widgetDropdownUrl": "/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryService.ts",
- "widgetDropdownControllerUrl": "/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts",
+ "widgetDropdownUrl": "/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController",
+ "widgetDropdownControllerUrl": "/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController",
"dataTypeJava": "int",
"dataTypeTypescript": "number",
+ "dataTypeJavaClass": "Integer",
"inputRule": ""
}
],
@@ -152,6 +157,7 @@
"tooltip": "City",
"type": "SETTING",
"dataSource": "DefaultDB",
+ "javaPerspectiveName": "settings",
"referencedProjections": [
{
"name": "Country",
@@ -169,8 +175,6 @@
"properties": [
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": true,
"dataName": "COUNTRY_ID",
"dataNullable": true,
@@ -193,12 +197,11 @@
"widgetDropdownControllerUrl": "",
"dataTypeJava": "int",
"dataTypeTypescript": "number",
+ "dataTypeJavaClass": "Integer",
"inputRule": ""
},
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataLength": "255",
"dataName": "COUNTRY_NAME",
"dataNullable": true,
@@ -222,14 +225,13 @@
"widgetDropdownControllerUrl": "",
"dataTypeJava": "string",
"dataTypeTypescript": "string",
+ "dataTypeJavaClass": "String",
"minLength": 0,
"maxLength": 20,
"inputRule": ""
},
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataLength": "2",
"dataName": "COUNTRY_CODE2",
"dataNullable": true,
@@ -253,14 +255,13 @@
"widgetDropdownControllerUrl": "",
"dataTypeJava": "string",
"dataTypeTypescript": "string",
+ "dataTypeJavaClass": "String",
"minLength": 0,
"maxLength": 2,
"inputRule": ""
},
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataLength": "3",
"dataName": "COUNTRY_CODE3",
"dataNullable": true,
@@ -284,14 +285,13 @@
"widgetDropdownControllerUrl": "",
"dataTypeJava": "string",
"dataTypeTypescript": "string",
+ "dataTypeJavaClass": "String",
"minLength": 0,
"maxLength": 3,
"inputRule": ""
},
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataLength": "3",
"dataName": "COUNTRY_NUMERIC",
"dataNullable": true,
@@ -315,6 +315,7 @@
"widgetDropdownControllerUrl": "",
"dataTypeJava": "string",
"dataTypeTypescript": "string",
+ "dataTypeJavaClass": "String",
"minLength": 0,
"maxLength": 3,
"inputRule": ""
@@ -335,11 +336,11 @@
"multilingual": "false",
"name": "Country",
"perspectiveHeader": "",
- "perspectiveIcon": "/services/web/resources/unicons/globe.svg",
- "perspectiveLabel": "Entities",
+ "perspectiveIcon": "globe",
+ "perspectiveLabel": "Settings",
"perspectiveName": "Settings",
"perspectiveNavId": "",
- "perspectiveOrder": "100",
+ "perspectiveOrder": "990",
"perspectiveRole": "",
"projectionReferencedEntity": "Country",
"projectionReferencedModel": "/workspace/codbex-countries/codbex-countries.model",
@@ -347,6 +348,7 @@
"tooltip": "Country",
"type": "PROJECTION",
"dataSource": "DefaultDB",
+ "javaPerspectiveName": "settings",
"referencedProjections": [],
"primaryKeys": [
"Id"
diff --git a/codbex-cities/codbex-cities.model b/codbex-cities/codbex-cities.model
index 655735b..70aeb87 100644
--- a/codbex-cities/codbex-cities.model
+++ b/codbex-cities/codbex-cities.model
@@ -51,7 +51,7 @@
"relationshipName": "City_Country",
"relationshipEntityName": "Country",
"relationshipEntityPerspectiveName": "Settings",
- "relationshipEntityPerspectiveLabel": "Entities"
+ "relationshipEntityPerspectiveLabel": "Settings"
}
],
"caption": "Manage entity City",
@@ -87,8 +87,6 @@
"properties": [
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "true",
"dataName": "COUNTRY_ID",
"dataNullable": "true",
@@ -104,8 +102,6 @@
},
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataLength": "255",
"dataName": "COUNTRY_NAME",
"dataNullable": "true",
@@ -121,8 +117,6 @@
},
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataLength": "2",
"dataName": "COUNTRY_CODE2",
"dataNullable": "true",
@@ -138,8 +132,6 @@
},
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataLength": "3",
"dataName": "COUNTRY_CODE3",
"dataNullable": "true",
@@ -155,8 +147,6 @@
},
{
"auditType": "NONE",
- "calculatedPropertyExpressionCreate": "",
- "calculatedPropertyExpressionUpdate": "",
"dataLength": "3",
"dataName": "COUNTRY_NUMERIC",
"dataNullable": "true",
@@ -186,11 +176,11 @@
"multilingual": "false",
"name": "Country",
"perspectiveHeader": "",
- "perspectiveIcon": "/services/web/resources/unicons/globe.svg",
- "perspectiveLabel": "Entities",
+ "perspectiveIcon": "globe",
+ "perspectiveLabel": "Settings",
"perspectiveName": "Settings",
"perspectiveNavId": "",
- "perspectiveOrder": "100",
+ "perspectiveOrder": "990",
"perspectiveRole": "",
"projectionReferencedEntity": "Country",
"projectionReferencedModel": "/workspace/codbex-countries/codbex-countries.model",
diff --git a/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts b/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts
deleted file mode 100644
index 3eb1a58..0000000
--- a/codbex-cities/gen/codbex-cities/api/Settings/CityController.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 { 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()?.split("_")[0]
- };
-
- 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/CityController.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()?.split("_")[0]
- };
- 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/data/Settings/CityEntity.ts b/codbex-cities/gen/codbex-cities/data/Settings/CityEntity.ts
deleted file mode 100644
index e994e52..0000000
--- a/codbex-cities/gen/codbex-cities/data/Settings/CityEntity.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} 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
deleted file mode 100644
index 36123c6..0000000
--- a/codbex-cities/gen/codbex-cities/data/Settings/CityRepository.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 { 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/odata/codbex-cities.odata b/codbex-cities/gen/codbex-cities/odata/codbex-cities.odata
deleted file mode 100644
index f149140..0000000
--- a/codbex-cities/gen/codbex-cities/odata/codbex-cities.odata
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "namespace": "",
- "entities": []
-}
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 05c5322..ec99bdd 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/CityController.ts';
+ EntityServiceProvider.baseUrl = '/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController';
}])
.controller('PageController', ($scope, $http, EntityService, Extensions, LocaleService, ButtonStates) => {
const Dialogs = new DialogHub();
@@ -100,7 +100,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer
if (optionsCountryHasMore) {
const optionsCountrySearchValues = Array.from(new Set(response.data.map(e => e.Country)));
if (optionsCountrySearchValues.length > 0) {
- $http.post('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts/search', {
+ $http.post('/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController/search', {
conditions: [
{ propertyName: 'Id', operator: 'IN', value: optionsCountrySearchValues }
]
@@ -231,9 +231,9 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer
let optionsCountryHasMore = true;
- $http.get('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts/count').then((response) => {
+ $http.get('/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController/count').then((response) => {
const optionsCountryCount = response.data.count;
- $http.get('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts').then((response) => {
+ $http.get('/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController').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 2a5646c..4beab91 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
@@ -82,7 +82,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle
$scope.loadMoreOptionsCountry = () => {
const limit = 20;
$scope.optionsCountryLoading = true;
- $http.get(`/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts?$limit=${limit}&$offset=${++loadMoreOptionsCountryCounter * limit}`)
+ $http.get(`/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController?$limit=${limit}&$offset=${++loadMoreOptionsCountryCounter * limit}`)
.then((response) => {
const optionValues = allValuesCountry.map(e => e.value);
const resultValues = response.data.map(e => ({
@@ -132,7 +132,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle
}
})
if (!cacheHit) {
- $http.post('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts/search', {
+ $http.post('/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController/search', {
conditions: [
{ propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` }
]
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 2fc916d..a40c342 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/CityController.ts';
+ EntityServiceProvider.baseUrl = '/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController';
}])
.controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => {
const Dialogs = new DialogHub();
@@ -81,11 +81,11 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer
});
};
- $scope.serviceCountry = '/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts';
+ $scope.serviceCountry = '/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController';
$scope.optionsCountry = [];
- $http.get('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts').then((response) => {
+ $http.get('/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController').then((response) => {
$scope.optionsCountry = response.data.map(e => ({
value: e.Id,
text: e.Name
@@ -109,7 +109,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer
$scope.loadMoreOptionsCountry = () => {
const limit = 20;
$scope.optionsCountryLoading = true;
- $http.get(`/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts?$limit=${limit}&$offset=${++loadMoreOptionsCountryCounter * limit}`)
+ $http.get(`/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController?$limit=${limit}&$offset=${++loadMoreOptionsCountryCounter * limit}`)
.then((response) => {
const optionValues = allValuesCountry.map(e => e.value);
const resultValues = response.data.map(e => ({
@@ -159,7 +159,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer
}
})
if (!cacheHit) {
- $http.post('/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts/search', {
+ $http.post('/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController/search', {
conditions: [
{ propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` }
]
diff --git a/codbex-cities/gen/codbex_cities/api/settings/CityController.java b/codbex-cities/gen/codbex_cities/api/settings/CityController.java
new file mode 100644
index 0000000..4faa112
--- /dev/null
+++ b/codbex-cities/gen/codbex_cities/api/settings/CityController.java
@@ -0,0 +1,173 @@
+package gen.codbex_cities.api.settings;
+
+import gen.codbex_cities.data.settings.CityEntity;
+import gen.codbex_cities.data.settings.CityRepository;
+
+import org.eclipse.dirigible.components.api.security.UserFacade;
+import org.eclipse.dirigible.sdk.platform.Documentation;
+import org.eclipse.dirigible.sdk.component.Inject;
+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;
+
+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-cities - City Controller")
+public class CityController {
+
+ private static final Set FILTER_FIELDS = Set.of("Id", "Name", "Country");
+
+ @Inject
+ private CityRepository repository;
+
+ @Get
+ @Documentation("List City")
+ 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 City")
+ public Map count() {
+ checkPermissions("read");
+ return Map.of("count", repository.count());
+ }
+
+ @Post("/count")
+ @Documentation("Count City with filter")
+ public Map countWithFilter(@Body Map filter) {
+ checkPermissions("read");
+ return Map.of("count", (long) runFilter(filter).size());
+ }
+
+ @Post("/search")
+ @Documentation("Search City")
+ public List search(@Body Map filter) {
+ checkPermissions("read");
+ List result = runFilter(filter);
+ return result;
+ }
+
+ @Get("/{id}")
+ @Documentation("Get City by id")
+ public CityEntity getById(@PathParam("id") Integer id) {
+ checkPermissions("read");
+ CityEntity entity = repository.findOne(id)
+ .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "City not found"));
+ return entity;
+ }
+
+ @Post
+ @Documentation("Create City")
+ public CityEntity create(@Body CityEntity entity) {
+ checkPermissions("write");
+ validate(entity);
+ return repository.save(entity);
+ }
+
+ @Put("/{id}")
+ @Documentation("Update City by id")
+ public CityEntity update(@PathParam("id") Integer id, @Body CityEntity entity) {
+ checkPermissions("write");
+ entity.Id = id;
+ validate(entity);
+ return repository.update(entity);
+ }
+
+ @Delete("/{id}")
+ @Documentation("Delete City by id")
+ public void deleteById(@PathParam("id") Integer id) {
+ checkPermissions("write");
+ if (repository.findOne(id).isEmpty()) {
+ throw new ResponseStatusException(HttpStatus.NOT_FOUND, "City not found");
+ }
+ repository.deleteById(id);
+ }
+
+ private List runFilter(Map filter) {
+ StringBuilder hql = new StringBuilder("from CityEntity 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-cities.Cities.CityReadOnly") || UserFacade.isInRole("codbex-cities.Cities.CityFullAccess"))) {
+ throw new ResponseStatusException(HttpStatus.FORBIDDEN);
+ }
+ if ("write".equals(op) && !UserFacade.isInRole("codbex-cities.Cities.CityFullAccess")) {
+ throw new ResponseStatusException(HttpStatus.FORBIDDEN);
+ }
+ }
+
+ private static void validate(CityEntity entity) {
+ if (entity.Name == null) {
+ throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' property is required");
+ }
+ if (entity.Name != null && entity.Name.length() > 100) {
+ throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 100");
+ }
+ if (entity.Country == null) {
+ throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Country' property is required");
+ }
+ }
+}
diff --git a/codbex-cities/gen/codbex-cities/data/Settings/City.extensionpoint b/codbex-cities/gen/codbex_cities/data/settings/City.extensionpoint
similarity index 98%
rename from codbex-cities/gen/codbex-cities/data/Settings/City.extensionpoint
rename to codbex-cities/gen/codbex_cities/data/settings/City.extensionpoint
index d80896c..eb19810 100644
--- a/codbex-cities/gen/codbex-cities/data/Settings/City.extensionpoint
+++ b/codbex-cities/gen/codbex_cities/data/settings/City.extensionpoint
@@ -1,4 +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.java b/codbex-cities/gen/codbex_cities/data/settings/CityEntity.java
new file mode 100644
index 0000000..c847961
--- /dev/null
+++ b/codbex-cities/gen/codbex_cities/data/settings/CityEntity.java
@@ -0,0 +1,34 @@
+package gen.codbex_cities.data.settings;
+
+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_CITY")
+@Documentation("City entity mapping")
+public class CityEntity {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "CITY_ID")
+ @Documentation("Id")
+ public Integer Id;
+
+ @Column(name = "CITY_NAME", length = 100, nullable = false)
+ @Documentation("Name")
+ public String Name;
+
+ @Column(name = "CITY_COUNTRY", nullable = false)
+ @Documentation("Country")
+ public Integer Country;
+
+}
diff --git a/codbex-cities/gen/codbex_cities/data/settings/CityRepository.java b/codbex-cities/gen/codbex_cities/data/settings/CityRepository.java
new file mode 100644
index 0000000..01891aa
--- /dev/null
+++ b/codbex-cities/gen/codbex_cities/data/settings/CityRepository.java
@@ -0,0 +1,12 @@
+package gen.codbex_cities.data.settings;
+
+import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository;
+import org.eclipse.dirigible.sdk.component.Repository;
+
+@Repository
+public class CityRepository extends JavaRepository {
+
+ public CityRepository() {
+ super(CityEntity.class);
+ }
+}
diff --git a/codbex-cities/gen/codbex-cities/roles/default-roles.roles b/codbex-cities/gen/codbex_cities/roles/default-roles.roles
similarity index 99%
rename from codbex-cities/gen/codbex-cities/roles/default-roles.roles
rename to codbex-cities/gen/codbex_cities/roles/default-roles.roles
index c896ce4..1b52fb2 100644
--- a/codbex-cities/gen/codbex-cities/roles/default-roles.roles
+++ b/codbex-cities/gen/codbex_cities/roles/default-roles.roles
@@ -7,4 +7,4 @@
"name": "codbex-cities.Cities.CityFullAccess",
"description": "A role that grants full access for City."
}
-]
\ No newline at end of file
+]