Esempio n. 1
0
 /**
  * Define new use case
  *
  * @param $description
  * @return UseCase
  */
 public function useCase($description)
 {
     $urlUseCaseSpec = new UseCase($this->baseUrl, $this->url);
     $urlUseCaseSpec->setDescription($description);
     $this->useCases[] = $urlUseCaseSpec;
     $this->currentUseCaseSpec = $urlUseCaseSpec;
     return $urlUseCaseSpec;
 }
function src_row($uc, $indentation, TableCreator $table_creator)
{
    $req_id = array();
    $uc->with('idUseCase');
    $uc->idUseCase->with('requirements');
    foreach ($uc->idUseCase->requirements as $rq) {
        array_push($req_id, $table_creator->link($rq->public_id(), $rq->public_id()));
    }
    $cells = array($table_creator->child_indentation($indentation), $table_creator->link($uc->public_id(), $uc->public_id()), $table_creator->link($uc->public_id(), $uc->title), implode("\n\n", $req_id));
    $ret = $table_creator->row($cells);
    $nested = UseCase::model()->findAll("t.parent = :parent", array(':parent' => $uc->id_use_case));
    foreach ($nested as $nuc) {
        $ret .= src_row($nuc, $indentation + 1, $table_creator);
    }
    return $ret;
}
digraph EveryUseCase {
rankdir="LR";

<?php 
function print_uc($useCase)
{
    $id = 'uc_' . $useCase->id_use_case;
    echo $id . ' [label="' . $useCase->title . " (" . $useCase->public_id() . ")\"];\n";
    if (is_numeric($useCase->parent)) {
        echo 'uc_' . $useCase->parent . " -> {$id};\n";
    }
    echo "\n";
    $useCase->with('useCases');
    if (isset($useCase->useCases)) {
        //echo "subgraph cluster_$id {\n";
        foreach ($useCase->useCases as $ch) {
            print_uc($ch);
        }
        //echo "}\n";
    }
}
foreach (UseCase::model()->findAll('t.parent is null') as $useCase) {
    print_uc($useCase);
}
?>


}
 public function remove()
 {
     if (!isset($_SESSION['logged'])) {
         return call('pages', 'home');
     } else {
         if (!isset($_GET['code'])) {
             return call('pages', 'error', 2);
         }
         UseCase::remove($_GET['code']);
         return call('usecases', 'index');
     }
 }
Esempio n. 5
0
        //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) {
    echo "<pre>{$source}</pre>";
}
?>
 
Esempio n. 6
0
/* @var $this UseCaseController */
/* @var $model UseCase */
function display_uc($useCase, $raw)
{
    echo "\\item \\hyperlink{" . $useCase->public_id() . "}{" . $useCase->public_id() . " - " . $useCase->title . "} \n";
    $useCase->with('useCases');
    if (isset($useCase->useCases) && count($useCase->useCases) > 0) {
        echo "\\begin{itemize}\n";
        foreach ($useCase->useCases as $child) {
            display_uc($child, $raw);
        }
        echo "\\end{itemize}\n";
    }
}
$toplevel = UseCase::model()->findAll('parent is null');
foreach ($toplevel as $useCase) {
    foreach ($useCase->useCases as $child) {
        echo "\\paragraph{\\hyperlink{" . $useCase->public_id() . "}{" . $useCase->public_id() . " - " . $useCase->title . "}} \n";
        $child->with('useCases');
        if (isset($child->useCases) && count($child->useCases) > 0) {
            echo "\\begin{itemize}\n";
            foreach ($child->useCases as $grand) {
                display_uc($grand, $raw);
            }
            echo "\\end{itemize}\n";
        }
    }
}
?>
 
Esempio n. 7
0
<?php

$uc = UseCase::model()->with('useCaseEvents')->findByPk($id);
if ($uc == null) {
    die;
}
$actors = array();
foreach ($uc->useCaseEvents as $ev) {
    $ev->with('primaryActor', 'actors');
    foreach ($ev->actors as $act) {
        $actors[$act->id_actor] = $act;
    }
    $actors[$ev->primaryActor->id_actor] = $ev->primaryActor;
}
?>
digraph UseCase {
    rankdir=LR;
    compound=true;

    // Actors
    subgraph primaryActors {
        peripheries=0;
        labelloc="b";
        node [shape=plaintext];
        edge  [arrowhead="oarrow", minlen=3];

        // Sticky men 
        <?php 
foreach ($actors as $act) {
    echo "subgraph clusterActor{$act->id_actor} {\n                    label=\"{$act->description}\";\n                    actor_{$act->id_actor}[image=\"protected/components/ucase_script/man.svg\" label=\"\"];\n                };\n";
    $act->with('parent0');
 function getChildren($model)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "parent = {$model->id_use_case}";
     $children = UseCase::model()->findAll($criteria);
     return $children;
 }