【问题标题】:Flow for conditionals inside sequence diagram序列图中条件的流程
【发布时间】:2018-03-04 02:54:32
【问题描述】:

我需要在 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 {
 ...
}

如何调用内部方法?

【问题讨论】:

  • 请不要只求我们为您解决问题。向我们展示如何尝试自己解决问题,然后向我们确切地展示结果是什么,并告诉我们您为什么觉得它不起作用。请参阅“What Have You Tried?”了解您真正需要阅读的优秀文章。
  • @JohnSaunders 我的错,我忘了附上图片,我已经固定在帖子上了,看看
  • 图片分辨率太低,无法读取...
  • @ThomasKilian 在新的tab 中打开图片,图片分辨率不错,但请调整大小

标签: uml sequence-diagram


【解决方案1】:

实际上你所问的没有意义(请参阅我的评论:UML Sequence Diagram help needed)。 SD 并不意味着以图形符号重复算法。为此目的,代码要好得多。在 SD 中显示循环和 if 条件的可能性仅用于系统的高级视图。

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

【讨论】:

  • 我知道还有一些其他的图表,比如活动图,也许我可以在那个图表上展示更多,但是参考这个并根据代码,你认为我还缺少什么吗?如果您将使用 SD 表示代码,您会怎么做?我的意思是你能检查我的图表并告诉我你是否会添加其他内容?
  • 基本上没问题。两件事:1)回报应该是虚线2)SD中的编号是不寻常的(多余的);它只在AD中使用
  • 谢谢,可以看一下this的话题吗?是围绕同一个话题,但我打开了一个新的,而不是劫持这个
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-02-11
  • 1970-01-01
  • 2021-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-20
相关资源
最近更新 更多