序列图内的条件流程

时间:2015-03-16 22:34:23

标签: uml sequence-diagram

我需要在UML序列图中记录方法setRepresentative。这是代码方法:

class ReptoolController extends PageController {

    private function setRepresentative($request, $action, $case)
    {
        ...

        $repappConfig = new RepappConfig();
        $repappConfig = $this->getDoctrine()->getRepository('AppBundle:RepappConfig')->findOneBy(array("app_id"=>$id));
        $project_id = $repappConfig->getProjectId();
        $company_id = $repappConfig->getCompanyId();
        $project = $this->getDoctrine()->getRepository('AppBundle:Project')->find($project_id);
        $brand = $this->getDoctrine()->getRepository('AppBundle:Brand')->findOneBy(array("project"=>$project_id));

        $company = $this->getDoctrine()->getRepository('AppBundle:Company')->find($company_id);

        $territory = new Territory();
        if(is_numeric($territory_name))
        {
            $tempName = "ID";
        }
        else
        {
            $tempName = "territory";
        }

        if($territory = $this->getDoctrine()->getRepository('AppBundle:Territory')->findOneBy(array($tempName=>$territory_name)))
        {
            $territory_id = $territory->getID();
            $response->territory_id = $territory_id;

            if($brand)
            {
                $is_enabled = 1;
                $position = 1;

                $brand_id = $brand->getID();

                $terr_brand_xrf = $this->getDoctrine()->getRepository('AppBundle:TerritoryBrandXref')->findOneBy(array("territory"=>$territory_id, "brand"=>$brand_id));

                if(!$terr_brand_xrf)
                {
                    $terr_brand_xref = new TerritoryBrandXref($territory,$brand,$position);
                    $terr_brand_xref->setIsEnabled($is_enabled);
                    $terr_brand_xref->updateTimestamps();

                    $em = $this->getDoctrine()->getEntityManager();
                    $em->persist($terr_brand_xref);
                    $em->flush();
                }
            }
        }
        else
        {

            $territory->setTerritory($territory_name);
            $territory->setProject($project);

            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($territory);
            $em->flush();
            $territory_id = $territory->getID();
            $response->territory_id = $territory_id;

            if($brand)
            {
                $is_enabled = 1;
                $position = 1;

                $brand_id = $brand->getID();

                $response->brand_id= $brand_id;

                $terr_brand_xref = new TerritoryBrandXref($territory,$brand,$position);
                $terr_brand_xref->setIsEnabled($is_enabled);
                $terr_brand_xref->updateTimestamps();

                $em = $this->getDoctrine()->getEntityManager();
                $em->persist($terr_brand_xref);
                $em->flush();
            }
        }

        $controller_response = new Response( json_encode($response) );
        $controller_response->headers->set('Content-Type', 'application/json; charset=utf-8');
        return $controller_response;
    }

}

这是我现在的图表:

enter image description here

如何绘制这段代码中的条件:

if($territory = $this->getDoctrine()->getRepository('PDOneBundle:Territory')->findOneBy(array($tempName=>$territory_name)))
{
 ...
} else {
 ...
}

如何调用内部方法?

1 个答案:

答案 0 :(得分:1)

实际上你提出的问题没有意义(请参阅我的评论:UML Sequence Diagram help needed)。 SD并不意味着以图形表示法重复算法。代码对于这个目的要好得多。显示循环的可能性以及SD内的条件是否仅用于系统的高级视图。

在您的情况下,您应该专注于运行时的某些方面。就像一个重要的快照。使用真正顺序的消息流为技术用例创建SD。最终创建多个SD来照亮不同的方面。但是不要试图在一个SD中按下整个算法。