Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
synergy-components
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Irina Oleynik
synergy-components
Commits
5da8c4c9
Commit
5da8c4c9
authored
Jan 21, 2022
by
Elizaveta Kakhovskaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Библиотека для скриптов интерпретатора
parent
b6ea5bdf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
195 additions
and
0 deletions
+195
-0
interpreter/interpreter_library
interpreter/interpreter_library
+195
-0
No files found.
interpreter/interpreter_library
0 → 100644
View file @
5da8c4c9
let API = {
getHttpClient: function(){
let client = new org.apache.commons.httpclient.HttpClient();
let creds = new org.apache.commons.httpclient.UsernamePasswordCredentials(login, password);
client.getParams().setAuthenticationPreemptive(true);
client.getState().setCredentials(org.apache.commons.httpclient.auth.AuthScope.ANY, creds);
return client;
},
httpGetMethod: function(methods, type) {
let client = this.getHttpClient();
let get = new org.apache.commons.httpclient.methods.GetMethod("http://127.0.0.1:8080/Synergy/" + methods);
get.setRequestHeader("Content-type", "application/json");
client.executeMethod(get);
let resp = get.getResponseBodyAsString();
get.releaseConnection();
return type == 'text' ? resp : JSON.parse(resp);
},
httpPostMethod: function(methods, params, contentType) {
let client = this.getHttpClient();
let post = new org.apache.commons.httpclient.methods.PostMethod("http://127.0.0.1:8080/Synergy/" + methods);
if(contentType) post.setRequestBody(JSON.stringify(params));
else for(let key in params) post.addParameter(key, params[key]);
post.setRequestHeader("Content-type", contentType || "application/x-www-form-urlencoded; charset=utf-8");
let resp = client.executeMethod(post);
if(contentType) resp = JSON.parse(post.getResponseBodyAsString());
post.releaseConnection();
return resp;
},
createDocRCC: function(registryCode, data) {
return this.httpPostMethod("rest/api/registry/create_doc_rcc", {
registryCode: registryCode,
data: data
}, "application/json; charset=utf-8");
},
activateDoc: function(documentID) {
return this.httpGetMethod("rest/api/registry/activate_doc?documentID=" + documentID);
},
getFormData: function(asfDataId) {
return this.httpGetMethod("rest/api/asforms/data/" + asfDataId)
},
saveFormData: function(asfData) {
return this.httpPostMethod("rest/api/asforms/form/multipartdata", {
form: asfData.form,
uuid: asfData.uuid,
data: "\"data\":" + JSON.stringify(asfData.data)
});
},
mergeFormData: function(asfData) {
return this.httpPostMethod("rest/api/asforms/data/merge", {
uuid: asfData.uuid,
data: asfData.data
}, "application/json; charset=utf-8");
},
sendNotification: function(body) {
/*body = {
header: 'theme',
message: 'subject',
emails: [emails]
}*/
return this.httpPostMethod("rest/api/notifications/send", body, "application/json; charset=utf-8");
},
getAsfDataId: function(documentID) {
return this.httpGetMethod("rest/api/formPlayer/getAsfDataUUID?documentID=" + documentID, 'text');
},
getDocumentID: function(asfDataId) {
return this.httpGetMethod("rest/api/formPlayer/documentIdentifier?dataUUID=" + asfDataId, 'text');
},
getDocumentInfo: function(documentID) {
return this.httpGetMethod("rest/api/docflow/doc/document_info?documentID=" + documentID);
},
getDocMeaningContent: function(documentID) {
return this.httpGetMethod("rest/api/formPlayer/getDocMeaningContent?documentId=" + documentID, 'text');
},
getProcesses: function(documentID) {
return this.httpGetMethod("rest/api/workflow/get_execution_process?documentID=" + documentID);
},
getWorkCompletionData: function(workID) {
return this.httpGetMethod("rest/api/workflow/work/get_completion_data?workID=" + workID);
},
getFormDescription: function(formID) {
return this.httpGetMethod("rest/api/asforms/form/" + formID + "?isMobile=false");
},
getSynergyCalendar: function(start, finish) {
return this.httpGetMethod("rest/api/settings/calendar?date_start=" + start + "&date_finish=" + finish);
},
getFormForResult: function(formCode, workID) {
return this.httpGetMethod("rest/api/workflow/work/get_form_for_result?formCode=" + formCode + "&workID=" + workID);
},
finishWork: function(actionID, file_identifier) {
return this.httpPostMethod("rest/api/workflow/work/set_result", {
workID: actionID,
completionForm: "FORM",
type: 'work',
file_identifier: file_identifier
});
}
};
let log = {
parse: function(args) {
let result = [];
for (let x in args) result.push(JSON.stringify(args[x], null, 4));
return documentID + '\n' + result.join('\n');
},
info: function() {
console.info(this.parse(arguments));
},
error: function() {
console.error(this.parse(arguments));
}
}
let UTILS = {
createField: function(fieldData) {
let field = {};
for (let key in fieldData) field[key] = fieldData[key];
return field;
},
getValue: function(data, cmpID) {
data = data.data ? data.data : data;
for(let i = 0; i < data.length; i++)
if (data[i].id === cmpID) return data[i];
return null;
},
setValue: function(asfData, cmpID, data) {
let field = this.getValue(asfData, cmpID);
if(field) {
for (let key in data) {
if(key === 'id' || key === 'type') continue;
field[key] = data[key];
}
return field;
} else {
asfData = asfData.data ? asfData.data : asfData;
field = this.createField(data);
field.id = cmpID;
asfData.push(field);
return field;
}
},
getTableBlockIndex: function(data, cmp) {
let res = 0;
data = data.data ? data.data : data;
data.forEach(function(item) {
if (item.id.slice(0, item.id.indexOf('-b')) === cmp) res++;
});
return res === 0 ? 1 : ++res;
}
};
UTILS.formatDate = function(datetime, time) {
let result = datetime.getFullYear() + '-' +
('0' + (datetime.getMonth() + 1)).slice(-2) + '-' +
('0' + datetime.getDate()).slice(-2) + ' ' +
('0' + datetime.getHours()).slice(-2) + ':' +
('0' + datetime.getMinutes()).slice(-2) + ':' +
('0' + datetime.getSeconds()).slice(-2);
return time ? result : result.substring(0, result.indexOf(' '));
};
UTILS.getCurrentDateParse = function() {
return this.formatDate(new Date(), true); /*yyyy-mm-dd HH:MM:SS*/
};
UTILS.parseDateTime = function(datetime /*yyyy-mm-dd HH:MM:SS*/) {
datetime = datetime.split(/\D/);
return new Date(datetime[0], datetime[1] - 1, datetime[2], datetime[3] || 0, datetime[4] || 0, datetime[5] || 0);
};
UTILS.getCmpType = function(formDescription, cmpID) {
let result = null;
for (let i = 0; i < formDescription.properties.length; i++) {
if (formDescription.properties[i].id === cmpID) {
result = formDescription.properties[i].type;
break;
}
if (formDescription.properties[i].type === "table") {
result = this.getCmpType(formDescription.properties[i], cmpID) || result;
}
}
return result;
};
UTILS.getParams = function(str){
return str.split('$').filter(function(item) {
if (item.indexOf('{') !== -1) return item;
}).map(function(item) {
return item.substring(item.indexOf('{') + 1, item.indexOf('}'));
});
};
//выпиливыние из массива повторяющихся елементов
Array.prototype.uniq = function() {
return this.filter(function(v, i, a){ return i == a.indexOf(v) });
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment