Example #1
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree(MocaNode actNode)
        {
            actNode.appendChildAttribute("attributeName", this.AttributeName);
            actNode.appendChildAttribute("attributeGuid", this.AttributeGUID);
            MocaNode valueExpNode = actNode.appendChildNode("valueExpression");

            this.ValueExpression.serializeToMocaTree(valueExpNode);
            return(actNode);
        }
Example #2
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree()
        {
            MocaNode tggNode = base.serializeToMocaTree();

            tggNode.Name = "TGG";

            MocaNode domainsNode = tggNode.appendChildNode("domains");

            MocaNode metamodelsNode = tggNode.appendChildNode("metamodels");



            foreach (Metamodel metamodel in this.Metamodels)
            {
                MocaNode metamodelNode = metamodelsNode.appendChildNode("Metamodel");
                metamodel.serializeToMocaTree(metamodelNode);
            }
            foreach (Domain domain in this.Domains)
            {
                MocaNode domainNode = domainsNode.appendChildNode("Domain");
                domain.serializeToMocaTree(domainNode);
            }

            this.Constraints.Sort(new CSPConstraintComparer());


            MocaNode constraintsNode         = tggNode.appendChildNode(ConstraintsChildNodeName);
            MocaNode declarationsNode        = constraintsNode.appendChildNode(DeclarationsChildNodeName);
            MocaNode constraintInstancesNode = constraintsNode.appendChildNode(ConstraintInstancesChildNodeName);

            //only persist user defined constraints
            foreach (CSPConstraint constr in this.Constraints)
            {
                if (constr.UserDefined)
                {
                    MocaNode constraintNode = declarationsNode.appendChildNode("");
                    constr.serializeToMocaTree(constraintNode);
                }
            }

            return(tggNode);
        }
        public override Serialization.MocaTree.MocaNode serializeToMocaTree()
        {
            MocaNode statementNode = base.serializeToMocaTree();

            statementNode.appendChildAttribute("type", "statement");
            if (this.StatementExpression != null)
            {
                MocaNode stat = statementNode.appendChildNode("statementExpression");
                this.StatementExpression.serializeToMocaTree(stat);
            }
            return(statementNode);
        }
Example #4
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree()
        {
            MocaNode stopNode = base.serializeToMocaTree();

            stopNode.appendChildAttribute("type", "stop");
            if (this.ReturnValue != null)
            {
                MocaNode ret = stopNode.appendChildNode("returnValue");
                this.ReturnValue.serializeToMocaTree(ret);
                Name = ReturnValue.ToString();
            }
            return(stopNode);
        }
Example #5
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree(MocaNode actNode)
        {
            MocaNode valueExpressionNode = actNode.appendChildNode("valueExpression");

            if (this.ValueExpression != null)
            {
                this.ValueExpression.serializeToMocaTree(valueExpressionNode);
            }

            actNode.appendChildAttribute("parameterGuid", this.ParameterGuid);
            actNode.appendChildAttribute("parameterType", this.ParameterType);

            return(actNode);
        }
        public override Serialization.MocaTree.MocaNode  serializeToMocaTree(Serialization.MocaTree.MocaNode actNode)
        {
            actNode.appendChildAttribute("constraintName", constraintName);

            MocaNode exprNode = actNode.appendChildNode("expressions");

            foreach (Expression expr in typedInExpressions)
            {
                MocaNode expressionNode = exprNode.appendChildNode("Expression");
                expr.serializeToMocaTree(expressionNode);
            }

            return(actNode);
        }
Example #7
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree()
        {
            MocaNode constraintNode = new MocaNode("ConstraintInstance");

            MocaNode entries = constraintNode.appendChildNode("entries");

            foreach (CSPInstanceEntry createdEntry in createdEntries)
            {
                entries.appendChildNode(createdEntry.serializeToMocaTree(new MocaNode("Entry")));
            }


            return(constraintNode);
        }
