Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 61 additions & 61 deletions codbex-contracts/codbex-contracts.edm

Large diffs are not rendered by default.

258 changes: 237 additions & 21 deletions codbex-contracts/codbex-contracts.gen

Large diffs are not rendered by default.

91 changes: 76 additions & 15 deletions codbex-contracts/codbex-contracts.model

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, Post, Put, Delete, response } from "sdk/http"
import { Extensions } from "sdk/extensions"
import { Controller, Get, Post, Put, Delete, request, response } from "@aerokit/sdk/http"
import { Extensions } from "@aerokit/sdk/extensions"
import { ContractRepository, ContractEntityOptions } from "../../dao/Contract/ContractRepository";
import { user } from "sdk/security"
import { user } from "@aerokit/sdk/security"
import { ForbiddenError } from "../utils/ForbiddenError";
import { ValidationError } from "../utils/ValidationError";
import { HttpUtils } from "../utils/HttpUtils";
Expand All @@ -21,7 +21,8 @@ class ContractService {
this.checkPermissions("read");
const options: ContractEntityOptions = {
$limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined,
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined,
$language: request.getLocale().split("_")[0]
};

return this.repository.findAll(options);
Expand All @@ -48,7 +49,7 @@ class ContractService {
public count() {
try {
this.checkPermissions("read");
return this.repository.count();
return { count: this.repository.count() };
} catch (error: any) {
this.handleError(error);
}
Expand All @@ -58,7 +59,7 @@ class ContractService {
public countWithFilter(filter: any) {
try {
this.checkPermissions("read");
return this.repository.count(filter);
return { count: this.repository.count(filter) };
} catch (error: any) {
this.handleError(error);
}
Expand All @@ -79,7 +80,10 @@ class ContractService {
try {
this.checkPermissions("read");
const id = parseInt(ctx.pathParameters.id);
const entity = this.repository.findById(id);
const options: ContractEntityOptions = {
$language: request.getLocale().split("_")[0]
};
const entity = this.repository.findById(id, options);
if (entity) {
return entity;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, Post, Put, Delete, response } from "sdk/http"
import { Extensions } from "sdk/extensions"
import { Controller, Get, Post, Put, Delete, request, response } from "@aerokit/sdk/http"
import { Extensions } from "@aerokit/sdk/extensions"
import { EmployeeContractItemRepository, EmployeeContractItemEntityOptions } from "../../dao/EmployeeContracts/EmployeeContractItemRepository";
import { user } from "sdk/security"
import { user } from "@aerokit/sdk/security"
import { ForbiddenError } from "../utils/ForbiddenError";
import { ValidationError } from "../utils/ValidationError";
import { HttpUtils } from "../utils/HttpUtils";
Expand All @@ -19,7 +19,8 @@ class EmployeeContractItemService {
this.checkPermissions("read");
const options: EmployeeContractItemEntityOptions = {
$limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined,
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined,
$language: request.getLocale().split("_")[0]
};

let EmployeeContract = parseInt(ctx.queryParameters.EmployeeContract);
Expand Down Expand Up @@ -57,7 +58,7 @@ class EmployeeContractItemService {
public count() {
try {
this.checkPermissions("read");
return this.repository.count();
return { count: this.repository.count() };
} catch (error: any) {
this.handleError(error);
}
Expand All @@ -67,7 +68,7 @@ class EmployeeContractItemService {
public countWithFilter(filter: any) {
try {
this.checkPermissions("read");
return this.repository.count(filter);
return { count: this.repository.count(filter) };
} catch (error: any) {
this.handleError(error);
}
Expand All @@ -88,7 +89,10 @@ class EmployeeContractItemService {
try {
this.checkPermissions("read");
const id = parseInt(ctx.pathParameters.id);
const entity = this.repository.findById(id);
const options: EmployeeContractItemEntityOptions = {
$language: request.getLocale().split("_")[0]
};
const entity = this.repository.findById(id, options);
if (entity) {
return entity;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, Post, Put, Delete, response } from "sdk/http"
import { Extensions } from "sdk/extensions"
import { Controller, Get, Post, Put, Delete, request, response } from "@aerokit/sdk/http"
import { Extensions } from "@aerokit/sdk/extensions"
import { EmployeeContractRepository, EmployeeContractEntityOptions } from "../../dao/EmployeeContracts/EmployeeContractRepository";
import { user } from "sdk/security"
import { user } from "@aerokit/sdk/security"
import { ForbiddenError } from "../utils/ForbiddenError";
import { ValidationError } from "../utils/ValidationError";
import { HttpUtils } from "../utils/HttpUtils";
Expand All @@ -21,7 +21,8 @@ class EmployeeContractService {
this.checkPermissions("read");
const options: EmployeeContractEntityOptions = {
$limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined,
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined,
$language: request.getLocale().split("_")[0]
};

return this.repository.findAll(options);
Expand All @@ -48,7 +49,7 @@ class EmployeeContractService {
public count() {
try {
this.checkPermissions("read");
return this.repository.count();
return { count: this.repository.count() };
} catch (error: any) {
this.handleError(error);
}
Expand All @@ -58,7 +59,7 @@ class EmployeeContractService {
public countWithFilter(filter: any) {
try {
this.checkPermissions("read");
return this.repository.count(filter);
return { count: this.repository.count(filter) };
} catch (error: any) {
this.handleError(error);
}
Expand All @@ -79,7 +80,10 @@ class EmployeeContractService {
try {
this.checkPermissions("read");
const id = parseInt(ctx.pathParameters.id);
const entity = this.repository.findById(id);
const options: EmployeeContractEntityOptions = {
$language: request.getLocale().split("_")[0]
};
const entity = this.repository.findById(id, options);
if (entity) {
return entity;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, Post, Put, Delete, response } from "sdk/http"
import { Extensions } from "sdk/extensions"
import { Controller, Get, Post, Put, Delete, request, response } from "@aerokit/sdk/http"
import { Extensions } from "@aerokit/sdk/extensions"
import { ContractTypeRepository, ContractTypeEntityOptions } from "../../dao/Settings/ContractTypeRepository";
import { user } from "sdk/security"
import { user } from "@aerokit/sdk/security"
import { ForbiddenError } from "../utils/ForbiddenError";
import { ValidationError } from "../utils/ValidationError";
import { HttpUtils } from "../utils/HttpUtils";
Expand All @@ -19,7 +19,8 @@ class ContractTypeService {
this.checkPermissions("read");
const options: ContractTypeEntityOptions = {
$limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined,
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined,
$language: request.getLocale().split("_")[0]
};

return this.repository.findAll(options);
Expand All @@ -46,7 +47,7 @@ class ContractTypeService {
public count() {
try {
this.checkPermissions("read");
return this.repository.count();
return { count: this.repository.count() };
} catch (error: any) {
this.handleError(error);
}
Expand All @@ -56,7 +57,7 @@ class ContractTypeService {
public countWithFilter(filter: any) {
try {
this.checkPermissions("read");
return this.repository.count(filter);
return { count: this.repository.count(filter) };
} catch (error: any) {
this.handleError(error);
}
Expand All @@ -77,7 +78,10 @@ class ContractTypeService {
try {
this.checkPermissions("read");
const id = parseInt(ctx.pathParameters.id);
const entity = this.repository.findById(id);
const options: ContractTypeEntityOptions = {
$language: request.getLocale().split("_")[0]
};
const entity = this.repository.findById(id, options);
if (entity) {
return entity;
} else {
Expand Down
4 changes: 2 additions & 2 deletions codbex-contracts/gen/codbex-contracts/api/utils/HttpUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { response } from "sdk/http";
import { response } from "@aerokit/sdk/http";

export class HttpUtils {

Expand Down Expand Up @@ -57,4 +57,4 @@ export class HttpUtils {
response.println(JSON.stringify(body));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { query } from "sdk/db";
import { producer } from "sdk/messaging";
import { extensions } from "sdk/extensions";
import { dao as daoApi } from "sdk/db";
import { sql, query } from "@aerokit/sdk/db";
import { producer } from "@aerokit/sdk/messaging";
import { extensions } from "@aerokit/sdk/extensions";
import { dao as daoApi } from "@aerokit/sdk/db";
import { EntityUtils } from "../utils/EntityUtils";
// custom imports
import { NumberGeneratorService } from "/codbex-number-generator/service/generator";
Expand Down Expand Up @@ -105,12 +105,13 @@ export interface ContractEntityOptions {
},
$select?: (keyof ContractEntity)[],
$sort?: string | (keyof ContractEntity)[],
$order?: 'asc' | 'desc',
$order?: 'ASC' | 'DESC',
$offset?: number,
$limit?: number,
$language?: string
}

interface ContractEntityEvent {
export interface ContractEntityEvent {
readonly operation: 'create' | 'update' | 'delete';
readonly table: string;
readonly entity: Partial<ContractEntity>;
Expand All @@ -121,7 +122,7 @@ interface ContractEntityEvent {
}
}

interface ContractUpdateEntityEvent extends ContractEntityEvent {
export interface ContractUpdateEntityEvent extends ContractEntityEvent {
readonly previousEntity: ContractEntity;
}

Expand Down Expand Up @@ -178,18 +179,19 @@ export class ContractRepository {
private readonly dao;

constructor(dataSource = "DefaultDB") {
this.dao = daoApi.create(ContractRepository.DEFINITION, null, dataSource);
this.dao = daoApi.create(ContractRepository.DEFINITION, undefined, dataSource);
}

public findAll(options?: ContractEntityOptions): ContractEntity[] {
return this.dao.list(options).map((e: ContractEntity) => {
public findAll(options: ContractEntityOptions = {}): ContractEntity[] {
let list = this.dao.list(options).map((e: ContractEntity) => {
EntityUtils.setDate(e, "StartDate");
EntityUtils.setDate(e, "EndDate");
return e;
});
return list;
}

public findById(id: number): ContractEntity | undefined {
public findById(id: number, options: ContractEntityOptions = {}): ContractEntity | undefined {
const entity = this.dao.find(id);
EntityUtils.setDate(entity, "StartDate");
EntityUtils.setDate(entity, "EndDate");
Expand All @@ -200,7 +202,7 @@ export class ContractRepository {
EntityUtils.setLocalDate(entity, "StartDate");
EntityUtils.setLocalDate(entity, "EndDate");
// @ts-ignore
(entity as ContractEntity).Number = new NumberGeneratorService().generate(23);
(entity as ContractEntity).Number = new NumberGeneratorService().generateByType('Contract');
const id = this.dao.insert(entity);
this.triggerEvent({
operation: "create",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { query } from "sdk/db";
import { producer } from "sdk/messaging";
import { extensions } from "sdk/extensions";
import { dao as daoApi } from "sdk/db";
import { sql, query } from "@aerokit/sdk/db";
import { producer } from "@aerokit/sdk/messaging";
import { extensions } from "@aerokit/sdk/extensions";
import { dao as daoApi } from "@aerokit/sdk/db";

export interface EmployeeContractItemEntity {
readonly Id: number;
Expand Down Expand Up @@ -67,12 +67,13 @@ export interface EmployeeContractItemEntityOptions {
},
$select?: (keyof EmployeeContractItemEntity)[],
$sort?: string | (keyof EmployeeContractItemEntity)[],
$order?: 'asc' | 'desc',
$order?: 'ASC' | 'DESC',
$offset?: number,
$limit?: number,
$language?: string
}

interface EmployeeContractItemEntityEvent {
export interface EmployeeContractItemEntityEvent {
readonly operation: 'create' | 'update' | 'delete';
readonly table: string;
readonly entity: Partial<EmployeeContractItemEntity>;
Expand All @@ -83,7 +84,7 @@ interface EmployeeContractItemEntityEvent {
}
}

interface EmployeeContractItemUpdateEntityEvent extends EmployeeContractItemEntityEvent {
export interface EmployeeContractItemUpdateEntityEvent extends EmployeeContractItemEntityEvent {
readonly previousEntity: EmployeeContractItemEntity;
}

Expand Down Expand Up @@ -120,14 +121,15 @@ export class EmployeeContractItemRepository {
private readonly dao;

constructor(dataSource = "DefaultDB") {
this.dao = daoApi.create(EmployeeContractItemRepository.DEFINITION, null, dataSource);
this.dao = daoApi.create(EmployeeContractItemRepository.DEFINITION, undefined, dataSource);
}

public findAll(options?: EmployeeContractItemEntityOptions): EmployeeContractItemEntity[] {
return this.dao.list(options);
public findAll(options: EmployeeContractItemEntityOptions = {}): EmployeeContractItemEntity[] {
let list = this.dao.list(options);
return list;
}

public findById(id: number): EmployeeContractItemEntity | undefined {
public findById(id: number, options: EmployeeContractItemEntityOptions = {}): EmployeeContractItemEntity | undefined {
const entity = this.dao.find(id);
return entity ?? undefined;
}
Expand Down
Loading
Loading