Пример #1
0
        private void ValidateAssociation(UmlDiagram diagram, UmlBase item)
        {
            UmlAssociation association = (UmlAssociation)item;

            if (association.End1 == null || association.End2 == null)
            {
                log("[ERROR] Association " + HttpUtility.UrlDecode(diagram.Name) + "#" + HttpUtility.UrlDecode(association.Name) + " is invalid.", 3);
            }
            else if (association.End1 is UmlActor && association.End2 is UmlActor)
            {
                log("[ERROR] Actors cannot be connected together. Found at" + HttpUtility.UrlDecode(association.End1.Name) + "#" + HttpUtility.UrlDecode(association.End2.Name), 3);
            }
            else if (association.End1 is UmlUseCase && association.End2 is UmlUseCase)
            {
                Boolean isIncExt = false;
                foreach (String s in association.Stereotypes)
                {
                    if (s.Equals("Extend") || s.Equals("Include"))
                    {
                        isIncExt = true;
                        break;
                    }
                }

                if (!isIncExt)
                {
                    log("[ERROR] Use cases cannot be connected together. Found at" + HttpUtility.UrlDecode(association.End1.Name) + "#" + HttpUtility.UrlDecode(association.End2.Name), 3);
                }
            }
        }
Пример #2
0
        private void ValidateActor(UmlDiagram diagram, UmlBase item)
        {
            UmlActor actor = (UmlActor)item;

            //store requires tags for Actor element
            String[] requiresTags = new String[] { "TDHOST" };
            foreach (String tag in requiresTags)
            {
                String value = actor.GetTaggedValue(tag);

                if (value == null)
                {
                    log("[ERROR] Missing " + tag + " in " + HttpUtility.UrlDecode(diagram.Name) + " # " + HttpUtility.UrlDecode(actor.Name) + " element.", 3);
                }
                else
                {
                    switch (tag)
                    {
                    case "TDHOST":
                        if (tag.Length < 1)
                        {
                            log("[ERROR] Tag {" + tag + "} has no valid value for Actor {" + HttpUtility.UrlDecode(actor.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3);
                        }
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Valida um elemento de acordo com o tipo e diagrama ao qual pertence
        /// </summary>
        public void ValidateElement(UmlDiagram diagram, UmlBase element)
        {
            foreach (KeyValuePair <string, string> pair in element.TaggedValues)
            {
                MethodInfo method = this.GetType().GetMethod(
                    diagram.GetType().Name + "_" + element.GetType().Name + "_" + pair.Key);

                String info;
                if (element is UmlUseCase)
                {
                    UmlUseCase aux = (UmlUseCase)element;
                    info = diagram.Name + " >> " + aux.Name + " >> " + pair.Key;
                }
                else
                {
                    info = diagram.Name + " >> " + element.Name + " >> " + pair.Key;
                }



                if (method != null)
                {
                    method.Invoke(this, new object[] { pair.Value, info });
                }
            }
        }
Пример #4
0
        public void ValidateElement(UmlDiagram diagram, UmlBase element)
        {
            foreach (KeyValuePair <string, string> pair in element.TaggedValues)
            {
                String name = diagram.GetType().Name + "_" + element.GetType().Name + "_" + pair.Key;

                if (pair.Key.Contains("jude.hyperlink"))
                {
                    name = pair.Key.Replace('.', '_');
                }

                MethodInfo method = this.GetType().GetMethod(name);

                String info;
                if (element is UmlUseCase)
                {
                    UmlUseCase aux = (UmlUseCase)element;
                    info = diagram.Name + " >> " + aux.Name + " >> " + pair.Key;
                }
                else
                {
                    info = diagram.Name + " >> " + element.Name + " >> " + pair.Key;
                }
                if (method != null)
                {
                    method.Invoke(this, new object[] { pair.Value, info });
                }
            }
        }
        private void ValidateAssociation(UmlDiagram diagram, UmlBase item)
        {
            UmlAssociation association = (UmlAssociation)item;

            if (association.End1 == null || association.End2 == null)
            {
                log("[ERROR] Association " + HttpUtility.UrlDecode(diagram.Name) + "#" + HttpUtility.UrlDecode(association.Name) + " is invalid.", 3);
            }
            else if (association.End1 is UmlActor && association.End2 is UmlActor)
            {
                log("[ERROR] Actors cannot be connected together. Found at " + HttpUtility.UrlDecode(association.End1.Name) + "#" + HttpUtility.UrlDecode(association.End2.Name), 3);
            }
            else if (association.End1 is UmlUseCase && association.End2 is UmlUseCase)
            {
                bool isIncExt = false;
                foreach (String s in association.Stereotypes)
                {
                    if (s.Equals("Extend") || s.Equals("Include"))
                    {
                        isIncExt = true;
                        break;
                    }
                }

                if (!isIncExt)
                {
                    log("[ERROR] Use cases cannot be connected together. Found at " + HttpUtility.UrlDecode(association.End1.Name) + "#" + HttpUtility.UrlDecode(association.End2.Name), 3);
                }
            }
            //TODO: Change TDprob validation
            //else if (association.GetTaggedValue("TDprob") == null)
            //{
            //    log("[ERROR] Missing TDprob in " + HttpUtility.UrlDecode(diagram.Name) + " # " + HttpUtility.UrlDecode(association.Name) + " element.", 3);
            //}
        }
Пример #6
0
        //public bool ParseOatsToXMI(String pathOatsScript, String XMISavePath)
        //{
        //    String SPC = @"[\t\ ]";
        //    ANY = new Regex(@"([A-Za-z0-9,\(\)\[\]/\*&_#\- ""]*)");
        //    IMPORT = new Regex(@"import ([A-Za-z0-9.\*]+);");
        //    OPEN_BRACKET = new Regex(@"([\t\ ]*){");
        //    CLOSE_BRACKET = new Regex(@"([\t\ ]*)}");
        //    CLASS = new Regex(@"public class ([A-Za-z][A-Za-z0-9_]*) extends IteratingVUserScript {");
        //    SCR_SERV = new Regex(@"^" + SPC + @"*@ScriptService ([A-Za-z0-9\*\.\ ]+);$");
        //    MET = new Regex(@"public void ([A-Za-z][A-Za-z0-9_]*)\(\) throws Exception {");
        //    BEGIN_STEP = new Regex(@"(" + SPC + "*)beginStep" + ANY + ";");
        //    END_STEP = new Regex(@"(" + SPC + @"*)endStep\(\);");
        //    WWINDOW = new Regex(@"web.window\(" + ANY);
        //    WTEXT_BOX = new Regex(@"web.textBox\(" + ANY);
        //    WBUTTON = new Regex(@"web.button\(" + ANY);
        //    WLINK = new Regex(@"web.link\(" + ANY);
        //    WB_CLICK = new Regex(@"(" + SPC + @"*).click\(\);");
        //    WW_CLOSE = new Regex(@"(" + SPC + @"*).close\(\);");
        //    OPEN_COMM = new Regex(@"(" + SPC + @"*)/\*\*");
        //    CLOSE_COMM = new Regex(@"(" + SPC + @"*)*[\ ]*/");
        //    THINKTIME = new Regex(@"think\([0-9]+(.[0-9])*\)");
        //    BROWSER_LCH = new Regex(@"browser.launch\(\)");

        //    using (sr = new StreamReader(pathOatsScript))
        //    {
        //        lc = 0;
        //        line = "";
        //        model = new UmlModel("Oats Parsed Model");
        //        actDiagram = new UmlActivityDiagram("Test Diagram");
        //        UmlInitialState initial = new UmlInitialState();
        //        UmlFinalState final = new UmlFinalState();
        //        activity = null;
        //        lastActivity = null;
        //        actDiagram.UmlObjects.Add(initial);
        //        lastActivity = initial;
        //        taggedValues = null;
        //        S();

        //        if (sr.Peek() > 0)
        //            throw new Exception("Parser error. Not EOF");

        //        activity = final;
        //        actDiagram.UmlObjects.Add(final);
        //        addTransition();

        //        model.AddDiagram(actDiagram);
        //        XmlDocument xd = model.ToXmi();

        //        XmlWriterSettings settings = new XmlWriterSettings();
        //        settings.Encoding = new UTF8Encoding(false);
        //        settings.Indent = true;
        //        settings.CheckCharacters = true;

        //        using (XmlWriter writer = XmlWriter.Create(XMISavePath + "\\" + model.Name + ".xml", settings))
        //            xd.Save(writer);

        //        return true;
        //    }
        //}

        private void SetTaggedValues(Dictionary <string, string> values, UmlBase umlElement)
        {
            if (values == null)
            {
                return;
            }
            foreach (KeyValuePair <string, string> kp in values)
            {
                umlElement.SetTaggedValue(kp.Key, kp.Value);
            }
        }
        private void ValidateActor(UmlDiagram diagram, UmlBase item)
        {
            UmlActor actor = (UmlActor)item;

            //store required tags for Actor element
            String[] requiredTags = new String[] { "TDHOST", "TDRAMPUPTIME", "TDRAMPDOWNTIME", "TDPOPULATION" };
            foreach (String tag in requiredTags)
            {
                String value = actor.GetTaggedValue(tag);

                if (value == null)
                {
                    log("[ERROR] Missing " + tag + " in " + HttpUtility.UrlDecode(diagram.Name) + " # " + HttpUtility.UrlDecode(actor.Name) + " element. Using empty string as value.", 3);
                }
                else
                {
                    switch (tag)
                    {
                    case "TDHOST":
                        if (tag.Length < 1)
                        {
                            log("[ERROR] Tag {" + tag + "} has no valid value for Actor {" + HttpUtility.UrlDecode(actor.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3);
                        }
                        break;

                    default:
                        Double val = 0;
                        try
                        {
                            val = Convert.ToDouble(actor.GetTaggedValue(tag));
                        }
                        catch
                        {
                            log("[ERROR] Tag {" + tag + "} has no valid value for Actor {" + HttpUtility.UrlDecode(actor.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3);
                        }
                        if (val <= 0)
                        {
                            log("[ERROR] Tag {" + tag + "} has no valid value for Actor {" + HttpUtility.UrlDecode(actor.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3);
                        }
                        break;
                    }
                }
            }
        }
        private void ValidateUseCase(UmlModel model, UmlDiagram diagram, UmlBase item)
        {
            UmlUseCase uCase = (UmlUseCase)item;

            bool existeAC = false;

            foreach (UmlActivityDiagram actD in model.Diagrams.OfType <UmlActivityDiagram> ())
            {
                if (actD.Name == uCase.Name)
                {
                    existeAC = true;
                    break;
                }
            }

            if (!existeAC)
            {
                log("[ERROR] Missing activity diagram for \"" + HttpUtility.UrlDecode(uCase.Name) + "\" use case.", 3);
            }
        }
Пример #9
0
 private Boolean IsTransition(UmlBase element)
 {
     return(element is UmlTransition);
 }