Skip to content

Commit

Permalink
embeddable adaptation
Browse files Browse the repository at this point in the history
  • Loading branch information
delchev committed Feb 29, 2024
1 parent 391eebe commit 1f88d16
Show file tree
Hide file tree
Showing 27 changed files with 806 additions and 193 deletions.
26 changes: 13 additions & 13 deletions codbex-currencies/codbex-currencies.edm

Large diffs are not rendered by default.

106 changes: 90 additions & 16 deletions codbex-currencies/codbex-currencies.gen

Large diffs are not rendered by default.

54 changes: 44 additions & 10 deletions codbex-currencies/codbex-currencies.model
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
{
"properties": [
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "true",
"dataLength": "0",
"dataName": "CURRENCY_ID",
Expand All @@ -13,13 +14,16 @@
"dataType": "INTEGER",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Id",
"widgetIsMajor": "true",
"widgetLength": "20",
"widgetSize": "",
"widgetType": "TEXTBOX"
},
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "false",
"dataLength": "3",
"dataName": "CURRENCY_CODE",
Expand All @@ -30,13 +34,16 @@
"dataType": "VARCHAR",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Code",
"widgetIsMajor": "true",
"widgetLength": "3",
"widgetSize": "fd-col-md--2 fd-col--3",
"widgetType": "TEXTBOX"
},
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "false",
"dataLength": "127",
"dataName": "CURRENCY_NAME",
Expand All @@ -47,13 +54,16 @@
"dataType": "VARCHAR",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Name",
"widgetIsMajor": "true",
"widgetLength": "20",
"widgetSize": "fd-col-md--6 fd-col--9",
"widgetType": "TEXTBOX"
},
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "false",
"dataLength": "3",
"dataName": "CURRENCY_NUMERIC",
Expand All @@ -64,13 +74,16 @@
"dataType": "VARCHAR",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Numeric",
"widgetIsMajor": "true",
"widgetLength": "3",
"widgetSize": "fd-col-md--2 fd-col--3",
"widgetType": "TEXTBOX"
},
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "false",
"dataLength": "20",
"dataName": "CURRENCY_ROUNDING",
Expand All @@ -81,13 +94,16 @@
"dataType": "INTEGER",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Rounding",
"widgetIsMajor": "true",
"widgetLength": "20",
"widgetSize": "fd-col-md--2 fd-col--3",
"widgetType": "NUMBER"
},
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "false",
"dataLength": "20",
"dataName": "CURRENCY_BASE",
Expand All @@ -98,13 +114,16 @@
"dataType": "BOOLEAN",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Base",
"widgetIsMajor": "true",
"widgetLength": "20",
"widgetSize": "",
"widgetType": "CHECKBOX"
},
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "false",
"dataLength": "20",
"dataName": "CURRENCY_RATE",
Expand All @@ -115,16 +134,19 @@
"dataType": "DOUBLE",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Rate",
"widgetIsMajor": "true",
"widgetLength": "20",
"widgetSize": "fd-col-md--4 fd-col--6",
"widgetType": "NUMBER"
}
],
"caption": "Manage entity Currency",
"dataCount": "SELECT COUNT(*) AS COUNT FROM \"${tablePrefix}CURRENCY\"",
"dataName": "CURRENCY",
"dataQuery": "",
"disableGeneration": "false",
"icon": "/services/web/resources/unicons/file.svg",
"layoutType": "MANAGE_MASTER",
"menuIndex": "100",
Expand All @@ -142,7 +164,8 @@
{
"properties": [
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "true",
"dataLength": "0",
"dataName": "CURRENCYRATE_ID",
Expand All @@ -151,33 +174,41 @@
"dataType": "INTEGER",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Id",
"widgetIsMajor": "true",
"widgetLength": "20",
"widgetSize": "",
"widgetType": "TEXTBOX"
},
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "false",
"dataLength": "0",
"dataName": "CURRENCYRATE_CURRENCY",
"dataNullable": "true",
"dataPrecision": "NaN",
"dataPrimaryKey": "false",
"dataScale": "NaN",
"dataType": "INTEGER",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Currency",
"relationshipCardinality": "1_n",
"relationshipName": "CurrencyRate_Currency",
"relationshipType": "COMPOSITION",
"widgetIsMajor": "true",
"widgetLength": "20",
"widgetSize": "fd-col-md--2 fd-col--3",
"widgetType": "TEXTBOX",
"relationshipEntityName": "Currency",
"relationshipEntityPerspectiveName": "Currencies"
},
{
"calculatedPropertyExpression": "",
"calculatedPropertyExpressionCreate": "",
"calculatedPropertyExpressionUpdate": "",
"dataAutoIncrement": "false",
"dataLength": "20",
"dataName": "CURRENCYRATE_DATE",
Expand All @@ -188,16 +219,19 @@
"dataType": "DATE",
"dataUnique": "false",
"isCalculatedProperty": "false",
"isRequiredProperty": "false",
"name": "Date",
"widgetIsMajor": "true",
"widgetLength": "20",
"widgetSize": "",
"widgetType": "DATE"
}
],
"caption": "Manage entity CurrencyRate",
"dataCount": "SELECT COUNT(*) AS COUNT FROM \"${tablePrefix}CURRENCYRATE\"",
"dataName": "CURRENCYRATE",
"dataQuery": "",
"disableGeneration": "false",
"icon": "/services/web/resources/unicons/file.svg",
"layoutType": "MANAGE_DETAILS",
"menuIndex": "100",
Expand Down
33 changes: 28 additions & 5 deletions codbex-currencies/gen/api/Currencies/CurrencyRateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ class CurrencyRateService {
@Get("/")
public getAll(_: any, ctx: any) {
try {
let Currency = parseInt(ctx.queryParameters.Currency);
Currency = isNaN(Currency) ? ctx.queryParameters.Currency : Currency;
const options: CurrencyRateEntityOptions = {
$filter: {
equals: {
Currency: Currency
}
},
$limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined,
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined
};
Expand All @@ -33,12 +40,28 @@ class CurrencyRateService {
}
}

@Get("/count/:Currency")
public count(_: any, ctx: any) {
@Get("/count")
public count() {
try {
let Currency = parseInt(ctx.pathParameters.Currency);
Currency = isNaN(Currency) ? ctx.pathParameters.Currency : Currency;
return this.repository.count(Currency);
return this.repository.count();
} catch (error: any) {
this.handleError(error);
}
}

@Post("/count")
public countWithFilter(filter: any) {
try {
return this.repository.count(filter);
} catch (error: any) {
this.handleError(error);
}
}

@Post("/search")
public search(filter: any) {
try {
return this.repository.findAll(filter);
} catch (error: any) {
this.handleError(error);
}
Expand Down
18 changes: 18 additions & 0 deletions codbex-currencies/gen/api/Currencies/CurrencyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ class CurrencyService {
}
}

@Post("/count")
public countWithFilter(filter: any) {
try {
return this.repository.count(filter);
} catch (error: any) {
this.handleError(error);
}
}

@Post("/search")
public search(filter: any) {
try {
return this.repository.findAll(filter);
} catch (error: any) {
this.handleError(error);
}
}

@Get("/:id")
public getById(_: any, ctx: any) {
try {
Expand Down
4 changes: 2 additions & 2 deletions codbex-currencies/gen/api/utils/HttpUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export class HttpUtils {
HttpUtils.sendResponse(201, entity);
}

// HTTP 200
// HTTP 204
public static sendResponseNoContent(): void {
HttpUtils.sendResponse(204);
}

// HTTP 400
public static sendResponseBadRequest(message): void {
HttpUtils.sendResponse(404, {
HttpUtils.sendResponse(400, {
"code": 400,
"message": message
});
Expand Down
18 changes: 4 additions & 14 deletions codbex-currencies/gen/dao/Currencies/CurrencyRateRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,11 @@ export class CurrencyRateRepository {
});
}



public count(Currency: number): number {
const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_CURRENCYRATE" WHERE "CURRENCYRATE_CURRENCY" = ?', [Currency]);
if (resultSet !== null && resultSet[0] !== null) {
if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) {
return resultSet[0].COUNT;
} else if (resultSet[0].count !== undefined && resultSet[0].count !== null) {
return resultSet[0].count;
}
}
return 0;
public count(options?: CurrencyRateEntityOptions): number {
return this.dao.count(options);
}

public customDataCount(): number {
public customDataCount(options?: CurrencyRateEntityOptions): number {
const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_CURRENCYRATE"');
if (resultSet !== null && resultSet[0] !== null) {
if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) {
Expand All @@ -215,6 +205,6 @@ export class CurrencyRateRepository {
console.error(error);
}
});
producer.queue("codbex-currencies/Currencies/CurrencyRate").send(JSON.stringify(data));
producer.topic("codbex-currencies/Currencies/CurrencyRate").send(JSON.stringify(data));
}
}
8 changes: 4 additions & 4 deletions codbex-currencies/gen/dao/Currencies/CurrencyRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ export class CurrencyRepository {
});
}

public count(): number {
return this.dao.count();
public count(options?: CurrencyEntityOptions): number {
return this.dao.count(options);
}

public customDataCount(): number {
public customDataCount(options?: CurrencyEntityOptions): number {
const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_CURRENCY"');
if (resultSet !== null && resultSet[0] !== null) {
if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) {
Expand All @@ -261,6 +261,6 @@ export class CurrencyRepository {
console.error(error);
}
});
producer.queue("codbex-currencies/Currencies/Currency").send(JSON.stringify(data));
producer.topic("codbex-currencies/Currencies/Currency").send(JSON.stringify(data));
}
}
2 changes: 2 additions & 0 deletions codbex-currencies/gen/schema/codbex-currencies.schema
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
{
"type": "INTEGER",
"length": 0,
"precision": "NaN",
"scale": "NaN",
"nullable": true,
"name": "CURRENCYRATE_CURRENCY"
},
Expand Down
Loading

0 comments on commit 1f88d16

Please sign in to comment.