Example #8
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree(MocaNode actNode)
        {
            actNode.appendChildAttribute("name", this.Name);
            MocaNode parametersNode = actNode.appendChildNode(EOperation.ParametersChildNodeName);

            foreach (EParameter eParameter in this.EParameters)
            {
                MocaNode eParameterNode = parametersNode.appendChildNode("EParameter");
                eParameter.serializeToMocaTree(eParameterNode);
            }
            actNode.appendChildAttribute(Main.GuidStringName, this.EaMethod.MethodGUID);
            actNode.appendChildAttribute("typeGuid", this.typeGuid);
            actNode.appendChildAttribute("returnType", this.returnType);

            return(actNode);
        }
Example #9
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree()
        {
            MocaNode eEnumNode = new MocaNode("EEnum");

            eEnumNode.appendChildAttribute("name", this.eaEEnumElement.Name);
            eEnumNode.appendChildAttribute(Main.GuidStringName, this.eaEEnumElement.ElementGUID);

            MocaNode eLiteralsNode = eEnumNode.appendChildNode("literals");

            foreach (EEnumLiteral literal in this.Literals)
            {
                MocaNode eLiteralNode = eLiteralsNode.appendChildNode("EEnumLiteral");
                literal.serializeToMocaTree(eLiteralNode);
            }

            return(eEnumNode);
        }
        public override Serialization.MocaTree.MocaNode serializeToMocaTree()
        {
            MocaNode mocaNode = new MocaNode("ObjectVariable");

            mocaNode.appendChildAttribute(Main.GuidStringName, this.sqlElement.ElementGUID);
            if (this.Classifier != null)
            {
                mocaNode.appendChildAttribute("typeGuid", this.Classifier.EaElement.ElementGUID);
            }
            else
            {
                mocaNode.appendChildAttribute("typeGuid", "");
            }
            mocaNode.appendChildAttribute(BindingStateTaggedValueName, this.BindingState.ToString().ToLower());
            mocaNode.appendChildAttribute(BindingOperatorTaggedValueName, this.BindingOperator.ToString().ToLower());
            mocaNode.appendChildAttribute("name", this.Name);
            mocaNode.appendChildAttribute(BindingSemanticsTaggedValueName, this.BindingSemantics.ToString().ToLower());
            mocaNode.appendChildAttribute(NacIndexTaggedValueName, NacIndex.ToString());


            MocaNode constraintsNode = mocaNode.appendChildNode("constraints");
            MocaNode assignmentsNode = mocaNode.appendChildNode("attributeAssignments");

            mocaNode.appendChildNode(ObjectVariable.OutgoingLinksNodeName);

            foreach (Constraint constraint in this.Constraints)
            {
                MocaNode constNode = constraintsNode.appendChildNode("constraint");
                constraint.serializeToMocaTree(constNode);
            }
            foreach (AttributeAssignment attrAssignment in this.AttributeAssignments)
            {
                attrAssignment.OvName = this.Name;
                MocaNode attANode = assignmentsNode.appendChildNode("attributeAssignment");
                attrAssignment.serializeToMocaTree(attANode);
            }
            if (this.BindingExpression != null)
            {
                MocaNode bindNode = mocaNode.appendChildNode("bindingExpression");
                this.BindingExpression.serializeToMocaTree(bindNode);
            }


            return(mocaNode);
        }
Example #11
0
        internal void enhanceMetamodelNodeWithDependencies(SQLPackage outermostPackage, MocaNode outermostPackageNode)
        {
            var dependencyList = dependencies[outermostPackage.Name];

            MocaNode dependenciesNode = outermostPackageNode.appendChildNode("dependencies");

            if (dependencyList.Count != 0)
            {
                int counter = 0;
                foreach (String dependency in dependencyList)
                {
                    MetamodelHelper mmHelper = packageNameToEPackage[dependency].helper as MetamodelHelper;
                    if (!showStatusBar)
                    {
                        Console.Out.WriteLine("SCALE:Export Dependency '" + mmHelper.pluginID + "' %" + counter + "/" + dependencyList.Count + "#");
                    }
                    dependenciesNode.appendChildNode(mmHelper.pluginID);
                    counter++;
                }
            }
        }
