内部条件序列图的流程

Flow for conditionals inside 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;
    }

}

这是我现在的图表:

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

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

如何调用内部方法?

实际上你问的是没有意义的(在这里看我的评论:UML Sequence Diagram help needed)。 SD 并不意味着以图形符号重复算法。为此,代码要好得多。显示循环的可能性以及 SD 内部的条件是否意味着仅用于系统的高级视图。

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