Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customers synchronization #32

Merged
merged 1 commit into from
Jan 8, 2024
Merged
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
6 changes: 3 additions & 3 deletions codbex-portunus/codbex-portunus.edm

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions codbex-portunus/codbex-portunus.gen
Original file line number Diff line number Diff line change
Expand Up @@ -1303,9 +1303,11 @@
"calculatedPropertyExpression": "",
"dataAutoIncrement": false,
"dataLength": "20",
"dataName": "CUSTOMER_PROPERTY9",
"dataName": "CUSTOMER_CODE",
"dataNullable": true,
"dataPrecision": "NaN",
"dataPrimaryKey": false,
"dataScale": "NaN",
"dataType": "VARCHAR",
"dataUnique": false,
"isCalculatedProperty": false,
Expand All @@ -1323,12 +1325,12 @@
"calculatedPropertyExpression": "",
"dataAutoIncrement": false,
"dataLength": "20",
"dataName": "CUSTOMER_PROPERTY10",
"dataName": "CUSTOMER_DATE_ADDED",
"dataNullable": true,
"dataPrecision": "NaN",
"dataPrimaryKey": false,
"dataScale": "NaN",
"dataType": "DATE",
"dataType": "TIMESTAMP",
"dataUnique": false,
"isCalculatedProperty": false,
"name": "DateAdded",
Expand Down Expand Up @@ -1553,9 +1555,11 @@
"calculatedPropertyExpression": "",
"dataAutoIncrement": false,
"dataLength": "20",
"dataName": "CUSTOMER_PROPERTY9",
"dataName": "CUSTOMER_CODE",
"dataNullable": true,
"dataPrecision": "NaN",
"dataPrimaryKey": false,
"dataScale": "NaN",
"dataType": "VARCHAR",
"dataUnique": false,
"isCalculatedProperty": false,
Expand All @@ -1573,12 +1577,12 @@
"calculatedPropertyExpression": "",
"dataAutoIncrement": false,
"dataLength": "20",
"dataName": "CUSTOMER_PROPERTY10",
"dataName": "CUSTOMER_DATE_ADDED",
"dataNullable": true,
"dataPrecision": "NaN",
"dataPrimaryKey": false,
"dataScale": "NaN",
"dataType": "DATE",
"dataType": "TIMESTAMP",
"dataUnique": false,
"isCalculatedProperty": false,
"name": "DateAdded",
Expand Down
8 changes: 5 additions & 3 deletions codbex-portunus/codbex-portunus.model
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,11 @@
"calculatedPropertyExpression": "",
"dataAutoIncrement": "false",
"dataLength": "20",
"dataName": "CUSTOMER_PROPERTY9",
"dataName": "CUSTOMER_CODE",
"dataNullable": "true",
"dataPrecision": "NaN",
"dataPrimaryKey": "false",
"dataScale": "NaN",
"dataType": "VARCHAR",
"dataUnique": "false",
"isCalculatedProperty": "false",
Expand All @@ -697,12 +699,12 @@
"calculatedPropertyExpression": "",
"dataAutoIncrement": "false",
"dataLength": "20",
"dataName": "CUSTOMER_PROPERTY10",
"dataName": "CUSTOMER_DATE_ADDED",
"dataNullable": "true",
"dataPrecision": "NaN",
"dataPrimaryKey": "false",
"dataScale": "NaN",
"dataType": "DATE",
"dataType": "TIMESTAMP",
"dataUnique": "false",
"isCalculatedProperty": "false",
"name": "DateAdded",
Expand Down
18 changes: 5 additions & 13 deletions codbex-portunus/gen/dao/Customer/Customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const query = require("db/query");
const producer = require("messaging/producer");
const extensions = require('extensions/extensions');
const daoApi = require("db/dao");
const EntityUtils = require("codbex-portunus/gen/dao/utils/EntityUtils");

