Download this file

data.js    96 lines (84 with data), 3.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Copyright (c) 2013/2014, Intel Performance Learning Solutions Ltd, Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
**/
/**Contains all functions which retrieve/post data from/to server
*
* Created by : Sridhar Voorakkara (vsridhar420@gmail.com)
*/
//get list of business processes for a user
var getBpList = function(callback) {
xmlhttpGet('lists/businessprocess/'+userStatus().user+'?term=', function(err, data) {
checkFOrErrorAndSendData(err, data, callback);
});
};
//get list of alternates context models for a business process
var getAlternateList = function(bpId, callback) {
xmlhttpGet('lists/alternate/'+bpId+'?term=', function(err, data) {
checkFOrErrorAndSendData(err, data, callback);
});
};
//get an alternates context model for a business process
var getAlternative = function(bpId, riskName, altIdx, callback) {
var url = 'uiapi/alternate/'+bpId;
var queryString = "risk="+riskName+"&altIdx="+altIdx+"&user="+userStatus().user;
xmlhttpPost(url, queryString, function(err, data) {
checkFOrErrorAndSendData(err, data, callback);
});
};
//get an alternates context model for a business process
var getCostProjection = function(bpId, riskName, altIdx, callback) {
var bp = getResourceJson();
var url = 'uiapi/costings';
var qs = "user="+userStatus().user+"&data=" + JSON.stringify(bp);
displayWait();
xmlhttpPost(url, qs, displayRecommendation);
};
//get list of resources for a business process
var getResources = function(bpId, callback) {
var url = 'lists/resources/'+bpId+'?term=';
xmlhttpGet(url, function(err, data) {
checkFOrErrorAndSendData(err, data, callback);
});
};
//get a list of artifacts for a business process
var getArtifacts = function (bpId, callback) {
var url = 'lists/artifacts/'+bpId;
xmlhttpGet(url, function(err, data) {
checkFOrErrorAndSendData(err, data, callback);
});
};
//get a list of events for a business process
var getEvents = function(bpName, callback) {
var url = 'plan/events/'+userStatus().user+'/'+bpName;
xmlhttpGet(url, function(err, data) {
checkFOrErrorAndSendData(err, data, callback);
});
};
//get metadata for an artifact
var getMetadata = function (bpName, artifactId, callback) {
var url = 'plan/artifact/'+userStatus().user+'/'+bpName+'/'+artifactId+'/metadata';
xmlhttpGet(url, function(err, data) {
checkFOrErrorAndSendData(err, data, callback);
});
};
//set the metadata for an artifact
var setMetadata = function (data, callback) {
var url = 'plan/artifact/'+userStatus().user+'/'+data.bpName+'/'+data.artifactId+'/metadata';
var queryString = "op=save-metadata&type=json&data="+JSON.stringify(data.metadata);
xmlhttpPost(url, queryString, function(err, data) {
checkFOrErrorAndSendData(err, data, callback);
});
};