forked from josephwilk/iwfms
/
processSubmition.php
117 lines (73 loc) · 2.95 KB
/
processSubmition.php
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
<?
include_once( 'includes/configuration/core_configuration.php');
include_once("includes/commonPages/system_header.php");
if( $_SESSION['posted'] ){//This form has been posted so prevent a refresh
errors::errorMessage("The Form cannot be re-posted! Please go back to the home page");
}
else{
//Indicate the form has been posted
$_SESSION['posted'] = true;
debug::transferFormPosts($_POST);
//Fetch the plans from the database
$planGraphList = graphPlanDatabaseAccess::getPlanGraphList($_POST['workflowID']);
$result = planAction::actOnPlan($planGraphList, "edgeProgression");
$plannerProgress[0] = $result['actionPackets'];
$match=false;
$edgeProgressionResult = true;
$goal=false;
$indexTest=1;
while(!$match && $edgeProgressionResult && !$goal){//Process all edgeProgression actions
//Fetch the action packets
$actionPackets = $plannerProgress[0];
//Check the edgeprogression action has been matched
$edgeProgressionPacket = planningAgent::action($actionPackets, $_POST );
//Retreive whether the edge progression test was passed
$edgeProgressionResult = $edgeProgressionPacket['match'];
//Retrive the selected action packet
$selectedActionPacket = $edgeProgressionPacket['actionPacket'];
if($edgeProgressionResult){//The edgeprogression test succeded
//Check the chosen action packet
if( $selectedActionPacket->atGoal() ){//At goal node
$goal=true;
planArchieving::archive($_POST['workflowID']);
systemMessages::message("Goal node reached!");
}
else{
//Only one action packet should be returned
$plans = $selectedActionPacket->getPlans();
$newPlannerProgress = planAction::fetchNextAction($plans);
$action = node::getNodeData($newPlannerProgress[1]);
if($action->getPredicateName() != 'edgeProgression'){
$match=true;
}
else{
}
$plannerProgress = $newPlannerProgress;
$newPlannerProgress=array();
}
}
}
debug::message("edge progression test :" . $edgeProgressionResult);
if($edgeProgressionResult){
if(!$goal){//No point in updating plans if we have reached the goal
planningAgent::updatePlans($plans);
}
$xmlParser = new XMLtoArray($_POST['formName'].'.xml');
$xmlTree = $xmlParser->process();
//Package the xml data into objects
$xmlPackage= xmlPackage::package($xmlTree);
//Display the data as HTML
xmlDatabase::updateDatabases($xmlPackage, $_POST['workflowID'], $_POST, $goal);
}
else{//no progress
errors::errorMessage("Progression to a new workflow stage failed!");
$xmlParser = new XMLtoArray("jobSpecification.xml");
$xmlTree = $xmlParser->process();
//Package the xml data
$xmlPackage= xmlPackage::package($xmlTree);
//Display the data as HTML
xmlPackage::displayItem($xmlPackage,$_POST['workflowID'],'workflow','Current workflow item');
}
}
include_once("includes/commonPages/system_footer.php");
?>