/** * @see ProjectTemplateInterface::delete() * @return bool * @throws ProjectTemplateDeleteException * @throws ProjectTemplateDeleteInUseException * @throws ProjectTemplateDeleteOLDLDeleteExcepion */ public function delete() { global $transaction; if ($this->project_template and $this->project_template_id) { $project_array = Project::list_entries_by_template_id($this->project_template_id); if (is_array($project_array)) { if (count($project_array) != 0) { throw new ProjectTemplateDeleteInUseException(); } } $transaction_id = $transaction->begin(); $oldl = new Oldl($this->project_template->get_template_id()); if ($this->project_template->delete() == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectTemplateDeleteException("DB delete failed"); } if ($oldl->delete() == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectTemplateDeleteOLDLDeleteException(); } else { if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } } else { throw new ProjectTemplateDeleteException("Missing Information"); } }
/** * @see SampleTemplateInterface::delete() * @return bool */ public function delete() { global $transaction; if ($this->sample_template and $this->sample_template_id) { $sample_array = Sample::list_entries_by_template_id($this->sample_template_id); if (is_array($sample_array)) { if (count($sample_array) != 0) { return false; } } $transaction_id = $transaction->begin(); $oldl = new Oldl($this->sample_template->get_template_id()); if ($this->sample_template->delete() == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } if ($oldl->delete() == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } else { if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } } else { return false; } }