/** * Add a new rule in the DB * * @param Tracker_Workflow_Trigger_TriggerRule $rule */ public function add(Tracker_Workflow_Trigger_TriggerRule $rule) { try { $this->dao->enableExceptionsOnError(); $this->dao->startTransaction(); $rule_id = $this->dao->addTarget($rule->getTarget()->getValue()->getId(), $rule->getCondition()); $rule->setId($rule_id); foreach ($rule->getTriggers() as $triggering_field) { $this->dao->addTriggeringField($rule_id, $triggering_field->getValue()->getId()); } $this->dao->commit(); } catch (DataAccessException $exception) { throw new Tracker_Workflow_Trigger_Exception_RuleException('Database error: cannot save'); } }