Example #12
0
        public override void addAttributesDuringExport(MocaNode pkgNode)
        {
            base.addAttributesDuringExport(pkgNode);

            List <CSPConstraint> tempList = new List <CSPConstraint>();

            CSPUtil.addDefaultConstraints(tempList);

            MocaNode constraintRootNode = pkgNode.getChildNodeWithName(ConstraintsChildNodeName);

            if (constraintRootNode != null)
            {
                MocaNode declarationsRootNode = constraintRootNode.getChildNodeWithName(DeclarationsChildNodeName);
                if (declarationsRootNode != null)
                {
                    foreach (CSPConstraint constr in tempList)
                    {
                        MocaNode constraintNode = declarationsRootNode.appendChildNode("");
                        constr.serializeToMocaTree(constraintNode);
                    }
                }
            }
        }
Example #13
0
        public void processActivityNode(SQLElement activityNodeEAElement)
        {
            if (Serialization.MocaTaggableElement.isIgnored(activityNodeEAElement))
            {
                return;
            }

            ActivityNode actNode = null;

            if (activityNodeEAElement.Stereotype == "StoryNode" || activityNodeEAElement.Elements.Count > 0 || (activityNodeEAElement.Elements.Count == 0 && activityNodeEAElement.Notes == "" && activityNodeEAElement.Subtype != 100 && activityNodeEAElement.Subtype != 101))
            {
                actNode = new StoryNode(repository, activityNodeEAElement);
            }
            else if (activityNodeEAElement.Stereotype == "StopNode" || activityNodeEAElement.Subtype == 101)
            {
                actNode = new StopNode(repository, activityNodeEAElement);
            }
            else if (activityNodeEAElement.Stereotype == "StartNode" || activityNodeEAElement.Subtype == 100)
            {
                actNode = new StartNode(repository, activityNodeEAElement);
            }
            else if (activityNodeEAElement.Stereotype == "StatementNode" || (activityNodeEAElement.Elements.Count == 0 && activityNodeEAElement.Notes != ""))
            {
                actNode = new StatementNode(repository, activityNodeEAElement);
            }

            Boolean        valid       = actNode.loadTreeFromTaggedValue();
            SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(activityNodeEAElement, Main.MoflonExportTreeTaggedValueName);

            MocaNode activityNodeMocaNode = new MocaNode();

            activityNodeMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement);
            this.currentNode.appendChildNode(activityNodeMocaNode);

            foreach (SQLConnector activityEdge in activityNodeEAElement.Connectors)
            {
                if ((activityEdge.Stereotype == SDMModelingMain.ActivityEdgeStereotype || activityEdge.Stereotype == "") && activityEdge.Type == "ControlFlow" && activityEdge.ClientID == activityNodeEAElement.ElementID)
                {
                    this.currentNode = activityNodeMocaNode.getChildNodeWithName(ActivityNode.OutgoingTransitionsNodeName);
                    processActivityEdge(activityEdge);
                }
            }
            foreach (SQLElement storyNodeChild in activityNodeEAElement.Elements)
            {
                if (storyNodeChild.Stereotype == SDMModelingMain.ObjectVariableStereotype || storyNodeChild.Stereotype == "SDM_Object")
                {
                    this.currentNode = activityNodeMocaNode.getChildNodeWithName(StoryPattern.ObjectVariablesChildNodeName);
                    processObjectVariable(storyNodeChild);
                }
                else if (storyNodeChild.Stereotype == SDMModelingMain.CSPInstanceStereotype)
                {
                    this.currentNode = activityNodeMocaNode.getChildNodeWithName("AttributeConstraints");
                    if (currentNode == null)
                    {
                        this.currentNode = activityNodeMocaNode.appendChildNode("AttributeConstraints");
                    }

                    MocaNode cspNode = currentNode.appendChildNode("AttributeConstraint");
                    cspNode.appendChildAttribute("constraintSpec", storyNodeChild.Notes);
                    SQLTaggedValue nacIndexTag = EAUtil.findTaggedValue(storyNodeChild, "nacIndex");
                    if (nacIndexTag != null)
                    {
                        String nacIndex = nacIndexTag.Value;
                        cspNode.appendChildAttribute("nacIndex", nacIndex != "" ? nacIndex : "-1");
                    }
                }
            }
        }
