diff --git a/codbex-partners/codbex-partners.edm b/codbex-partners/codbex-partners.edm index 83c2678..438adca 100644 --- a/codbex-partners/codbex-partners.edm +++ b/codbex-partners/codbex-partners.edm @@ -5,12 +5,12 @@ - + - - + + @@ -26,7 +26,7 @@ - + @@ -68,24 +68,12 @@ - - - - - - - - - - - - - + @@ -134,9 +122,21 @@ - + + + + + + + + + + + + + - + @@ -146,5 +146,5 @@ - + \ No newline at end of file diff --git a/codbex-partners/codbex-partners.gen b/codbex-partners/codbex-partners.gen index a07762f..280b740 100644 --- a/codbex-partners/codbex-partners.gen +++ b/codbex-partners/codbex-partners.gen @@ -7,9 +7,10 @@ "projectName": "codbex-partners", "workspaceName": "workspace", "filePath": "codbex-partners.model", - "templateId": "template-application-angular-v2/template/template.js", + "templateId": "template-application-angular-java/template/template.js", "fileName": "codbex-partners", "genFolderName": "codbex-partners", + "javaRuntime": true, "javaGenFolderName": "codbex_partners", "dataSource": "DefaultDB", "perspectives": { @@ -114,15 +115,15 @@ }, "Settings": { "views": [ - "City", - "Country" + "Country", + "City" ], "name": "Settings", "label": "Settings", "header": "", "order": "100", "navId": "", - "icon": "/services/web/resources/unicons/globe.svg", + "icon": "/services/web/resources/unicons/copy.svg", "role": "" } }, @@ -286,8 +287,8 @@ }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", "dataName": "CUSTOMER_NAME", "dataNullable": true, @@ -376,36 +377,6 @@ "maxLength": 15, "inputRule": "" }, - { - "auditType": "NONE", - "dataLength": "20", - "dataName": "CUSTOMER_FAX", - "dataNullable": true, - "dataType": "VARCHAR", - "description": "", - "name": "Fax", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", - "widgetType": "TEXTBOX", - "dataNotNull": false, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "dataUnique": false, - "isRequiredProperty": false, - "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "Fax", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 20, - "inputRule": "" - }, { "auditType": "NONE", "dataName": "CUSTOMER_COUNTRY", @@ -424,7 +395,7 @@ "relationshipName": "Customer_Country", "relationshipEntityName": "Country", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities", + "relationshipEntityPerspectiveLabel": "Settings", "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, @@ -432,8 +403,8 @@ "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", @@ -448,10 +419,6 @@ "isRequiredProperty": true, "name": "City", "tooltip": "", - "widgetDependsOnEntity": "Country", - "widgetDependsOnFilterBy": "Country", - "widgetDependsOnProperty": "Country", - "widgetDependsOnValueFrom": "Id", "widgetDropDownKey": "Id", "widgetDropDownValue": "Name", "widgetIsMajor": true, @@ -461,7 +428,7 @@ "relationshipName": "Customer_City", "relationshipEntityName": "City", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities", + "relationshipEntityPerspectiveLabel": "Settings", "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, @@ -469,13 +436,43 @@ "isCalculatedProperty": false, "isReadOnlyProperty": false, "widgetLabel": "City", - "widgetDropdownUrl": "/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts", - "widgetDropdownControllerUrl": "/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts", + "widgetDropdownUrl": "/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController", + "widgetDropdownControllerUrl": "/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController", "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", "inputRule": "" }, + { + "auditType": "NONE", + "dataLength": "20", + "dataName": "CUSTOMER_FAX", + "dataNullable": true, + "dataType": "VARCHAR", + "description": "", + "name": "Fax", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "dataUnique": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Fax", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 20, + "inputRule": "" + }, { "auditType": "NONE", "dataLength": "255", @@ -883,8 +880,8 @@ }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", "dataName": "CUSTOMER_NAME", "dataNullable": true, @@ -973,36 +970,6 @@ "maxLength": 15, "inputRule": "" }, - { - "auditType": "NONE", - "dataLength": "20", - "dataName": "CUSTOMER_FAX", - "dataNullable": true, - "dataType": "VARCHAR", - "description": "", - "name": "Fax", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", - "widgetType": "TEXTBOX", - "dataNotNull": false, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "dataUnique": false, - "isRequiredProperty": false, - "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "Fax", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 20, - "inputRule": "" - }, { "auditType": "NONE", "dataName": "CUSTOMER_COUNTRY", @@ -1021,7 +988,7 @@ "relationshipName": "Customer_Country", "relationshipEntityName": "Country", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities", + "relationshipEntityPerspectiveLabel": "Settings", "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, @@ -1029,8 +996,8 @@ "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", @@ -1045,10 +1012,6 @@ "isRequiredProperty": true, "name": "City", "tooltip": "", - "widgetDependsOnEntity": "Country", - "widgetDependsOnFilterBy": "Country", - "widgetDependsOnProperty": "Country", - "widgetDependsOnValueFrom": "Id", "widgetDropDownKey": "Id", "widgetDropDownValue": "Name", "widgetIsMajor": true, @@ -1058,7 +1021,7 @@ "relationshipName": "Customer_City", "relationshipEntityName": "City", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities", + "relationshipEntityPerspectiveLabel": "Settings", "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, @@ -1066,13 +1029,43 @@ "isCalculatedProperty": false, "isReadOnlyProperty": false, "widgetLabel": "City", - "widgetDropdownUrl": "/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityService.ts", - "widgetDropdownControllerUrl": "/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts", + "widgetDropdownUrl": "/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController", + "widgetDropdownControllerUrl": "/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController", "dataTypeJava": "int", "dataTypeTypescript": "number", "dataTypeJavaClass": "Integer", "inputRule": "" }, + { + "auditType": "NONE", + "dataLength": "20", + "dataName": "CUSTOMER_FAX", + "dataNullable": true, + "dataType": "VARCHAR", + "description": "", + "name": "Fax", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "dataUnique": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Fax", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 20, + "inputRule": "" + }, { "auditType": "NONE", "dataLength": "255", @@ -1467,8 +1460,8 @@ }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", "dataName": "SUPPLIER_NAME", "dataNullable": true, @@ -1892,8 +1885,8 @@ }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", "dataName": "SUPPLIER_NAME", "dataNullable": true, @@ -2936,7 +2929,7 @@ { "auditType": "NONE", "dataAutoIncrement": true, - "dataName": "CITY_ID", + "dataName": "MANUFACTURER_ID", "dataNullable": true, "dataPrimaryKey": true, "dataType": "INTEGER", @@ -2962,15 +2955,15 @@ }, { "auditType": "NONE", - "dataLength": "100", - "dataName": "CITY_NAME", + "dataLength": "50", + "dataName": "MANUFACTURER_FIRSTNAME", "dataNullable": true, "dataType": "VARCHAR", "description": "", - "name": "Name", + "name": "FirstName", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "100", + "widgetLength": "50", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": false, @@ -2980,32 +2973,29 @@ "isRequiredProperty": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "Name", + "widgetLabel": "FirstName", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 100, + "maxLength": 50, "inputRule": "" }, { "auditType": "NONE", - "dataName": "CITY_COUNTRY", + "dataLength": "50", + "dataName": "MANUFACTURER_LASTNAME", "dataNullable": true, - "dataType": "INTEGER", + "dataType": "VARCHAR", "description": "", - "name": "Country", - "relationshipEntityPerspectiveName": "Settings", - "relationshipName": "City_Country", + "name": "LastName", "tooltip": "", - "widgetDropDownKey": "Id", - "widgetDropDownValue": "Name", "widgetIsMajor": true, - "widgetLength": "20", + "widgetLength": "50", "widgetSize": "", - "widgetType": "DROPDOWN", + "widgetType": "TEXTBOX", "dataNotNull": false, "dataAutoIncrement": false, "dataPrimaryKey": false, @@ -3013,102 +3003,67 @@ "isRequiredProperty": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "Country", - "widgetDropdownUrl": "/services/ts/codbex-partners/gen/codbex-partners/api/Settings/undefinedService.ts", - "widgetDropdownControllerUrl": "/services/ts/codbex-partners/gen/codbex-partners/api/Settings/undefinedController.ts", - "dataTypeJava": "int", - "dataTypeTypescript": "number", - "dataTypeJavaClass": "Integer", + "widgetLabel": "LastName", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 50, "inputRule": "" - } - ], - "caption": "Manage entity City", - "dataCount": "SELECT COUNT(*) AS COUNT FROM \"CODBEX_CITY\"", - "dataName": "CITY", - "dataQuery": "", - "description": "Manage entity City", - "generateDefaultRoles": "false", - "generateReport": "false", - "icon": "/services/web/resources/unicons/file.svg", - "layoutType": "MANAGE", - "menuIndex": "100", - "menuKey": "city", - "menuLabel": "City", - "multilingual": "false", - "name": "City", - "perspectiveHeader": "", - "perspectiveIcon": "/services/web/resources/unicons/building.svg", - "perspectiveLabel": "Entities", - "perspectiveName": "Settings", - "perspectiveNavId": "", - "perspectiveOrder": "100", - "perspectiveRole": "", - "projectionReferencedEntity": "City", - "projectionReferencedModel": "/workspace/codbex-cities/codbex-cities.model", - "title": "City", - "tooltip": "City", - "type": "PROJECTION", - "dataSource": "DefaultDB", - "javaPerspectiveName": "settings", - "referencedProjections": [], - "primaryKeys": [ - "Id" - ], - "primaryKeysString": "Id", - "hasDropdowns": true - }, - { - "properties": [ + }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataAutoIncrement": true, - "dataName": "COUNTRY_ID", + "dataLength": "255", + "dataName": "MANUFACTURER_LEGALENTITYNAME", "dataNullable": true, - "dataPrimaryKey": true, - "dataType": "INTEGER", + "dataType": "VARCHAR", "description": "", - "name": "Id", + "name": "LegalEntityName", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "20", + "widgetLength": "255", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, "dataUnique": false, "isRequiredProperty": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "Id", + "widgetLabel": "LegalEntityName", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", - "dataTypeJava": "int", - "dataTypeTypescript": "number", - "dataTypeJavaClass": "Integer", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 255, "inputRule": "" }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", - "dataName": "COUNTRY_NAME", + "dataName": "MANUFACTURER_NAME", "dataNullable": true, "dataType": "VARCHAR", - "dataUnique": true, "description": "", + "isCalculatedProperty": true, "name": "Name", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "fd-col-md--4 fd-col--6", + "widgetLength": "255", + "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": false, "dataAutoIncrement": false, "dataPrimaryKey": false, + "dataUnique": false, "isRequiredProperty": false, - "isCalculatedProperty": false, "isReadOnlyProperty": false, "widgetLabel": "Name", "widgetDropdownUrl": "", @@ -3117,240 +3072,170 @@ "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 20, + "maxLength": 255, "inputRule": "" }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataLength": "2", - "dataName": "COUNTRY_CODE2", - "dataNullable": true, - "dataType": "CHAR", + "dataLength": "100", + "dataName": "MANUFACTURER_EMAIL", + "dataNullable": false, + "dataType": "VARCHAR", "dataUnique": true, "description": "", - "name": "Code2", + "isRequiredProperty": true, + "name": "Email", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", - "widgetType": "TEXTBOX", - "dataNotNull": false, + "widgetLength": "100", + "widgetSize": "", + "widgetType": "EMAIL", + "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, - "isRequiredProperty": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "Code2", + "widgetLabel": "Email", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 2, + "maxLength": 100, "inputRule": "" }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataLength": "3", - "dataName": "COUNTRY_CODE3", - "dataNullable": true, - "dataType": "CHAR", - "dataUnique": true, + "dataLength": "15", + "dataName": "MANUFACTURER_PHONE", + "dataNullable": false, + "dataType": "VARCHAR", "description": "", - "name": "Code3", + "isRequiredProperty": true, + "name": "Phone", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", - "widgetType": "TEXTBOX", - "dataNotNull": false, + "widgetLength": "15", + "widgetSize": "", + "widgetType": "TEL", + "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, - "isRequiredProperty": false, + "dataUnique": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "Code3", + "widgetLabel": "Phone", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 3, + "maxLength": 15, "inputRule": "" }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataLength": "3", - "dataName": "COUNTRY_NUMERIC", - "dataNullable": true, - "dataType": "CHAR", - "dataUnique": true, + "dataLength": "20", + "dataName": "MANUFACTURER_FAX", + "dataNullable": false, + "dataType": "VARCHAR", "description": "", - "name": "Numeric", + "isRequiredProperty": true, + "name": "Fax", "tooltip": "", "widgetIsMajor": true, "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", + "widgetSize": "", "widgetType": "TEXTBOX", - "dataNotNull": false, + "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, - "isRequiredProperty": false, + "dataUnique": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "Numeric", + "widgetLabel": "Fax", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 3, - "inputRule": "" - } - ], - "caption": "Manage entity Country", - "dataCount": "SELECT COUNT(*) AS COUNT FROM \"CODBEX_COUNTRY\"", - "dataName": "COUNTRY", - "dataQuery": "", - "description": "Manage entity Country", - "generateDefaultRoles": "false", - "generateReport": "false", - "icon": "/services/web/resources/unicons/file.svg", - "layoutType": "MANAGE", - "menuIndex": "100", - "menuKey": "country", - "menuLabel": "Country", - "multilingual": "false", - "name": "Country", - "perspectiveHeader": "", - "perspectiveIcon": "/services/web/resources/unicons/globe.svg", - "perspectiveLabel": "Entities", - "perspectiveName": "Settings", - "perspectiveNavId": "", - "perspectiveOrder": "100", - "perspectiveRole": "", - "projectionReferencedEntity": "Country", - "projectionReferencedModel": "/workspace/codbex-countries/codbex-countries.model", - "title": "Country", - "tooltip": "Country", - "type": "PROJECTION", - "dataSource": "DefaultDB", - "javaPerspectiveName": "settings", - "referencedProjections": [], - "primaryKeys": [ - "Id" - ], - "primaryKeysString": "Id" - }, - { - "properties": [ - { - "auditType": "NONE", - "dataAutoIncrement": true, - "dataName": "MANUFACTURER_ID", - "dataNullable": true, - "dataPrimaryKey": true, - "dataType": "INTEGER", - "description": "", - "name": "Id", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "", - "widgetType": "TEXTBOX", - "dataNotNull": false, - "dataUnique": false, - "isRequiredProperty": false, - "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "Id", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "int", - "dataTypeTypescript": "number", - "dataTypeJavaClass": "Integer", + "maxLength": 20, "inputRule": "" }, { "auditType": "NONE", - "dataLength": "50", - "dataName": "MANUFACTURER_FIRSTNAME", - "dataNullable": true, + "dataLength": "15", + "dataName": "MANUFACTURER_TIN", + "dataNullable": false, "dataType": "VARCHAR", + "dataUnique": true, "description": "", - "name": "FirstName", + "isRequiredProperty": true, + "name": "TIN", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "50", + "widgetLength": "15", "widgetSize": "", "widgetType": "TEXTBOX", - "dataNotNull": false, + "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, - "dataUnique": false, - "isRequiredProperty": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "FirstName", + "widgetLabel": "TIN", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 50, + "maxLength": 15, "inputRule": "" }, { "auditType": "NONE", - "dataLength": "50", - "dataName": "MANUFACTURER_LASTNAME", - "dataNullable": true, + "dataLength": "34", + "dataName": "MANUFACTURER_IBAN", + "dataNullable": false, "dataType": "VARCHAR", + "dataUnique": true, "description": "", - "name": "LastName", + "isRequiredProperty": true, + "name": "IBAN", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "50", + "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", - "dataNotNull": false, + "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, - "dataUnique": false, - "isRequiredProperty": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "LastName", + "widgetLabel": "IBAN", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 50, - "inputRule": "" + "maxLength": 34, + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { - "auditType": "NONE", - "dataLength": "255", - "dataName": "MANUFACTURER_LEGALENTITYNAME", + "auditType": "CREATED_AT", + "dataName": "MANUFACTURER_CREATEDAT", "dataNullable": true, - "dataType": "VARCHAR", + "dataType": "TIMESTAMP", "description": "", - "name": "LegalEntityName", + "name": "CreatedAt", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "255", + "widgetLength": "20", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": false, @@ -3360,30 +3245,27 @@ "isRequiredProperty": false, "isCalculatedProperty": false, "isReadOnlyProperty": false, - "widgetLabel": "LegalEntityName", + "widgetLabel": "CreatedAt", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 255, + "dataTypeJava": "timestamp", + "dataTypeTypescript": "Date", + "dataTypeJavaClass": "java.time.Instant", + "isDateType": true, "inputRule": "" }, { - "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "dataLength": "255", - "dataName": "MANUFACTURER_NAME", + "auditType": "CREATED_BY", + "dataLength": "20", + "dataName": "MANUFACTURER_CREATEDBY", "dataNullable": true, "dataType": "VARCHAR", "description": "", - "isCalculatedProperty": true, - "name": "Name", + "isReadOnlyProperty": true, + "name": "CreatedBy", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "255", + "widgetLength": "20", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": false, @@ -3391,282 +3273,73 @@ "dataPrimaryKey": false, "dataUnique": false, "isRequiredProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "Name", + "isCalculatedProperty": false, + "widgetLabel": "CreatedBy", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 255, + "maxLength": 20, "inputRule": "" }, { - "auditType": "NONE", - "dataLength": "100", - "dataName": "MANUFACTURER_EMAIL", - "dataNullable": false, - "dataType": "VARCHAR", - "dataUnique": true, + "auditType": "UPDATED_AT", + "dataName": "MANUFACTURER_UPDATEDAT", + "dataNullable": true, + "dataType": "TIMESTAMP", "description": "", - "isRequiredProperty": true, - "name": "Email", + "isReadOnlyProperty": true, + "name": "UpdatedAt", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "100", + "widgetLength": "20", "widgetSize": "", - "widgetType": "EMAIL", - "dataNotNull": true, + "widgetType": "TEXTBOX", + "dataNotNull": false, "dataAutoIncrement": false, "dataPrimaryKey": false, + "dataUnique": false, + "isRequiredProperty": false, "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "Email", + "widgetLabel": "UpdatedAt", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 100, + "dataTypeJava": "timestamp", + "dataTypeTypescript": "Date", + "dataTypeJavaClass": "java.time.Instant", + "isDateType": true, "inputRule": "" }, { - "auditType": "NONE", - "dataLength": "15", - "dataName": "MANUFACTURER_PHONE", - "dataNullable": false, + "auditType": "UPDATED_BY", + "dataLength": "20", + "dataName": "MANUFACTURER_UPDATEDBY", + "dataNullable": true, "dataType": "VARCHAR", "description": "", - "isRequiredProperty": true, - "name": "Phone", + "isReadOnlyProperty": true, + "name": "UpdatedBy", "tooltip": "", "widgetIsMajor": true, - "widgetLength": "15", + "widgetLength": "20", "widgetSize": "", - "widgetType": "TEL", - "dataNotNull": true, + "widgetType": "TEXTBOX", + "dataNotNull": false, "dataAutoIncrement": false, "dataPrimaryKey": false, "dataUnique": false, + "isRequiredProperty": false, "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "Phone", + "widgetLabel": "UpdatedBy", "widgetDropdownUrl": "", "widgetDropdownControllerUrl": "", "dataTypeJava": "string", "dataTypeTypescript": "string", "dataTypeJavaClass": "String", "minLength": 0, - "maxLength": 15, - "inputRule": "" - }, - { - "auditType": "NONE", - "dataLength": "20", - "dataName": "MANUFACTURER_FAX", - "dataNullable": false, - "dataType": "VARCHAR", - "description": "", - "isRequiredProperty": true, - "name": "Fax", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "", - "widgetType": "TEXTBOX", - "dataNotNull": true, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "dataUnique": false, - "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "Fax", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 20, - "inputRule": "" - }, - { - "auditType": "NONE", - "dataLength": "15", - "dataName": "MANUFACTURER_TIN", - "dataNullable": false, - "dataType": "VARCHAR", - "dataUnique": true, - "description": "", - "isRequiredProperty": true, - "name": "TIN", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "15", - "widgetSize": "", - "widgetType": "TEXTBOX", - "dataNotNull": true, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "TIN", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 15, - "inputRule": "" - }, - { - "auditType": "NONE", - "dataLength": "34", - "dataName": "MANUFACTURER_IBAN", - "dataNullable": false, - "dataType": "VARCHAR", - "dataUnique": true, - "description": "", - "isRequiredProperty": true, - "name": "IBAN", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "34", - "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", - "widgetSize": "", - "widgetType": "TEXTBOX", - "dataNotNull": true, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "IBAN", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 34, - "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" - }, - { - "auditType": "CREATED_AT", - "dataName": "MANUFACTURER_CREATEDAT", - "dataNullable": true, - "dataType": "TIMESTAMP", - "description": "", - "name": "CreatedAt", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "", - "widgetType": "TEXTBOX", - "dataNotNull": false, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "dataUnique": false, - "isRequiredProperty": false, - "isCalculatedProperty": false, - "isReadOnlyProperty": false, - "widgetLabel": "CreatedAt", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "timestamp", - "dataTypeTypescript": "Date", - "dataTypeJavaClass": "java.time.Instant", - "isDateType": true, - "inputRule": "" - }, - { - "auditType": "CREATED_BY", - "dataLength": "20", - "dataName": "MANUFACTURER_CREATEDBY", - "dataNullable": true, - "dataType": "VARCHAR", - "description": "", - "isReadOnlyProperty": true, - "name": "CreatedBy", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "", - "widgetType": "TEXTBOX", - "dataNotNull": false, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "dataUnique": false, - "isRequiredProperty": false, - "isCalculatedProperty": false, - "widgetLabel": "CreatedBy", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 20, - "inputRule": "" - }, - { - "auditType": "UPDATED_AT", - "dataName": "MANUFACTURER_UPDATEDAT", - "dataNullable": true, - "dataType": "TIMESTAMP", - "description": "", - "isReadOnlyProperty": true, - "name": "UpdatedAt", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "", - "widgetType": "TEXTBOX", - "dataNotNull": false, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "dataUnique": false, - "isRequiredProperty": false, - "isCalculatedProperty": false, - "widgetLabel": "UpdatedAt", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "timestamp", - "dataTypeTypescript": "Date", - "dataTypeJavaClass": "java.time.Instant", - "isDateType": true, - "inputRule": "" - }, - { - "auditType": "UPDATED_BY", - "dataLength": "20", - "dataName": "MANUFACTURER_UPDATEDBY", - "dataNullable": true, - "dataType": "VARCHAR", - "description": "", - "isReadOnlyProperty": true, - "name": "UpdatedBy", - "tooltip": "", - "widgetIsMajor": true, - "widgetLength": "20", - "widgetSize": "", - "widgetType": "TEXTBOX", - "dataNotNull": false, - "dataAutoIncrement": false, - "dataPrimaryKey": false, - "dataUnique": false, - "isRequiredProperty": false, - "isCalculatedProperty": false, - "widgetLabel": "UpdatedBy", - "widgetDropdownUrl": "", - "widgetDropdownControllerUrl": "", - "dataTypeJava": "string", - "dataTypeTypescript": "string", - "dataTypeJavaClass": "String", - "minLength": 0, - "maxLength": 20, + "maxLength": 20, "inputRule": "" } ], @@ -3797,8 +3470,8 @@ }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", "dataName": "MANUFACTURER_NAME", "dataNullable": true, @@ -4931,6 +4604,317 @@ "masterEntity": "Manufacturer", "masterEntityId": "Manufacturer", "hasDates": true + }, + { + "properties": [ + { + "auditType": "NONE", + "dataAutoIncrement": true, + "dataName": "COUNTRY_ID", + "dataNullable": true, + "dataPrimaryKey": true, + "dataType": "INTEGER", + "description": "", + "name": "Id", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataUnique": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Id", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "int", + "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", + "inputRule": "" + }, + { + "auditType": "NONE", + "dataLength": "255", + "dataName": "COUNTRY_NAME", + "dataNullable": true, + "dataType": "VARCHAR", + "dataUnique": true, + "description": "", + "name": "Name", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "fd-col-md--4 fd-col--6", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Name", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 20, + "inputRule": "" + }, + { + "auditType": "NONE", + "dataLength": "2", + "dataName": "COUNTRY_CODE2", + "dataNullable": true, + "dataType": "CHAR", + "dataUnique": true, + "description": "", + "name": "Code2", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Code2", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 2, + "inputRule": "" + }, + { + "auditType": "NONE", + "dataLength": "3", + "dataName": "COUNTRY_CODE3", + "dataNullable": true, + "dataType": "CHAR", + "dataUnique": true, + "description": "", + "name": "Code3", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Code3", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 3, + "inputRule": "" + }, + { + "auditType": "NONE", + "dataLength": "3", + "dataName": "COUNTRY_NUMERIC", + "dataNullable": true, + "dataType": "CHAR", + "dataUnique": true, + "description": "", + "name": "Numeric", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Numeric", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 3, + "inputRule": "" + } + ], + "caption": "Manage entity Country", + "dataCount": "SELECT COUNT(*) AS COUNT FROM \"CODBEX_COUNTRY\"", + "dataName": "COUNTRY", + "dataQuery": "", + "description": "Manage entity Country", + "generateDefaultRoles": "false", + "generateReport": "false", + "icon": "/services/web/resources/unicons/file.svg", + "layoutType": "MANAGE", + "menuIndex": "100", + "menuKey": "country", + "menuLabel": "Country", + "multilingual": "false", + "name": "Country", + "perspectiveHeader": "", + "perspectiveIcon": "globe", + "perspectiveLabel": "Settings", + "perspectiveName": "Settings", + "perspectiveNavId": "", + "perspectiveOrder": "990", + "perspectiveRole": "", + "projectionReferencedEntity": "Country", + "projectionReferencedModel": "/workspace/codbex-countries/codbex-countries.model", + "title": "Country", + "tooltip": "Country", + "type": "PROJECTION", + "dataSource": "DefaultDB", + "javaPerspectiveName": "settings", + "referencedProjections": [], + "primaryKeys": [ + "Id" + ], + "primaryKeysString": "Id" + }, + { + "properties": [ + { + "auditType": "NONE", + "dataAutoIncrement": true, + "dataName": "CITY_ID", + "dataNullable": true, + "dataPrimaryKey": true, + "dataType": "INTEGER", + "description": "", + "name": "Id", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataUnique": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Id", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "int", + "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", + "inputRule": "" + }, + { + "auditType": "NONE", + "dataLength": "100", + "dataName": "CITY_NAME", + "dataNullable": true, + "dataType": "VARCHAR", + "description": "", + "isRequiredProperty": true, + "name": "Name", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "100", + "widgetSize": "", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "dataUnique": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Name", + "widgetDropdownUrl": "", + "widgetDropdownControllerUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "dataTypeJavaClass": "String", + "minLength": 0, + "maxLength": 100, + "inputRule": "" + }, + { + "auditType": "NONE", + "dataName": "CITY_COUNTRY", + "dataNullable": true, + "dataType": "INTEGER", + "description": "", + "isRequiredProperty": true, + "name": "Country", + "relationshipEntityPerspectiveLabel": "Settings", + "relationshipEntityPerspectiveName": "Settings", + "relationshipName": "City_Country", + "tooltip": "", + "widgetDropDownKey": "Id", + "widgetDropDownValue": "Name", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "", + "widgetType": "DROPDOWN", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "dataUnique": false, + "isCalculatedProperty": false, + "isReadOnlyProperty": false, + "widgetLabel": "Country", + "widgetDropdownUrl": "/services/java/codbex-partners/gen/codbex_partners/api/settings/undefinedController", + "widgetDropdownControllerUrl": "/services/java/codbex-partners/gen/codbex_partners/api/settings/undefinedController", + "dataTypeJava": "int", + "dataTypeTypescript": "number", + "dataTypeJavaClass": "Integer", + "inputRule": "" + } + ], + "caption": "Manage entity City", + "dataCount": "SELECT COUNT(*) AS COUNT FROM \"CODBEX_CITY\"", + "dataName": "CITY", + "dataQuery": "", + "description": "Manage entity City", + "generateDefaultRoles": "false", + "generateReport": "false", + "icon": "/services/web/resources/unicons/file.svg", + "layoutType": "MANAGE", + "menuIndex": "100", + "menuKey": "city", + "menuLabel": "City", + "multilingual": "false", + "name": "City", + "perspectiveHeader": "", + "perspectiveIcon": "/services/web/resources/unicons/copy.svg", + "perspectiveLabel": "Settings", + "perspectiveName": "Settings", + "perspectiveNavId": "", + "perspectiveOrder": "100", + "perspectiveRole": "", + "projectionReferencedEntity": "City", + "projectionReferencedModel": "/workspace/codbex-cities/codbex-cities.model", + "title": "City", + "tooltip": "City", + "type": "PROJECTION", + "dataSource": "DefaultDB", + "javaPerspectiveName": "settings", + "referencedProjections": [], + "primaryKeys": [ + "Id" + ], + "primaryKeysString": "Id", + "hasDropdowns": true } ] } \ No newline at end of file diff --git a/codbex-partners/codbex-partners.model b/codbex-partners/codbex-partners.model index ee32bc8..a34d22e 100644 --- a/codbex-partners/codbex-partners.model +++ b/codbex-partners/codbex-partners.model @@ -62,8 +62,8 @@ }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", "dataName": "CUSTOMER_NAME", "dataNullable": "true", @@ -108,20 +108,6 @@ "widgetSize": "fd-col-md--2 fd-col--3", "widgetType": "TEL" }, - { - "auditType": "NONE", - "dataLength": "20", - "dataName": "CUSTOMER_FAX", - "dataNullable": "true", - "dataType": "VARCHAR", - "description": "", - "name": "Fax", - "tooltip": "", - "widgetIsMajor": "true", - "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", - "widgetType": "TEXTBOX" - }, { "auditType": "NONE", "dataName": "CUSTOMER_COUNTRY", @@ -140,7 +126,7 @@ "relationshipName": "Customer_Country", "relationshipEntityName": "Country", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities" + "relationshipEntityPerspectiveLabel": "Settings" }, { "auditType": "NONE", @@ -151,10 +137,6 @@ "isRequiredProperty": "true", "name": "City", "tooltip": "", - "widgetDependsOnEntity": "Country", - "widgetDependsOnFilterBy": "Country", - "widgetDependsOnProperty": "Country", - "widgetDependsOnValueFrom": "Id", "widgetDropDownKey": "Id", "widgetDropDownValue": "Name", "widgetIsMajor": "true", @@ -164,7 +146,21 @@ "relationshipName": "Customer_City", "relationshipEntityName": "City", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities" + "relationshipEntityPerspectiveLabel": "Settings" + }, + { + "auditType": "NONE", + "dataLength": "20", + "dataName": "CUSTOMER_FAX", + "dataNullable": "true", + "dataType": "VARCHAR", + "description": "", + "name": "Fax", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX" }, { "auditType": "NONE", @@ -390,8 +386,8 @@ }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", "dataName": "SUPPLIER_NAME", "dataNullable": "true", @@ -980,197 +976,6 @@ "tooltip": "ManufacturerNote", "type": "DEPENDENT" }, - { - "properties": [ - { - "auditType": "NONE", - "dataAutoIncrement": "true", - "dataName": "CITY_ID", - "dataNullable": "true", - "dataPrimaryKey": "true", - "dataType": "INTEGER", - "description": "", - "name": "Id", - "tooltip": "", - "widgetIsMajor": "true", - "widgetLength": "20", - "widgetSize": "", - "widgetType": "TEXTBOX" - }, - { - "auditType": "NONE", - "dataLength": "100", - "dataName": "CITY_NAME", - "dataNullable": "true", - "dataType": "VARCHAR", - "description": "", - "name": "Name", - "tooltip": "", - "widgetIsMajor": "true", - "widgetLength": "100", - "widgetSize": "", - "widgetType": "TEXTBOX" - }, - { - "auditType": "NONE", - "dataName": "CITY_COUNTRY", - "dataNullable": "true", - "dataType": "INTEGER", - "description": "", - "name": "Country", - "relationshipEntityPerspectiveName": "Settings", - "relationshipName": "City_Country", - "tooltip": "", - "widgetDropDownKey": "Id", - "widgetDropDownValue": "Name", - "widgetIsMajor": "true", - "widgetLength": "20", - "widgetSize": "", - "widgetType": "DROPDOWN" - } - ], - "caption": "Manage entity City", - "dataCount": "SELECT COUNT(*) AS COUNT FROM \"${tablePrefix}CITY\"", - "dataName": "CITY", - "dataQuery": "", - "description": "Manage entity City", - "generateDefaultRoles": "false", - "generateReport": "false", - "icon": "/services/web/resources/unicons/file.svg", - "layoutType": "MANAGE", - "menuIndex": "100", - "menuKey": "city", - "menuLabel": "City", - "multilingual": "false", - "name": "City", - "perspectiveHeader": "", - "perspectiveIcon": "/services/web/resources/unicons/building.svg", - "perspectiveLabel": "Entities", - "perspectiveName": "Settings", - "perspectiveNavId": "", - "perspectiveOrder": "100", - "perspectiveRole": "", - "projectionReferencedEntity": "City", - "projectionReferencedModel": "/workspace/codbex-cities/codbex-cities.model", - "title": "City", - "tooltip": "City", - "type": "PROJECTION" - }, - { - "properties": [ - { - "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataAutoIncrement": "true", - "dataName": "COUNTRY_ID", - "dataNullable": "true", - "dataPrimaryKey": "true", - "dataType": "INTEGER", - "description": "", - "name": "Id", - "tooltip": "", - "widgetIsMajor": "true", - "widgetLength": "20", - "widgetSize": "", - "widgetType": "TEXTBOX" - }, - { - "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataLength": "255", - "dataName": "COUNTRY_NAME", - "dataNullable": "true", - "dataType": "VARCHAR", - "dataUnique": "true", - "description": "", - "name": "Name", - "tooltip": "", - "widgetIsMajor": "true", - "widgetLength": "20", - "widgetSize": "fd-col-md--4 fd-col--6", - "widgetType": "TEXTBOX" - }, - { - "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataLength": "2", - "dataName": "COUNTRY_CODE2", - "dataNullable": "true", - "dataType": "CHAR", - "dataUnique": "true", - "description": "", - "name": "Code2", - "tooltip": "", - "widgetIsMajor": "true", - "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", - "widgetType": "TEXTBOX" - }, - { - "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataLength": "3", - "dataName": "COUNTRY_CODE3", - "dataNullable": "true", - "dataType": "CHAR", - "dataUnique": "true", - "description": "", - "name": "Code3", - "tooltip": "", - "widgetIsMajor": "true", - "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", - "widgetType": "TEXTBOX" - }, - { - "auditType": "NONE", - "calculatedPropertyExpressionCreate": "", - "calculatedPropertyExpressionUpdate": "", - "dataLength": "3", - "dataName": "COUNTRY_NUMERIC", - "dataNullable": "true", - "dataType": "CHAR", - "dataUnique": "true", - "description": "", - "name": "Numeric", - "tooltip": "", - "widgetIsMajor": "true", - "widgetLength": "20", - "widgetSize": "fd-col-md--2 fd-col--3", - "widgetType": "TEXTBOX" - } - ], - "caption": "Manage entity Country", - "dataCount": "SELECT COUNT(*) AS COUNT FROM \"${tablePrefix}COUNTRY\"", - "dataName": "COUNTRY", - "dataQuery": "", - "description": "Manage entity Country", - "generateDefaultRoles": "false", - "generateReport": "false", - "icon": "/services/web/resources/unicons/file.svg", - "layoutType": "MANAGE", - "menuIndex": "100", - "menuKey": "country", - "menuLabel": "Country", - "multilingual": "false", - "name": "Country", - "perspectiveHeader": "", - "perspectiveIcon": "/services/web/resources/unicons/globe.svg", - "perspectiveLabel": "Entities", - "perspectiveName": "Settings", - "perspectiveNavId": "", - "perspectiveOrder": "100", - "perspectiveRole": "", - "projectionReferencedEntity": "Country", - "projectionReferencedModel": "/workspace/codbex-countries/codbex-countries.model", - "title": "Country", - "tooltip": "Country", - "type": "PROJECTION" - }, { "properties": [ { @@ -1232,8 +1037,8 @@ }, { "auditType": "NONE", - "calculatedPropertyExpressionCreate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", - "calculatedPropertyExpressionUpdate": "(entity.FirstName && entity.LastName) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionCreate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", + "calculatedPropertyExpressionUpdate": "(entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + \" \" + entity.LastName) : entity.LegalEntityName", "dataLength": "255", "dataName": "MANUFACTURER_NAME", "dataNullable": "true", @@ -1872,6 +1677,190 @@ "title": "ManufacturerContact", "tooltip": "ManufacturerContact", "type": "DEPENDENT" + }, + { + "properties": [ + { + "auditType": "NONE", + "dataAutoIncrement": "true", + "dataName": "COUNTRY_ID", + "dataNullable": "true", + "dataPrimaryKey": "true", + "dataType": "INTEGER", + "description": "", + "name": "Id", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "", + "widgetType": "TEXTBOX" + }, + { + "auditType": "NONE", + "dataLength": "255", + "dataName": "COUNTRY_NAME", + "dataNullable": "true", + "dataType": "VARCHAR", + "dataUnique": "true", + "description": "", + "name": "Name", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "fd-col-md--4 fd-col--6", + "widgetType": "TEXTBOX" + }, + { + "auditType": "NONE", + "dataLength": "2", + "dataName": "COUNTRY_CODE2", + "dataNullable": "true", + "dataType": "CHAR", + "dataUnique": "true", + "description": "", + "name": "Code2", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX" + }, + { + "auditType": "NONE", + "dataLength": "3", + "dataName": "COUNTRY_CODE3", + "dataNullable": "true", + "dataType": "CHAR", + "dataUnique": "true", + "description": "", + "name": "Code3", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX" + }, + { + "auditType": "NONE", + "dataLength": "3", + "dataName": "COUNTRY_NUMERIC", + "dataNullable": "true", + "dataType": "CHAR", + "dataUnique": "true", + "description": "", + "name": "Numeric", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "fd-col-md--2 fd-col--3", + "widgetType": "TEXTBOX" + } + ], + "caption": "Manage entity Country", + "dataCount": "SELECT COUNT(*) AS COUNT FROM \"${tablePrefix}COUNTRY\"", + "dataName": "COUNTRY", + "dataQuery": "", + "description": "Manage entity Country", + "generateDefaultRoles": "false", + "generateReport": "false", + "icon": "/services/web/resources/unicons/file.svg", + "layoutType": "MANAGE", + "menuIndex": "100", + "menuKey": "country", + "menuLabel": "Country", + "multilingual": "false", + "name": "Country", + "perspectiveHeader": "", + "perspectiveIcon": "globe", + "perspectiveLabel": "Settings", + "perspectiveName": "Settings", + "perspectiveNavId": "", + "perspectiveOrder": "990", + "perspectiveRole": "", + "projectionReferencedEntity": "Country", + "projectionReferencedModel": "/workspace/codbex-countries/codbex-countries.model", + "title": "Country", + "tooltip": "Country", + "type": "PROJECTION" + }, + { + "properties": [ + { + "auditType": "NONE", + "dataAutoIncrement": "true", + "dataName": "CITY_ID", + "dataNullable": "true", + "dataPrimaryKey": "true", + "dataType": "INTEGER", + "description": "", + "name": "Id", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "", + "widgetType": "TEXTBOX" + }, + { + "auditType": "NONE", + "dataLength": "100", + "dataName": "CITY_NAME", + "dataNullable": "true", + "dataType": "VARCHAR", + "description": "", + "isRequiredProperty": "true", + "name": "Name", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "100", + "widgetSize": "", + "widgetType": "TEXTBOX" + }, + { + "auditType": "NONE", + "dataName": "CITY_COUNTRY", + "dataNullable": "true", + "dataType": "INTEGER", + "description": "", + "isRequiredProperty": "true", + "name": "Country", + "relationshipEntityPerspectiveLabel": "Settings", + "relationshipEntityPerspectiveName": "Settings", + "relationshipName": "City_Country", + "tooltip": "", + "widgetDropDownKey": "Id", + "widgetDropDownValue": "Name", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "", + "widgetType": "DROPDOWN" + } + ], + "caption": "Manage entity City", + "dataCount": "SELECT COUNT(*) AS COUNT FROM \"${tablePrefix}CITY\"", + "dataName": "CITY", + "dataQuery": "", + "description": "Manage entity City", + "generateDefaultRoles": "false", + "generateReport": "false", + "icon": "/services/web/resources/unicons/file.svg", + "layoutType": "MANAGE", + "menuIndex": "100", + "menuKey": "city", + "menuLabel": "City", + "multilingual": "false", + "name": "City", + "perspectiveHeader": "", + "perspectiveIcon": "/services/web/resources/unicons/copy.svg", + "perspectiveLabel": "Settings", + "perspectiveName": "Settings", + "perspectiveNavId": "", + "perspectiveOrder": "100", + "perspectiveRole": "", + "projectionReferencedEntity": "City", + "projectionReferencedModel": "/workspace/codbex-cities/codbex-cities.model", + "title": "City", + "tooltip": "City", + "type": "PROJECTION" } ], "perspectives": [ diff --git a/codbex-partners/gen/codbex-partners/api/Customers/CustomerContactController.ts b/codbex-partners/gen/codbex-partners/api/Customers/CustomerContactController.ts deleted file mode 100644 index d8ea3a1..0000000 --- a/codbex-partners/gen/codbex-partners/api/Customers/CustomerContactController.ts +++ /dev/null @@ -1,210 +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 { CustomerContactRepository } from '../../data/Customers/CustomerContactRepository' -import { CustomerContactEntity } from '../../data/Customers/CustomerContactEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Customers-CustomerContact', ['validate']); - -@Controller -@Documentation('codbex-partners - CustomerContact Controller') -@Injected() -class CustomerContactController { - - @Inject('CustomerContactRepository') - private readonly repository!: CustomerContactRepository; - - @Get('/') - @Documentation('Get All CustomerContact') - public getAll(_: any, ctx: any): CustomerContactEntity[] { - 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] - }; - - let Customer = parseInt(ctx.queryParameters.Customer); - Customer = isNaN(Customer) ? ctx.queryParameters.Customer : Customer; - - if (Customer !== undefined) { - options.$filter = { - equals: { - Customer: Customer - } - }; - } - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/') - @Documentation('Create CustomerContact') - public create(entity: CustomerContactEntity): CustomerContactEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerContactController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count CustomerContact') - 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 CustomerContact 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 CustomerContact') - public search(filter: any): CustomerContactEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get CustomerContact by id') - public getById(_: any, ctx: any): CustomerContactEntity { - 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('CustomerContact not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update CustomerContact by id') - public update(entity: CustomerContactEntity, ctx: any): CustomerContactEntity { - 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 CustomerContact 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('CustomerContact 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-partners.Customers.CustomerContactReadOnly') || user.isInRole('codbex-partners.Customers.CustomerContactFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-partners.Customers.CustomerContactFullAccess')) { - 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 > 255) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [255] characters`); - } - if (entity.Designation === null || entity.Designation === undefined) { - throw new ValidationError(`The 'Designation' property is required, provide a valid value`); - } - if (entity.Designation?.length > 255) { - throw new ValidationError(`The 'Designation' exceeds the maximum length of [255] characters`); - } - if (entity.Email === null || entity.Email === undefined) { - throw new ValidationError(`The 'Email' property is required, provide a valid value`); - } - if (entity.Email?.length > 100) { - throw new ValidationError(`The 'Email' exceeds the maximum length of [100] characters`); - } - if (entity.Phone === null || entity.Phone === undefined) { - throw new ValidationError(`The 'Phone' property is required, provide a valid value`); - } - if (entity.Phone?.length > 15) { - throw new ValidationError(`The 'Phone' exceeds the maximum length of [15] characters`); - } - if (entity.CreatedBy?.length > 20) { - throw new ValidationError(`The 'CreatedBy' exceeds the maximum length of [20] characters`); - } - for (const next of validationModules) { - next.validate(entity); - } - } - -} diff --git a/codbex-partners/gen/codbex-partners/api/Customers/CustomerController.ts b/codbex-partners/gen/codbex-partners/api/Customers/CustomerController.ts deleted file mode 100644 index 92c9404..0000000 --- a/codbex-partners/gen/codbex-partners/api/Customers/CustomerController.ts +++ /dev/null @@ -1,241 +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 { CustomerRepository } from '../../data/Customers/CustomerRepository' -import { CustomerEntity } from '../../data/Customers/CustomerEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Customers-Customer', ['validate']); - -@Controller -@Documentation('codbex-partners - Customer Controller') -@Injected() -class CustomerController { - - @Inject('CustomerRepository') - private readonly repository!: CustomerRepository; - - @Get('/') - @Documentation('Get All Customer') - public getAll(_: any, ctx: any): CustomerEntity[] { - 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 Customer') - public create(entity: CustomerEntity): CustomerEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count Customer') - 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 Customer 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 Customer') - public search(filter: any): CustomerEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get Customer by id') - public getById(_: any, ctx: any): CustomerEntity { - 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('Customer not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update Customer by id') - public update(entity: CustomerEntity, ctx: any): CustomerEntity { - 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 Customer 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('Customer 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-partners.Customers.CustomerReadOnly') || user.isInRole('codbex-partners.Customers.CustomerFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-partners.Customers.CustomerFullAccess')) { - throw new ForbiddenError(); - } - } - - private validateEntity(entity: any): void { - if (entity.FirstName?.length > 50) { - throw new ValidationError(`The 'FirstName' exceeds the maximum length of [50] characters`); - } - if (entity.LastName?.length > 50) { - throw new ValidationError(`The 'LastName' exceeds the maximum length of [50] characters`); - } - if (entity.LegalEntityName?.length > 255) { - throw new ValidationError(`The 'LegalEntityName' exceeds the maximum length of [255] characters`); - } - if (entity.Name?.length > 255) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [255] characters`); - } - if (entity.Email === null || entity.Email === undefined) { - throw new ValidationError(`The 'Email' property is required, provide a valid value`); - } - if (entity.Email?.length > 100) { - throw new ValidationError(`The 'Email' exceeds the maximum length of [100] characters`); - } - if (entity.Phone === null || entity.Phone === undefined) { - throw new ValidationError(`The 'Phone' property is required, provide a valid value`); - } - if (entity.Phone?.length > 15) { - throw new ValidationError(`The 'Phone' exceeds the maximum length of [15] characters`); - } - if (entity.Fax?.length > 20) { - throw new ValidationError(`The 'Fax' exceeds the maximum length of [20] characters`); - } - if (entity.Country === null || entity.Country === undefined) { - throw new ValidationError(`The 'Country' property is required, provide a valid value`); - } - if (entity.City === null || entity.City === undefined) { - throw new ValidationError(`The 'City' property is required, provide a valid value`); - } - if (entity.Address === null || entity.Address === undefined) { - throw new ValidationError(`The 'Address' property is required, provide a valid value`); - } - if (entity.Address?.length > 255) { - throw new ValidationError(`The 'Address' exceeds the maximum length of [255] characters`); - } - if (entity.PostalCode === null || entity.PostalCode === undefined) { - throw new ValidationError(`The 'PostalCode' property is required, provide a valid value`); - } - if (entity.PostalCode?.length > 10) { - throw new ValidationError(`The 'PostalCode' exceeds the maximum length of [10] characters`); - } - if (entity.TIN === null || entity.TIN === undefined) { - throw new ValidationError(`The 'TIN' property is required, provide a valid value`); - } - if (entity.TIN?.length > 15) { - throw new ValidationError(`The 'TIN' exceeds the maximum length of [15] characters`); - } - if (entity.IBAN === null || entity.IBAN === undefined) { - throw new ValidationError(`The 'IBAN' property is required, provide a valid value`); - } - if (entity.IBAN?.length > 34) { - throw new ValidationError(`The 'IBAN' exceeds the maximum length of [34] characters`); - } - if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.IBAN)) { - throw new ValidationError(`The value provided for the 'IBAN' property ('[${entity.IBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); - } - if (entity.ResponsiblePerson?.length > 150) { - throw new ValidationError(`The 'ResponsiblePerson' exceeds the maximum length of [150] characters`); - } - 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-partners/gen/codbex-partners/api/Customers/CustomerNoteController.ts b/codbex-partners/gen/codbex-partners/api/Customers/CustomerNoteController.ts deleted file mode 100644 index 912b687..0000000 --- a/codbex-partners/gen/codbex-partners/api/Customers/CustomerNoteController.ts +++ /dev/null @@ -1,195 +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 { CustomerNoteRepository } from '../../data/Customers/CustomerNoteRepository' -import { CustomerNoteEntity } from '../../data/Customers/CustomerNoteEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Customers-CustomerNote', ['validate']); - -@Controller -@Documentation('codbex-partners - CustomerNote Controller') -@Injected() -class CustomerNoteController { - - @Inject('CustomerNoteRepository') - private readonly repository!: CustomerNoteRepository; - - @Get('/') - @Documentation('Get All CustomerNote') - public getAll(_: any, ctx: any): CustomerNoteEntity[] { - 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] - }; - - let Customer = parseInt(ctx.queryParameters.Customer); - Customer = isNaN(Customer) ? ctx.queryParameters.Customer : Customer; - - if (Customer !== undefined) { - options.$filter = { - equals: { - Customer: Customer - } - }; - } - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/') - @Documentation('Create CustomerNote') - public create(entity: CustomerNoteEntity): CustomerNoteEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerNoteController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count CustomerNote') - 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 CustomerNote 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 CustomerNote') - public search(filter: any): CustomerNoteEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get CustomerNote by id') - public getById(_: any, ctx: any): CustomerNoteEntity { - 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('CustomerNote not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update CustomerNote by id') - public update(entity: CustomerNoteEntity, ctx: any): CustomerNoteEntity { - 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 CustomerNote 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('CustomerNote 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-partners.Customers.CustomerNoteReadOnly') || user.isInRole('codbex-partners.Customers.CustomerNoteFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-partners.Customers.CustomerNoteFullAccess')) { - throw new ForbiddenError(); - } - } - - private validateEntity(entity: any): void { - if (entity.Note === null || entity.Note === undefined) { - throw new ValidationError(`The 'Note' property is required, provide a valid value`); - } - if (entity.Note?.length > 5000) { - throw new ValidationError(`The 'Note' exceeds the maximum length of [5000] characters`); - } - 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-partners/gen/codbex-partners/api/Manufacturers/ManufacturerContactController.ts b/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerContactController.ts deleted file mode 100644 index d4d6c78..0000000 --- a/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerContactController.ts +++ /dev/null @@ -1,191 +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 { ManufacturerContactRepository } from '../../data/Manufacturers/ManufacturerContactRepository' -import { ManufacturerContactEntity } from '../../data/Manufacturers/ManufacturerContactEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Manufacturers-ManufacturerContact', ['validate']); - -@Controller -@Documentation('codbex-partners - ManufacturerContact Controller') -@Injected() -class ManufacturerContactController { - - @Inject('ManufacturerContactRepository') - private readonly repository!: ManufacturerContactRepository; - - @Get('/') - @Documentation('Get All ManufacturerContact') - public getAll(_: any, ctx: any): ManufacturerContactEntity[] { - 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] - }; - - let Manufacturer = parseInt(ctx.queryParameters.Manufacturer); - Manufacturer = isNaN(Manufacturer) ? ctx.queryParameters.Manufacturer : Manufacturer; - - if (Manufacturer !== undefined) { - options.$filter = { - equals: { - Manufacturer: Manufacturer - } - }; - } - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/') - @Documentation('Create ManufacturerContact') - public create(entity: ManufacturerContactEntity): ManufacturerContactEntity { - try { - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerContactController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count ManufacturerContact') - public count(): { count: number } { - try { - return { count: this.repository.count() }; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/count') - @Documentation('Count ManufacturerContact 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 ManufacturerContact') - public search(filter: any): ManufacturerContactEntity[] { - try { - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get ManufacturerContact by id') - public getById(_: any, ctx: any): ManufacturerContactEntity { - 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('ManufacturerContact not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update ManufacturerContact by id') - public update(entity: ManufacturerContactEntity, ctx: any): ManufacturerContactEntity { - 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 ManufacturerContact 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('ManufacturerContact 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 > 255) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [255] characters`); - } - if (entity.Designation === null || entity.Designation === undefined) { - throw new ValidationError(`The 'Designation' property is required, provide a valid value`); - } - if (entity.Designation?.length > 255) { - throw new ValidationError(`The 'Designation' exceeds the maximum length of [255] characters`); - } - if (entity.Email === null || entity.Email === undefined) { - throw new ValidationError(`The 'Email' property is required, provide a valid value`); - } - if (entity.Email?.length > 100) { - throw new ValidationError(`The 'Email' exceeds the maximum length of [100] characters`); - } - if (entity.Phone === null || entity.Phone === undefined) { - throw new ValidationError(`The 'Phone' property is required, provide a valid value`); - } - if (entity.Phone?.length > 15) { - throw new ValidationError(`The 'Phone' exceeds the maximum length of [15] characters`); - } - if (entity.CreatedBy?.length > 20) { - throw new ValidationError(`The 'CreatedBy' exceeds the maximum length of [20] characters`); - } - for (const next of validationModules) { - next.validate(entity); - } - } - -} diff --git a/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerController.ts b/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerController.ts deleted file mode 100644 index 53e9b35..0000000 --- a/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerController.ts +++ /dev/null @@ -1,223 +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 { ManufacturerRepository } from '../../data/Manufacturers/ManufacturerRepository' -import { ManufacturerEntity } from '../../data/Manufacturers/ManufacturerEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Manufacturers-Manufacturer', ['validate']); - -@Controller -@Documentation('codbex-partners - Manufacturer Controller') -@Injected() -class ManufacturerController { - - @Inject('ManufacturerRepository') - private readonly repository!: ManufacturerRepository; - - @Get('/') - @Documentation('Get All Manufacturer') - public getAll(_: any, ctx: any): ManufacturerEntity[] { - 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 Manufacturer') - public create(entity: ManufacturerEntity): ManufacturerEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count Manufacturer') - 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 Manufacturer 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 Manufacturer') - public search(filter: any): ManufacturerEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get Manufacturer by id') - public getById(_: any, ctx: any): ManufacturerEntity { - 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('Manufacturer not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update Manufacturer by id') - public update(entity: ManufacturerEntity, ctx: any): ManufacturerEntity { - 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 Manufacturer 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('Manufacturer 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-partners.Manufacturers.ManufacturerReadOnly') || user.isInRole('codbex-partners.Manufacturers.ManufacturerFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-partners.Manufacturers.ManufacturerFullAccess')) { - throw new ForbiddenError(); - } - } - - private validateEntity(entity: any): void { - if (entity.FirstName?.length > 50) { - throw new ValidationError(`The 'FirstName' exceeds the maximum length of [50] characters`); - } - if (entity.LastName?.length > 50) { - throw new ValidationError(`The 'LastName' exceeds the maximum length of [50] characters`); - } - if (entity.LegalEntityName?.length > 255) { - throw new ValidationError(`The 'LegalEntityName' exceeds the maximum length of [255] characters`); - } - if (entity.Name?.length > 255) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [255] characters`); - } - if (entity.Email === null || entity.Email === undefined) { - throw new ValidationError(`The 'Email' property is required, provide a valid value`); - } - if (entity.Email?.length > 100) { - throw new ValidationError(`The 'Email' exceeds the maximum length of [100] characters`); - } - if (entity.Phone === null || entity.Phone === undefined) { - throw new ValidationError(`The 'Phone' property is required, provide a valid value`); - } - if (entity.Phone?.length > 15) { - throw new ValidationError(`The 'Phone' exceeds the maximum length of [15] characters`); - } - if (entity.Fax === null || entity.Fax === undefined) { - throw new ValidationError(`The 'Fax' property is required, provide a valid value`); - } - if (entity.Fax?.length > 20) { - throw new ValidationError(`The 'Fax' exceeds the maximum length of [20] characters`); - } - if (entity.TIN === null || entity.TIN === undefined) { - throw new ValidationError(`The 'TIN' property is required, provide a valid value`); - } - if (entity.TIN?.length > 15) { - throw new ValidationError(`The 'TIN' exceeds the maximum length of [15] characters`); - } - if (entity.IBAN === null || entity.IBAN === undefined) { - throw new ValidationError(`The 'IBAN' property is required, provide a valid value`); - } - if (entity.IBAN?.length > 34) { - throw new ValidationError(`The 'IBAN' exceeds the maximum length of [34] characters`); - } - if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.IBAN)) { - throw new ValidationError(`The value provided for the 'IBAN' property ('[${entity.IBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); - } - 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-partners/gen/codbex-partners/api/Manufacturers/ManufacturerNoteController.ts b/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerNoteController.ts deleted file mode 100644 index 0930448..0000000 --- a/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerNoteController.ts +++ /dev/null @@ -1,184 +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 { ManufacturerNoteRepository } from '../../data/Manufacturers/ManufacturerNoteRepository' -import { ManufacturerNoteEntity } from '../../data/Manufacturers/ManufacturerNoteEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Manufacturers-ManufacturerNote', ['validate']); - -@Controller -@Documentation('codbex-partners - ManufacturerNote Controller') -@Injected() -class ManufacturerNoteController { - - @Inject('ManufacturerNoteRepository') - private readonly repository!: ManufacturerNoteRepository; - - @Get('/') - @Documentation('Get All ManufacturerNote') - public getAll(_: any, ctx: any): ManufacturerNoteEntity[] { - 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 ManufacturerNote') - public create(entity: ManufacturerNoteEntity): ManufacturerNoteEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerNoteController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count ManufacturerNote') - 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 ManufacturerNote 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 ManufacturerNote') - public search(filter: any): ManufacturerNoteEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get ManufacturerNote by id') - public getById(_: any, ctx: any): ManufacturerNoteEntity { - 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('ManufacturerNote not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update ManufacturerNote by id') - public update(entity: ManufacturerNoteEntity, ctx: any): ManufacturerNoteEntity { - 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 ManufacturerNote 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('ManufacturerNote 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-partners.Manufacturers.ManufacturerNoteReadOnly') || user.isInRole('codbex-partners.Manufacturers.ManufacturerNoteFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-partners.Manufacturers.ManufacturerNoteFullAccess')) { - throw new ForbiddenError(); - } - } - - private validateEntity(entity: any): void { - if (entity.Note === null || entity.Note === undefined) { - throw new ValidationError(`The 'Note' property is required, provide a valid value`); - } - if (entity.Note?.length > 5000) { - throw new ValidationError(`The 'Note' exceeds the maximum length of [5000] characters`); - } - 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-partners/gen/codbex-partners/api/Suppliers/SupplierContactController.ts b/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierContactController.ts deleted file mode 100644 index a09d4a5..0000000 --- a/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierContactController.ts +++ /dev/null @@ -1,191 +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 { SupplierContactRepository } from '../../data/Suppliers/SupplierContactRepository' -import { SupplierContactEntity } from '../../data/Suppliers/SupplierContactEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Suppliers-SupplierContact', ['validate']); - -@Controller -@Documentation('codbex-partners - SupplierContact Controller') -@Injected() -class SupplierContactController { - - @Inject('SupplierContactRepository') - private readonly repository!: SupplierContactRepository; - - @Get('/') - @Documentation('Get All SupplierContact') - public getAll(_: any, ctx: any): SupplierContactEntity[] { - 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] - }; - - let Supplier = parseInt(ctx.queryParameters.Supplier); - Supplier = isNaN(Supplier) ? ctx.queryParameters.Supplier : Supplier; - - if (Supplier !== undefined) { - options.$filter = { - equals: { - Supplier: Supplier - } - }; - } - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/') - @Documentation('Create SupplierContact') - public create(entity: SupplierContactEntity): SupplierContactEntity { - try { - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierContactController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count SupplierContact') - public count(): { count: number } { - try { - return { count: this.repository.count() }; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/count') - @Documentation('Count SupplierContact 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 SupplierContact') - public search(filter: any): SupplierContactEntity[] { - try { - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get SupplierContact by id') - public getById(_: any, ctx: any): SupplierContactEntity { - 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('SupplierContact not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update SupplierContact by id') - public update(entity: SupplierContactEntity, ctx: any): SupplierContactEntity { - 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 SupplierContact 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('SupplierContact 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 > 255) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [255] characters`); - } - if (entity.Designation === null || entity.Designation === undefined) { - throw new ValidationError(`The 'Designation' property is required, provide a valid value`); - } - if (entity.Designation?.length > 255) { - throw new ValidationError(`The 'Designation' exceeds the maximum length of [255] characters`); - } - if (entity.Email === null || entity.Email === undefined) { - throw new ValidationError(`The 'Email' property is required, provide a valid value`); - } - if (entity.Email?.length > 100) { - throw new ValidationError(`The 'Email' exceeds the maximum length of [100] characters`); - } - if (entity.Phone === null || entity.Phone === undefined) { - throw new ValidationError(`The 'Phone' property is required, provide a valid value`); - } - if (entity.Phone?.length > 15) { - throw new ValidationError(`The 'Phone' exceeds the maximum length of [15] characters`); - } - if (entity.CreatedBy?.length > 20) { - throw new ValidationError(`The 'CreatedBy' exceeds the maximum length of [20] characters`); - } - for (const next of validationModules) { - next.validate(entity); - } - } - -} diff --git a/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierController.ts b/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierController.ts deleted file mode 100644 index c6eb9ec..0000000 --- a/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierController.ts +++ /dev/null @@ -1,223 +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 { SupplierRepository } from '../../data/Suppliers/SupplierRepository' -import { SupplierEntity } from '../../data/Suppliers/SupplierEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Suppliers-Supplier', ['validate']); - -@Controller -@Documentation('codbex-partners - Supplier Controller') -@Injected() -class SupplierController { - - @Inject('SupplierRepository') - private readonly repository!: SupplierRepository; - - @Get('/') - @Documentation('Get All Supplier') - public getAll(_: any, ctx: any): SupplierEntity[] { - 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 Supplier') - public create(entity: SupplierEntity): SupplierEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count Supplier') - 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 Supplier 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 Supplier') - public search(filter: any): SupplierEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get Supplier by id') - public getById(_: any, ctx: any): SupplierEntity { - 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('Supplier not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update Supplier by id') - public update(entity: SupplierEntity, ctx: any): SupplierEntity { - 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 Supplier 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('Supplier 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-partners.Suppliers.SupplierReadOnly') || user.isInRole('codbex-partners.Suppliers.SupplierFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-partners.Suppliers.SupplierFullAccess')) { - throw new ForbiddenError(); - } - } - - private validateEntity(entity: any): void { - if (entity.FirstName?.length > 50) { - throw new ValidationError(`The 'FirstName' exceeds the maximum length of [50] characters`); - } - if (entity.LastName?.length > 50) { - throw new ValidationError(`The 'LastName' exceeds the maximum length of [50] characters`); - } - if (entity.LegalEntityName?.length > 255) { - throw new ValidationError(`The 'LegalEntityName' exceeds the maximum length of [255] characters`); - } - if (entity.Name?.length > 255) { - throw new ValidationError(`The 'Name' exceeds the maximum length of [255] characters`); - } - if (entity.Email === null || entity.Email === undefined) { - throw new ValidationError(`The 'Email' property is required, provide a valid value`); - } - if (entity.Email?.length > 100) { - throw new ValidationError(`The 'Email' exceeds the maximum length of [100] characters`); - } - if (entity.Phone === null || entity.Phone === undefined) { - throw new ValidationError(`The 'Phone' property is required, provide a valid value`); - } - if (entity.Phone?.length > 15) { - throw new ValidationError(`The 'Phone' exceeds the maximum length of [15] characters`); - } - if (entity.Fax === null || entity.Fax === undefined) { - throw new ValidationError(`The 'Fax' property is required, provide a valid value`); - } - if (entity.Fax?.length > 20) { - throw new ValidationError(`The 'Fax' exceeds the maximum length of [20] characters`); - } - if (entity.TIN === null || entity.TIN === undefined) { - throw new ValidationError(`The 'TIN' property is required, provide a valid value`); - } - if (entity.TIN?.length > 15) { - throw new ValidationError(`The 'TIN' exceeds the maximum length of [15] characters`); - } - if (entity.IBAN === null || entity.IBAN === undefined) { - throw new ValidationError(`The 'IBAN' property is required, provide a valid value`); - } - if (entity.IBAN?.length > 34) { - throw new ValidationError(`The 'IBAN' exceeds the maximum length of [34] characters`); - } - if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.IBAN)) { - throw new ValidationError(`The value provided for the 'IBAN' property ('[${entity.IBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); - } - 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-partners/gen/codbex-partners/api/Suppliers/SupplierNoteController.ts b/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierNoteController.ts deleted file mode 100644 index 8a4017a..0000000 --- a/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierNoteController.ts +++ /dev/null @@ -1,195 +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 { SupplierNoteRepository } from '../../data/Suppliers/SupplierNoteRepository' -import { SupplierNoteEntity } from '../../data/Suppliers/SupplierNoteEntity' - -const validationModules = await Extensions.loadExtensionModules('codbex-partners-Suppliers-SupplierNote', ['validate']); - -@Controller -@Documentation('codbex-partners - SupplierNote Controller') -@Injected() -class SupplierNoteController { - - @Inject('SupplierNoteRepository') - private readonly repository!: SupplierNoteRepository; - - @Get('/') - @Documentation('Get All SupplierNote') - public getAll(_: any, ctx: any): SupplierNoteEntity[] { - 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] - }; - - let Supplier = parseInt(ctx.queryParameters.Supplier); - Supplier = isNaN(Supplier) ? ctx.queryParameters.Supplier : Supplier; - - if (Supplier !== undefined) { - options.$filter = { - equals: { - Supplier: Supplier - } - }; - } - - return this.repository.findAll(options); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Post('/') - @Documentation('Create SupplierNote') - public create(entity: SupplierNoteEntity): SupplierNoteEntity { - try { - this.checkPermissions('write'); - this.validateEntity(entity); - entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierNoteController.ts/' + entity.Id); - response.setStatus(response.CREATED); - return entity; - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/count') - @Documentation('Count SupplierNote') - 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 SupplierNote 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 SupplierNote') - public search(filter: any): SupplierNoteEntity[] { - try { - this.checkPermissions('read'); - return this.repository.findAll(filter); - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Get('/:id') - @Documentation('Get SupplierNote by id') - public getById(_: any, ctx: any): SupplierNoteEntity { - 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('SupplierNote not found'); - } - } catch (error: any) { - this.handleError(error); - } - return undefined as any; - } - - @Put('/:id') - @Documentation('Update SupplierNote by id') - public update(entity: SupplierNoteEntity, ctx: any): SupplierNoteEntity { - 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 SupplierNote 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('SupplierNote 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-partners.Suppliers.SupplierNoteReadOnly') || user.isInRole('codbex-partners.Suppliers.SupplierNoteFullAccess'))) { - throw new ForbiddenError(); - } - if (operationType === 'write' && !user.isInRole('codbex-partners.Suppliers.SupplierNoteFullAccess')) { - throw new ForbiddenError(); - } - } - - private validateEntity(entity: any): void { - if (entity.Note === null || entity.Note === undefined) { - throw new ValidationError(`The 'Note' property is required, provide a valid value`); - } - if (entity.Note?.length > 5000) { - throw new ValidationError(`The 'Note' exceeds the maximum length of [5000] characters`); - } - 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-partners/gen/codbex-partners/data/Customers/CustomerContactEntity.ts b/codbex-partners/gen/codbex-partners/data/Customers/CustomerContactEntity.ts deleted file mode 100644 index ba62359..0000000 --- a/codbex-partners/gen/codbex-partners/data/Customers/CustomerContactEntity.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('CustomerContactEntity') -@Table('CODBEX_CUSTOMERCONTACT') -@Documentation('CustomerContact entity mapping') -export class CustomerContactEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'CUSTOMERCONTACT_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Customer') - @Column({ - name: 'CUSTOMERCONTACT_CUSTOMER', - type: 'integer', - nullable: true, - }) - public Customer?: number; - - @Documentation('Name') - @Column({ - name: 'CUSTOMERCONTACT_NAME', - type: 'string', - length: 255, - }) - public Name!: string; - - @Documentation('Designation') - @Column({ - name: 'CUSTOMERCONTACT_DESIGNATION', - type: 'string', - length: 255, - }) - public Designation!: string; - - @Documentation('Email') - @Column({ - name: 'CUSTOMERCONTACT_EMAIL', - type: 'string', - length: 100, - }) - public Email!: string; - - @Documentation('Phone') - @Column({ - name: 'CUSTOMERCONTACT_PHONE', - type: 'string', - length: 15, - }) - public Phone!: string; - - @Documentation('CreatedAt') - @Column({ - name: 'CUSTOMERCONTACT_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'CUSTOMERCONTACT_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - -} - -(new CustomerContactEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Customers/CustomerContactRepository.ts b/codbex-partners/gen/codbex-partners/data/Customers/CustomerContactRepository.ts deleted file mode 100644 index 49e8017..0000000 --- a/codbex-partners/gen/codbex-partners/data/Customers/CustomerContactRepository.ts +++ /dev/null @@ -1,41 +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 { CustomerContactEntity } from './CustomerContactEntity' - -@Component('CustomerContactRepository') -export class CustomerContactRepository extends Repository { - - constructor() { - super((CustomerContactEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): CustomerContactEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - } - return entity; - } - - public override findAll(options?: Options): CustomerContactEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - }); - return entities; - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-partners-Customers-CustomerContact', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Customers-CustomerContact').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/data/Customers/CustomerEntity.ts b/codbex-partners/gen/codbex-partners/data/Customers/CustomerEntity.ts deleted file mode 100644 index 04ac1f5..0000000 --- a/codbex-partners/gen/codbex-partners/data/Customers/CustomerEntity.ts +++ /dev/null @@ -1,173 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('CustomerEntity') -@Table('CODBEX_CUSTOMER') -@Documentation('Customer entity mapping') -export class CustomerEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'CUSTOMER_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('FirstName') - @Column({ - name: 'CUSTOMER_FIRSTNAME', - type: 'string', - length: 50, - nullable: true, - }) - public FirstName?: string; - - @Documentation('LastName') - @Column({ - name: 'CUSTOMER_LASTNAME', - type: 'string', - length: 50, - nullable: true, - }) - public LastName?: string; - - @Documentation('LegalEntityName') - @Column({ - name: 'CUSTOMER_LEGALENTITYNAME', - type: 'string', - length: 255, - nullable: true, - }) - public LegalEntityName?: string; - - @Documentation('Name') - @Column({ - name: 'CUSTOMER_NAME', - type: 'string', - length: 255, - nullable: true, - }) - public Name?: string; - - @Documentation('Email') - @Column({ - name: 'CUSTOMER_EMAIL', - type: 'string', - length: 100, - }) - public Email!: string; - - @Documentation('Phone') - @Column({ - name: 'CUSTOMER_PHONE', - type: 'string', - length: 15, - }) - public Phone!: string; - - @Documentation('Fax') - @Column({ - name: 'CUSTOMER_FAX', - type: 'string', - length: 20, - nullable: true, - }) - public Fax?: string; - - @Documentation('Country') - @Column({ - name: 'CUSTOMER_COUNTRY', - type: 'integer', - }) - public Country!: number; - - @Documentation('City') - @Column({ - name: 'CUSTOMER_CITY', - type: 'integer', - }) - public City!: number; - - @Documentation('Address') - @Column({ - name: 'CUSTOMER_ADDRESS', - type: 'string', - length: 255, - }) - public Address!: string; - - @Documentation('PostalCode') - @Column({ - name: 'CUSTOMER_POSTALCODE', - type: 'string', - length: 10, - }) - public PostalCode!: string; - - @Documentation('TIN') - @Column({ - name: 'CUSTOMER_TIN', - type: 'string', - length: 15, - }) - public TIN!: string; - - @Documentation('IBAN') - @Column({ - name: 'CUSTOMER_IBAN', - type: 'string', - length: 34, - }) - public IBAN!: string; - - @Documentation('ResponsiblePerson') - @Column({ - name: 'CUSTOMER_RESPONSIBLEPERSON', - type: 'string', - length: 150, - nullable: true, - }) - public ResponsiblePerson?: string; - - @Documentation('CreatedAt') - @Column({ - name: 'CUSTOMER_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'CUSTOMER_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - - @Documentation('UpdatedAt') - @Column({ - name: 'CUSTOMER_UPDATEDAT', - type: 'timestamp', - nullable: true, - }) - @UpdatedAt() - public UpdatedAt?: Date; - - @Documentation('UpdatedBy') - @Column({ - name: 'CUSTOMER_UPDATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @UpdatedBy() - public UpdatedBy?: string; - -} - -(new CustomerEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Customers/CustomerNoteEntity.ts b/codbex-partners/gen/codbex-partners/data/Customers/CustomerNoteEntity.ts deleted file mode 100644 index 4487db3..0000000 --- a/codbex-partners/gen/codbex-partners/data/Customers/CustomerNoteEntity.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('CustomerNoteEntity') -@Table('CODBEX_CUSTOMERNOTE') -@Documentation('CustomerNote entity mapping') -export class CustomerNoteEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'CUSTOMERNOTE_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Customer') - @Column({ - name: 'CUSTOMERNOTE_CUSTOMER', - type: 'integer', - nullable: true, - }) - public Customer?: number; - - @Documentation('Note') - @Column({ - name: 'CUSTOMERNOTE_NOTE', - type: 'string', - length: 5000, - }) - public Note!: string; - - @Documentation('CreatedAt') - @Column({ - name: 'CUSTOMERNOTE_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'CUSTOMERNOTE_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - - @Documentation('UpdatedAt') - @Column({ - name: 'CUSTOMERNOTE_UPDATEDAT', - type: 'timestamp', - nullable: true, - }) - @UpdatedAt() - public UpdatedAt?: Date; - - @Documentation('UpdatedBy') - @Column({ - name: 'CUSTOMERNOTE_UPDATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @UpdatedBy() - public UpdatedBy?: string; - -} - -(new CustomerNoteEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Customers/CustomerNoteRepository.ts b/codbex-partners/gen/codbex-partners/data/Customers/CustomerNoteRepository.ts deleted file mode 100644 index e949dfc..0000000 --- a/codbex-partners/gen/codbex-partners/data/Customers/CustomerNoteRepository.ts +++ /dev/null @@ -1,43 +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 { CustomerNoteEntity } from './CustomerNoteEntity' - -@Component('CustomerNoteRepository') -export class CustomerNoteRepository extends Repository { - - constructor() { - super((CustomerNoteEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): CustomerNoteEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - 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): CustomerNoteEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - 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-partners-Customers-CustomerNote', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Customers-CustomerNote').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/data/Customers/CustomerRepository.ts b/codbex-partners/gen/codbex-partners/data/Customers/CustomerRepository.ts deleted file mode 100644 index b06872e..0000000 --- a/codbex-partners/gen/codbex-partners/data/Customers/CustomerRepository.ts +++ /dev/null @@ -1,59 +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 { CustomerEntity } from './CustomerEntity' - -@Component('CustomerRepository') -export class CustomerRepository extends Repository { - - constructor() { - super((CustomerEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): CustomerEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - 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): CustomerEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - entity.UpdatedAt = entity.UpdatedAt ? new Date(entity.UpdatedAt) : undefined; - }); - return entities; - } - - public override create(entity: CustomerEntity): string | number { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - return super.create(entity); - } - - public override update(entity: CustomerEntity): void { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - super.update(entity); - } - - public override upsert(entity: CustomerEntity): string | number { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - return super.upsert(entity); - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-partners-Customers-Customer', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Customers-Customer').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContactEntity.ts b/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContactEntity.ts deleted file mode 100644 index c130669..0000000 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContactEntity.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('ManufacturerContactEntity') -@Table('CODBEX_MANUFACTURERCONTACT') -@Documentation('ManufacturerContact entity mapping') -export class ManufacturerContactEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'MANUFACTURERCONTACT_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Manufacturer') - @Column({ - name: 'MANUFACTURERCONTACT_MANUFACTURER', - type: 'integer', - nullable: true, - }) - public Manufacturer?: number; - - @Documentation('Name') - @Column({ - name: 'MANUFACTURERCONTACT_NAME', - type: 'string', - length: 255, - }) - public Name!: string; - - @Documentation('Designation') - @Column({ - name: 'MANUFACTURERCONTACT_DESIGNATION', - type: 'string', - length: 255, - }) - public Designation!: string; - - @Documentation('Email') - @Column({ - name: 'MANUFACTURERCONTACT_EMAIL', - type: 'string', - length: 100, - }) - public Email!: string; - - @Documentation('Phone') - @Column({ - name: 'MANUFACTURERCONTACT_PHONE', - type: 'string', - length: 15, - }) - public Phone!: string; - - @Documentation('CreatedAt') - @Column({ - name: 'MANUFACTURERCONTACT_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'MANUFACTURERCONTACT_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - -} - -(new ManufacturerContactEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContactRepository.ts b/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContactRepository.ts deleted file mode 100644 index 74e94f9..0000000 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContactRepository.ts +++ /dev/null @@ -1,41 +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 { ManufacturerContactEntity } from './ManufacturerContactEntity' - -@Component('ManufacturerContactRepository') -export class ManufacturerContactRepository extends Repository { - - constructor() { - super((ManufacturerContactEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): ManufacturerContactEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - } - return entity; - } - - public override findAll(options?: Options): ManufacturerContactEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - }); - return entities; - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-partners-Manufacturers-ManufacturerContact', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Manufacturers-ManufacturerContact').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerEntity.ts b/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerEntity.ts deleted file mode 100644 index 6e75d83..0000000 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerEntity.ts +++ /dev/null @@ -1,133 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('ManufacturerEntity') -@Table('CODBEX_MANUFACTURER') -@Documentation('Manufacturer entity mapping') -export class ManufacturerEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'MANUFACTURER_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('FirstName') - @Column({ - name: 'MANUFACTURER_FIRSTNAME', - type: 'string', - length: 50, - nullable: true, - }) - public FirstName?: string; - - @Documentation('LastName') - @Column({ - name: 'MANUFACTURER_LASTNAME', - type: 'string', - length: 50, - nullable: true, - }) - public LastName?: string; - - @Documentation('LegalEntityName') - @Column({ - name: 'MANUFACTURER_LEGALENTITYNAME', - type: 'string', - length: 255, - nullable: true, - }) - public LegalEntityName?: string; - - @Documentation('Name') - @Column({ - name: 'MANUFACTURER_NAME', - type: 'string', - length: 255, - nullable: true, - }) - public Name?: string; - - @Documentation('Email') - @Column({ - name: 'MANUFACTURER_EMAIL', - type: 'string', - length: 100, - }) - public Email!: string; - - @Documentation('Phone') - @Column({ - name: 'MANUFACTURER_PHONE', - type: 'string', - length: 15, - }) - public Phone!: string; - - @Documentation('Fax') - @Column({ - name: 'MANUFACTURER_FAX', - type: 'string', - length: 20, - }) - public Fax!: string; - - @Documentation('TIN') - @Column({ - name: 'MANUFACTURER_TIN', - type: 'string', - length: 15, - }) - public TIN!: string; - - @Documentation('IBAN') - @Column({ - name: 'MANUFACTURER_IBAN', - type: 'string', - length: 34, - }) - public IBAN!: string; - - @Documentation('CreatedAt') - @Column({ - name: 'MANUFACTURER_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'MANUFACTURER_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - - @Documentation('UpdatedAt') - @Column({ - name: 'MANUFACTURER_UPDATEDAT', - type: 'timestamp', - nullable: true, - }) - @UpdatedAt() - public UpdatedAt?: Date; - - @Documentation('UpdatedBy') - @Column({ - name: 'MANUFACTURER_UPDATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @UpdatedBy() - public UpdatedBy?: string; - -} - -(new ManufacturerEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNoteEntity.ts b/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNoteEntity.ts deleted file mode 100644 index 4dbdd2b..0000000 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNoteEntity.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('ManufacturerNoteEntity') -@Table('CODBEX_MANUFACTURERNOTE') -@Documentation('ManufacturerNote entity mapping') -export class ManufacturerNoteEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'MANUFACTURERNOTE_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Manufacturer') - @Column({ - name: 'MANUFACTURERNOTE_MANUFACTURER', - type: 'integer', - nullable: true, - }) - public Manufacturer?: number; - - @Documentation('Note') - @Column({ - name: 'MANUFACTURERNOTE_NOTE', - type: 'string', - length: 5000, - }) - public Note!: string; - - @Documentation('CreatedAt') - @Column({ - name: 'MANUFACTURERNOTE_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'MANUFACTURERNOTE_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - - @Documentation('UpdatedAt') - @Column({ - name: 'MANUFACTURERNOTE_UPDATEDAT', - type: 'timestamp', - nullable: true, - }) - @UpdatedAt() - public UpdatedAt?: Date; - - @Documentation('UpdatedBy') - @Column({ - name: 'MANUFACTURERNOTE_UPDATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @UpdatedBy() - public UpdatedBy?: string; - -} - -(new ManufacturerNoteEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNoteRepository.ts b/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNoteRepository.ts deleted file mode 100644 index 987fb0f..0000000 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNoteRepository.ts +++ /dev/null @@ -1,43 +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 { ManufacturerNoteEntity } from './ManufacturerNoteEntity' - -@Component('ManufacturerNoteRepository') -export class ManufacturerNoteRepository extends Repository { - - constructor() { - super((ManufacturerNoteEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): ManufacturerNoteEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - 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): ManufacturerNoteEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - 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-partners-Manufacturers-ManufacturerNote', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Manufacturers-ManufacturerNote').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerRepository.ts b/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerRepository.ts deleted file mode 100644 index f8e89ee..0000000 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerRepository.ts +++ /dev/null @@ -1,59 +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 { ManufacturerEntity } from './ManufacturerEntity' - -@Component('ManufacturerRepository') -export class ManufacturerRepository extends Repository { - - constructor() { - super((ManufacturerEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): ManufacturerEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - 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): ManufacturerEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - entity.UpdatedAt = entity.UpdatedAt ? new Date(entity.UpdatedAt) : undefined; - }); - return entities; - } - - public override create(entity: ManufacturerEntity): string | number { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - return super.create(entity); - } - - public override update(entity: ManufacturerEntity): void { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - super.update(entity); - } - - public override upsert(entity: ManufacturerEntity): string | number { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - return super.upsert(entity); - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-partners-Manufacturers-Manufacturer', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Manufacturers-Manufacturer').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContactEntity.ts b/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContactEntity.ts deleted file mode 100644 index 8cd38cb..0000000 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContactEntity.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('SupplierContactEntity') -@Table('CODBEX_SUPPLIERCONTACT') -@Documentation('SupplierContact entity mapping') -export class SupplierContactEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'SUPPLIERCONTACT_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Supplier') - @Column({ - name: 'SUPPLIERCONTACT_SUPPLIER', - type: 'integer', - nullable: true, - }) - public Supplier?: number; - - @Documentation('Name') - @Column({ - name: 'SUPPLIERCONTACT_NAME', - type: 'string', - length: 255, - }) - public Name!: string; - - @Documentation('Designation') - @Column({ - name: 'SUPPLIERCONTACT_DESIGNATION', - type: 'string', - length: 255, - }) - public Designation!: string; - - @Documentation('Email') - @Column({ - name: 'SUPPLIERCONTACT_EMAIL', - type: 'string', - length: 100, - }) - public Email!: string; - - @Documentation('Phone') - @Column({ - name: 'SUPPLIERCONTACT_PHONE', - type: 'string', - length: 15, - }) - public Phone!: string; - - @Documentation('CreatedAt') - @Column({ - name: 'SUPPLIERCONTACT_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'SUPPLIERCONTACT_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - -} - -(new SupplierContactEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContactRepository.ts b/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContactRepository.ts deleted file mode 100644 index f9c333c..0000000 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContactRepository.ts +++ /dev/null @@ -1,41 +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 { SupplierContactEntity } from './SupplierContactEntity' - -@Component('SupplierContactRepository') -export class SupplierContactRepository extends Repository { - - constructor() { - super((SupplierContactEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): SupplierContactEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - } - return entity; - } - - public override findAll(options?: Options): SupplierContactEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - }); - return entities; - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-partners-Suppliers-SupplierContact', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Suppliers-SupplierContact').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierEntity.ts b/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierEntity.ts deleted file mode 100644 index 145b489..0000000 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierEntity.ts +++ /dev/null @@ -1,133 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('SupplierEntity') -@Table('CODBEX_SUPPLIER') -@Documentation('Supplier entity mapping') -export class SupplierEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'SUPPLIER_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('FirstName') - @Column({ - name: 'SUPPLIER_FIRSTNAME', - type: 'string', - length: 50, - nullable: true, - }) - public FirstName?: string; - - @Documentation('LastName') - @Column({ - name: 'SUPPLIER_LASTNAME', - type: 'string', - length: 50, - nullable: true, - }) - public LastName?: string; - - @Documentation('LegalEntityName') - @Column({ - name: 'SUPPLIER_LEGALENTITYNAME', - type: 'string', - length: 255, - nullable: true, - }) - public LegalEntityName?: string; - - @Documentation('Name') - @Column({ - name: 'SUPPLIER_NAME', - type: 'string', - length: 255, - nullable: true, - }) - public Name?: string; - - @Documentation('Email') - @Column({ - name: 'SUPPLIER_EMAIL', - type: 'string', - length: 100, - }) - public Email!: string; - - @Documentation('Phone') - @Column({ - name: 'SUPPLIER_PHONE', - type: 'string', - length: 15, - }) - public Phone!: string; - - @Documentation('Fax') - @Column({ - name: 'SUPPLIER_FAX', - type: 'string', - length: 20, - }) - public Fax!: string; - - @Documentation('TIN') - @Column({ - name: 'SUPPLIER_TIN', - type: 'string', - length: 15, - }) - public TIN!: string; - - @Documentation('IBAN') - @Column({ - name: 'SUPPLIER_IBAN', - type: 'string', - length: 34, - }) - public IBAN!: string; - - @Documentation('CreatedAt') - @Column({ - name: 'SUPPLIER_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'SUPPLIER_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - - @Documentation('UpdatedAt') - @Column({ - name: 'SUPPLIER_UPDATEDAT', - type: 'timestamp', - nullable: true, - }) - @UpdatedAt() - public UpdatedAt?: Date; - - @Documentation('UpdatedBy') - @Column({ - name: 'SUPPLIER_UPDATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @UpdatedBy() - public UpdatedBy?: string; - -} - -(new SupplierEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNoteEntity.ts b/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNoteEntity.ts deleted file mode 100644 index 197c323..0000000 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNoteEntity.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Entity, Table, Id, Generated, Column, Documentation, CreatedAt, CreatedBy, UpdatedAt, UpdatedBy} from '@aerokit/sdk/db' - -@Entity('SupplierNoteEntity') -@Table('CODBEX_SUPPLIERNOTE') -@Documentation('SupplierNote entity mapping') -export class SupplierNoteEntity { - - @Id() - @Generated('sequence') - @Documentation('Id') - @Column({ - name: 'SUPPLIERNOTE_ID', - type: 'integer', - }) - public Id?: number; - - @Documentation('Supplier') - @Column({ - name: 'SUPPLIERNOTE_SUPPLIER', - type: 'integer', - nullable: true, - }) - public Supplier?: number; - - @Documentation('Note') - @Column({ - name: 'SUPPLIERNOTE_NOTE', - type: 'string', - length: 5000, - }) - public Note!: string; - - @Documentation('CreatedAt') - @Column({ - name: 'SUPPLIERNOTE_CREATEDAT', - type: 'timestamp', - nullable: true, - }) - @CreatedAt() - public CreatedAt?: Date; - - @Documentation('CreatedBy') - @Column({ - name: 'SUPPLIERNOTE_CREATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @CreatedBy() - public CreatedBy?: string; - - @Documentation('UpdatedAt') - @Column({ - name: 'SUPPLIERNOTE_UPDATEDAT', - type: 'timestamp', - nullable: true, - }) - @UpdatedAt() - public UpdatedAt?: Date; - - @Documentation('UpdatedBy') - @Column({ - name: 'SUPPLIERNOTE_UPDATEDBY', - type: 'string', - length: 20, - nullable: true, - }) - @UpdatedBy() - public UpdatedBy?: string; - -} - -(new SupplierNoteEntity()); diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNoteRepository.ts b/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNoteRepository.ts deleted file mode 100644 index df16b24..0000000 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNoteRepository.ts +++ /dev/null @@ -1,43 +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 { SupplierNoteEntity } from './SupplierNoteEntity' - -@Component('SupplierNoteRepository') -export class SupplierNoteRepository extends Repository { - - constructor() { - super((SupplierNoteEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): SupplierNoteEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - 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): SupplierNoteEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - 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-partners-Suppliers-SupplierNote', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Suppliers-SupplierNote').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierRepository.ts b/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierRepository.ts deleted file mode 100644 index d45f101..0000000 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierRepository.ts +++ /dev/null @@ -1,59 +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 { SupplierEntity } from './SupplierEntity' - -@Component('SupplierRepository') -export class SupplierRepository extends Repository { - - constructor() { - super((SupplierEntity as EntityConstructor)); - } - - public override findById(id: string | number, options?: Options): SupplierEntity | undefined { - const entity = super.findById(id, options); - if (entity) { - 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): SupplierEntity[] { - const entities = super.findAll(options); - entities.forEach(entity => { - entity.CreatedAt = entity.CreatedAt ? new Date(entity.CreatedAt) : undefined; - entity.UpdatedAt = entity.UpdatedAt ? new Date(entity.UpdatedAt) : undefined; - }); - return entities; - } - - public override create(entity: SupplierEntity): string | number { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - return super.create(entity); - } - - public override update(entity: SupplierEntity): void { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - super.update(entity); - } - - public override upsert(entity: SupplierEntity): string | number { - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - entity.Name = (entity.FirstName && entity.LastName) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; - return super.upsert(entity); - } - - protected override async triggerEvent(data: EntityEvent): Promise { - const triggerExtensions = await Extensions.loadExtensionModules('codbex-partners-Suppliers-Supplier', ['trigger']); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - Producer.topic('codbex-partners-Suppliers-Supplier').send(JSON.stringify(data)); - } -} diff --git a/codbex-partners/gen/codbex-partners/odata/codbex-partners.odata b/codbex-partners/gen/codbex-partners/odata/codbex-partners.odata deleted file mode 100644 index f149140..0000000 --- a/codbex-partners/gen/codbex-partners/odata/codbex-partners.odata +++ /dev/null @@ -1,4 +0,0 @@ -{ - "namespace": "", - "entities": [] -} diff --git a/codbex-partners/gen/codbex-partners/schema/codbex-partners.schema b/codbex-partners/gen/codbex-partners/schema/codbex-partners.schema index 9845650..4019bbe 100644 --- a/codbex-partners/gen/codbex-partners/schema/codbex-partners.schema +++ b/codbex-partners/gen/codbex-partners/schema/codbex-partners.schema @@ -47,12 +47,6 @@ "length": 15, "name": "CUSTOMER_PHONE" }, - { - "type": "VARCHAR", - "length": 20, - "nullable": true, - "name": "CUSTOMER_FAX" - }, { "type": "INTEGER", "name": "CUSTOMER_COUNTRY" @@ -61,6 +55,12 @@ "type": "INTEGER", "name": "CUSTOMER_CITY" }, + { + "type": "VARCHAR", + "length": 20, + "nullable": true, + "name": "CUSTOMER_FAX" + }, { "type": "VARCHAR", "length": 255, diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerContact/controller.js b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerContact/controller.js index 02fb752..b4bd70e 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerContact/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerContact/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerContactController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/customers/CustomerContactController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerContact/dialog-window/controller.js b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerContact/dialog-window/controller.js index 89ef587..dbc5cfd 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerContact/dialog-window/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerContact/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerContactController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/customers/CustomerContactController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerNote/controller.js b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerNote/controller.js index b20bca3..66f781e 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerNote/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerNote/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerNoteController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/customers/CustomerNoteController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerNote/dialog-window/controller.js b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerNote/dialog-window/controller.js index c914a31..115d0d8 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerNote/dialog-window/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/CustomerNote/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerNoteController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/customers/CustomerNoteController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/controller.js b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/controller.js index 64aa145..1bb5723 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/customers/CustomerController'; }]) .controller('PageController', ($scope, $http, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); @@ -105,7 +105,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 } ] @@ -128,7 +128,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer if (optionsCityHasMore) { const optionsCitySearchValues = Array.from(new Set(response.data.map(e => e.City))); if (optionsCitySearchValues.length > 0) { - $http.post('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts/search', { + $http.post('/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController/search', { conditions: [ { propertyName: 'Id', operator: 'IN', value: optionsCitySearchValues } ] @@ -260,9 +260,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 @@ -288,9 +288,9 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer }); let optionsCityHasMore = true; - $http.get('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts/count').then((response) => { + $http.get('/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController/count').then((response) => { const optionsCityCount = response.data.count; - $http.get('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts').then((response) => { + $http.get('/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController').then((response) => { $scope.optionsCity = response.data.map(e => ({ value: e.Id, text: e.Name diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-filter/controller.js b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-filter/controller.js index 9702060..d24cb7b 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-filter/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-filter/controller.js @@ -68,10 +68,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle const condition = { propertyName: 'Phone', operator: 'LIKE', value: `%${entity.Phone}%` }; filter.$filter.conditions.push(condition); } - if (entity.Fax) { - const condition = { propertyName: 'Fax', operator: 'LIKE', value: `%${entity.Fax}%` }; - filter.$filter.conditions.push(condition); - } if (entity.Country !== undefined) { const condition = { propertyName: 'Country', operator: 'EQ', value: entity.Country }; filter.$filter.conditions.push(condition); @@ -80,6 +76,10 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle const condition = { propertyName: 'City', operator: 'EQ', value: entity.City }; filter.$filter.conditions.push(condition); } + if (entity.Fax) { + const condition = { propertyName: 'Fax', operator: 'LIKE', value: `%${entity.Fax}%` }; + filter.$filter.conditions.push(condition); + } if (entity.Address) { const condition = { propertyName: 'Address', operator: 'LIKE', value: `%${entity.Address}%` }; filter.$filter.conditions.push(condition); @@ -158,7 +158,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 => ({ @@ -208,7 +208,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}%` } ] @@ -247,7 +247,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle $scope.loadMoreOptionsCity = () => { const limit = 20; $scope.optionsCityLoading = true; - $http.get(`/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts?$limit=${limit}&$offset=${++loadMoreOptionsCityCounter * limit}`) + $http.get(`/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController?$limit=${limit}&$offset=${++loadMoreOptionsCityCounter * limit}`) .then((response) => { const optionValues = allValuesCity.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -297,7 +297,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controlle } }) if (!cacheHit) { - $http.post('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts/search', { + $http.post('/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-filter/index.html b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-filter/index.html index 949319a..f3ea414 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-filter/index.html +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-filter/index.html @@ -119,23 +119,6 @@ - -
- {{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_FAX' | t }} -
-
- - - - -
-
{{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_COUNTRY' | t }} @@ -178,6 +161,23 @@
+ +
+ {{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_FAX' | t }} +
+
+ + + + +
+
{{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_ADDRESS' | t }} diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-window/controller.js b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-window/controller.js index 1d7abb7..5dc7978 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-window/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/customers/CustomerController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); @@ -89,11 +89,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 @@ -117,7 +117,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 => ({ @@ -167,7 +167,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}%` } ] @@ -196,11 +196,11 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } } }; - $scope.serviceCity = '/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts'; + $scope.serviceCity = '/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController'; $scope.optionsCity = []; - $http.get('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts').then((response) => { + $http.get('/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController').then((response) => { $scope.optionsCity = response.data.map(e => ({ value: e.Id, text: e.Name @@ -224,7 +224,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.loadMoreOptionsCity = () => { const limit = 20; $scope.optionsCityLoading = true; - $http.get(`/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts?$limit=${limit}&$offset=${++loadMoreOptionsCityCounter * limit}`) + $http.get(`/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController?$limit=${limit}&$offset=${++loadMoreOptionsCityCounter * limit}`) .then((response) => { const optionValues = allValuesCity.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -274,7 +274,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } }) if (!cacheHit) { - $http.post('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts/search', { + $http.post('/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] @@ -309,35 +309,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } - $scope.$watch('entity.Country', (newValue, oldValue) => { - if (newValue !== undefined && newValue !== null) { - $http.get($scope.serviceCountry + '/' + newValue).then((response) => { - let valueFrom = response.data.Id; - $http.post('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts/search', { - conditions: [ - { propertyName: 'Country', operator: 'EQ', value: valueFrom } - ] - }).then((response) => { - $scope.optionsCity = response.data.map(e => ({ - value: e.Id, - text: e.Name - })); - if ($scope.action !== 'select' && newValue !== oldValue) { - if ($scope.optionsCity.length == 1) { - $scope.entity.City = $scope.optionsCity[0].value; - } else { - $scope.entity.City = undefined; - } - } - }, (error) => { - console.error(error); - }); - }, (error) => { - console.error(error); - }); - } - }); - $scope.alert = (message) => { if (message) Dialogs.showAlert({ title: description, diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-window/index.html b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-window/index.html index b6fbf56..26aa585 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-window/index.html +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/dialog-window/index.html @@ -142,27 +142,6 @@
- -
- {{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_FAX' | t }} -
-
- - - - -
-
{{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_COUNTRY' | t }} @@ -209,6 +188,27 @@
+ +
+ {{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_FAX' | t }} +
+
+ + + + +
+
{{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_ADDRESS' | t }} diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/index.html b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/index.html index d9aa8de..077f6c5 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/index.html +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/index.html @@ -45,9 +45,9 @@ {{next.Name}} | {{next.Email}} | {{next.Phone}} | - {{next.Fax}} | {{optionsCountryValue(next.Country)}} | {{optionsCityValue(next.City)}} | + {{next.Fax}} | {{next.Address}} | {{next.PostalCode}} | {{next.TIN}} | diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/main-details/controller.js b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/main-details/controller.js index 3517ece..33efef3 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/main-details/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/main-details/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(["EntityServiceProvider", (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Customers/CustomerController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/customers/CustomerController'; }]) .controller('PageController', ($scope, $http, Extensions, LocaleService, EntityService) => { const Dialogs = new DialogHub(); @@ -92,38 +92,9 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer }); }}); - $scope.serviceCountry = '/services/ts/codbex-countries/gen/codbex-countries/api/Settings/CountryController.ts'; - $scope.serviceCity = '/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts'; + $scope.serviceCountry = '/services/java/codbex-countries/gen/codbex_countries/api/settings/CountryController'; + $scope.serviceCity = '/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController'; - - $scope.$watch('entity.Country', (newValue, oldValue) => { - if (newValue !== undefined && newValue !== null) { - $http.get($scope.serviceCountry + '/' + newValue).then((response) => { - let valueFrom = response.data.Id; - $http.post('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts/search', { - conditions: [ - { propertyName: 'Country', operator: 'EQ', value: valueFrom } - ] - }).then((response) => { - $scope.optionsCity = response.data.map(e => ({ - value: e.Id, - text: e.Name - })); - if ($scope.action !== 'select' && newValue !== oldValue) { - if ($scope.optionsCity.length == 1) { - $scope.entity.City = $scope.optionsCity[0].value; - } else { - $scope.entity.City = undefined; - } - } - }, (error) => { - console.error(error); - }); - }, (error) => { - console.error(error); - }); - } - }); //-----------------Events-------------------// $scope.create = () => { @@ -216,7 +187,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 => ({ @@ -266,7 +237,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}%` } ] @@ -298,7 +269,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.refreshCountry = () => { $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 @@ -323,7 +294,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.loadMoreOptionsCity = () => { const limit = 20; $scope.optionsCityLoading = true; - $http.get(`/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts?$limit=${limit}&$offset=${++loadMoreOptionsCityCounter * limit}`) + $http.get(`/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController?$limit=${limit}&$offset=${++loadMoreOptionsCityCounter * limit}`) .then((response) => { const optionValues = allValuesCity.map(e => e.value); const resultValues = response.data.map(e => ({ @@ -373,7 +344,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer } }) if (!cacheHit) { - $http.post('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts/search', { + $http.post('/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController/search', { conditions: [ { propertyName: 'Name', operator: 'LIKE', value: `${event.originalEvent.target.value}%` } ] @@ -405,7 +376,7 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntitySer $scope.refreshCity = () => { $scope.optionsCity = []; - $http.get('/services/ts/codbex-cities/gen/codbex-cities/api/Settings/CityController.ts').then((response) => { + $http.get('/services/java/codbex-cities/gen/codbex_cities/api/settings/CityController').then((response) => { $scope.optionsCity = response.data.map(e => ({ value: e.Id, text: e.Name diff --git a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/main-details/index.html b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/main-details/index.html index ac04c8f..4db98e0 100644 --- a/codbex-partners/gen/codbex-partners/ui/Customers/Customer/main-details/index.html +++ b/codbex-partners/gen/codbex-partners/ui/Customers/Customer/main-details/index.html @@ -140,27 +140,6 @@
- -
- {{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_FAX' | t }} -
-
- - - - -
-
{{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_COUNTRY' | t }} @@ -215,6 +194,27 @@
+ +
+ {{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_FAX' | t }} +
+
+ + + + +
+
{{ 'codbex-partners:codbex-partners-model.t.CUSTOMER_ADDRESS' | t }} diff --git a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/ManufacturerContact/controller.js b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/ManufacturerContact/controller.js index 13b7765..ea0ef11 100644 --- a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/ManufacturerContact/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/ManufacturerContact/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerContactController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerContactController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/ManufacturerContact/dialog-window/controller.js b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/ManufacturerContact/dialog-window/controller.js index f8da0d9..e469a4e 100644 --- a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/ManufacturerContact/dialog-window/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/ManufacturerContact/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerContactController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerContactController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/controller.js b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/controller.js index da5c058..aca31b6 100644 --- a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/dialog-window/controller.js b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/dialog-window/controller.js index 820f5c1..04e1a25 100644 --- a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/dialog-window/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/main-details/controller.js b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/main-details/controller.js index 507b22c..c66e665 100644 --- a/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/main-details/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Manufacturers/Manufacturer/main-details/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(["EntityServiceProvider", (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Manufacturers/ManufacturerController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerController'; }]) .controller('PageController', ($scope, $http, Extensions, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierContact/controller.js b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierContact/controller.js index a78023a..030c38e 100644 --- a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierContact/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierContact/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierContactController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/suppliers/SupplierContactController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierContact/dialog-window/controller.js b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierContact/dialog-window/controller.js index 3da8de8..56e269c 100644 --- a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierContact/dialog-window/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierContact/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierContactController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/suppliers/SupplierContactController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierNote/controller.js b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierNote/controller.js index 81a244f..4dea660 100644 --- a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierNote/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierNote/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierNoteController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/suppliers/SupplierNoteController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierNote/dialog-window/controller.js b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierNote/dialog-window/controller.js index bfcaf1c..e93a8ad 100644 --- a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierNote/dialog-window/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/SupplierNote/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierNoteController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/suppliers/SupplierNoteController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/controller.js b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/controller.js index aac1d13..f1ad545 100644 --- a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/suppliers/SupplierController'; }]) .controller('PageController', ($scope, EntityService, Extensions, LocaleService, ButtonStates) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/dialog-window/controller.js b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/dialog-window/controller.js index a900c2a..1d429f8 100644 --- a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/dialog-window/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/dialog-window/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(['EntityServiceProvider', (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/suppliers/SupplierController'; }]) .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/main-details/controller.js b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/main-details/controller.js index 27d6b5d..74c5b17 100644 --- a/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/main-details/controller.js +++ b/codbex-partners/gen/codbex-partners/ui/Suppliers/Supplier/main-details/controller.js @@ -1,6 +1,6 @@ angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) .config(["EntityServiceProvider", (EntityServiceProvider) => { - EntityServiceProvider.baseUrl = '/services/ts/codbex-partners/gen/codbex-partners/api/Suppliers/SupplierController.ts'; + EntityServiceProvider.baseUrl = '/services/java/codbex-partners/gen/codbex_partners/api/suppliers/SupplierController'; }]) .controller('PageController', ($scope, $http, Extensions, LocaleService, EntityService) => { const Dialogs = new DialogHub(); diff --git a/codbex-partners/gen/codbex_partners/api/customers/CustomerContactController.java b/codbex-partners/gen/codbex_partners/api/customers/CustomerContactController.java new file mode 100644 index 0000000..e9a248e --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/customers/CustomerContactController.java @@ -0,0 +1,199 @@ +package gen.codbex_partners.api.customers; + +import gen.codbex_partners.data.customers.CustomerContactEntity; +import gen.codbex_partners.data.customers.CustomerContactRepository; + +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-partners - CustomerContact Controller") +public class CustomerContactController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Customer", "Name", "Designation", "Email", "Phone", "CreatedAt", "CreatedBy"); + + @Inject + private CustomerContactRepository repository; + + @Get + @Documentation("List CustomerContact") + public List getAll(@QueryParam("$limit") Integer limit, + @QueryParam("$offset") Integer offset, + @QueryParam("Customer") String Customer) { + checkPermissions("read"); + int actualLimit = limit != null ? limit.intValue() : 20; + int actualOffset = offset != null ? offset.intValue() : 0; + List result; + if (Customer != null) { + Map params = new LinkedHashMap<>(); + params.put("Customer", Customer); + result = repository.query("from CustomerContactEntity e where e.Customer = :Customer", params); + } else { + result = repository.findAll(actualLimit, actualOffset); + } + return result; + } + + @Get("/count") + @Documentation("Count CustomerContact") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count CustomerContact with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search CustomerContact") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get CustomerContact by id") + public CustomerContactEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + CustomerContactEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "CustomerContact not found")); + return entity; + } + + @Post + @Documentation("Create CustomerContact") + public CustomerContactEntity create(@Body CustomerContactEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update CustomerContact by id") + public CustomerContactEntity update(@PathParam("id") Integer id, @Body CustomerContactEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete CustomerContact by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "CustomerContact not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from CustomerContactEntity 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-partners.Customers.CustomerContactReadOnly") || UserFacade.isInRole("codbex-partners.Customers.CustomerContactFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-partners.Customers.CustomerContactFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(CustomerContactEntity entity) { + if (entity.Name == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' property is required"); + } + if (entity.Name != null && entity.Name.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 255"); + } + if (entity.Designation == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Designation' property is required"); + } + if (entity.Designation != null && entity.Designation.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Designation' exceeds the maximum length of 255"); + } + if (entity.Email == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' property is required"); + } + if (entity.Email != null && entity.Email.length() > 100) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' exceeds the maximum length of 100"); + } + if (entity.Phone == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' property is required"); + } + if (entity.Phone != null && entity.Phone.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' exceeds the maximum length of 15"); + } + if (entity.CreatedBy != null && entity.CreatedBy.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'CreatedBy' exceeds the maximum length of 20"); + } + } +} diff --git a/codbex-partners/gen/codbex_partners/api/customers/CustomerController.java b/codbex-partners/gen/codbex_partners/api/customers/CustomerController.java new file mode 100644 index 0000000..7422ce7 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/customers/CustomerController.java @@ -0,0 +1,233 @@ +package gen.codbex_partners.api.customers; + +import gen.codbex_partners.data.customers.CustomerEntity; +import gen.codbex_partners.data.customers.CustomerRepository; + +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-partners - Customer Controller") +public class CustomerController { + + private static final Set FILTER_FIELDS = Set.of("Id", "FirstName", "LastName", "LegalEntityName", "Name", "Email", "Phone", "Country", "City", "Fax", "Address", "PostalCode", "TIN", "IBAN", "ResponsiblePerson", "CreatedAt", "CreatedBy", "UpdatedAt", "UpdatedBy"); + + @Inject + private CustomerRepository repository; + + @Get + @Documentation("List Customer") + 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 Customer") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count Customer with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search Customer") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get Customer by id") + public CustomerEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + CustomerEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Customer not found")); + return entity; + } + + @Post + @Documentation("Create Customer") + public CustomerEntity create(@Body CustomerEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update Customer by id") + public CustomerEntity update(@PathParam("id") Integer id, @Body CustomerEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete Customer by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Customer not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from CustomerEntity 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-partners.Customers.CustomerReadOnly") || UserFacade.isInRole("codbex-partners.Customers.CustomerFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-partners.Customers.CustomerFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(CustomerEntity entity) { + if (entity.FirstName != null && entity.FirstName.length() > 50) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'FirstName' exceeds the maximum length of 50"); + } + if (entity.LastName != null && entity.LastName.length() > 50) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'LastName' exceeds the maximum length of 50"); + } + if (entity.LegalEntityName != null && entity.LegalEntityName.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'LegalEntityName' exceeds the maximum length of 255"); + } + if (entity.Name != null && entity.Name.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 255"); + } + if (entity.Email == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' property is required"); + } + if (entity.Email != null && entity.Email.length() > 100) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' exceeds the maximum length of 100"); + } + if (entity.Phone == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' property is required"); + } + if (entity.Phone != null && entity.Phone.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' exceeds the maximum length of 15"); + } + if (entity.Country == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Country' property is required"); + } + if (entity.City == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'City' property is required"); + } + if (entity.Fax != null && entity.Fax.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Fax' exceeds the maximum length of 20"); + } + if (entity.Address == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Address' property is required"); + } + if (entity.Address != null && entity.Address.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Address' exceeds the maximum length of 255"); + } + if (entity.PostalCode == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'PostalCode' property is required"); + } + if (entity.PostalCode != null && entity.PostalCode.length() > 10) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'PostalCode' exceeds the maximum length of 10"); + } + if (entity.TIN == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'TIN' property is required"); + } + if (entity.TIN != null && entity.TIN.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'TIN' exceeds the maximum length of 15"); + } + if (entity.IBAN == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'IBAN' property is required"); + } + if (entity.IBAN != null && entity.IBAN.length() > 34) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'IBAN' exceeds the maximum length of 34"); + } + if (entity.IBAN != null && !entity.IBAN.toString().matches("^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$")) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The value of 'IBAN' does not match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'"); + } + if (entity.ResponsiblePerson != null && entity.ResponsiblePerson.length() > 150) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'ResponsiblePerson' exceeds the maximum length of 150"); + } + 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-partners/gen/codbex_partners/api/customers/CustomerNoteController.java b/codbex-partners/gen/codbex_partners/api/customers/CustomerNoteController.java new file mode 100644 index 0000000..815abb9 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/customers/CustomerNoteController.java @@ -0,0 +1,184 @@ +package gen.codbex_partners.api.customers; + +import gen.codbex_partners.data.customers.CustomerNoteEntity; +import gen.codbex_partners.data.customers.CustomerNoteRepository; + +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-partners - CustomerNote Controller") +public class CustomerNoteController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Customer", "Note", "CreatedAt", "CreatedBy", "UpdatedAt", "UpdatedBy"); + + @Inject + private CustomerNoteRepository repository; + + @Get + @Documentation("List CustomerNote") + public List getAll(@QueryParam("$limit") Integer limit, + @QueryParam("$offset") Integer offset, + @QueryParam("Customer") String Customer) { + checkPermissions("read"); + int actualLimit = limit != null ? limit.intValue() : 20; + int actualOffset = offset != null ? offset.intValue() : 0; + List result; + if (Customer != null) { + Map params = new LinkedHashMap<>(); + params.put("Customer", Customer); + result = repository.query("from CustomerNoteEntity e where e.Customer = :Customer", params); + } else { + result = repository.findAll(actualLimit, actualOffset); + } + return result; + } + + @Get("/count") + @Documentation("Count CustomerNote") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count CustomerNote with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search CustomerNote") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get CustomerNote by id") + public CustomerNoteEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + CustomerNoteEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "CustomerNote not found")); + return entity; + } + + @Post + @Documentation("Create CustomerNote") + public CustomerNoteEntity create(@Body CustomerNoteEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update CustomerNote by id") + public CustomerNoteEntity update(@PathParam("id") Integer id, @Body CustomerNoteEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete CustomerNote by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "CustomerNote not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from CustomerNoteEntity 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-partners.Customers.CustomerNoteReadOnly") || UserFacade.isInRole("codbex-partners.Customers.CustomerNoteFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-partners.Customers.CustomerNoteFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(CustomerNoteEntity entity) { + if (entity.Note == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Note' property is required"); + } + if (entity.Note != null && entity.Note.length() > 5000) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Note' exceeds the maximum length of 5000"); + } + 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-partners/gen/codbex_partners/api/manufacturers/ManufacturerContactController.java b/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerContactController.java new file mode 100644 index 0000000..9a5b2a5 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerContactController.java @@ -0,0 +1,182 @@ +package gen.codbex_partners.api.manufacturers; + +import gen.codbex_partners.data.manufacturers.ManufacturerContactEntity; +import gen.codbex_partners.data.manufacturers.ManufacturerContactRepository; + +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-partners - ManufacturerContact Controller") +public class ManufacturerContactController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Manufacturer", "Name", "Designation", "Email", "Phone", "CreatedAt", "CreatedBy"); + + @Inject + private ManufacturerContactRepository repository; + + @Get + @Documentation("List ManufacturerContact") + public List getAll(@QueryParam("$limit") Integer limit, + @QueryParam("$offset") Integer offset, + @QueryParam("Manufacturer") String Manufacturer) { + int actualLimit = limit != null ? limit.intValue() : 20; + int actualOffset = offset != null ? offset.intValue() : 0; + List result; + if (Manufacturer != null) { + Map params = new LinkedHashMap<>(); + params.put("Manufacturer", Manufacturer); + result = repository.query("from ManufacturerContactEntity e where e.Manufacturer = :Manufacturer", params); + } else { + result = repository.findAll(actualLimit, actualOffset); + } + return result; + } + + @Get("/count") + @Documentation("Count ManufacturerContact") + public Map count() { + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count ManufacturerContact with filter") + public Map countWithFilter(@Body Map filter) { + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search ManufacturerContact") + public List search(@Body Map filter) { + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get ManufacturerContact by id") + public ManufacturerContactEntity getById(@PathParam("id") Integer id) { + ManufacturerContactEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "ManufacturerContact not found")); + return entity; + } + + @Post + @Documentation("Create ManufacturerContact") + public ManufacturerContactEntity create(@Body ManufacturerContactEntity entity) { + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update ManufacturerContact by id") + public ManufacturerContactEntity update(@PathParam("id") Integer id, @Body ManufacturerContactEntity entity) { + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete ManufacturerContact by id") + public void deleteById(@PathParam("id") Integer id) { + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "ManufacturerContact not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from ManufacturerContactEntity 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(ManufacturerContactEntity entity) { + if (entity.Name == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' property is required"); + } + if (entity.Name != null && entity.Name.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 255"); + } + if (entity.Designation == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Designation' property is required"); + } + if (entity.Designation != null && entity.Designation.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Designation' exceeds the maximum length of 255"); + } + if (entity.Email == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' property is required"); + } + if (entity.Email != null && entity.Email.length() > 100) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' exceeds the maximum length of 100"); + } + if (entity.Phone == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' property is required"); + } + if (entity.Phone != null && entity.Phone.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' exceeds the maximum length of 15"); + } + if (entity.CreatedBy != null && entity.CreatedBy.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'CreatedBy' exceeds the maximum length of 20"); + } + } +} diff --git a/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerController.java b/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerController.java new file mode 100644 index 0000000..2adad68 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerController.java @@ -0,0 +1,215 @@ +package gen.codbex_partners.api.manufacturers; + +import gen.codbex_partners.data.manufacturers.ManufacturerEntity; +import gen.codbex_partners.data.manufacturers.ManufacturerRepository; + +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-partners - Manufacturer Controller") +public class ManufacturerController { + + private static final Set FILTER_FIELDS = Set.of("Id", "FirstName", "LastName", "LegalEntityName", "Name", "Email", "Phone", "Fax", "TIN", "IBAN", "CreatedAt", "CreatedBy", "UpdatedAt", "UpdatedBy"); + + @Inject + private ManufacturerRepository repository; + + @Get + @Documentation("List Manufacturer") + 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 Manufacturer") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count Manufacturer with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search Manufacturer") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get Manufacturer by id") + public ManufacturerEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + ManufacturerEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Manufacturer not found")); + return entity; + } + + @Post + @Documentation("Create Manufacturer") + public ManufacturerEntity create(@Body ManufacturerEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update Manufacturer by id") + public ManufacturerEntity update(@PathParam("id") Integer id, @Body ManufacturerEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete Manufacturer by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Manufacturer not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from ManufacturerEntity 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-partners.Manufacturers.ManufacturerReadOnly") || UserFacade.isInRole("codbex-partners.Manufacturers.ManufacturerFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-partners.Manufacturers.ManufacturerFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(ManufacturerEntity entity) { + if (entity.FirstName != null && entity.FirstName.length() > 50) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'FirstName' exceeds the maximum length of 50"); + } + if (entity.LastName != null && entity.LastName.length() > 50) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'LastName' exceeds the maximum length of 50"); + } + if (entity.LegalEntityName != null && entity.LegalEntityName.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'LegalEntityName' exceeds the maximum length of 255"); + } + if (entity.Name != null && entity.Name.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 255"); + } + if (entity.Email == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' property is required"); + } + if (entity.Email != null && entity.Email.length() > 100) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' exceeds the maximum length of 100"); + } + if (entity.Phone == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' property is required"); + } + if (entity.Phone != null && entity.Phone.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' exceeds the maximum length of 15"); + } + if (entity.Fax == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Fax' property is required"); + } + if (entity.Fax != null && entity.Fax.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Fax' exceeds the maximum length of 20"); + } + if (entity.TIN == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'TIN' property is required"); + } + if (entity.TIN != null && entity.TIN.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'TIN' exceeds the maximum length of 15"); + } + if (entity.IBAN == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'IBAN' property is required"); + } + if (entity.IBAN != null && entity.IBAN.length() > 34) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'IBAN' exceeds the maximum length of 34"); + } + if (entity.IBAN != null && !entity.IBAN.toString().matches("^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$")) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The value of 'IBAN' does not match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'"); + } + 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-partners/gen/codbex_partners/api/manufacturers/ManufacturerNoteController.java b/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerNoteController.java new file mode 100644 index 0000000..70c1fec --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/manufacturers/ManufacturerNoteController.java @@ -0,0 +1,176 @@ +package gen.codbex_partners.api.manufacturers; + +import gen.codbex_partners.data.manufacturers.ManufacturerNoteEntity; +import gen.codbex_partners.data.manufacturers.ManufacturerNoteRepository; + +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-partners - ManufacturerNote Controller") +public class ManufacturerNoteController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Manufacturer", "Note", "CreatedAt", "CreatedBy", "UpdatedAt", "UpdatedBy"); + + @Inject + private ManufacturerNoteRepository repository; + + @Get + @Documentation("List ManufacturerNote") + 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 ManufacturerNote") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count ManufacturerNote with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search ManufacturerNote") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get ManufacturerNote by id") + public ManufacturerNoteEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + ManufacturerNoteEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "ManufacturerNote not found")); + return entity; + } + + @Post + @Documentation("Create ManufacturerNote") + public ManufacturerNoteEntity create(@Body ManufacturerNoteEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update ManufacturerNote by id") + public ManufacturerNoteEntity update(@PathParam("id") Integer id, @Body ManufacturerNoteEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete ManufacturerNote by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "ManufacturerNote not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from ManufacturerNoteEntity 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-partners.Manufacturers.ManufacturerNoteReadOnly") || UserFacade.isInRole("codbex-partners.Manufacturers.ManufacturerNoteFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-partners.Manufacturers.ManufacturerNoteFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(ManufacturerNoteEntity entity) { + if (entity.Note == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Note' property is required"); + } + if (entity.Note != null && entity.Note.length() > 5000) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Note' exceeds the maximum length of 5000"); + } + 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-partners/gen/codbex_partners/api/suppliers/SupplierContactController.java b/codbex-partners/gen/codbex_partners/api/suppliers/SupplierContactController.java new file mode 100644 index 0000000..84d84b7 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/suppliers/SupplierContactController.java @@ -0,0 +1,182 @@ +package gen.codbex_partners.api.suppliers; + +import gen.codbex_partners.data.suppliers.SupplierContactEntity; +import gen.codbex_partners.data.suppliers.SupplierContactRepository; + +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-partners - SupplierContact Controller") +public class SupplierContactController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Supplier", "Name", "Designation", "Email", "Phone", "CreatedAt", "CreatedBy"); + + @Inject + private SupplierContactRepository repository; + + @Get + @Documentation("List SupplierContact") + public List getAll(@QueryParam("$limit") Integer limit, + @QueryParam("$offset") Integer offset, + @QueryParam("Supplier") String Supplier) { + int actualLimit = limit != null ? limit.intValue() : 20; + int actualOffset = offset != null ? offset.intValue() : 0; + List result; + if (Supplier != null) { + Map params = new LinkedHashMap<>(); + params.put("Supplier", Supplier); + result = repository.query("from SupplierContactEntity e where e.Supplier = :Supplier", params); + } else { + result = repository.findAll(actualLimit, actualOffset); + } + return result; + } + + @Get("/count") + @Documentation("Count SupplierContact") + public Map count() { + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count SupplierContact with filter") + public Map countWithFilter(@Body Map filter) { + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search SupplierContact") + public List search(@Body Map filter) { + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get SupplierContact by id") + public SupplierContactEntity getById(@PathParam("id") Integer id) { + SupplierContactEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "SupplierContact not found")); + return entity; + } + + @Post + @Documentation("Create SupplierContact") + public SupplierContactEntity create(@Body SupplierContactEntity entity) { + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update SupplierContact by id") + public SupplierContactEntity update(@PathParam("id") Integer id, @Body SupplierContactEntity entity) { + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete SupplierContact by id") + public void deleteById(@PathParam("id") Integer id) { + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "SupplierContact not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from SupplierContactEntity 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(SupplierContactEntity entity) { + if (entity.Name == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' property is required"); + } + if (entity.Name != null && entity.Name.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 255"); + } + if (entity.Designation == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Designation' property is required"); + } + if (entity.Designation != null && entity.Designation.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Designation' exceeds the maximum length of 255"); + } + if (entity.Email == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' property is required"); + } + if (entity.Email != null && entity.Email.length() > 100) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' exceeds the maximum length of 100"); + } + if (entity.Phone == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' property is required"); + } + if (entity.Phone != null && entity.Phone.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' exceeds the maximum length of 15"); + } + if (entity.CreatedBy != null && entity.CreatedBy.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'CreatedBy' exceeds the maximum length of 20"); + } + } +} diff --git a/codbex-partners/gen/codbex_partners/api/suppliers/SupplierController.java b/codbex-partners/gen/codbex_partners/api/suppliers/SupplierController.java new file mode 100644 index 0000000..085e67e --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/suppliers/SupplierController.java @@ -0,0 +1,215 @@ +package gen.codbex_partners.api.suppliers; + +import gen.codbex_partners.data.suppliers.SupplierEntity; +import gen.codbex_partners.data.suppliers.SupplierRepository; + +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-partners - Supplier Controller") +public class SupplierController { + + private static final Set FILTER_FIELDS = Set.of("Id", "FirstName", "LastName", "LegalEntityName", "Name", "Email", "Phone", "Fax", "TIN", "IBAN", "CreatedAt", "CreatedBy", "UpdatedAt", "UpdatedBy"); + + @Inject + private SupplierRepository repository; + + @Get + @Documentation("List Supplier") + 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 Supplier") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count Supplier with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search Supplier") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get Supplier by id") + public SupplierEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + SupplierEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Supplier not found")); + return entity; + } + + @Post + @Documentation("Create Supplier") + public SupplierEntity create(@Body SupplierEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update Supplier by id") + public SupplierEntity update(@PathParam("id") Integer id, @Body SupplierEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete Supplier by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Supplier not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from SupplierEntity 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-partners.Suppliers.SupplierReadOnly") || UserFacade.isInRole("codbex-partners.Suppliers.SupplierFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-partners.Suppliers.SupplierFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(SupplierEntity entity) { + if (entity.FirstName != null && entity.FirstName.length() > 50) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'FirstName' exceeds the maximum length of 50"); + } + if (entity.LastName != null && entity.LastName.length() > 50) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'LastName' exceeds the maximum length of 50"); + } + if (entity.LegalEntityName != null && entity.LegalEntityName.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'LegalEntityName' exceeds the maximum length of 255"); + } + if (entity.Name != null && entity.Name.length() > 255) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Name' exceeds the maximum length of 255"); + } + if (entity.Email == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' property is required"); + } + if (entity.Email != null && entity.Email.length() > 100) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Email' exceeds the maximum length of 100"); + } + if (entity.Phone == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' property is required"); + } + if (entity.Phone != null && entity.Phone.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Phone' exceeds the maximum length of 15"); + } + if (entity.Fax == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Fax' property is required"); + } + if (entity.Fax != null && entity.Fax.length() > 20) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Fax' exceeds the maximum length of 20"); + } + if (entity.TIN == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'TIN' property is required"); + } + if (entity.TIN != null && entity.TIN.length() > 15) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'TIN' exceeds the maximum length of 15"); + } + if (entity.IBAN == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'IBAN' property is required"); + } + if (entity.IBAN != null && entity.IBAN.length() > 34) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'IBAN' exceeds the maximum length of 34"); + } + if (entity.IBAN != null && !entity.IBAN.toString().matches("^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$")) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The value of 'IBAN' does not match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'"); + } + 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-partners/gen/codbex_partners/api/suppliers/SupplierNoteController.java b/codbex-partners/gen/codbex_partners/api/suppliers/SupplierNoteController.java new file mode 100644 index 0000000..74fd90c --- /dev/null +++ b/codbex-partners/gen/codbex_partners/api/suppliers/SupplierNoteController.java @@ -0,0 +1,184 @@ +package gen.codbex_partners.api.suppliers; + +import gen.codbex_partners.data.suppliers.SupplierNoteEntity; +import gen.codbex_partners.data.suppliers.SupplierNoteRepository; + +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-partners - SupplierNote Controller") +public class SupplierNoteController { + + private static final Set FILTER_FIELDS = Set.of("Id", "Supplier", "Note", "CreatedAt", "CreatedBy", "UpdatedAt", "UpdatedBy"); + + @Inject + private SupplierNoteRepository repository; + + @Get + @Documentation("List SupplierNote") + public List getAll(@QueryParam("$limit") Integer limit, + @QueryParam("$offset") Integer offset, + @QueryParam("Supplier") String Supplier) { + checkPermissions("read"); + int actualLimit = limit != null ? limit.intValue() : 20; + int actualOffset = offset != null ? offset.intValue() : 0; + List result; + if (Supplier != null) { + Map params = new LinkedHashMap<>(); + params.put("Supplier", Supplier); + result = repository.query("from SupplierNoteEntity e where e.Supplier = :Supplier", params); + } else { + result = repository.findAll(actualLimit, actualOffset); + } + return result; + } + + @Get("/count") + @Documentation("Count SupplierNote") + public Map count() { + checkPermissions("read"); + return Map.of("count", repository.count()); + } + + @Post("/count") + @Documentation("Count SupplierNote with filter") + public Map countWithFilter(@Body Map filter) { + checkPermissions("read"); + return Map.of("count", (long) runFilter(filter).size()); + } + + @Post("/search") + @Documentation("Search SupplierNote") + public List search(@Body Map filter) { + checkPermissions("read"); + List result = runFilter(filter); + return result; + } + + @Get("/{id}") + @Documentation("Get SupplierNote by id") + public SupplierNoteEntity getById(@PathParam("id") Integer id) { + checkPermissions("read"); + SupplierNoteEntity entity = repository.findOne(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "SupplierNote not found")); + return entity; + } + + @Post + @Documentation("Create SupplierNote") + public SupplierNoteEntity create(@Body SupplierNoteEntity entity) { + checkPermissions("write"); + validate(entity); + return repository.save(entity); + } + + @Put("/{id}") + @Documentation("Update SupplierNote by id") + public SupplierNoteEntity update(@PathParam("id") Integer id, @Body SupplierNoteEntity entity) { + checkPermissions("write"); + entity.Id = id; + validate(entity); + return repository.update(entity); + } + + @Delete("/{id}") + @Documentation("Delete SupplierNote by id") + public void deleteById(@PathParam("id") Integer id) { + checkPermissions("write"); + if (repository.findOne(id).isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "SupplierNote not found"); + } + repository.deleteById(id); + } + + private List runFilter(Map filter) { + StringBuilder hql = new StringBuilder("from SupplierNoteEntity 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-partners.Suppliers.SupplierNoteReadOnly") || UserFacade.isInRole("codbex-partners.Suppliers.SupplierNoteFullAccess"))) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + if ("write".equals(op) && !UserFacade.isInRole("codbex-partners.Suppliers.SupplierNoteFullAccess")) { + throw new ResponseStatusException(HttpStatus.FORBIDDEN); + } + } + + private static void validate(SupplierNoteEntity entity) { + if (entity.Note == null) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Note' property is required"); + } + if (entity.Note != null && entity.Note.length() > 5000) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The 'Note' exceeds the maximum length of 5000"); + } + 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-partners/gen/codbex-partners/data/Customers/Customer.extensionpoint b/codbex-partners/gen/codbex_partners/data/customers/Customer.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Customers/Customer.extensionpoint rename to codbex-partners/gen/codbex_partners/data/customers/Customer.extensionpoint index ea09d03..d435e56 100644 --- a/codbex-partners/gen/codbex-partners/data/Customers/Customer.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/customers/Customer.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Customers-Customer", "description": "Extension Point for the codbex-partners-Customers-Customer entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex-partners/data/Customers/CustomerContact.extensionpoint b/codbex-partners/gen/codbex_partners/data/customers/CustomerContact.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Customers/CustomerContact.extensionpoint rename to codbex-partners/gen/codbex_partners/data/customers/CustomerContact.extensionpoint index 30191ad..8e5593f 100644 --- a/codbex-partners/gen/codbex-partners/data/Customers/CustomerContact.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/customers/CustomerContact.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Customers-CustomerContact", "description": "Extension Point for the codbex-partners-Customers-CustomerContact entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex_partners/data/customers/CustomerContactEntity.java b/codbex-partners/gen/codbex_partners/data/customers/CustomerContactEntity.java new file mode 100644 index 0000000..1aa3655 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/customers/CustomerContactEntity.java @@ -0,0 +1,56 @@ +package gen.codbex_partners.data.customers; + +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_CUSTOMERCONTACT") +@Documentation("CustomerContact entity mapping") +public class CustomerContactEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "CUSTOMERCONTACT_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "CUSTOMERCONTACT_CUSTOMER", nullable = true) + @Documentation("Customer") + public Integer Customer; + + @Column(name = "CUSTOMERCONTACT_NAME", length = 255, nullable = false) + @Documentation("Name") + public String Name; + + @Column(name = "CUSTOMERCONTACT_DESIGNATION", length = 255, nullable = false) + @Documentation("Designation") + public String Designation; + + @Column(name = "CUSTOMERCONTACT_EMAIL", length = 100, nullable = false, unique = true) + @Documentation("Email") + public String Email; + + @Column(name = "CUSTOMERCONTACT_PHONE", length = 15, nullable = false) + @Documentation("Phone") + public String Phone; + + @CreatedAt + @Column(name = "CUSTOMERCONTACT_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "CUSTOMERCONTACT_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + +} diff --git a/codbex-partners/gen/codbex_partners/data/customers/CustomerContactRepository.java b/codbex-partners/gen/codbex_partners/data/customers/CustomerContactRepository.java new file mode 100644 index 0000000..b286f84 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/customers/CustomerContactRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_partners.data.customers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class CustomerContactRepository extends JavaRepository { + + public CustomerContactRepository() { + super(CustomerContactEntity.class); + } +} diff --git a/codbex-partners/gen/codbex_partners/data/customers/CustomerEntity.java b/codbex-partners/gen/codbex_partners/data/customers/CustomerEntity.java new file mode 100644 index 0000000..767a8e6 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/customers/CustomerEntity.java @@ -0,0 +1,102 @@ +package gen.codbex_partners.data.customers; + +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_CUSTOMER") +@Documentation("Customer entity mapping") +public class CustomerEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "CUSTOMER_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "CUSTOMER_FIRSTNAME", length = 50, nullable = true) + @Documentation("FirstName") + public String FirstName; + + @Column(name = "CUSTOMER_LASTNAME", length = 50, nullable = true) + @Documentation("LastName") + public String LastName; + + @Column(name = "CUSTOMER_LEGALENTITYNAME", length = 255, nullable = true) + @Documentation("LegalEntityName") + public String LegalEntityName; + + @Column(name = "CUSTOMER_NAME", length = 255, nullable = true) + @Documentation("Name") + public String Name; + + @Column(name = "CUSTOMER_EMAIL", length = 100, nullable = false, unique = true) + @Documentation("Email") + public String Email; + + @Column(name = "CUSTOMER_PHONE", length = 15, nullable = false) + @Documentation("Phone") + public String Phone; + + @Column(name = "CUSTOMER_COUNTRY", nullable = false) + @Documentation("Country") + public Integer Country; + + @Column(name = "CUSTOMER_CITY", nullable = false) + @Documentation("City") + public Integer City; + + @Column(name = "CUSTOMER_FAX", length = 20, nullable = true) + @Documentation("Fax") + public String Fax; + + @Column(name = "CUSTOMER_ADDRESS", length = 255, nullable = false) + @Documentation("Address") + public String Address; + + @Column(name = "CUSTOMER_POSTALCODE", length = 10, nullable = false) + @Documentation("PostalCode") + public String PostalCode; + + @Column(name = "CUSTOMER_TIN", length = 15, nullable = false, unique = true) + @Documentation("TIN") + public String TIN; + + @Column(name = "CUSTOMER_IBAN", length = 34, nullable = false, unique = true) + @Documentation("IBAN") + public String IBAN; + + @Column(name = "CUSTOMER_RESPONSIBLEPERSON", length = 150, nullable = true) + @Documentation("ResponsiblePerson") + public String ResponsiblePerson; + + @CreatedAt + @Column(name = "CUSTOMER_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "CUSTOMER_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + + @UpdatedAt + @Column(name = "CUSTOMER_UPDATEDAT", nullable = true) + @Documentation("UpdatedAt") + public java.time.Instant UpdatedAt; + + @UpdatedBy + @Column(name = "CUSTOMER_UPDATEDBY", length = 20, nullable = true) + @Documentation("UpdatedBy") + public String UpdatedBy; + +} diff --git a/codbex-partners/gen/codbex-partners/data/Customers/CustomerNote.extensionpoint b/codbex-partners/gen/codbex_partners/data/customers/CustomerNote.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Customers/CustomerNote.extensionpoint rename to codbex-partners/gen/codbex_partners/data/customers/CustomerNote.extensionpoint index f351445..2650427 100644 --- a/codbex-partners/gen/codbex-partners/data/Customers/CustomerNote.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/customers/CustomerNote.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Customers-CustomerNote", "description": "Extension Point for the codbex-partners-Customers-CustomerNote entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex_partners/data/customers/CustomerNoteEntity.java b/codbex-partners/gen/codbex_partners/data/customers/CustomerNoteEntity.java new file mode 100644 index 0000000..1767f96 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/customers/CustomerNoteEntity.java @@ -0,0 +1,54 @@ +package gen.codbex_partners.data.customers; + +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_CUSTOMERNOTE") +@Documentation("CustomerNote entity mapping") +public class CustomerNoteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "CUSTOMERNOTE_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "CUSTOMERNOTE_CUSTOMER", nullable = true) + @Documentation("Customer") + public Integer Customer; + + @Column(name = "CUSTOMERNOTE_NOTE", length = 5000, nullable = false) + @Documentation("Note") + public String Note; + + @CreatedAt + @Column(name = "CUSTOMERNOTE_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "CUSTOMERNOTE_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + + @UpdatedAt + @Column(name = "CUSTOMERNOTE_UPDATEDAT", nullable = true) + @Documentation("UpdatedAt") + public java.time.Instant UpdatedAt; + + @UpdatedBy + @Column(name = "CUSTOMERNOTE_UPDATEDBY", length = 20, nullable = true) + @Documentation("UpdatedBy") + public String UpdatedBy; + +} diff --git a/codbex-partners/gen/codbex_partners/data/customers/CustomerNoteRepository.java b/codbex-partners/gen/codbex_partners/data/customers/CustomerNoteRepository.java new file mode 100644 index 0000000..dada9eb --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/customers/CustomerNoteRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_partners.data.customers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class CustomerNoteRepository extends JavaRepository { + + public CustomerNoteRepository() { + super(CustomerNoteEntity.class); + } +} diff --git a/codbex-partners/gen/codbex_partners/data/customers/CustomerRepository.java b/codbex-partners/gen/codbex_partners/data/customers/CustomerRepository.java new file mode 100644 index 0000000..4ca60bf --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/customers/CustomerRepository.java @@ -0,0 +1,24 @@ +package gen.codbex_partners.data.customers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class CustomerRepository extends JavaRepository { + + public CustomerRepository() { + super(CustomerEntity.class); + } + + @Override + public CustomerEntity save(CustomerEntity entity) { + entity.Name = (entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; + return super.save(entity); + } + + @Override + public CustomerEntity update(CustomerEntity entity) { + entity.Name = (entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; + return super.update(entity); + } +} diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/Manufacturer.extensionpoint b/codbex-partners/gen/codbex_partners/data/manufacturers/Manufacturer.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Manufacturers/Manufacturer.extensionpoint rename to codbex-partners/gen/codbex_partners/data/manufacturers/Manufacturer.extensionpoint index e4ca25f..db4cba7 100644 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/Manufacturer.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/Manufacturer.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Manufacturers-Manufacturer", "description": "Extension Point for the codbex-partners-Manufacturers-Manufacturer entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContact.extensionpoint b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContact.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContact.extensionpoint rename to codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContact.extensionpoint index 9617477..1f7650b 100644 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerContact.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContact.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Manufacturers-ManufacturerContact", "description": "Extension Point for the codbex-partners-Manufacturers-ManufacturerContact entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContactEntity.java b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContactEntity.java new file mode 100644 index 0000000..daab4ee --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContactEntity.java @@ -0,0 +1,56 @@ +package gen.codbex_partners.data.manufacturers; + +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_MANUFACTURERCONTACT") +@Documentation("ManufacturerContact entity mapping") +public class ManufacturerContactEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "MANUFACTURERCONTACT_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "MANUFACTURERCONTACT_MANUFACTURER", nullable = true) + @Documentation("Manufacturer") + public Integer Manufacturer; + + @Column(name = "MANUFACTURERCONTACT_NAME", length = 255, nullable = false) + @Documentation("Name") + public String Name; + + @Column(name = "MANUFACTURERCONTACT_DESIGNATION", length = 255, nullable = false) + @Documentation("Designation") + public String Designation; + + @Column(name = "MANUFACTURERCONTACT_EMAIL", length = 100, nullable = false, unique = true) + @Documentation("Email") + public String Email; + + @Column(name = "MANUFACTURERCONTACT_PHONE", length = 15, nullable = false) + @Documentation("Phone") + public String Phone; + + @CreatedAt + @Column(name = "MANUFACTURERCONTACT_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "MANUFACTURERCONTACT_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + +} diff --git a/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContactRepository.java b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContactRepository.java new file mode 100644 index 0000000..400b1ea --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerContactRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_partners.data.manufacturers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class ManufacturerContactRepository extends JavaRepository { + + public ManufacturerContactRepository() { + super(ManufacturerContactEntity.class); + } +} diff --git a/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerEntity.java b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerEntity.java new file mode 100644 index 0000000..537e645 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerEntity.java @@ -0,0 +1,82 @@ +package gen.codbex_partners.data.manufacturers; + +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_MANUFACTURER") +@Documentation("Manufacturer entity mapping") +public class ManufacturerEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "MANUFACTURER_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "MANUFACTURER_FIRSTNAME", length = 50, nullable = true) + @Documentation("FirstName") + public String FirstName; + + @Column(name = "MANUFACTURER_LASTNAME", length = 50, nullable = true) + @Documentation("LastName") + public String LastName; + + @Column(name = "MANUFACTURER_LEGALENTITYNAME", length = 255, nullable = true) + @Documentation("LegalEntityName") + public String LegalEntityName; + + @Column(name = "MANUFACTURER_NAME", length = 255, nullable = true) + @Documentation("Name") + public String Name; + + @Column(name = "MANUFACTURER_EMAIL", length = 100, nullable = false, unique = true) + @Documentation("Email") + public String Email; + + @Column(name = "MANUFACTURER_PHONE", length = 15, nullable = false) + @Documentation("Phone") + public String Phone; + + @Column(name = "MANUFACTURER_FAX", length = 20, nullable = false) + @Documentation("Fax") + public String Fax; + + @Column(name = "MANUFACTURER_TIN", length = 15, nullable = false, unique = true) + @Documentation("TIN") + public String TIN; + + @Column(name = "MANUFACTURER_IBAN", length = 34, nullable = false, unique = true) + @Documentation("IBAN") + public String IBAN; + + @CreatedAt + @Column(name = "MANUFACTURER_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "MANUFACTURER_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + + @UpdatedAt + @Column(name = "MANUFACTURER_UPDATEDAT", nullable = true) + @Documentation("UpdatedAt") + public java.time.Instant UpdatedAt; + + @UpdatedBy + @Column(name = "MANUFACTURER_UPDATEDBY", length = 20, nullable = true) + @Documentation("UpdatedBy") + public String UpdatedBy; + +} diff --git a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNote.extensionpoint b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNote.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNote.extensionpoint rename to codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNote.extensionpoint index 5f3b2f1..ea59855 100644 --- a/codbex-partners/gen/codbex-partners/data/Manufacturers/ManufacturerNote.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNote.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Manufacturers-ManufacturerNote", "description": "Extension Point for the codbex-partners-Manufacturers-ManufacturerNote entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNoteEntity.java b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNoteEntity.java new file mode 100644 index 0000000..628b772 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNoteEntity.java @@ -0,0 +1,54 @@ +package gen.codbex_partners.data.manufacturers; + +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_MANUFACTURERNOTE") +@Documentation("ManufacturerNote entity mapping") +public class ManufacturerNoteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "MANUFACTURERNOTE_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "MANUFACTURERNOTE_MANUFACTURER", nullable = true) + @Documentation("Manufacturer") + public Integer Manufacturer; + + @Column(name = "MANUFACTURERNOTE_NOTE", length = 5000, nullable = false) + @Documentation("Note") + public String Note; + + @CreatedAt + @Column(name = "MANUFACTURERNOTE_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "MANUFACTURERNOTE_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + + @UpdatedAt + @Column(name = "MANUFACTURERNOTE_UPDATEDAT", nullable = true) + @Documentation("UpdatedAt") + public java.time.Instant UpdatedAt; + + @UpdatedBy + @Column(name = "MANUFACTURERNOTE_UPDATEDBY", length = 20, nullable = true) + @Documentation("UpdatedBy") + public String UpdatedBy; + +} diff --git a/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNoteRepository.java b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNoteRepository.java new file mode 100644 index 0000000..2bf1bb1 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerNoteRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_partners.data.manufacturers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class ManufacturerNoteRepository extends JavaRepository { + + public ManufacturerNoteRepository() { + super(ManufacturerNoteEntity.class); + } +} diff --git a/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerRepository.java b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerRepository.java new file mode 100644 index 0000000..a90fb42 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/manufacturers/ManufacturerRepository.java @@ -0,0 +1,24 @@ +package gen.codbex_partners.data.manufacturers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class ManufacturerRepository extends JavaRepository { + + public ManufacturerRepository() { + super(ManufacturerEntity.class); + } + + @Override + public ManufacturerEntity save(ManufacturerEntity entity) { + entity.Name = (entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; + return super.save(entity); + } + + @Override + public ManufacturerEntity update(ManufacturerEntity entity) { + entity.Name = (entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; + return super.update(entity); + } +} diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/Supplier.extensionpoint b/codbex-partners/gen/codbex_partners/data/suppliers/Supplier.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Suppliers/Supplier.extensionpoint rename to codbex-partners/gen/codbex_partners/data/suppliers/Supplier.extensionpoint index 8909ecb..7fe1450 100644 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/Supplier.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/suppliers/Supplier.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Suppliers-Supplier", "description": "Extension Point for the codbex-partners-Suppliers-Supplier entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContact.extensionpoint b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierContact.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContact.extensionpoint rename to codbex-partners/gen/codbex_partners/data/suppliers/SupplierContact.extensionpoint index 8c5a275..95ba585 100644 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierContact.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierContact.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Suppliers-SupplierContact", "description": "Extension Point for the codbex-partners-Suppliers-SupplierContact entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex_partners/data/suppliers/SupplierContactEntity.java b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierContactEntity.java new file mode 100644 index 0000000..d7e5712 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierContactEntity.java @@ -0,0 +1,56 @@ +package gen.codbex_partners.data.suppliers; + +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_SUPPLIERCONTACT") +@Documentation("SupplierContact entity mapping") +public class SupplierContactEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "SUPPLIERCONTACT_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "SUPPLIERCONTACT_SUPPLIER", nullable = true) + @Documentation("Supplier") + public Integer Supplier; + + @Column(name = "SUPPLIERCONTACT_NAME", length = 255, nullable = false) + @Documentation("Name") + public String Name; + + @Column(name = "SUPPLIERCONTACT_DESIGNATION", length = 255, nullable = false) + @Documentation("Designation") + public String Designation; + + @Column(name = "SUPPLIERCONTACT_EMAIL", length = 100, nullable = false, unique = true) + @Documentation("Email") + public String Email; + + @Column(name = "SUPPLIERCONTACT_PHONE", length = 15, nullable = false) + @Documentation("Phone") + public String Phone; + + @CreatedAt + @Column(name = "SUPPLIERCONTACT_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "SUPPLIERCONTACT_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + +} diff --git a/codbex-partners/gen/codbex_partners/data/suppliers/SupplierContactRepository.java b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierContactRepository.java new file mode 100644 index 0000000..493917f --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierContactRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_partners.data.suppliers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class SupplierContactRepository extends JavaRepository { + + public SupplierContactRepository() { + super(SupplierContactEntity.class); + } +} diff --git a/codbex-partners/gen/codbex_partners/data/suppliers/SupplierEntity.java b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierEntity.java new file mode 100644 index 0000000..91ecb64 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierEntity.java @@ -0,0 +1,82 @@ +package gen.codbex_partners.data.suppliers; + +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_SUPPLIER") +@Documentation("Supplier entity mapping") +public class SupplierEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "SUPPLIER_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "SUPPLIER_FIRSTNAME", length = 50, nullable = true) + @Documentation("FirstName") + public String FirstName; + + @Column(name = "SUPPLIER_LASTNAME", length = 50, nullable = true) + @Documentation("LastName") + public String LastName; + + @Column(name = "SUPPLIER_LEGALENTITYNAME", length = 255, nullable = true) + @Documentation("LegalEntityName") + public String LegalEntityName; + + @Column(name = "SUPPLIER_NAME", length = 255, nullable = true) + @Documentation("Name") + public String Name; + + @Column(name = "SUPPLIER_EMAIL", length = 100, nullable = false, unique = true) + @Documentation("Email") + public String Email; + + @Column(name = "SUPPLIER_PHONE", length = 15, nullable = false) + @Documentation("Phone") + public String Phone; + + @Column(name = "SUPPLIER_FAX", length = 20, nullable = false) + @Documentation("Fax") + public String Fax; + + @Column(name = "SUPPLIER_TIN", length = 15, nullable = false, unique = true) + @Documentation("TIN") + public String TIN; + + @Column(name = "SUPPLIER_IBAN", length = 34, nullable = false, unique = true) + @Documentation("IBAN") + public String IBAN; + + @CreatedAt + @Column(name = "SUPPLIER_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "SUPPLIER_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + + @UpdatedAt + @Column(name = "SUPPLIER_UPDATEDAT", nullable = true) + @Documentation("UpdatedAt") + public java.time.Instant UpdatedAt; + + @UpdatedBy + @Column(name = "SUPPLIER_UPDATEDBY", length = 20, nullable = true) + @Documentation("UpdatedBy") + public String UpdatedBy; + +} diff --git a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNote.extensionpoint b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierNote.extensionpoint similarity index 98% rename from codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNote.extensionpoint rename to codbex-partners/gen/codbex_partners/data/suppliers/SupplierNote.extensionpoint index 3ca580d..5bf4c48 100644 --- a/codbex-partners/gen/codbex-partners/data/Suppliers/SupplierNote.extensionpoint +++ b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierNote.extensionpoint @@ -1,4 +1,4 @@ { "name": "codbex-partners-Suppliers-SupplierNote", "description": "Extension Point for the codbex-partners-Suppliers-SupplierNote entity" -} \ No newline at end of file +} diff --git a/codbex-partners/gen/codbex_partners/data/suppliers/SupplierNoteEntity.java b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierNoteEntity.java new file mode 100644 index 0000000..256170b --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierNoteEntity.java @@ -0,0 +1,54 @@ +package gen.codbex_partners.data.suppliers; + +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_SUPPLIERNOTE") +@Documentation("SupplierNote entity mapping") +public class SupplierNoteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "SUPPLIERNOTE_ID") + @Documentation("Id") + public Integer Id; + + @Column(name = "SUPPLIERNOTE_SUPPLIER", nullable = true) + @Documentation("Supplier") + public Integer Supplier; + + @Column(name = "SUPPLIERNOTE_NOTE", length = 5000, nullable = false) + @Documentation("Note") + public String Note; + + @CreatedAt + @Column(name = "SUPPLIERNOTE_CREATEDAT", nullable = true) + @Documentation("CreatedAt") + public java.time.Instant CreatedAt; + + @CreatedBy + @Column(name = "SUPPLIERNOTE_CREATEDBY", length = 20, nullable = true) + @Documentation("CreatedBy") + public String CreatedBy; + + @UpdatedAt + @Column(name = "SUPPLIERNOTE_UPDATEDAT", nullable = true) + @Documentation("UpdatedAt") + public java.time.Instant UpdatedAt; + + @UpdatedBy + @Column(name = "SUPPLIERNOTE_UPDATEDBY", length = 20, nullable = true) + @Documentation("UpdatedBy") + public String UpdatedBy; + +} diff --git a/codbex-partners/gen/codbex_partners/data/suppliers/SupplierNoteRepository.java b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierNoteRepository.java new file mode 100644 index 0000000..7953063 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierNoteRepository.java @@ -0,0 +1,12 @@ +package gen.codbex_partners.data.suppliers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class SupplierNoteRepository extends JavaRepository { + + public SupplierNoteRepository() { + super(SupplierNoteEntity.class); + } +} diff --git a/codbex-partners/gen/codbex_partners/data/suppliers/SupplierRepository.java b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierRepository.java new file mode 100644 index 0000000..1901e21 --- /dev/null +++ b/codbex-partners/gen/codbex_partners/data/suppliers/SupplierRepository.java @@ -0,0 +1,24 @@ +package gen.codbex_partners.data.suppliers; + +import org.eclipse.dirigible.components.data.store.java.repository.JavaRepository; +import org.eclipse.dirigible.sdk.component.Repository; + +@Repository +public class SupplierRepository extends JavaRepository { + + public SupplierRepository() { + super(SupplierEntity.class); + } + + @Override + public SupplierEntity save(SupplierEntity entity) { + entity.Name = (entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; + return super.save(entity); + } + + @Override + public SupplierEntity update(SupplierEntity entity) { + entity.Name = (entity.FirstName != null && !entity.FirstName.trim().isEmpty() && entity.LastName != null && !entity.LastName.trim().isEmpty()) ? (entity.FirstName + " " + entity.LastName) : entity.LegalEntityName; + return super.update(entity); + } +} diff --git a/codbex-partners/gen/codbex-partners/roles/default-roles.roles b/codbex-partners/gen/codbex_partners/roles/default-roles.roles similarity index 99% rename from codbex-partners/gen/codbex-partners/roles/default-roles.roles rename to codbex-partners/gen/codbex_partners/roles/default-roles.roles index 38b4711..dfcfc7c 100644 --- a/codbex-partners/gen/codbex-partners/roles/default-roles.roles +++ b/codbex-partners/gen/codbex_partners/roles/default-roles.roles @@ -55,4 +55,4 @@ "name": "codbex-partners.Customers.CustomerContactFullAccess", "description": "A role that grants full access for CustomerContact." } -] \ No newline at end of file +] diff --git a/codbex-partners/translations/en-US/codbex-partners.model.json b/codbex-partners/translations/en-US/codbex-partners.model.json index 590f92d..92d9921 100644 --- a/codbex-partners/translations/en-US/codbex-partners.model.json +++ b/codbex-partners/translations/en-US/codbex-partners.model.json @@ -74,9 +74,9 @@ "CUSTOMER_NAME": "Name", "CUSTOMER_EMAIL": "Email", "CUSTOMER_PHONE": "Phone", - "CUSTOMER_FAX": "Fax", "CUSTOMER_COUNTRY": "Country", "CUSTOMER_CITY": "City", + "CUSTOMER_FAX": "Fax", "CUSTOMER_ADDRESS": "Address", "CUSTOMER_POSTALCODE": "PostalCode", "CUSTOMER_TIN": "TIN", @@ -125,16 +125,6 @@ "MANUFACTURERNOTE_CREATEDBY": "CreatedBy", "MANUFACTURERNOTE_UPDATEDAT": "UpdatedAt", "MANUFACTURERNOTE_UPDATEDBY": "UpdatedBy", - "CITY": "City", - "CITY_ID": "Id", - "CITY_NAME": "Name", - "CITY_COUNTRY": "Country", - "COUNTRY": "Country", - "COUNTRY_ID": "Id", - "COUNTRY_NAME": "Name", - "COUNTRY_CODE2": "Code2", - "COUNTRY_CODE3": "Code3", - "COUNTRY_NUMERIC": "Numeric", "MANUFACTURER": "Manufacturer", "MANUFACTURER_ID": "Id", "MANUFACTURER_FIRSTNAME": "FirstName", @@ -177,6 +167,16 @@ "MANUFACTURERCONTACT_PHONE": "Phone", "MANUFACTURERCONTACT_CREATEDAT": "CreatedAt", "MANUFACTURERCONTACT_CREATEDBY": "CreatedBy", + "COUNTRY": "Country", + "COUNTRY_ID": "Id", + "COUNTRY_NAME": "Name", + "COUNTRY_CODE2": "Code2", + "COUNTRY_CODE3": "Code3", + "COUNTRY_NUMERIC": "Numeric", + "CITY": "City", + "CITY_ID": "Id", + "CITY_NAME": "Name", + "CITY_COUNTRY": "Country", "Customers": "Customers", "Suppliers": "Suppliers", "Manufacturers": "Manufacturers"