/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = UseCaseEvent::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
$string .= "Caso d'uso {$number}: {$useCase->title}"; $string .= "\n \\begin{figure}[H]\n \\centering \n \\includegraphics[scale=0.95]{img/ucsample.pdf}\n \\caption{Caso d'uso {$number} (UC{$number})}\\label{fig:uc_{$number}} \n \\end{figure}"; $string .= "\n \\begin{itemize}\n \\item \\textbf{Attori}: {$actors};\n \\item \\textbf{Scopo e descrizione}: {$useCase->description}; \n \\item \\textbf{Pre-condizioni}: {$useCase->pre};\n \\item \\textbf{Flusso principale degli eventi}:\n \\begin{enumerate}\n"; foreach (UseCaseEvent::model()->findAll("use_case = {$useCase->id_use_case} AND category = 1") as $event) { //TODO reorder results by 'order' field $string .= " \\item {$event->description}"; if ($event->refers_to) { $number = $this->generateNumber(UseCase::model()->findByPk($event->refers_to)); $string .= " (UC{$number})"; } echo "\n"; } $string .= "\n \\end{enumerate}\n"; if (UseCaseController::hasAlternate($useCase)) { $string .= " \\item \\textbf{Scenari Alternativi}:\n \\begin{enumerate}\n"; foreach (UseCaseEvent::model()->findAll("use_case = {$useCase->id_use_case} AND category = 2") as $event) { //TODO reorder results by 'order' field $string .= " \\item {$event->description}"; if ($event->refers_to) { $number = UseCaseController::generateNumber(UseCase::model()->findByPk($event->refers_to)); $string .= "(UC{$number})"; } echo "\n"; } $string .= "\n \\end{enumerate}\n"; } $string .= " \\item \\textbf{Post-condizioni}: {$useCase->post};\n"; $string .= " \\end{itemize}"; $sourceArray[UseCaseController::generateNumber($useCase)] = $string; } foreach ($sourceArray as $key => $source) {
function getActors($model) { $actors = array(); $string = ''; foreach (UseCaseEvent::model()->findAll("use_case = {$model->id_use_case}") as $events) { $actor = $events->primary_actor; if (!isset($actors[$actor])) { $actors[$actor] = 0; } else { $actors[$actor]++; } } foreach ($actors as $idA => $t) { $string .= Actor::model()->findByPk($idA)->description . ", "; } return $string != '' ? substr($string, 0, -2) : $string; }
function display_uc($useCase, $raw) { $string = ''; $id = $useCase->public_id(); //$actors = implode(', ',$useCase->actors()); $string .= "\\hypertarget{{$id}}{}\n\\subsection{Caso d'uso {$id}: {$useCase->title}}"; if (isset($useCase->useCaseEvents) && count($useCase->useCaseEvents)) { $string .= "\n \\begin{figure}[H]\n \\centering\n \\includegraphics[scale=0.95]{img/{$id}.pdf}\n \\caption{Caso d'uso {$id}: {$useCase->title}}\\label{fig:{$id}} \n \\end{figure}"; } $string .= "\\begin{itemize}\n"; /// @warning HARD CODED DB PK!!!!!!!!!!! if ($useCase->id_use_case != 52) { $string .= "\\item \\textbf{Attori}: Utente;\n"; } $string .= "\\item \\textbf{Scopo e descrizione}: {$useCase->description}; \n \\item \\textbf{Precondizione}: {$useCase->pre};\n"; $prim = UseCaseEvent::model()->findAll(array('order' => '`order`', 'condition' => 'category=1 and use_case=:uc', 'params' => array(':uc' => $useCase->id_use_case))); if (count($prim) > 0) { $string .= "\n \\item \\textbf{Flusso principale degli eventi}:\n \\begin{enumerate}\n"; foreach ($prim as $event) { $string .= " \\item {$event->description}"; if ($event->refers_to) { $child_id = $event->with('refersTo')->refersTo->public_id(); $string .= " (\\hyperlink{{$child_id}}{{$child_id}})"; } $string .= ";\n"; } $string .= "\n \\end{enumerate}\n"; } $alt = UseCaseEvent::model()->findAll(array('order' => '`order`', 'condition' => 'category=3 and use_case=:uc', 'params' => array(':uc' => $useCase->id_use_case))); if (count($alt)) { $string .= " \\item \\textbf{Estensioni}:\n \\begin{enumerate}\n"; foreach ($alt as $event) { $string .= " \\item {$event->description}"; if ($event->refers_to) { $child_id = $event->with('refersTo')->refersTo->public_id(); $string .= " (\\hyperlink{{$child_id}}{{$child_id}})"; } $string .= ";\n"; } $string .= "\n \\end{enumerate}\n"; } $alt = UseCaseEvent::model()->findAll(array('order' => '`order`', 'condition' => 'category=4 and use_case=:uc', 'params' => array(':uc' => $useCase->id_use_case))); if (count($alt)) { $string .= " \\item \\textbf{Inclusioni}:\n \\begin{enumerate}\n"; foreach ($alt as $event) { $string .= " \\item {$event->description}"; if ($event->refers_to) { $child_id = $event->with('refersTo')->refersTo->public_id(); $string .= " (\\hyperlink{{$child_id}}{{$child_id}})"; } $string .= ";\n"; } $string .= "\n \\end{enumerate}\n"; } $alt = UseCaseEvent::model()->findAll(array('order' => '`order`', 'condition' => 'category=2 and use_case=:uc', 'params' => array(':uc' => $useCase->id_use_case))); //$useCase->with(array('useCaseEvents'=>array('condition'=>'category=2','order'=>'order'))); if (count($alt)) { $string .= " \\item \\textbf{Scenari Alternativi}:\n \\begin{enumerate}\n"; foreach ($alt as $event) { $string .= " \\item {$event->description}"; if ($event->refers_to) { $child_id = $event->with('refersTo')->refersTo->public_id(); $string .= " (\\hyperlink{{$child_id}}{{$child_id}})"; } $string .= ";\n"; } $string .= "\n \\end{enumerate}\n"; } $string .= " \\item \\textbf{Postcondizione}: {$useCase->post}.\n"; $string .= " \\end{itemize}\n"; if ($raw) { echo "{$string}"; } else { echo "<pre>{$string}</pre>"; } $useCase->with('useCases'); if (isset($useCase->useCases)) { foreach ($useCase->useCases as $child) { display_uc($child, $raw); } } }
CHtml::link($data->refersTo->public_id(), array("useCase/view","id"=>$data->refers_to)) : null'), array('class' => 'CDataColumn', 'name' => 'Primary Actor', 'type' => 'html', 'value' => '$data->primaryActor->description'), 'order', array('class' => 'CButtonColumn', 'buttons' => array('view' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/view/$data->primaryKey")'), 'update' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/update/$data->primaryKey")'), 'delete' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/delete/$data->primaryKey")')))))); echo "<h3>Inlude</h3>"; echo CHtml::link("Add new Event to Include Scenario", array("useCaseEvent/create", "uc" => $model->id_use_case, "cat" => "4")); $criteria = new CDbCriteria(); $criteria->condition = "use_case = {$model->id_use_case} AND category = 4"; $criteria->order = "`order`"; $events = UseCaseEvent::model()->with('category0', 'useCase', 'primaryActor')->findAll($criteria); $dataProvider = new CActiveDataProvider('UseCaseEvent', array('pagination' => array('pageSize' => 20))); $dataProvider->setCriteria($criteria); $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $dataProvider, 'columns' => array('id_event', array('class' => 'CDataColumn', 'name' => 'category', 'type' => 'html', 'value' => '$data->category0->name'), 'description', array('class' => 'CDataColumn', 'name' => 'Refers To', 'type' => 'html', 'value' => 'isset($data->refersTo) ? CHtml::link($data->refersTo->public_id(), array("useCase/view","id"=>$data->refers_to)) : null'), array('class' => 'CDataColumn', 'name' => 'Primary Actor', 'type' => 'html', 'value' => '$data->primaryActor->description'), 'order', array('class' => 'CButtonColumn', 'buttons' => array('view' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/view/$data->primaryKey")'), 'update' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/update/$data->primaryKey")'), 'delete' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/delete/$data->primaryKey")')))))); echo "<h3>Alternate</h3>"; echo CHtml::link("Add new Event to Alternate Scenario", array("useCaseEvent/create", "uc" => $model->id_use_case, "cat" => "2")); $criteria = new CDbCriteria(); $criteria->condition = "use_case = {$model->id_use_case} AND category = 2"; $criteria->order = "`order`"; $events = UseCaseEvent::model()->with('category0', 'useCase', 'primaryActor')->findAll($criteria); $dataProvider = new CActiveDataProvider('UseCaseEvent', array('pagination' => array('pageSize' => 20))); $dataProvider->setCriteria($criteria); $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $dataProvider, 'columns' => array('id_event', array('class' => 'CDataColumn', 'name' => 'category', 'type' => 'html', 'value' => '$data->category0->name'), 'description', array('class' => 'CDataColumn', 'name' => 'Refers To', 'type' => 'html', 'value' => 'isset($data->refersTo) ? CHtml::link($data->refersTo->public_id(), array("useCase/view","id"=>$data->refers_to)) : null'), array('class' => 'CDataColumn', 'name' => 'Primary Actor', 'type' => 'html', 'value' => '$data->primaryActor->description'), 'order', array('class' => 'CButtonColumn', 'buttons' => array('view' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/view/$data->primaryKey")'), 'update' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/update/$data->primaryKey")'), 'delete' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/delete/$data->primaryKey")')))))); echo CHtml::image(CHtml::normalizeUrl(array('imagesvg', 'id' => $model->id_use_case)), ''); ?>