Example #14
0
        public void importERef(SQLElement parent, MocaNode referencesNode)
        {
            foreach (MocaNode refNode in referencesNode.Children)
            {
                String refGuid = refNode.getAttributeOrCreate(Main.GuidStringName).Value;

                String oppositeGuid = refNode.getAttributeOrCreate("oppositeGuid").Value;

                bool containment = refNode.getAttributeOrCreate("containment").Value == "true";
                bool hasOpposite = oppositeGuid != "";

                SQLElement client  = parent;
                String     supGuid = refNode.getAttributeOrCreate("typeGuid").Value;

                EA.Connector con = null;
                if (MainImport.getInstance().ElementGuidToElement.ContainsKey(supGuid))
                {
                    EA.Element supplier = MainImport.getInstance().ElementGuidToElement[supGuid];
                    if (hasOpposite)
                    {
                        if (!oppositeGuid.EndsWith("Client") && !oppositeGuid.EndsWith("Supplier"))
                        {
                        }
                        if (MainImport.getInstance().ReferenceGuidToReference.ContainsKey(oppositeGuid))
                        {
                            con = MainImport.getInstance().ReferenceGuidToReference[oppositeGuid];
                            refNode.getAttributeOrCreate(Main.GuidStringName).Value = "Client";
                        }
                        else
                        {
                            int supplierAggregation = 0;
                            int clientAggregation   = 0;
                            if (containment)
                            {
                                if (oppositeGuid.EndsWith("Client"))
                                {
                                    clientAggregation = 2;
                                }
                                else
                                {
                                    supplierAggregation = 2;
                                }
                            }

                            con = createConnector(client, sqlRep.GetElementByID(supplier.ElementID), refGuid, Main.EAAssociationType, supplierAggregation, clientAggregation, hasOpposite);
                            refNode.getAttributeOrCreate(Main.GuidStringName).Value = "Supplier";
                        }
                    }
                    else
                    {
                        con = createConnector(sqlRep.GetElementByID(client.ElementID), sqlRep.GetElementByID(supplier.ElementID), refGuid, Main.EAAssociationType, 0, 0, hasOpposite);
                        refNode.getAttributeOrCreate(Main.GuidStringName).Value = "Supplier";
                    }
                }
                if (con != null)
                {
                    if (!MainImport.getInstance().ReferenceGuidToReference.ContainsKey(refGuid))
                    {
                        MainImport.getInstance().ReferenceGuidToReference.Add(refGuid, con);
                    }

                    refGuid = refGuid.Replace("Client", "").Replace("Supplier", "");

                    if (!MainImport.getInstance().OldGuidToNewGuid.ContainsKey(refGuid))
                    {
                        MainImport.getInstance().OldGuidToNewGuid.Add(refGuid, con.ConnectorGUID);
                    }



                    if (!MainImport.getInstance().ReferenceGuidToReference.ContainsKey(con.ConnectorGUID))
                    {
                        MainImport.getInstance().ReferenceGuidToReference.Add(con.ConnectorGUID, con);
                    }

                    MocaNode referencesNodeSet = new MocaNode("references");


                    if (MainImport.getInstance().ReferenceGuidToClientTarget.ContainsKey(con.ConnectorGUID))
                    {
                        referencesNodeSet = MainImport.getInstance().ReferenceGuidToClientTarget[con.ConnectorGUID];
                    }
                    else
                    {
                        MainImport.getInstance().ReferenceGuidToClientTarget.Add(con.ConnectorGUID, referencesNodeSet);
                    }



                    referencesNodeSet.appendChildNode(refNode);
                }
            }
        }
