Пример #1
0
        private String GenerateExpectedResult(UmlTransition tran)
        {
            String TDexpectedResult = HttpUtility.UrlDecode(tran.GetTaggedValue("TDEXPECTEDRESULT"));
            String aux;
            bool   cycle = false;

            if (tran.GetTaggedValue("TDCYCLETRAN") != null)
            {
                cycle = (tran.GetTaggedValue("TDCYCLETRAN").Equals("true") ? true : false);
            }
            if (!String.IsNullOrEmpty(TDexpectedResult))
            {
                TDexpectedResult = FillTD(TDexpectedResult, cycle);
                aux = HttpUtility.UrlDecode(TDexpectedResult);
                aux = aux.Replace(" | ", "|");
                aux = aux.Replace("| ", "|");
                aux = aux.Replace(" |", "|");
                aux = aux.Replace("|", "." + Environment.NewLine);
                aux = aux + ".";

                return(aux);
            }
            else
            {
                return(" ");
            }
        }
Пример #2
0
        private String GenerateDescription(UmlTransition tran)
        {
            String aux   = tran.Target.Name + Environment.NewLine + Environment.NewLine;
            bool   cycle = false;

            if (tran.GetTaggedValue("TDCYCLETRAN") != null)
            {
                cycle = (tran.GetTaggedValue("TDCYCLETRAN").Equals("true") ? true : false);
            }
            if (!String.IsNullOrEmpty(aux))
            {
                String TDaction = HttpUtility.UrlDecode(tran.GetTaggedValue("TDACTION"));
                TDaction = FillTD(TDaction, cycle);
                aux     += "- " + TDaction;
                aux      = HttpUtility.UrlDecode(aux);
                aux      = aux.Replace(" | ", "|");
                aux      = aux.Replace("| ", "|");
                aux      = aux.Replace(" |", "|");
                aux      = aux.Replace("|", ";" + Environment.NewLine + "- ");
                aux      = aux + ";";

                return(aux);
            }
            else
            {
                return(" ");
            }
        }
Пример #3
0
        private void OGMA(ClassNode lex)
        {
            model = new UmlModel("script");

            GenerateUseCaseDiagram();

            acdiagram = new UmlActivityDiagram("UseCase0");
            UmlInitialState initial = new UmlInitialState();

            initial.Name = "InitialNode";
            acdiagram.UmlObjects.Add(initial);

            model.AddDiagram(acdiagram);

            LIST_IMPORT(lex.Derivations[0]);
            CLASS(lex.Derivations[1]);

            String currentActionValue = lastAssociation.GetTaggedValue("TDACTION");

            lastAssociation.SetTaggedValue("TDACTION", currentActionValue + "");
            acdiagram.UmlObjects.Add(lastAssociation);

            UmlFinalState final = new UmlFinalState();

            final.Name = "FinalNode";
            acdiagram.UmlObjects.Add(final);
            lastAssociation        = new UmlTransition();
            lastAssociation.Source = lastActivity;
            lastAssociation.Target = (UmlElement)acdiagram.UmlObjects[acdiagram.UmlObjects.Count - 1];
            acdiagram.UmlObjects.Add(lastAssociation);
        }
