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
community
synergy-components
Commits
f308b53d
Commit
f308b53d
authored
Sep 09, 2022
by
Samir Sadyhov
🤔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update interpreter_library
parent
e00e2ab6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
2 deletions
+60
-2
interpreter/interpreter_library
interpreter/interpreter_library
+60
-2
No files found.
interpreter/interpreter_library
View file @
f308b53d
let API = {
let API = {
host: "http://127.0.0.1:8080/Synergy/",
getHttpClient: function(){
getHttpClient: function(){
let client = new org.apache.commons.httpclient.HttpClient();
let client = new org.apache.commons.httpclient.HttpClient();
let creds = new org.apache.commons.httpclient.UsernamePasswordCredentials(login, password);
let creds = new org.apache.commons.httpclient.UsernamePasswordCredentials(login, password);
...
@@ -8,7 +10,7 @@ let API = {
...
@@ -8,7 +10,7 @@ let API = {
},
},
httpGetMethod: function(methods, type) {
httpGetMethod: function(methods, type) {
let client = this.getHttpClient();
let client = this.getHttpClient();
let get = new org.apache.commons.httpclient.methods.GetMethod(
"http://127.0.0.1:8080/Synergy/"
+ methods);
let get = new org.apache.commons.httpclient.methods.GetMethod(
this.host
+ methods);
get.setRequestHeader("Content-type", "application/json");
get.setRequestHeader("Content-type", "application/json");
client.executeMethod(get);
client.executeMethod(get);
let resp = get.getResponseBodyAsString();
let resp = get.getResponseBodyAsString();
...
@@ -17,7 +19,7 @@ let API = {
...
@@ -17,7 +19,7 @@ let API = {
},
},
httpPostMethod: function(methods, params, contentType) {
httpPostMethod: function(methods, params, contentType) {
let client = this.getHttpClient();
let client = this.getHttpClient();
let post = new org.apache.commons.httpclient.methods.PostMethod(
"http://127.0.0.1:8080/Synergy/"
+ methods);
let post = new org.apache.commons.httpclient.methods.PostMethod(
this.host
+ methods);
if(contentType) post.setRequestBody(JSON.stringify(params));
if(contentType) post.setRequestBody(JSON.stringify(params));
else for(let key in params) post.addParameter(key, params[key]);
else for(let key in params) post.addParameter(key, params[key]);
post.setRequestHeader("Content-type", contentType || "application/x-www-form-urlencoded; charset=utf-8");
post.setRequestHeader("Content-type", contentType || "application/x-www-form-urlencoded; charset=utf-8");
...
@@ -83,6 +85,12 @@ let API = {
...
@@ -83,6 +85,12 @@ let API = {
getSynergyCalendar: function(start, finish) {
getSynergyCalendar: function(start, finish) {
return this.httpGetMethod("rest/api/settings/calendar?date_start=" + start + "&date_finish=" + finish);
return this.httpGetMethod("rest/api/settings/calendar?date_start=" + start + "&date_finish=" + finish);
},
},
getWorkTime: function(startDate, finishDate) {
return this.httpGetMethod("rest/api/workflow/getWorkTime?startDate=" + encodeURIComponent(startDate) + "&finishDate=" + encodeURIComponent(finishDate));
},
getFinishDate: function(startDate, duration) {
return this.httpGetMethod("rest/api/workflow/get_finish_date?startDate=" + encodeURIComponent(startDate) + "&duration=" + duration);
},
getFormForResult: function(formCode, workID) {
getFormForResult: function(formCode, workID) {
return this.httpGetMethod("rest/api/workflow/work/get_form_for_result?formCode=" + formCode + "&workID=" + workID);
return this.httpGetMethod("rest/api/workflow/work/get_form_for_result?formCode=" + formCode + "&workID=" + workID);
},
},
...
@@ -93,6 +101,56 @@ let API = {
...
@@ -93,6 +101,56 @@ let API = {
type: 'work',
type: 'work',
file_identifier: file_identifier
file_identifier: file_identifier
});
});
},
getPrintFilePDF: function(asfDataId) {
let client = this.getHttpClient();
let post = new org.apache.commons.httpclient.methods.PostMethod(this.host + "rest/api/asforms/data/print");
post.setRequestBody('{"dataUUID": "' + asfDataId + '", "format": "PDF"}');
post.setRequestHeader("Content-type", "application/json");
post.setRequestHeader("Content-disposition", "attachment; filename=printFile.pdf");
let resp = client.executeMethod(post);
let pdfResult = post.getResponseBody();
post.releaseConnection();
return pdfResult;
},
startUpload: function() {
return this.httpGetMethod("rest/api/storage/start_upload");
},
uploadPart: function(filePath, file) {
//filePath - result api/storage/start_upload
let client = this.getHttpClient();
let uploadPart = new org.apache.commons.httpclient.methods.PostMethod(this.host + "rest/api/storage/upload_part?file=" + filePath);
let base64 = java.util.Base64.getEncoder();
let encodedBytes = base64.encode(file);
encodedBytes = new org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource("filename.txt", encodedBytes);
let filePart = new org.apache.commons.httpclient.methods.multipart.FilePart("body", encodedBytes);
let parts = new Array();
parts.push(filePart);
let entity = new org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity(parts, uploadPart.getParams());
uploadPart.setRequestEntity(entity);
let uploadStatus = client.executeMethod(uploadPart);
let uploadResult = uploadPart.getResponseBodyAsString();
uploadPart.releaseConnection();
return uploadResult;
},
addFileInForm: function(asfDataId, fileName, filePath, overwrite) {
//filePath - result api/storage/start_upload
let client = this.getHttpClient();
let params = "?dataUUID=" + asfDataId + "&fileName=" + fileName + "&filePath=" + filePath;
if(overwrite) params += "&overwrite=true";
let post = new org.apache.commons.httpclient.methods.PostMethod(this.host + "rest/api/storage/asffile/addFile" + params);
post.setRequestHeader("Content-type", "application/json; charset=utf-8");
let resp = client.executeMethod(post);
resp = JSON.parse(post.getResponseBodyAsString());
post.releaseConnection();
return resp;
},
appendTable: function(uuid, tableId, data) {
return this.httpPostMethod("rest/api/asforms/data/append_table", {
uuid: uuid,
tableId: tableId,
data: data
}, "application/json; charset=utf-8");
}
}
};
};
...
...
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