Example #15
0
        public MocaNode processEClass(SQLElement eaClass)
        {
            //this.exportProgressBar.invokePerformNext("Exporting EClass: " + eaClass.Name);

            SQLTaggedValue changesTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonChangesTreeTaggedValueName);


            SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonExportTreeTaggedValueName);

            if (mocaTreeTag != null)
            {
                EClass eClass = new EClass(eaClass, repository);
                eClass.loadTreeFromTaggedValue();
                MocaNode eClassMocaNode = MocaTreeUtil.mocaNodeFromXmlString(mocaTreeTag.Notes);

                eClass.addMocaAttributesDuringExport(eClassMocaNode);

                if (changesTreeTag != null)
                {
                    MocaNode eClassChangesNode = MocaTreeUtil.mocaNodeFromXmlString(changesTreeTag.Notes);
                    eClass.addMocaAttributesDuringExport(eClassChangesNode);
                }
                //add baseclass dependencies
                foreach (var baseClass in eClassMocaNode.getAttributeOrCreate("baseClasses").Value.Split(" ".ToArray()))
                {
                    if (baseClass != "")
                    {
                        SQLElement baseclass = repository.GetElementByGuid(baseClass);
                        Export.computeAndAddToDependencies(repository, baseclass);
                    }
                }

                this.currentNode.appendChildNode(eClassMocaNode);

                //process SDM Container Objects
                int counter = 0;
                foreach (SQLElement possibleSDMContainer in eaClass.Elements)
                {
                    if (possibleSDMContainer.Stereotype == SDMModelingMain.SdmContainerStereotype || possibleSDMContainer.Stereotype == "SDM_Container")
                    {
                        String   associatedMethodguid = EAEcoreAddin.Util.EAUtil.findTaggedValue(possibleSDMContainer, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value;
                        MocaNode operationsNode       = eClassMocaNode.getChildNodeWithName(EClass.OperationsChildNodeName);
                        MocaNode owningOperationNode  = null;
                        if (!Export.showStatusBar)
                        {
                            Console.Out.WriteLine("SCALE:Export SDM '" + possibleSDMContainer.Name + "' %" + counter + "/" + eaClass.Elements.Count + "#");
                        }
                        counter++;
                        foreach (MocaNode EOperationNode in operationsNode.Children)
                        {
                            MocaAttribute guidAttribute = EOperationNode.getAttributeOrCreate(Main.GuidStringName);
                            if (guidAttribute != null && guidAttribute.Value == associatedMethodguid)
                            {
                                owningOperationNode = EOperationNode;
                            }
                        }

                        if (owningOperationNode != null)
                        {
                            MocaNode sdmActivityNode = this.sdmExport.processActivity(possibleSDMContainer);
                            owningOperationNode.appendChildNode(sdmActivityNode);
                        }
                    }
                }

                foreach (SQLAttribute element in eaClass.Attributes)
                {
                    string     t           = element.Type;
                    int        cid         = element.ClassifierID;
                    SQLElement typeElement = repository.GetElementByIDNullable(cid);
                    Export.computeAndAddToDependencies(repository, typeElement);
                }

                counter = 0;
                foreach (SQLConnector ereference in eaClass.Connectors)
                {
                    if (ereference.Type == Main.EAAssociationType)
                    {
                        if (!Export.showStatusBar)
                        {
                            Console.Out.WriteLine("SCALE:Export EReference '" + ereference.Name + "' %" + counter + "/" + eaClass.Connectors.Count + "#");
                        }
                        counter++;
                        MocaNode referencesNode = eClassMocaNode.getChildNodeWithName(EClass.ReferencesChildNodeName);

                        if (ereference.ClientID != eaClass.ElementID && ereference.ClientEnd.IsNavigable)
                        {
                            this.currentNode = referencesNode;
                            processEReference(ereference, ereference.ClientEnd.End);
                        }
                        else if (ereference.SupplierID != eaClass.ElementID && ereference.SupplierEnd.IsNavigable)
                        {
                            this.currentNode = referencesNode;
                            processEReference(ereference, ereference.SupplierEnd.End);
                        }

                        if (ereference.SupplierID == eaClass.ElementID && ereference.ClientID == eaClass.ElementID && ereference.SupplierEnd.IsNavigable)
                        {
                            this.currentNode = referencesNode;
                            processEReference(ereference, ereference.SupplierEnd.End);
                        }
                        if (ereference.SupplierID == eaClass.ElementID && ereference.ClientID == eaClass.ElementID && ereference.ClientEnd.IsNavigable)
                        {
                            this.currentNode = referencesNode;
                            processEReference(ereference, ereference.ClientEnd.End);
                        }
                    }
                }
                return(eClassMocaNode);
            }
            return(null);
        }