Changeset 2908


Ignore:
Timestamp:
06/09/10 10:58:45 (14 years ago)
Author:
asaikawa
Message:

Ticket #1082 - Alteracoes para remocao da coluna wf_parent_activity_id da tabela egw_wf_interinstance_relations

Location:
trunk/workflow
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/workflow/inc/class.so_move_instances.inc.php

    r2591 r2908  
    318318                } 
    319319 
    320                 /* format the array elements for use in a SELECT SQL statement, e.g. [iid => 12, aid = 27] would produce (12, 27) */ 
    321                 $instanceActivityList = array_map(create_function('$e', 'return \'(\' . $e[\'iid\'] . \', \' . $e[\'aid\'] . \')\';'), $instanceActivityList); 
    322  
    323                 /* update the interinstance relations of the modified rows of the instance_activities table */ 
    324                 $resultSet = $this->db->query("SELECT wf_parent_instance_id, wf_parent_activity_id FROM egw_wf_interinstance_relations WHERE ((wf_parent_instance_id, wf_parent_activity_id) IN (" . implode(', ', $instanceActivityList) . "))"); 
    325                 $rows = $resultSet->GetArray(-1); 
    326                 if (is_array($rows)) 
    327                 { 
    328                         foreach ($rows as $row) 
    329                         { 
    330                                 /* update the activity ID */ 
    331                                 if (!$this->db->query("UPDATE egw_wf_interinstance_relations SET wf_parent_activity_id = ? WHERE (wf_parent_instance_id = ?) AND (wf_parent_activity_id = ?)", array($activitiesConvert[$row['wf_parent_activity_id']], $row['wf_parent_instance_id'], $row['wf_parent_activity_id']))) 
    332                                 { 
    333                                         $this->db->FailTrans(); 
    334                                         return array('error' => 'Erro atualizando a tabela de relacionamento inter-instância. Nenhuma modificação foi salva'); 
    335                                 } 
    336                         } 
    337                 } 
    338  
    339320                /* in case of success, commit the modifications */ 
    340321                $this->db->CompleteTrans(); 
  • trunk/workflow/inc/engine/src/API/Instance.php

    r2887 r2908  
    8484   */ 
    8585  var $parentLock = false; 
    86   /** 
    87    * @var int $parentActivityId The activity ID of the parent instance 
    88    * @access public 
    89    */ 
    90   var $parentActivityId; 
    9186  /** 
    9287   * @var int $parentInstanceId The instance ID of the parent instance 
     
    490485    return ''; 
    491486  } 
    492   
     487 
    493488  /** 
    494489   * Creates a new instance. 
     
    503498  function _createNewInstance($activityId,$user) { 
    504499    // 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 where wf_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)); 
    506501    $this->pId = $pid; 
    507502    $this->setStatus('active'); 
     
    515510    $iid=$this->instanceId; 
    516511 
    517     $query = 'insert into '.GALAXIA_TABLE_PREFIX.'instances 
    518       (wf_instance_id, wf_started,wf_ended,wf_status,wf_p_id,wf_owner,wf_properties)  
    519       values(?,?,?,?,?,?,?)'; 
    520  
    521    $this->query($query,array((int)$iid, $now,0,'active',$pid,$user,$this->security_cleanup(Array(),false))); 
    522   
     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 
    523519    // Then add in ".GALAXIA_TABLE_PREFIX."instance_activities an entry for the 
    524520    // activity the user and status running and started now 
    525     $query = 'insert into '.GALAXIA_TABLE_PREFIX.'instance_activities (wf_instance_id,wf_activity_id,wf_user, 
    526             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                (?,?,?,?,?)'; 
    527525    $this->query($query,array((int)$iid,(int)$activityId,$user,(int)$now,'running')); 
    528526 
    529527    if (($this->isChildInstance) && (!is_null($this->parentInstanceId))) 
    530528    { 
    531       $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'interinstance_relations(wf_parent_instance_id, wf_parent_activity_id, wf_child_instance_id, wf_parent_lock) VALUES(?,?,?,?)'; 
    532       $this->query($query,array((int) $this->parentInstanceId, (int) $this->parentActivityId, (int) $iid, (int) (($this->parentLock) ? 1 : 0))); 
    533     } 
    534      
     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 
    535536    //update database with other datas stored in the object 
    536537    return $this->sync(); 
    537538  } 
    538    
     539 
    539540  /** 
    540541   * Sets the name of this instance 
     
    11421143    return $this->__activity_completed; 
    11431144  } 
    1144   
     1145 
    11451146  /** 
    11461147   * This function can be called by the instance object himself (for automatic activities) 
    1147    * or by the WfRuntime object. In interactive activities code users use complete() --without args--  
    1148    * 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. 
    11491150   * In non-interactive activities a call to a complete() will generate errors because the engine 
    11501151   * does it his own way as I said first. 
     
    11621163  { 
    11631164    //$this->db-> 
    1164     $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)); 
    11651166    if ($result->numRows() > 0) 
    11661167      die("Esta instância está aguardando que outras instâncias, das quais depende, sejam finalizadas."); 
     
    11701171    //The complete() is in a transaction, it will be completly done or not at all 
    11711172    $this->db->StartTrans(); 
    1172      
     1173 
    11731174    //lock rows and ensure access is granted 
    11741175    if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity'); 
  • trunk/workflow/inc/engine/src/common/WfRuntime.php

    r2776 r2908  
    10891089    $run_activity = Factory::newInstance('run_activity'); 
    10901090    $run_activity->runtime->instance->parentInstanceId = $this->instance_id; 
    1091     $run_activity->runtime->instance->parentActivityId = $this->activity_id; 
    10921091    $output = $run_activity->goChildInstance($activityID, $properties, $user, $parentLock); 
    10931092    $_REQUEST['iid'] = $iid; 
     
    11281127  function getParent() 
    11291128  { 
    1130     $resultSet = $this->query("SELECT wf_parent_instance_id, wf_parent_activity_id, wf_parent_lock FROM egw_wf_interinstance_relations WHERE (wf_child_instance_id = ?)", array($this->getInstanceId())); 
     1129    $resultSet = $this->query("SELECT wf_parent_instance_id, wf_parent_lock FROM egw_wf_interinstance_relations WHERE (wf_child_instance_id = ?)", array($this->getInstanceId())); 
    11311130    if (($row = $resultSet->fetchRow())) 
    1132       return array('instance_id' => $row['wf_parent_instance_id'], 'activity_id' => $row['wf_parent_activity_id'], 'lock' => ($row['wf_parent_lock'] == 1)); 
     1131      return array('instance_id' => $row['wf_parent_instance_id'], 'lock' => ($row['wf_parent_lock'] == 1)); 
    11331132    else 
    11341133      return false; 
  • trunk/workflow/setup/tables_current.inc.php

    r1229 r2908  
    190190                                'fd' => array( 
    191191                                        'wf_parent_instance_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    192                                         'wf_parent_activity_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    193192                                        'wf_child_instance_id'  => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    194193                                        'wf_parent_lock'                => array('type' => 'int', 'precision' => '2', 'nullable' => True) 
    195194                                ), 
    196                                 'pk' => array('wf_parent_instance_id', 'wf_parent_activity_id', 'wf_child_instance_id'), 
     195                                'pk' => array('wf_parent_instance_id', 'wf_child_instance_id'), 
    197196                                'fk' => array(), 
    198197                                'ix' => array(), 
  • trunk/workflow/setup/tables_update.inc.php

    r2757 r2908  
    12781278                        /* reconnect to the previous database */ 
    12791279                        $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
     1280 
     1281                        /* removing primary key of egw_wf_interinstance_relations */ 
     1282                        $GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations DROP CONSTRAINT egw_wf_interinstance_relations_pkey'); 
     1283 
     1284                        /* removing wf_parent_activity_id column from egw_wf_interinstance_relations table */ 
     1285                        $GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations DROP COLUMN wf_parent_activity_id'); 
     1286 
     1287                        /* adding primary key without the column removed */ 
     1288                        $GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations ADD CONSTRAINT egw_wf_interinstance_relations_pkey PRIMARY KEY (wf_parent_instance_id, wf_child_instance_id)'); 
    12801289                } 
    12811290 
Note: See TracChangeset for help on using the changeset viewer.