let dao = daoApi.create({
table: "CODBEX_CUSTOMER",
Expand Down Expand Up @@ -51,13 +50,13 @@ let dao = daoApi.create({
},
{
name: "Code",
column: "CUSTOMER_PROPERTY9",
column: "CUSTOMER_CODE",
type: "VARCHAR",
},
{
name: "DateAdded",
column: "CUSTOMER_PROPERTY10",
type: "DATE",
column: "CUSTOMER_DATE_ADDED",
type: "TIMESTAMP",
},
{
name: "Language",
Expand All @@ -68,20 +67,14 @@ let dao = daoApi.create({
});

exports.list = function(settings) {
return dao.list(settings).map(function(e) {
EntityUtils.setDate(e, "DateAdded");
return e;
});
return dao.list(settings);
};

exports.get = function(id) {
let entity = dao.find(id);
EntityUtils.setDate(entity, "DateAdded");
return entity;
return dao.find(id);
};

exports.create = function(entity) {
EntityUtils.setLocalDate(entity, "DateAdded");
let id = dao.insert(entity);
triggerEvent({
operation: "create",
Expand All @@ -97,7 +90,6 @@ exports.create = function(entity) {
};

exports.update = function(entity) {
// EntityUtils.setLocalDate(entity, "DateAdded");
dao.update(entity);
triggerEvent({
operation: "update",
Expand Down
8 changes: 5 additions & 3 deletions codbex-portunus/gen/schema/codbex-portunus.schema
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,18 @@
{
"type": "VARCHAR",
"length": 20,
"precision": "NaN",
"scale": "NaN",
"nullable": true,
"name": "CUSTOMER_PROPERTY9"
"name": "CUSTOMER_CODE"
},
{
"type": "DATE",
"type": "TIMESTAMP",
"length": 20,
"precision": "NaN",
"scale": "NaN",
"nullable": true,
"name": "CUSTOMER_PROPERTY10"
"name": "CUSTOMER_DATE_ADDED"
},
{
"type": "INTEGER",
Expand Down
73 changes: 73 additions & 0 deletions codbex-portunus/opencart/synchronization/sync-customers.camel
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
- route:
id: customers-sync-route
from:
uri: cron:TriggerCustomersReplication
id: trigger-customers-replication-cron
parameters:
schedule: '*/30 * * ? * *'
description: Trigger Customers Replication
steps:
- log:
message: Replicating customers from OpenCart DB...
id: log-about-to-start-customers-replication
logName: OpenCartCustomersReplication
loggingLevel: INFO
- setBody:
id: create-select-statement
expression:
constant:
expression: SELECT * FROM oc_customer
id: constant-e9a5
description: Create customers SELECT statement
- to:
uri: spring-jdbc:OpenCartDB
id: execute-get-customers
description: Get all customers
- split:
id: split-to-single-customer
expression:
simple:
expression: ${body}
id: simple-099e
description: Split to single customer
steps:
- setBody:
id: create-merge-statement
expression:
simple:
expression: |-
MERGE INTO CODBEX_CUSTOMER
(
CUSTOMER_ID, CUSTOMER_STORE, CUSTOMER_FIRSTNAME,
CUSTOMER_LASTNAME, CUSTOMER_EMAIL, CUSTOMER_TELEPHONE,
CUSTOMER_STATUS, CUSTOMER_LANGUAGE, CUSTOMER_CUSTOMFIELD,
CUSTOMER_CODE, CUSTOMER_DATE_ADDED

)
KEY(CUSTOMER_ID)
VALUES
(
${body['customer_id']},
${body['store_id']},
'${body['firstname']}',
'${body['lastname']}',
'${body['email']}',
'${body['telephone']}',
${body['status']},
${body['language_id']},
'${body['custom_field']}',
'${body['code']}',
'${body['date_added']}'
)
id: simple-b426
description: Create MERGE statement
- to:
uri: spring-jdbc:DefaultDB
id: merge-customer
description: Merge customer
- log:
message: Successfully replicated customers from OpenCart DB
id: log-customers-replication-completed
logName: OpenCartCustomersReplication
loggingLevel: INFO
description: Sync customers from OpenCart