public static Dictionary <String, UmlTransition> ParserTransition(XmlNode node, String id)
        {
            Dictionary <String, UmlTransition> dicTransition = new Dictionary <string, UmlTransition>();

            foreach (XmlNode NodeTransition in node.SelectNodes("//UML:ActivityGraph[@xmi.id='" + id + "']/*/UML:Transition", ns))
            {
                if (NodeTransition.Attributes["name"] != null)
                {
                    UmlTransition t = new UmlTransition();
                    t.Name = NodeTransition.Attributes["name"].Value;
                    t.Id   = NodeTransition.Attributes["xmi.id"].Value;

                    UmlTag.ParserTag(NodeTransition, ns, t);

                    foreach (XmlNode NodeTStateVertex in NodeTransition.SelectNodes("//UML:Transition[@xmi.id='" + t.Id + "']//UML:Transition.source//UML:StateVertex", ns))
                    {
                        t.Source = NodeTStateVertex.Attributes["xmi.idref"].Value;
                    }
                    foreach (XmlNode NodeStateVertex in NodeTransition.SelectNodes("//UML:Transition[@xmi.id='" + t.Id + "']//UML:Transition.target//UML:StateVertex", ns))
                    {
                        t.Target = NodeStateVertex.Attributes["xmi.idref"].Value;
                    }

                    foreach (XmlNode NodeNodeStateMachine in NodeTransition.SelectNodes("//UML:Transition[@xmi.id='" + t.Id + "']//UML:Transition.stateMachine//UML:StateMachine", ns))
                    {
                        t.refDiagramActivity = NodeNodeStateMachine.Attributes["xmi.idref"].Value;
                    }
                    dicTransition.Add(t.Id, t);
                }
            }
            return(dicTransition);
        }
        public UmlTransition buscaTransition(String id, Dictionary <String, UmlActionStateDiagram> dicActionDiagram)
        {
            foreach (String keyDiagram in dicActionDiagram.Keys)
            {
                UmlActionStateDiagram d = dicActionDiagram[keyDiagram];

                foreach (String keyTransition in d.transitions.Keys)
                {
                    if (id.Equals(keyTransition))
                    {
                        UmlTransition t = d.transitions[keyTransition];
                        return(t);
                    }
                }
            }
            return(null);
        }
Example #3
0
        public static void ParserTag(XmlNode node, XmlNamespaceManager ns, UmlBase UmlElement)
        {
            foreach (XmlNode XmlNode in node.SelectNodes("//UML:" + UmlElement.GetType().Name.Substring(3) + "[@xmi.id='" + UmlElement.Id + "']//UML:TaggedValue", ns))
            {
                UmlTag tag = new UmlTag();
                tag.name  = XmlNode.Attributes["tag"].Value;
                tag.id    = XmlNode.Attributes["xmi.id"].Value;
                tag.value = HttpUtility.UrlDecode(XmlNode.Attributes["value"].Value).Replace("+", " ");

                switch (UmlElement.GetType().Name)
                {
                case "UmlTransition":
                    switch (tag.name)
                    {
                    case "FTexpectedResult":
                        UmlTransition transition = UmlElement as UmlTransition;
                        transition.listExpectedResults.Add(tag);
                        break;

                    case "FTaction":
                        UmlElement.dictionaryTag.Add(tag.id, tag);
                        break;

                    default:
                        DialogResult dialogResult = MessageBox.Show("Use case" + tag.name + " has a invalid Tag. Are you sure you want to continue executing a parsing method?", "Error", MessageBoxButtons.YesNo);

                        if (dialogResult == DialogResult.No)
                        {
                            throw new eInvalidTag();
                        }
                        break;
                    }
                    break;

                default:
                    break;
                }
                if (tag.name.Equals("jude.hyperlink"))
                {
                    UmlActionState umlActivity = UmlElement as UmlActionState;
                    tag.value = getHyperLink(XmlNode.Attributes["value"].Value);
                    umlActivity.dicJudeHyperLink.Add(tag.value, tag.value);
                }
            }
        }
        public static Dictionary <String, UmlActionStateDiagram> ParseActivityDiagram(XmlDocument doc)
        {
            UmlActionStateDiagram.collectJudeHyperLinksReferences(doc);
            Dictionary <String, UmlActionStateDiagram> dictionaryActivityDiagram = new Dictionary <string, UmlActionStateDiagram>();


            foreach (XmlNode activityDiagramNode in doc.SelectNodes("//UML:Model//UML:ActivityGraph", ns))
            {
                if (activityDiagramNode.Attributes["xmi.id"] != null)
                {
                    UmlActionStateDiagram activityDiagram = new UmlActionStateDiagram();
                    activityDiagram.Name        = activityDiagramNode.Attributes["name"].Value;
                    activityDiagram.Id          = activityDiagramNode.Attributes["xmi.id"].Value;
                    activityDiagram.transitions = UmlTransition.ParserTransition(activityDiagramNode, activityDiagram.Id);
                    dictionaryActivityDiagram.Add(activityDiagram.Id, activityDiagram);
                    UmlActionState.ParseActivity(activityDiagramNode, activityDiagram.Id, activityDiagram);
                    activityDiagram.InitialActivity = UmlInitialState.ParserPseudostate(activityDiagramNode, activityDiagram.Id);
                    activityDiagram.FinalActivity   = UmlFinalState.ParserFinalState(activityDiagramNode, activityDiagram.Id);
                }
            }
            foreach (var item in dictionaryActivityDiagram.Keys)
            {
                foreach (var item2 in dictionaryActivityDiagram[item].dicAtivities.Keys)
                {
                    UmlActionState activity = dictionaryActivityDiagram[item].dicAtivities[item2];
                    foreach (String item3 in activity.dicJudeHyperLink.Keys)
                    {
                        //Id UML
                        String key = UmlActionStateDiagram.dicJudeHyperLinks[item3];
                        UmlActionStateDiagram diagram = dictionaryActivityDiagram[key];
                        activity.dicMyLinkedDiagrams.Add(diagram.Id, diagram);
                    }
                }
            }

            return(dictionaryActivityDiagram);
        }