xmlParse_wev8.js
6.24 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
var XmlParse = function () {
this.parse = function (xml) {
var workflowBase = new WorkflowBase();
xml = "<xml>" + xml + "</xml>";
$(xml).find('Proc').each(function() {
var $bpxml = $(this).children('BaseProperties');
var $vmlpxml = $(this).children('VMLProperties');
var node = new NodeBase();
node.id = $bpxml.attr("id");
node.text = $bpxml.attr("text");
node.procType = $bpxml.attr("procType");
node.nodetype = $bpxml.attr("nodetype");
node.nodeattribute = $vmlpxml.attr("nodeattribute");
node.passNum = $bpxml.attr("passNum");
node.nodeOptType = $bpxml.attr("optType");
node.nodeOperatorName = $bpxml.attr("nodeOperatorName");
node.nodeOperatorNames = $bpxml.attr("nodeOperatorNames");
node.nodeViewNames = $bpxml.attr("nodeViewNames");
node.nodeNotOperatorNames = $bpxml.attr("nodeNotOperatorNames");
/*
if (node.nodeOperatorName != null && node.nodeOperatorName != "" && node.nodeOperatorName.indexOf("_") != -1) {
node.nodeOperatorName = node.nodeOperatorName.split("_")[2];
}
if (node.nodeOperatorNames != null && node.nodeOperatorNames != "" && node.nodeOperatorNames.indexOf("_") != -1) {
var tnms = node.nodeOperatorNames.split(" ");
node.nodeOperatorNames = "";
for (var i=0; i<tnms.length; i++) {
if (tnms[i] != null && tnms[i] != "" && tnms[i].indexOf("_") != -1) {
node.nodeOperatorNames += tnms[i].split("_")[2] + " ";
}
}
}
if (node.nodeViewNames != null && node.nodeViewNames != "" && node.nodeViewNames.indexOf("_") != -1) {
var tnms = node.nodeViewNames.split(" ");
node.nodeViewNames = "";
for (var i=0; i<tnms.length; i++) {
if (tnms[i] != null && tnms[i] != "" && tnms[i].indexOf("_") != -1) {
node.nodeViewNames += tnms[i].split("_")[2] + " ";
}
}
}
if (node.nodeNotOperatorNames != null && node.nodeNotOperatorNames != "" && node.nodeNotOperatorNames.indexOf("_") != -1) {
var tnms = node.nodeNotOperatorNames.split(" ");
node.nodeNotOperatorNames = "";
for (var i=0; i<tnms.length; i++) {
if (tnms[i] != null && tnms[i] != "" && tnms[i].indexOf("_") != -1) {
node.nodeNotOperatorNames += tnms[i].split("_")[2] + " ";
}
}
}
*/
if (node.nodeNotOperatorNames == "" || node.nodeNotOperatorNames == null) {
node.nodeNotOperatorNames = node.nodeOperatorName;
}
node.shapetype = $vmlpxml.attr("shapetype");
node.width = $vmlpxml.attr("width");
node.height = $vmlpxml.attr("height");
node.x = parseInt($vmlpxml.attr("x")) - 48 + 60;
node.y = parseInt($vmlpxml.attr("y")) - 30 + 40;
node.zIndex = $vmlpxml.attr("zIndex");
workflowBase.nodeBases.push(node);
});
var newLineCount = 0;
$(xml).find('Step').each(function() {
var $bpxml = $(this).children('BaseProperties');
var $vmlpxml = $(this).children('VMLProperties');
var nl = new NodeLink();
nl.id = $bpxml.attr("id");
nl.text = $bpxml.attr("text");
nl.isNew = false;
nl.from = $bpxml.attr("from");
nl.to = $bpxml.attr("to");
nl.remindMsg = $bpxml.attr("remindMsg");
nl.isreject = $bpxml.attr("isreject");
nl.ismustpass = $bpxml.attr("ismustpass");
nl.directionfrom = $bpxml.attr("directionfrom");
nl.directionto = $bpxml.attr("directionto");
var startDirection = $bpxml.attr("startDirection");
var endDirection = $bpxml.attr("endDirection");
nl.startDirection = startDirection;
nl.endDirection = endDirection;
nl.hasRole = $bpxml.attr("hasRole");
nl.hasCondition = $bpxml.attr("hasCondition");
nl.ispass = $bpxml.attr("ispass");
nl.points = $vmlpxml.attr("newPoints");
if (nl.points == undefined || nl.points == null || nl.points == "") {
//nl.points = $vmlpxml.attr("points");
if (newLineCount == 0) {
backoldPic();
return;
}
try {
var tempPoints = "";
var startNode = workflowBase.getnNodeByNodeId(nl.from);
var endNode = workflowBase.getnNodeByNodeId(nl.to);
if (startNode.x < endNode.x && Math.abs(startNode.y - endNode.y) < 30) {
tempPoints = (startNode.x + 120) + "," + (startNode.y + 35) + ","
+ (endNode.x) + "," + (endNode.y + 35)
} else if (startNode.x > endNode.x && Math.abs(startNode.y - endNode.y) < 30) {
tempPoints = (startNode.x) + "," + (startNode.y + 35) + ","
+ (endNode.x + 120) + "," + (endNode.y + 35)
} else if (startNode.y < endNode.y ) {
tempPoints = (startNode.x + 60) + "," + (startNode.y + 100) + ","
+ (endNode.x + 60) + "," + (endNode.y)
} else if (startNode.y > endNode.y ) {
tempPoints = (startNode.x + 60) + "," + (startNode.y) + ","
+ (endNode.x + 60) + "," + (endNode.y + 100)
} else {
tempPoints = (startNode.x + 60) + "," + (startNode.y + 35) + ","
+ (endNode.x + 60) + "," + (endNode.y + 35)
}
nl.points = tempPoints;
} catch (e) {}
} else {
newLineCount++;
}
nl.shapetype = $vmlpxml.attr("shapetype");
nl.zIndex = $vmlpxml.attr("zIndex");
nl.fromRelX = $vmlpxml.attr("fromRelX");
nl.fromRelY = $vmlpxml.attr("fromRelY");
nl.toRelX = $vmlpxml.attr("toRelX");
nl.toRelY = $vmlpxml.attr("toRelY");
workflowBase.nodeLinks.push(nl);
});
$(xml).find('Group').each(function() {
var $bpxml = $(this);
var g = new Group();
g.id = $bpxml.attr("id");
g.workflowid = $bpxml.attr("workflowid");
g.groupName = $bpxml.attr("text");
g.direction = parseInt($bpxml.attr("direction"));
g.x = parseInt($bpxml.attr("x"));
g.y = parseInt($bpxml.attr("y"));
g.width = parseInt($bpxml.attr("width"));
g.height = parseInt($bpxml.attr("height"));
g.isNew = false;
workflowBase.groups.push(g);
});
return workflowBase;
};
};