0

I need to document in UML sequence diagram the method setRepresentative. This is the code method:

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;
    }

}

This is the diagram as I have it now:

enter image description here

How do I diagram the conditionals inside this piece of code:

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

How do I call the inside methods?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • Please don't just ask us to solve the problem for you. Show us how _you_ tried to solve the problem yourself, then show us _exactly_ what the result was, and tell us why you feel it didn't work. See "[What Have You Tried?](http://whathaveyoutried.com/)" for an excellent article that you _really need to read_. – John Saunders Mar 16 '15 at 22:37
  • @JohnSaunders my bad, I forgot to attach the image, I've already fixed on the post, take a look – ReynierPM Mar 16 '15 at 22:39
  • The resolution of the image is too low to read it... – qwerty_so Mar 16 '15 at 23:32
  • 1
    @ThomasKilian open the image in a new [tab](http://i.stack.imgur.com/psKfY.jpg), image has a good resolution but SO resize it – ReynierPM Mar 17 '15 at 01:24
  • See [uml-diagrams.org: UML Sequence Diagrams → Combined Fragment → Alternatives](http://www.uml-diagrams.org/sequence-diagrams-combined-fragment.html#operator-alt) – xmojmr Mar 17 '15 at 04:57
  • Sometimes you miss the obvious. I can see the picture now. – qwerty_so Mar 17 '15 at 08:19

1 Answers1

1

Actually what you are asking does not make sense (see my comment here: UML Sequence Diagram help needed). SDs are not meant to repeat algorithms in graphical notation. Code is much better for that purpose. The possibility to show loops and if conditions inside SDs is meant to be used only for a high level view of the system.

In your case you should concentrate on certain aspects of the runtime. Just like an important snapshot. Create a SD for the tech use case with a really sequential message flow. Eventually create more than one SD to light different aspects. But do NOT try to press the whole algorithm in a single SD.

Community
  • 1
  • 1
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • I know there are some other diagrams like Activity Diagram and perhaps I can show more on that one but refers to this and based on the code, do you think I'm missing something else? If you will represent the code using SD how do you do it? I mean can you check my diagram and tell me if you, on your side, will add something else? – ReynierPM Mar 17 '15 at 11:37
  • Basically its ok. 2 things: 1) returns should be dashed line 2) the numbering in SDs is unusualy (superfluous); it's only used in AD – qwerty_so Mar 17 '15 at 13:12
  • Thanks, can you take a look to [this](http://stackoverflow.com/questions/29112784/wrap-conditional-into-a-function-or-not-represent-it-at-all-in-a-sequence-diagra) topic? Is around the same topic but I opened a new one for not hijack this one – ReynierPM Mar 18 '15 at 01:42