- Timestamp:
- 07/15/10 17:50:39 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/workflow/branches/1015/inc/engine/src/API/Instance.php
r2588 r3061 84 84 */ 85 85 var $parentLock = false; 86 /**87 * @var int $parentActivityId The activity ID of the parent instance88 * @access public89 */90 var $parentActivityId;91 86 /** 92 87 * @var int $parentInstanceId The instance ID of the parent instance … … 490 485 return ''; 491 486 } 492 487 493 488 /** 494 489 * Creates a new instance. … … 503 498 function _createNewInstance($activityId,$user) { 504 499 // Creates a new instance setting up started, ended, user, status and owner 505 $pid = $this->getOne(' select wf_p_id from '.GALAXIA_TABLE_PREFIX.'activities wherewf_activity_id=?',array((int)$activityId));500 $pid = $this->getOne('SELECT wf_p_id FROM '.GALAXIA_TABLE_PREFIX.'activities WHERE wf_activity_id=?',array((int)$activityId)); 506 501 $this->pId = $pid; 507 502 $this->setStatus('active'); … … 510 505 $this->setStarted($now); 511 506 $this->setOwner($user); 512 513 $query = 'insert into '.GALAXIA_TABLE_PREFIX.'instances 514 (wf_started,wf_ended,wf_status,wf_p_id,wf_owner,wf_properties) 515 values(?,?,?,?,?,?)'; 516 $this->query($query,array($now,0,'active',$pid,$user,$this->security_cleanup(Array(),false))); 517 $this->instanceId = $this->getOne('select max(wf_instance_id) from '.GALAXIA_TABLE_PREFIX.'instances 518 where wf_started=? and wf_owner=?',array((int)$now,$user)); 507 508 //Get the id of new instance, before insert values in table and use this value from main table and relationship tables. 509 $this->instanceId = $this->getOne("SELECT nextval('seq_egw_wf_instances')"); 519 510 $iid=$this->instanceId; 520 511 512 $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'instances 513 (wf_instance_id, wf_started,wf_ended,wf_status,wf_p_id,wf_owner,wf_properties) 514 VALUES 515 (?,?,?,?,?,?,?)'; 516 517 $this->query($query,array((int)$iid, $now,0,'active',$pid,$user,$this->security_cleanup(Array(),false))); 518 521 519 // Then add in ".GALAXIA_TABLE_PREFIX."instance_activities an entry for the 522 520 // activity the user and status running and started now 523 $query = 'insert into '.GALAXIA_TABLE_PREFIX.'instance_activities (wf_instance_id,wf_activity_id,wf_user, 524 wf_started,wf_status) values(?,?,?,?,?)'; 521 $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'instance_activities 522 (wf_instance_id,wf_activity_id,wf_user,wf_started,wf_status) 523 VALUES 524 (?,?,?,?,?)'; 525 525 $this->query($query,array((int)$iid,(int)$activityId,$user,(int)$now,'running')); 526 526 527 527 if (($this->isChildInstance) && (!is_null($this->parentInstanceId))) 528 528 { 529 $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'interinstance_relations(wf_parent_instance_id, wf_parent_activity_id, wf_child_instance_id, wf_parent_lock) VALUES(?,?,?,?)'; 530 $this->query($query,array((int) $this->parentInstanceId, (int) $this->parentActivityId, (int) $iid, (int) (($this->parentLock) ? 1 : 0))); 531 } 532 529 $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'interinstance_relations 530 (wf_parent_instance_id, wf_child_instance_id, wf_parent_lock) 531 VALUES 532 (?,?,?)'; 533 $this->query($query,array((int) $this->parentInstanceId, (int) $iid, (int) (($this->parentLock) ? 1 : 0))); 534 } 535 533 536 //update database with other datas stored in the object 534 537 return $this->sync(); 535 538 } 536 539 537 540 /** 538 541 * Sets the name of this instance … … 1140 1143 return $this->__activity_completed; 1141 1144 } 1142 1145 1143 1146 /** 1144 1147 * This function can be called by the instance object himself (for automatic activities) 1145 * or by the WfRuntime object. In interactive activities code users use complete() --without args-- 1146 * which refer to the WfRuntime->complete() function which call this one. 1148 * or by the WfRuntime object. In interactive activities code users use complete() --without args-- 1149 * which refer to the WfRuntime->complete() function which call this one. 1147 1150 * In non-interactive activities a call to a complete() will generate errors because the engine 1148 1151 * does it his own way as I said first. … … 1160 1163 { 1161 1164 //$this->db-> 1162 $result = $this->query("SELECT 1 FROM " . GALAXIA_TABLE_PREFIX . "instances i, " . GALAXIA_TABLE_PREFIX . "interinstance_relations ir WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (i.wf_status IN ('active', 'exception')) AND (ir.wf_parent_lock = 1) AND (ir.wf_parent_instance_id = ?) AND (ir.wf_parent_activity_id = ?)", array($this->instanceId, $activityId));1165 $result = $this->query("SELECT 1 FROM " . GALAXIA_TABLE_PREFIX . "instances i, " . GALAXIA_TABLE_PREFIX . "interinstance_relations ir WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (i.wf_status IN ('active', 'exception')) AND (ir.wf_parent_lock = 1) AND (ir.wf_parent_instance_id = ?)", array($this->instanceId)); 1163 1166 if ($result->numRows() > 0) 1164 1167 die("Esta instância está aguardando que outras instâncias, das quais depende, sejam finalizadas."); … … 1168 1171 //The complete() is in a transaction, it will be completly done or not at all 1169 1172 $this->db->StartTrans(); 1170 1173 1171 1174 //lock rows and ensure access is granted 1172 1175 if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity');
Note: See TracChangeset
for help on using the changeset viewer.