function updateDatabases($xmlPackage, $workflowId, $formData, $goal) { global $db; $db = connect($xmlPackage->getDb()); debug::message("connect to db:" . $xmlPackage->getDb() . '<br>'); $newDataItem = new coreWorkflowDataPacket($workflowId, array()); $tables = $xmlPackage->getTables(); if (sizeof($tables) > 0) { //For each table for ($tableIndex = 0; $tableIndex < sizeof($tables); $tableIndex++) { $table = $tables[$tableIndex]->getTableName(); $valsArray['workflowId'] = $workflowId; $fields = $tables[$tableIndex]->getDbFields(); //The fields specificed for ($index = 0; $index < sizeof($fields); $index++) { $field = $fields[$index]; $valsArray[$field] = addslashes($formData[$field]); } //Does this workflow item already exist in the table $sql_query = "workflowId='{$workflowId}'"; if (dbpear::numRecords($table, "{$sql_query}")) { $keyName = dbs::getprimarykey($table); $keyValue = dbpear::selAttribute($keyName, $table, $sql_query); dbs::updaterecord($table, $valsArray, $keyName, $keyValue); } else { dbs::irrecord($table, $valsArray, false); } $db = connect('iWFMS'); } $xmlParser = new XMLtoArray("jobSpecification.xml"); $xmlTree = $xmlParser->process(); //Package the xml data $xmlPackage = xmlPackage::package($xmlTree); if (!$goal) { //We are not at the goal node //Display the data as HTML xmlPackage::displayItem($xmlPackage, $workflowId, 'workflow', 'Current workflow item'); } else { //We are at the goal node xmlPackage::displayArchiveItem($xmlPackage, $workflowId, 'workflowArchive', 'Current archived workflow item', 'archive'); } } else { $xmlParser = new XMLtoArray("jobSpecification.xml"); $xmlTree = $xmlParser->process(); //Package the xml data $xmlPackage = xmlPackage::package($xmlTree); //Display the data as HTML xmlPackage::displayItem($xmlPackage, $workflowId, 'workflow', 'Current workflow item'); } }
} 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";