示例#1
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);
                }
            }
        }
示例#2
0
        public static void ParseActivity(XmlNode node, String id, UmlActionStateDiagram activityDiagram)
        {
            foreach (XmlNode ActionStateNode in node.SelectNodes("//UML:ActivityGraph[@xmi.id='" + id + "']//UML:ActionState", ns))
            {
                UmlActionState activity = new UmlActionState();
                activity.Id   = ActionStateNode.Attributes["xmi.id"].Value;
                activity.Name = ActionStateNode.Attributes["name"].Value;
                activityDiagram.dicAtivities.Add(activity.Id, activity);

                UmlTag.ParserTag(ActionStateNode, ns, activity);

                foreach (XmlNode NodeStateVertex in ActionStateNode.SelectNodes("//UML:ActionState[@xmi.id='" + activity.Id + "']//UML:StateVertex.outgoing//UML:Transition", ns))
                {
                    activity.outgoing = NodeStateVertex.Attributes["xmi.idref"].Value;
                }
                foreach (XmlNode NodeStateVertex in ActionStateNode.SelectNodes("//UML:ActionState[@xmi.id='" + activity.Id + "']//UML:StateVertex.incoming//UML:Transition", ns))
                {
                    activity.incoming = NodeStateVertex.Attributes["xmi.idref"].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);
        }