-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadder.php
More file actions
339 lines (233 loc) · 8.48 KB
/
adder.php
File metadata and controls
339 lines (233 loc) · 8.48 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?php
require_once 'globalVariables.php';
require_once 'HTTP/Request2.php'; //uses PEAR
$pmui = unserialize($_POST['pmui']);
$id = $_POST['id'];
//var_dump($pmui);
$atname = "tool-id";
$tname = "translation";
$atorder = "order";
$torder = "1";
$placeInArr = "1";
unset($pmui['p_name']);
unset($pmui['p_descrip']);
//PREPARATION STAGE, check client, if client Symantec, use DDC, otherwise move on. If use
// DDC call WRF again, this time cat info should be in place
// Do we include the DST task?
// IF client is not symantec, do nothing, else add DDC to the array.
if (strtolower($pmui['p_client']) != "symantec"){
unset($pmui['p_client']);
unset($pmui['p_cat']);
//print "Deleted LMC for {$id} </br>"; // This removes the element from the array
} else {
unset($pmui['p_client']);
//We know client is symantec, check if cat is secur. of avail., if it is not, delete cat,
//else, save cat to add DST later on
if ((strtolower($pmui['p_cat']) != "security") && (strtolower($pmui['p_cat']) != "availability")) {
unset($pmui['p_cat']);
print "Deleted DST for {$id} </br>"; // This removes the element from the array
//unset($pmui['p_client']);
} else{
$pmui['p_cat'] = "DST";
//unset($pmui['p_client']);
}
}
//END OF Do we include the DST task?
/*
// Do we include the DST task?
//If p_cat is not security or availabitity, do not include DST
if ((strtolower($pmui['p_cat']) != "security") && (strtolower($pmui['p_cat']) != "availability")) {
unset($pmui['p_cat']);
print "Deleted DST for {$id} </br>"; // This removes the element from the array
// If we get here it means p_cat is security or availability, check if the client is symantec, if it is, add DST
} elseif (strtolower($pmui['p_client']) == "symantec") {
$pmui['p_cat'] = "DST";
$pmui[$placeInArr] = $pmui['p_cat'];
$placeInArr++;
unset($pmui['p_client']);
print "ADDED DST for {$id} </br>";
unset($pmui['p_cat']);
//If we get here in means p_cat is security or availability but the client is not symantec, just delete p_cat from array
} else {
unset($pmui['p_cat']);
unset($pmui['p_client']);
}
//END OF Do we include the DST task?
*/
// Do we include the LMC task?
if (strtolower($pmui['LMCresource']) == "no"){
unset($pmui['LMCresource']);
//print "Deleted LMC for {$id} </br>"; // This removes the element from the array
} else {
$pmui['LMCresource'] = "LMC";
$pmui[$placeInArr] = $pmui['LMCresource'];
$placeInArr++;
unset($pmui['LMCresource']);
}
//END OF Do we include the LMC task?
// Do we include the DST task?
if (array_key_exists('p_cat', $pmui)){
$pmui[$placeInArr] = $pmui['p_cat'];
$placeInArr++;
unset($pmui['p_cat']);
}
//END OF Do we include the DST task?
//Do we include MT
if (strtolower($pmui['p_useMt']) == "no"){
unset($pmui['p_useMt']);
//print "Deleted MACHINE TRANSLATION for {$id} </br>"; // This removes the element from the array
} else {
$pmui['p_useMt'] = "MT";
$pmui[$placeInArr] = $pmui['p_useMt'];
$placeInArr++;
unset($pmui['p_useMt']);
}
//END OF Do we include MT
//Do we include the RT task?
if (strtolower($pmui['p_useRating']) == "no"){
unset($pmui['p_useRating']); // This removes the element from the array
//print "Deleted RATING for {$id} </br>";
}else{
$pmui['p_useRating'] = "RT";
$pmui[$placeInArr] = $pmui['p_useRating'];
$placeInArr++;
unset($pmui['p_useRating']);
}
//END OF Do we include the RT task?
//Do we include the GS task?
if (strtolower($pmui['p_qrequirement']) !== "MELON"){
unset($pmui['p_qrequirement']);
//print "Deleted POST EDITING for {$id} </br>"; // This removes the element from the array
}else{
$pmui['p_qrequirement'] = "GS";
$pmui[$placeInArr] = $pmui['p_qrequirement'];
$placeInArr++;
unset($pmui['p_qrequirement']);
}
//END OF Do we include the GS task?
//we always include the CMP task?
$pmui[$placeInArr] = "CMP";
$placeInArr++;
//END OF we always include the CMP task
//unset($pmui['words']);
unset($pmui['p_startdate']);
unset($pmui['p_deadline']);
unset($pmui['p_budget']);
ksort($pmui);
//print "<br /><br />";
//GET THE DOCUMENT LOAD IT PREPARE TO WRITE ON IT
$doc = new DOMDocument();
$doc->load( $localFolder .$id .'.xlf' );
$xpath = new DOMXPath($doc);
$melons = $doc->getElementsByTagName( 'task' );
$text= "/n";
$torder= $melons->length;
$torder++;
//$torder++;
print "THE TASK COUNT IS {$torder}";
// DELETE DELETE OLD WF
$domNodeList = $doc->getElementsByTagname('workflow');
foreach ( $domNodeList as $domElement ) {
// ...do stuff with $domElement...
$domElement->parentNode->removeChild($domElement);
}
// END OF DELETE OLD WF
$form = "form";
$type = "text";
$tasklistf = "";
$headers = $doc->getElementsByTagName( 'header' );
$text= "/n";
foreach( $headers as $header )
{
$reference = $doc->createElement("reference");
$header->appendChild($reference);
$ifile = $doc->createElement("internal-file");
$reference->appendChild($ifile);
$ifile->setAttribute($form, $type);
$wf = $doc->createElement("workflow");
$ifile->appendChild($wf);
foreach ($pmui as $value) {
$ltask = $doc->createElement("task");
$wf->appendChild($ltask);
$ifile->setAttribute($form, $type);
$ltask->setAttribute($atname, $value);
$ltask->setAttribute($atorder, $torder);
//Create check to see if a comma or a full stop is needed. Coom
// becomes . if the order number is equal to the lengh of the
//array pmui (count($pmui)) otherwise, it is comma
$comm = ($torder == (count($pmui))) ? '.' : ', ';
$torder++;
$tasklist = $value;
$tasklistf = $tasklistf . $tasklist . $comm;
}
}
//PHASE STUFF FROM NAOTO
print "JUST BEFORE THE PHASE GROUP CHECK";
// CHECK if there is a phase-group if not, add it
$countNodes = $doc->getElementsByTagName('phase-group');
if ($countNodes->length==0) {
// add a phase group inside the header
print "No phase group";
$heads= $doc->getElementsByTagName('header');
$root_child=$doc->createElement('phase-group');
$heads ->appendChild($root_child);
} Else {
//There is a phase-group and nothing hapens
print "YAY phase group";
}
//Add check, if there is no phase group, must add it.
$phasegroups = $doc->getElementsByTagName('phase-group');
$toolid='WF';
$phasename='WF-Recommendation';
foreach($phasegroups as $phasegroup)
{
$root_child=$doc->createElement('phase');
$phasegroup ->appendChild($root_child);
$root_attr1 = $doc->createAttribute('phase-name');
$root_child->appendChild($root_attr1);
$root_text = $doc->createTextNode($phasename);
$root_attr1 ->appendChild($root_text);
$root_attr2 = $doc->createAttribute('company-name');
$root_child->appendChild($root_attr2);
$root_text = $doc->createTextNode('SomeCompany');
$root_attr2 ->appendChild($root_text);
$root_attr3 = $doc->createAttribute('process-name');
$root_child->appendChild($root_attr3);
$root_text = $doc->createTextNode('WF-Recommender');
$root_attr3 ->appendChild($root_text);
$root_attr4 = $doc->createAttribute('contact-name');
$root_child->appendChild($root_attr4);
$root_text = $doc->createTextNode('Aram');
$root_attr4 ->appendChild($root_text);
$root_attr5 = $doc->createAttribute('contact-email');
$root_child->appendChild($root_attr5);
$root_text = $doc->createTextNode('aram.morera-mesa@ul.ie');
$root_attr5 ->appendChild($root_text);
$root_attr6 = $doc->createAttribute('tool-id');
$root_child->appendChild($root_attr6);
$root_text = $doc->createTextNode($toolid);
$root_attr6 ->appendChild($root_text);
$date=date("r", time());
$root_attr7 = $doc->createAttribute('date');
$root_child->appendChild($root_attr7);
$root_text = $doc->createTextNode($date);
$root_attr7 ->appendChild($root_text);
}
// END OF PHASE STUFF FROM NAOTO
//var_dump($pmui);
$doc->save($localFolder . $id .'.xlf');
//}
//print "yo ";
$msg = "The workflow recommender has added ". ($torder - 1) . " task(s): " . $tasklistf ;
$request = new HTTP_Request2($this_url.'feedbacker.php', HTTP_Request2::METHOD_GET);
$url = $request->getUrl();
$url->setQueryVariable('id', $id); // set job id here
$url->setQueryVariable('msg', $msg); // set status id here
$request->send();
$request = new HTTP_Request2($this_url.'outputer.php', HTTP_Request2::METHOD_GET);
$url = $request->getUrl();
$url->setQueryVariable('id', $id); // set job id here
$melons=$request->send()->getBody();
//print "<br /><br /> parser done <br /><br /> ";
print $melons;
?>