Пример #4
0
        private void ValidateTransitionTags(UmlDiagram diagram, UmlTransition transition)
        {
            String[] validTagNames     = { "TDACTION", "TDEXPECTEDRESULT" };
            String[] mandatoryTagNames = { "TDACTION" };
            String[] optionalTag       = { "TDEXPECTEDRESULT" };

            //Acuse any unexpected tagged value.
            foreach (KeyValuePair <String, String> tagvalue in transition.TaggedValues)
            {
                if (!validTagNames.Contains(tagvalue.Key))
                {
                    log("[WARNING] Unexpected tag {" + tagvalue.Key + "} tagged in transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                }
            }
            //Acuse any missing tag.
            foreach (String tagvalue in mandatoryTagNames)
            {
                String value = transition.GetTaggedValue(tagvalue);
                if (value == null)
                {
                    log("[ERROR] Missing TDaction in {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at diagram {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3);
                }
                else
                {
                    //valid value by tag
                    switch (tagvalue)
                    {
                    case "TDACTION":
                        if (value.Length < 1)
                        {
                            log("[ERROR] Tag {TDaction} has no valid value for transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at diagram {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3);
                        }
                        break;
                    }
                }
            }
            foreach (String tagvalue in optionalTag)
            {
                String value = transition.GetTaggedValue(tagvalue);
                if (value == null)
                {
                    log("[WARNING] Missing TDexpectedResult in {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at diagram {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                }
                else
                {
                    //valid value by tag
                    switch (tagvalue)
                    {
                    case "TDEXPECTEDRESULT":
                        if (value.Length < 1)
                        {
                            log("[WARNING] Tag {TDexpectedResult} has no valid value for transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at diagram {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                        }

                        break;
                    }
                }
            }
        }
Пример #5
0
        public static List <Transition> parallelTransitions(UmlTransition t, UmlActivityDiagram actDiagram)
        {
            List <UmlTransition> listUmlTransition = new List <UmlTransition>();
            List <Transition>    listTransition    = new List <Transition>();
            Transition           tran1             = new Transition();

            foreach (UmlTransition tran in actDiagram.UmlObjects.OfType <UmlTransition>())
            {
                if (t.Target.Id.Equals(tran.Source.Id))
                {
                    listUmlTransition.Add(tran);
                }
            }

            Transition tran2 = new Transition();

            tran2.Action  = listUmlTransition[0].GetTaggedValue("TDACTION");
            tran2.Referer = listUmlTransition[0].GetTaggedValue("TDREFERER");
            tran2.Source  = t.Source.Name;
            tran2.Target  = listUmlTransition[0].Target.Name;
            listTransition.Add(tran2);

            UmlTransition transition = listUmlTransition[0];

            tran1.Action  = transition.GetTaggedValue("TDACTION");
            tran1.Referer = transition.GetTaggedValue("TDREFERER");
            tran1.Source  = transition.Target.Name;
            for (int i = 1; i < listUmlTransition.Count; i++)
            {
                transition    = listUmlTransition[i];
                tran1.Action  = transition.GetTaggedValue("TDACTION");
                tran1.Referer = transition.GetTaggedValue("TDREFERER");
                tran1.Target  = transition.Target.Name;
                listTransition.Add(tran1);
                tran1        = new Transition();
                tran1.Source = listTransition[listTransition.Count - 1].Target;
            }
            Transition    tran3         = new Transition();
            UmlTransition transitionAux = getNextState(listTransition[listTransition.Count - 1].Target, actDiagram);

            tran3.Action  = transitionAux.GetTaggedValue("TDACTION");
            tran3.Referer = transitionAux.GetTaggedValue("TDREFERER");
            tran3.Source  = listTransition[listTransition.Count - 1].Target;
            tran3.Target  = transitionAux.Target.Name;
            listTransition.Add(tran3);
            return(listTransition);
        }
Пример #6
0
        public static List <Transition> parallelTransitions(UmlTransition t, UmlActivityDiagram actDiagram)
        {
            List <UmlTransition> listUmlTransition = new List <UmlTransition>();
            List <Transition>    listTransition    = new List <Transition>();
            Transition           tran1             = new Transition();

            foreach (UmlTransition tran in actDiagram.UmlObjects.OfType <UmlTransition>())
            {
                if (t.Target.Id.Equals(tran.Source.Id))
                {
                    listUmlTransition.Add(tran);
                }
            }

            Transition tran2 = new Transition();

            tran2.Input = listUmlTransition[0].GetTaggedValue("TDACTION");
            if (listUmlTransition[0].GetTaggedValue("TDPARAMETERS") == null)
            {
                tran2.Output = "";
            }
            else
            {
                tran2.Output = listUmlTransition[0].GetTaggedValue("TDPARAMETERS");
            }
            tran2.SourceState = getState(t.Source.Name, actDiagram, listTransition);
            tran2.TargetState = getState(listUmlTransition[0].Target.Name, actDiagram, listTransition);;
            listTransition.Add(tran2);

            UmlTransition transition = listUmlTransition[0];

            tran1.Input = transition.GetTaggedValue("TDACTION");
            if (transition.GetTaggedValue("TDPARAMETERS") == null)
            {
                tran1.Output = "";
            }
            else
            {
                tran1.Output = transition.GetTaggedValue("TDPARAMETERS");
            }
            tran1.SourceState = getState(transition.Target.Name, actDiagram, listTransition);
            for (int i = 1; i < listUmlTransition.Count; i++)
            {
                transition  = listUmlTransition[i];
                tran1.Input = transition.GetTaggedValue("TDACTION");
                if (transition.GetTaggedValue("TDPARAMETERS") == null)
                {
                    tran1.Output = "";
                }
                else
                {
                    tran1.Output = transition.GetTaggedValue("TDPARAMETERS");
                }
                tran1.TargetState = getState(transition.Target.Name, actDiagram, listTransition);
                listTransition.Add(tran1);
                tran1             = new Transition();
                tran1.SourceState = listTransition[listTransition.Count - 1].TargetState;
            }
            Transition    tran3         = new Transition();
            UmlTransition transitionAux = getNextState(listTransition[listTransition.Count - 1].TargetState.Name, actDiagram);

            tran3.Input = transitionAux.GetTaggedValue("TDACTION");
            if (transitionAux.GetTaggedValue("TDPARAMETERS") == null)
            {
                tran3.Output = "";
            }
            else
            {
                tran3.Output = transitionAux.GetTaggedValue("TDPARAMETERS");
            }
            tran3.SourceState = listTransition[listTransition.Count - 1].TargetState;
            tran3.TargetState = getState(transitionAux.Target.Name, actDiagram, listTransition);
            listTransition.Add(tran3);
            return(listTransition);
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public string parse(GroupNode node)
        {
            string scrpt = "";

            try {
                if (node != null)
                {
                    tabHelper.incrementTabs();

                    bool   containsDtBnk     = false;
                    bool   containsCondition = false;
                    int    iterations        = 0;
                    string dataBank          = "";
                    string loopCondition     = "";
                    string stepScrpt         = buildStep(node.GroupName);
                    foreach (UmlTransition transition in node.Transitions)
                    {
                        /*
                         * 1 - buildStep()
                         * 2 - buildDataBank()
                         * 3 - buildLoop()
                         * 4 - verifyObject()
                         * 5 - buildObjScript()
                         * 6 - addThink()
                         */
                        Dictionary <TagNames, string> tags = extractTransitionTags(transition);

                        try {
                            if (string.IsNullOrEmpty(loopCondition))
                            {
                                loopCondition     = tags[TagNames.TDLoopCondition];
                                containsCondition = !string.IsNullOrEmpty(loopCondition);
                            }

                            if (iterations == 0)
                            {
                                iterations = Convert.ToInt32(tags[TagNames.TDIterations]);
                            }

                            if (!containsDtBnk)
                            {
                                string actions_Assert = tags[TagNames.TDAction] + ",{;" + tags[TagNames.TDAssert] + "}";

                                extractDataBanks(actions_Assert).ForEach(S => dataBank += S);
                                containsDtBnk = !string.IsNullOrEmpty(dataBank);
                            }
                        } catch (FormatException e) { } catch (Exception e) { }

                        //realiza a construcao do script para as tags desta transicao
                        scrpt += parse(tags);
                    }

                    //subgrupos
                    string subScrpt = "";
                    string cond     = "";
                    for (int j = 0; j < node.SubGroups.Count; j++)
                    {
                        GroupNode sub = node.SubGroups[j];
                        //caso a primeira transicao seja loopcond, remove
                        UmlTransition transition = null;
                        if (j == 0 && sub.Transitions.Count > 0)
                        {
                            transition = node.SubGroups[0].Transitions[0];
                            cond       = transition.GetTaggedValue("TDLOOPCONDITION");
                            transition.SetTaggedValue("TDLOOPCONDITION", "");
                        }
                        subScrpt += parse(sub);

                        if (!string.IsNullOrEmpty(cond) && transition != null)
                        {
                            transition.SetTaggedValue("TDLOOPCONDITION", cond);
                        }
                    }

                    //caso tenha subgrupos e tenha loop na primeira transicao
                    if (node.SubGroups.Count > 0)
                    {
                        try {
                            UmlTransition transition           = node.SubGroups[0].Transitions[0];
                            Dictionary <TagNames, string> tags = extractTransitionTags(transition);
                            string loopCond = "";
                            try {
                                loopCond = tags[TagNames.TDLoopCondition];
                            } catch (Exception e) { }

                            //caso tenha condicao para o loop, adiciona no while o subscript
                            if (!string.IsNullOrEmpty(loopCond))
                            {
                                subScrpt = buildWhile(loopCond, subScrpt);
                            }
                        } catch (Exception e) { }
                    }
                    scrpt += subScrpt;

                    //verifica entre estas transicoes se deve adicionar um loop...
                    if (iterations > 0)
                    {
                        scrpt = buildFor(iterations, scrpt);
                    }

                    //caso tenha que adicionar as transicoes no databank
                    if (containsDtBnk)
                    {
                        scrpt = dataBank + scrpt;
                    }

                    //step's loop
                    if (containsCondition)
                    {
                        scrpt = buildWhile(loopCondition, scrpt);
                    }

                    scrpt = string.Format(stepScrpt, scrpt);
                }
            } catch (Exception e) {
                scrpt = "";
            } finally {
                tabHelper.decrementTabs();
            }

            return(scrpt);
        }
Пример #8
0
        /// <summary>
        /// Extrai da transicao passada por parametro, todas as tags
        /// que foram anotadas no modelo.
        /// </summary>
        /// <param name="transition">Transicao do diagrama de atividades no modelo.</param>
        /// <returns></returns>
        protected Dictionary <TagNames, string> extractTransitionTags(UmlTransition transition)
        {
            Dictionary <TagNames, string> tags = new Dictionary <TagNames, string> ();

            string tagTDAction        = transition.GetTaggedValue("TDACTION");
            string tagTDAssert        = transition.GetTaggedValue("TDASSERT");
            string tagTDIterations    = transition.GetTaggedValue("TDITERATIONS");
            string tagTDLoopCondition = transition.GetTaggedValue("TDLOOPCONDITION");
            string tagTDObject        = transition.GetTaggedValue("TDOBJECT");
            string tagTDProtocol      = transition.GetTaggedValue("TDPROTOCOL");
            string tagTDProperties    = transition.GetTaggedValue("TDPROPERTIES");
            string tagTDWait          = transition.GetTaggedValue("TDWAIT");
            string tagTDVerify        = transition.GetTaggedValue("TDVERIFY");
            string tagParamcycle      = transition.GetTaggedValue("paramcycle");

            try {
                tagTDAction        = HttpUtility.UrlDecode(tagTDAction);
                tagTDAssert        = HttpUtility.UrlDecode(tagTDAssert);
                tagTDIterations    = HttpUtility.UrlDecode(tagTDIterations);
                tagTDLoopCondition = HttpUtility.UrlDecode(tagTDLoopCondition);
                tagTDObject        = HttpUtility.UrlDecode(tagTDObject);
                tagTDProtocol      = HttpUtility.UrlDecode(tagTDProtocol);
                tagTDProperties    = HttpUtility.UrlDecode(tagTDProperties);
                tagTDWait          = HttpUtility.UrlDecode(tagTDWait);
                tagTDVerify        = HttpUtility.UrlDecode(tagTDVerify);

                double auxTDwait = 0.0f;
                if (!string.IsNullOrEmpty(tagTDWait))
                {
                    auxTDwait = float.Parse(tagTDWait);
                }
                else
                {
                    try {
                        auxTDwait = Convert.ToDouble(Configuration.getInstance().getConfiguration(Configuration.Fields.waittime));
                    } catch (Exception e) { }
                }

                if (!string.IsNullOrEmpty(tagTDObject))
                {
                    tagTDObject = tagTDObject.Substring(0, tagTDObject.Length - 1).Substring(1);
                }
                else
                {
                    tagTDObject = "";
                }

                tagTDIterations = string.IsNullOrEmpty(tagTDIterations) || tagTDIterations.Equals("null") ? "0" : tagTDIterations;

                /*
                 * string verifyAll = Configuration.getInstance().getConfiguration("verifyall");
                 * verifyAll = verifyAll.Equals("") ? "false" : verifyAll;
                 */
                bool tagVerifyAux = false;
                try {
                    tagVerifyAux = bool.Parse(tagTDVerify);
                } catch (ArgumentNullException e) { } catch (FormatException e) { }

                /*
                 * try
                 * {
                 *  bool verifyAllAux = bool.Parse(verifyAll);
                 *  if (verifyAllAux)
                 *  {
                 *      tagVerifyAux = verifyAllAux;
                 *  }
                 * }
                 * catch (ArgumentNullException e) { }
                 * catch (FormatException e) { }
                 */
                tagTDVerify = tagVerifyAux.ToString();
            } catch (Exception e) {
                tagTDAction        = "";
                tagTDAssert        = "";
                tagTDIterations    = "";
                tagTDLoopCondition = "";
                tagTDObject        = "";
                tagTDProtocol      = "";
                tagTDProperties    = "";
                tagTDWait          = "";
                tagTDVerify        = "";
            }

            tags.Add(TagNames.TDAction, tagTDAction);
            tags.Add(TagNames.TDAssert, tagTDAssert);
            tags.Add(TagNames.TDLoopCondition, tagTDLoopCondition);
            tags.Add(TagNames.TDIterations, tagTDIterations);
            tags.Add(TagNames.TDObject, tagTDObject);
            tags.Add(TagNames.TDProperties, tagTDProperties);
            tags.Add(TagNames.TDProtocol, tagTDProtocol);
            tags.Add(TagNames.TDWait, tagTDWait);
            tags.Add(TagNames.TDVerify, tagTDVerify);
            tags.Add(TagNames.paramcycle, tagParamcycle);

            return(tags);
        }
        private void ValidateTransitionTags(UmlDiagram diagram, UmlTransition transition)
        {
            String[] validTagNames = { "TDACTION", "TDMETHOD", "TDEXPTIME", "TDTHINKTIME", "TDSAVEPARAMETERS", "TDCOOKIES", "TDBODY", "TDREFERER", "TDPARAMETERS" };
            //TODO: Confirm if TDreferer is a mandatory tag
            //String[] mandatoryTagNames = { "TDACTION", "TDREFERER" };
            String[] mandatoryTagNames = { "TDACTION" };
            String   auxValue          = "";

            //Acuse any unexpected tagged value.
            foreach (KeyValuePair <String, String> taggedValue in transition.TaggedValues)
            {
                if (!validTagNames.Contains(taggedValue.Key))
                {
                    log("[WARNING] Unexpected tag {" + taggedValue.Key + "} tagged in transition {" + transition.Source.Name + "->" + transition.Target.Name + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                }
                else
                {
                    switch (taggedValue.Key)
                    {
                    //TODO: Review all tags' error messages
                    case "TDMETHOD":
                        Boolean noErrors = new Boolean();
                        noErrors = ValidateTDmethod(diagram, transition, taggedValue);

                        if (!noErrors)
                        {
                            log("[WARNING] Tag {" + taggedValue.Key + "} has no valid value for transition {" + transition.Source.Name + "->" + transition.Target.Name + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                        }
                        break;

                    case "TDPARAMETERS":
                        noErrors = new Boolean();
                        noErrors = ValidateTDparameters(auxValue, taggedValue);

                        if (!noErrors)
                        {
                            log("[WARNING] Tag {" + taggedValue.Key + "} has no valid value for transition {" + transition.Source.Name + "->" + transition.Target.Name + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                        }
                        break;

                    case "TDEXPTIME":
                        noErrors = new Boolean();
                        noErrors = ValidateDoubleValue(taggedValue);

                        if (!noErrors)
                        {
                            log("[WARNING] Tag {" + taggedValue.Key + "} has no valid value for transition {" + transition.Source.Name + "->" + transition.Target.Name + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                        }
                        break;

                    case "TDTHINKTIME":
                        noErrors = new Boolean();
                        noErrors = ValidateDoubleValue(taggedValue);

                        if (!noErrors)
                        {
                            log("[WARNING] Tag {" + taggedValue.Key + "} has no valid value for transition {" + transition.Source.Name + "->" + transition.Target.Name + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                        }
                        break;

                    case "TDSAVEPARAMETERS":
                        noErrors = new Boolean();
                        noErrors = ValidateStringValue(taggedValue);

                        if (!noErrors)
                        {
                            log("[WARNING] Tag {" + taggedValue.Key + "} has no valid value for transition {" + transition.Source.Name + "->" + transition.Target.Name + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                        }
                        break;

                    case "TDCOOKIES":
                        noErrors = new Boolean();
                        noErrors = ValidateStringValue(taggedValue);

                        if (!noErrors)
                        {
                            log("[WARNING] Tag {" + taggedValue.Key + "} has no valid value for transition {" + transition.Source.Name + "->" + transition.Target.Name + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                        }
                        break;

                    case "TDBODY":
                        noErrors = new Boolean();
                        noErrors = ValidateStringValue(taggedValue);

                        if (!noErrors)
                        {
                            log("[WARNING] Tag {" + taggedValue.Key + "} has no valid value for transition {" + transition.Source.Name + "->" + transition.Target.Name + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2);
                        }
                        break;
                    }
                }
            }

            //String auxURL = "http://{Server.Server}";

            //Acuse any missing tag.
            foreach (String tagName in mandatoryTagNames)
            {
                //Boolean noErrors = new Boolean();
                String value = transition.GetTaggedValue(tagName);
                if (value == null)
                {
                    log("[ERROR] Tag {" + tagName + "} is meant to be tagged in transition {" + HttpUtility.UrlDecode(transition.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3);
                }
                //else
                //{
                //    noErrors = ValidateTDaction(diagram, transition, auxURL, tagName, value);
                //    if (!noErrors)
                //    {
                //        log("[ERROR] Tag {" + tagName + "} has no valid value for transition {" + HttpUtility.UrlDecode(transition.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3);
                //    }
                //}
            }
        }