Commit 52c0fa78 authored by Aurel's avatar Aurel

coding style + use of clearroad code

parent 3c0a2748
function ClearRoadBillingPeriodRegistration() {
if (!(this instanceof ClearRoadBillingPeriodRegistration)) {
return new ClearRoadBillingPeriodRegistration();
}
// cleanup the local storage before each run
var DATABASE = "cr-billing-period-registration";
// indexedDB.deleteDatabase('jio:' + DATABASE);
this.jio = jIO.createJIO({
type: "replicate",
use_remote_post: false,
conflict_handling: 1,
check_local_modification: false,
check_local_creation: true,
check_local_deletion: false,
check_remote_modification: false,
check_remote_creation: false,
check_remote_deletion: false,
local_sub_storage: {
type: "mapping",
map_id: ["equalSubProperty", "reference"],
sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "memory",
database: DATABASE
}
}
}
},
remote_sub_storage: {
type: "mapping",
map_id: ["equalSubProperty", "reference"],
mapping_dict: {"portal_type": ["equalValue", "Billing Period Message"],
"parent_relative_url": ["equalValue", "billing_period_message_module"]},
sub_storage: {
type: "erp5",
url: "https://softinst69465.host.vifib.net/erp5/web_site_module/hateoas",
default_view_reference: "jio_view"
}
}
});
}
ClearRoadBillingPeriodRegistration.prototype = new ClearRoadBillingPeriodRegistration();
ClearRoadBillingPeriodRegistration.prototype.constructor = ClearRoadBillingPeriodRegistration;
ClearRoadBillingPeriodRegistration.prototype.post = function(){
return this.jio.post.apply(this.jio, arguments);
};
ClearRoadBillingPeriodRegistration.prototype.sync = function(){
return this.jio.repair.apply(this.jio, arguments);
};
module.exports = ClearRoadBillingPeriodRegistration
// server.js // server.js
// where your node app starts // where your node app starts
"use strict"
URI = require("uri-js"); global.URI = require("uri-js");
RSVP = require('rsvp'); global.RSVP = require('rsvp');
UriTemplate = require("uritemplate"); global.UriTemplate = require("uritemplate");
moment = require('moment'); global.moment = require('moment');
navigator = require('navigator'); global.navigator = require('navigator');
Rusha = require('rusha'); global.Rusha = require('rusha');
FormData = require('formdata'); global.FormData = require('formdata');
atob = require('atob'); global.atob = require('atob');
FileReader = require("FileReader"); global.FileReader = require("FileReader");
Blob = require("Blob"); global.Blob = require("Blob");
localStorage = require('node-localstorage'); global.localStorage = require('node-localstorage');
global.btoa = require('btoa');
window = global; global.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest
sessionStorage = {};
global.window = global;
global.sessionStorage = {};
var jIO = require('jio'); var jIO = require('jio');
var ClearRoadBillingPeriodRegistration = require("clearroad");
var cr = new ClearRoadBillingPeriodRegistration();
console.log("init");
cr.post({
"reference" : "Q42",
"start_date" : "2017-02-01T00:00:00Z",
"stop_date" : "2017-03-01T00:00:00Z"
}).push(function (){
console.log("start sync...");
return cr.sync();
}).push(function (){
console.info("Sync done");
}, function (error) {
console.info("Error :");
console.warn(error.stack)
console.warn(error);
});
// init project // init project
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment