-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse5.php
More file actions
executable file
·303 lines (218 loc) · 9.96 KB
/
Copy pathparse5.php
File metadata and controls
executable file
·303 lines (218 loc) · 9.96 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
<?php
require_once 'HTTP/Request2.php'; //uses PEAR
require_once 'globalVariables.php';
$jobs = unserialize($_POST['jobs']);
$msg = ""; //A string to contain all the feedback
//print "from Parse <br /><br />";
foreach( $jobs as $id )
{
$xmlDoc = new DOMDocument();
$xmlDoc->load( $localFolder . $id . '.xlf' );
// CHECK if there is an external resource for the LMC
$countNodes = $xmlDoc->getElementsByTagName("external-file");
if ($countNodes->length==0) {
// print "THERE IS NO ATTACHED RESOURCE in job $id <br />";
$LMCresource = "no";
} Else {
$LMCresource = "yes";
}
//END OF CHECK if there is an external resource for the LMC
//CHECK IF THERE IS A WORDCOUNT
/*
$countNodes = $xmlDoc->getElementsByTagName("count");
if ($countNodes->length==0) {
//print "THERE IS NO COUNT in job $id <br />";
$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', 'There was no count element of any kind '); // set status id here
$request->send();
print "Job $id failed. Check feedback for more information. <br />";
die;
}
//END OF CHECK IF THERE IS A WORDCOUNT
//GET THE VALUE OF WORDCOUNT
foreach ( $countNodes as $countNode ) {
switch ($countNode->getAttribute('unit')) {
case 'word':
$words = $countNode->nodeValue;
//print "<br />The word count is: $words<br />";
break 2;
case 'segment':
print "<br />In project $id, there is a \"segment\" count. This system only uses word counts<br />";
$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', 'There is a \"segment\" count. This system only uses word counts'); // set status id here
$request->send();
break;
case 'character':
//print "<br />In project $id, there is a \"character\" count. This system only uses word counts<br />";
$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', 'There is a \"character\" count. This system only uses word counts'); // set status id here
$request->send();
break;
default:
//print "In project $id, there is no word count element";
$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', 'There is no word count element'); // set status id here
$request->send();
$request->send();
break;
}
}
*/
//END GET THE VALUE OF WORDCOUNT
//CHECK IF THERE IS EXISTING WORKFLOW INFORMATION AND
//AND THE FILE HAS NOT GONE TRHOUGH WFR YET, IF IT IS
//SO, THE FILE HAS TO BE SENT TO CMG
$searchNodes = $xmlDoc->getElementsByTagName( "workflow" );
//If there is no WORKFLOW
if ($searchNodes->length==0) {
//If there is no workflow do nothing
//print "THERE IS NO WORKFLOW";
}else{
//print "THERE IS WORKFLOW";
//This happens when THERE IS WORKFLOW info, check if the files has NOT gone
//through the WFR, if there is a phase that has the attribute
// tood id with the value WFR, then do Nothing
$searchNodes = $xmlDoc->getElementsByTagName( "phase" );
if ($searchNodes->length==0) {
//CHECK IF THERE IS NO PHASE IF IT IS SO
// SEND ERROR MESSAGE TO FEEDBACKER
$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', 'THERE IS WORKFLOW INFORMATINO FROM AN UNKNOWN SOURCE'); // set status id here
$request->send();
print "Job $id failed. Check feedback for more information. <br />";
exit();
}else{
//this happens if there is workflow and phase elements
foreach( $searchNodes as $searchNode ) {
$toolid = $searchNode->getAttribute('tool-id');
if ($toolid == "WFR"){
//print "THERE IS WORKFLOW AND THE FILE HAS BEEN THROUGH THE WFR";
//This happens if the file has been through the workflow
break;
}else{
//this happens if the file has not been through the WFR
//print "THERE IS WORKFLOW INFO BUT NO WRF";
//and there is workflow info, hence, send it to the CMG
//using adder3 that simply adds the phase and sends it back to
//outputter
require_once 'HTTP/Request2.php'; // uses Pear
$request = new HTTP_Request2($this_url.'/adder3.php');
$request->setMethod(HTTP_Request2::METHOD_POST)
->addPostParameter('id', $id);
$melons=$request->send()->getBody();
print "<br /><br /> parser done <br /><br /> ";
print $melons;
print "The file contained a custom workflow and has been sent back as it is.<br /> ";
exit();
}
}
}
$pmui = array("p_client"=>$p_client);
$pmui = serialize($pmui);
require_once 'HTTP/Request2.php'; // uses Pear
$request = new HTTP_Request2($this_url.'adder2.php');
$request->setMethod(HTTP_Request2::METHOD_POST)
->addPostParameter('pmui', $pmui)
->addPostParameter('id', $id);
$melons=$request->send()->getBody();
}
//CHECK IF THERE IS PMUI DATA
$searchNodes = $xmlDoc->getElementsByTagName( "pmui-data" );
//If there is no PMUI DATA send feedback using feedbacker
if ($searchNodes->length==0) {
//print "THERE IS NO PMUI DATA in job $id <br /> ";
$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', 'THERE IS NO PMUI DATA in job'); // set status id here
$request->send();
print "Job $id failed. Check feedback for more information. <br />";
//print "<br /> THe code to send the feedback HAS BEEN EXECUTED";
}else{
//END CHECK IF THERE IS PMUI DATA
//STORE PMUI DATA IN AN ARRAY
foreach( $searchNodes as $searchNode )
{
$p_name = $searchNode->getAttribute('pname');
$p_descrip = $searchNode->getAttribute('pdescription');
$p_startdate = $searchNode->getAttribute('startdate');
$p_deadline = $searchNode->getAttribute('deadline');
$p_budget = $searchNode->getAttribute('budget');
$p_qrequirement = $searchNode->getAttribute('qrequirement');
$p_client = $searchNode->getAttribute('client');
$p_useRating = $searchNode->getAttribute('use-rating');
$p_useMt = $searchNode->getAttribute('use-mt');
}
$request2 = new HTTP_Request2($locconnect.'get_resource.php?id='.$id, HTTP_Request2::METHOD_POST);
$url = $request2->getUrl();
$url->setQueryVariable('id', $id); // set job id here
$melons2=$request2->send()->getBody();
//print $melons2;
if ((substr($melons2, 1, 5)) == "error"){
$LMCresource = "NO";
}else{
$LMCresource = "YES";
}
//END CHECK FOR RESOURCE LMC
// CATEGORY STUFF
if ((strtolower($p_client)) == "symantec"){
$searchNodesCat = $xmlDoc->getElementsByTagName( "file" );
//Store category
foreach( $searchNodesCat as $searchNodeCat )
{
$p_cat = $searchNodeCat->getAttribute('category');
print "The cathegory is $p_cat <br /> ";
}
}else{}
// END CATEGORY STUFF
$countNodes = $xmlDoc->getElementsByTagName("phase-group");
if ($countNodes->length==0) {
//IF THIS HAPPENS IT IS BECAUSE THERE IS NO PHASE GROUP ELEMENT YET
//WHICH MEANS THAT THE FILE HAS NOT GONE THROUGH ANY COMPONENT YET
//SEND TO ADDER2 THAT ADDS ,THE WORKFLOW INFO FOR THE PREPARATION PHASE AND STOP THIS SCRIPT
$pmui = array("p_client"=>$p_client);
$pmui = serialize($pmui);
require_once 'HTTP/Request2.php'; // uses Pear
$request = new HTTP_Request2($this_url.'adder2.php');
$request->setMethod(HTTP_Request2::METHOD_POST)
->addPostParameter('pmui', $pmui)
->addPostParameter('id', $id);
$melons=$request->send()->getBody();
print "<br /><br /> parser done <br /><br /> ";
print $melons;
print "THE FILE WAS SENT FOR PREPARATION TESTING<br /> ";
exit();
//END SEND TO ADDER2 THAT ADDS THE WORKFLOW INFO FOR THE PREPARATION STAGE
} Else {}
//IF THIS HAPPENS IT IS BECAUSE THERE WERE PHASE ELEMENTS BEFORE, SO THE FILE IS ALREADY
//PREPARED AND WE NEED TO SEND IT FOR TRANSFORMATION PHASE
//CHECK FOR RESOURCE LMC STUFF
// IF WE GET HERE IT IS BECAUSE THE FILE HAS BEEN PREPARED.
$pmui = array("LMCresource"=>$LMCresource, "p_client"=>$p_client, "p_cat"=>$p_cat, "p_name"=>$p_name, "p_descrip"=>$p_descrip, "p_startdate"=>$p_startdate,"p_deadline"=> $p_deadline, "p_budget"=>$p_budget, "p_qrequirement"=>$p_qrequirement, "p_useRating"=>$p_useRating, "p_useMt"=>$p_useMt);
// with word count $pmui = array("LMCresource"=>$LMCresource, "p_cat"=>$p_cat, "p_name"=>$p_name, "p_descrip"=>$p_descrip, "words"=>$words, "p_startdate"=>$p_startdate,"p_deadline"=> $p_deadline, "p_budget"=>$p_budget, "p_qrequirement"=>$p_qrequirement, "p_useRating"=>$p_useRating, "p_useMt"=>$p_useMt);
// Original Line $pmui = array("LMCresource"=>$LMCresource, "p_name"=>$p_name, "p_descrip"=>$p_descrip, "words"=>$words, "p_startdate"=>$p_startdate,"p_deadline"=> $p_deadline, "p_budget"=>$p_budget, "p_qrequirement"=>$p_qrequirement, "p_useRating"=>$p_useRating, "p_useMt"=>$p_useMt);
//END STORE PMUI DATA IN AN ARRAY
//send to adder to Add tasks according to metadata
$pmui = serialize($pmui);
require_once 'HTTP/Request2.php'; // uses Pear
$request = new HTTP_Request2($this_url.'adder.php');
$request->setMethod(HTTP_Request2::METHOD_POST)
->addPostParameter('pmui', $pmui)
->addPostParameter('id', $id);
$melons=$request->send()->getBody();
//print "<br /><br /> parser done <br /><br /> ";
print $melons;
//if substr($melons, 0 = "There is no resource corresponding to Resource ID:"
}
}
?>