Beispiel #1
0
        public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (MocaTaggableElement.isIgnored(eaElement))
            {
                return(results);
            }

            if (eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype ||
                eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype ||
                eaElement.Stereotype == SDMModelingMain.StopNodeStereotype)
            {
                int incomingCount = 0;
                foreach (SQLConnector edge in eaElement.Connectors)
                {
                    if (edge.SupplierID == eaElement.ElementID)
                    {
                        incomingCount++;
                    }
                }
                if (incomingCount == 0)
                {
                    results.Add("At least one incoming Edge is needed");
                }
            }
            return(results);
        }
        private void validateEAElement(Object eaObject, SQLRepository repository, Boolean singleRulecheck)
        {
            SQLElement element = eaObject as SQLElement;

            //only do rules for Element, Attributes and Methods
            if (singleRulecheck)
            {
                foreach (SQLAttribute actAttribute in element.Attributes)
                {
                    RuleControl.deleteRuleResults(EA.ObjectType.otAttribute, actAttribute.AttributeID);
                    RuleControl.doRules(actAttribute, repository);
                }
                foreach (SQLMethod actMethod in element.Methods)
                {
                    RuleControl.deleteRuleResults(EA.ObjectType.otMethod, actMethod.MethodID);
                    RuleControl.doRules(actMethod, repository);
                }
                RuleControl.deleteRuleResults(EA.ObjectType.otElement, element.ElementID);
                RuleControl.doRules(element, repository);
            }
            else
            {
                List <SQLElement>   listOfElements   = new List <SQLElement>();
                List <SQLConnector> listOfConnectors = new List <SQLConnector>();
                List <SQLAttribute> listOfAttributes = new List <SQLAttribute>();
                List <SQLMethod>    listofMethods    = new List <SQLMethod>();
                List <SQLParameter> listofParameters = new List <SQLParameter>();
                List <SQLPackage>   listOfPackages   = new List <SQLPackage>();
                addElementChildFeatures(listOfElements, listOfConnectors, listOfAttributes, listofMethods, listofParameters, element);
                doRulesForFeatures(repository, listOfElements, listOfConnectors, listOfAttributes, listofMethods, listofParameters, listOfPackages);
            }
        }
Beispiel #3
0
        public void processTggEReference(SQLConnector eaReference, String clientOrSupplier)
        {
            SQLConnectorTag mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaReference, Main.MoflonExportTreeTaggedValueName);

            MocaNode referenceEndNode = new MocaNode();

            referenceEndNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement);

            SQLElement eTypeElement = null;

            if (clientOrSupplier == "Client")
            {
                referenceEndNode = referenceEndNode.getChildNodeWithName(EReference.ClientReferenceChildNodeName).Children[0];
                eTypeElement     = repository.GetElementByID(eaReference.ClientID);
            }
            else if (clientOrSupplier == "Supplier")
            {
                referenceEndNode = referenceEndNode.getChildNodeWithName(EReference.SupplierReferenceChildNodeName).Children[0];
                eTypeElement     = repository.GetElementByID(eaReference.SupplierID);
            }

            ExportMain.computeAndAddToDependencies(repository, eTypeElement);

            this.currentNode.appendChildNode(referenceEndNode);
        }
Beispiel #4
0
        private static void checkStatementNode(SQLElement eaElement, List <String> results)
        {
            int outgoingCount    = 0;
            int successEdgeCount = 0;
            int failureEdgeCount = 0;

            foreach (SQLConnector edge in eaElement.Connectors)
            {
                if (edge.ClientID == eaElement.ElementID)
                {
                    if (edge.TransitionGuard.ToLower() == "success")
                    {
                        successEdgeCount++;
                    }
                    else if (edge.TransitionGuard.ToLower() == "failure")
                    {
                        failureEdgeCount++;
                    }
                    outgoingCount++;
                }
            }
            if ((outgoingCount == 1 && (successEdgeCount == 1 || failureEdgeCount == 1)) ||
                (outgoingCount == 2 && (successEdgeCount != 1 || failureEdgeCount != 1)) ||
                outgoingCount > 2 ||
                outgoingCount < 1)
            {
                results.Add("StatementNode must have one outgoing Edge without Guard or two outgoing Edges with Success and Failure");
            }
        }
Beispiel #5
0
        public void processObjectVariable(SQLElement objectVariable)
        {
            SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(objectVariable, Main.MoflonExportTreeTaggedValueName);

            ObjectVariable ov = new ObjectVariable(objectVariable, repository);

            ov.loadTreeFromTaggedValue();

            SQLElement classifier = EAUtil.getClassifierElement(repository, objectVariable.ClassifierID);

            if (classifier != null)
            {
                Export.computeAndAddToDependencies(repository, classifier);
            }

            MocaNode ovMocaNode = new MocaNode();

            ovMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement);

            ov.addAttributesDuringExport(ovMocaNode);

            this.currentNode.appendChildNode(ovMocaNode);

            foreach (SQLConnector linkVariable in objectVariable.Connectors)
            {
                if ((linkVariable.Stereotype == SDMModelingMain.LinkVariableStereotype || linkVariable.Stereotype == "SDM_Association") && linkVariable.ClientID == objectVariable.ElementID)
                {
                    this.currentNode = ovMocaNode.getChildNodeWithName(ObjectVariable.OutgoingLinksNodeName);
                    processLinkVariable(linkVariable);
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// checks if the the parameter can be referenced from the object
        /// parameter is in the same sdm as the object)
        /// </summary>
        /// <param name="referencedParameter"></param>
        /// <param name="containingElement"></param>
        /// <param name="repository"></param>
        /// <returns></returns>
        public static Boolean checkParameterCanBeReferenced(SQLParameter referencedParameter, SQLElement containingElement, SQLRepository repository)
        {
            SQLElement containerOfOwningObject = containingElement;

            while (containerOfOwningObject.Stereotype != SDMModelingMain.SdmContainerStereotype && containerOfOwningObject.Stereotype != TGGModelingMain.TggRuleStereotype)
            {
                containerOfOwningObject = repository.GetElementByID(containerOfOwningObject.ParentID);
            }

            if (containerOfOwningObject.Stereotype == SDMModelingMain.SdmContainerStereotype)
            {
                SQLMethod referencedMethodOfSDM = repository.GetMethodByGuid(EAEcoreAddin.Util.EAUtil.findTaggedValue(containerOfOwningObject, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value);
                if (referencedMethodOfSDM != null)
                {
                    if (referencedParameter.OperationID != referencedMethodOfSDM.MethodID)
                    {
                        return(false);
                    }
                }
            }

            else if (containerOfOwningObject.Stereotype == TGGModelingMain.TggRuleStereotype)
            {
                SQLMethod method = repository.GetMethodByID(referencedParameter.OperationID);
                if (method.ParentID != containerOfOwningObject.ElementID)
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #7
0
        private static void checkForEachStoryNode(SQLElement eaElement, List <String> results)
        {
            int outgoingCount        = 0;
            int foreachEdgeExists    = 0;
            int endForEachEdgeExists = 0;

            foreach (SQLConnector edge in eaElement.Connectors)
            {
                if (edge.ClientID == eaElement.ElementID)
                {
                    if (edge.TransitionGuard.ToLower() == "each time")
                    {
                        foreachEdgeExists++;
                    }
                    else if (edge.TransitionGuard.ToLower() == "end")
                    {
                        endForEachEdgeExists++;
                    }
                    outgoingCount++;
                }
            }
            if (((foreachEdgeExists != 1 || endForEachEdgeExists != 1) && outgoingCount == 2) ||
                ((endForEachEdgeExists != 1 || foreachEdgeExists != 0) && outgoingCount == 1) ||
                outgoingCount == 0 ||
                outgoingCount > 2)
            {
                results.Add("ForEachNode must have two outgoing Edges with End and Each Time or one with End");
            }
        }
Beispiel #8
0
        private static int markElementOnDiagram(SQLElement element, SQLRepository repository)
        {
            EA.Element       realElement     = element.getRealElement();
            EA.DiagramObject diagramObject   = null;
            String           diagramIdResult = repository.SQLQuery("select * from t_diagramobjects where t_diagramobjects.Object_ID = " + realElement.ElementID);
            int    count     = 0;
            String diagramID = EAEcoreAddin.Util.EAUtil.getXMLNodeContentFromSQLQueryString(diagramIdResult, "Diagram_ID")[0];

            if (diagramID != "")
            {
                count = EAEcoreAddin.Util.EAUtil.getXMLNodeContentFromSQLQueryString(diagramIdResult, "Diagram_ID").Count;

                EA.Diagram diagram = repository.GetOriginalRepository().GetDiagramByID(int.Parse(diagramID));
                foreach (EA.DiagramObject diagObject in diagram.DiagramObjects)
                {
                    if (diagObject.ElementID == realElement.ElementID)
                    {
                        diagramObject = diagObject;
                    }
                }
                if (diagramObject != null)
                {
                    repository.OpenDiagram(diagram.DiagramID);

                    diagram.SelectedObjects.AddNew(diagramObject.ElementID.ToString(), "");

                    // repository.ReloadDiagram(diagram.DiagramID);
                }
            }
            return(count);
        }
        public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (Serialization.MocaTaggableElement.isIgnored(eaElement))
            {
                return(results);
            }

            if (eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype)
            {
                StoryNode storyNode = new StoryNode(repository, eaElement);
                if (!storyNode.loadTreeFromTaggedValue())
                {
                    results.Add("StoryNode is invalid and has to be updated manually");
                }
            }
            else if (eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype)
            {
                StatementNode stNode = new StatementNode(repository, eaElement);
                if (!stNode.loadTreeFromTaggedValue())
                {
                    results.Add("StatementNode is invalid and has to be updated manually");
                }
            }
            else if (eaElement.Stereotype == SDMModelingMain.StopNodeStereotype)
            {
                StopNode stopNode = new StopNode(repository, eaElement);
                if (!stopNode.loadTreeFromTaggedValue())
                {
                    results.Add("StopNode is invalid and has to be updated manually");
                }
            }
            return(results);
        }
Beispiel #10
0
        private static void printTGGOvObject(SQLElement child, EA.Diagram diagram, EA.Repository repository, List <Point> usedPoints)
        {
            TGGObjectVariable ov = new TGGObjectVariable(child, new SQLRepository(repository, false));

            ov.loadTreeFromTaggedValue();

            int x = 1;
            int y = 1;

            if (ov.domain == DomainType.TARGET)
            {
                x = 3;
            }

            while (usedPoints.Contains(new Point(x, y)))
            {
                y++;
            }

            EA.DiagramObject diagObject = diagram.DiagramObjects.AddNew("", "") as EA.DiagramObject;
            diagObject.ElementID = child.ElementID;
            diagObject.left      = x * 200;
            diagObject.right     = diagObject.left + 125;
            diagObject.top       = y * -100;
            diagObject.bottom    = diagObject.top - 50;
            diagObject.Update();
            usedPoints.Add(new Point(x, y));
        }
Beispiel #11
0
        private static int markAttributeOnDiagram(SQLAttribute attribute, SQLRepository repository)
        {
            SQLElement parentElement = repository.GetElementByID(attribute.ParentID);
            int        count         = markElementOnDiagram(parentElement, repository);

            return(count);
        }
Beispiel #12
0
        public override List <FirstObject> getFirstObjects(SQLElement elementToSearch, SQLRepository repository)
        {
            List <FirstObject> targetParameters = new List <FirstObject>();
            SQLMethod          associatedMethod = null;

            if (elementToSearch.Stereotype == SDMModelingMain.SdmContainerStereotype)
            {
                SQLTaggedValue assoMethodTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elementToSearch, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName);
                associatedMethod = repository.GetMethodByGuid(assoMethodTag.Value);
            }

            else if (elementToSearch.Stereotype == TGGModelingMain.TggRuleStereotype)
            {
                if (elementToSearch.Methods.Count > 0)
                {
                    associatedMethod = elementToSearch.Methods.GetAt(0);
                }
            }

            if (associatedMethod != null)
            {
                foreach (SQLParameter parameter in associatedMethod.Parameters)
                {
                    targetParameters.Add(new FirstObject(parameter));
                }
            }

            targetParameters.Sort(new EAObjectIComparer());
            return(targetParameters);
        }
Beispiel #13
0
        public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (eaConnector.Type == ECOREModelingMain.EReferenceConnectorType)
            {
                SQLElement sourceElement = repository.GetElementByID(eaConnector.ClientID);
                SQLElement targetElement = repository.GetElementByID(eaConnector.SupplierID);

                if (sourceElement.Stereotype == ECOREModelingMain.EClassStereotype)
                {
                    String clientResult   = checkCardinality(eaConnector.ClientEnd.Cardinality);
                    String supplierResult = checkCardinality(eaConnector.SupplierEnd.Cardinality);
                    if (clientResult != "")
                    {
                        results.Add(clientResult);
                    }
                    if (supplierResult != "")
                    {
                        results.Add(supplierResult);
                    }
                }
            }
            return(results);
        }
Beispiel #14
0
 public ActivityNode(SQLRepository repository, SQLElement activityNode)
 {
     this.Repository            = repository;
     this.ActivityNodeEAElement = activityNode;
     this.Name   = this.ActivityNodeEAElement.Name;
     this.EaGuid = this.ActivityNodeEAElement.ElementGUID;
 }
Beispiel #15
0
        private static Object computeActivityEdge(Object parent, SQLRepository repository, String pathEntry)
        {
            object     eaObject   = parent;
            SQLElement sourceEdge = null;
            SQLElement targetEdge = null;

            foreach (SQLElement activityNode in (eaObject as SQLElement).Elements)
            {
                if (activityNode.Name == getNameOfConnectorEntry(pathEntry, "source"))
                {
                    sourceEdge = activityNode;
                }
                if (activityNode.Name == getNameOfConnectorEntry(pathEntry, "target"))
                {
                    targetEdge = activityNode;
                }
            }
            foreach (SQLConnector activityEdge in sourceEdge.Connectors)
            {
                if (activityEdge.ClientID == sourceEdge.ElementID && activityEdge.SupplierID == targetEdge.ElementID)
                {
                    eaObject = activityEdge;
                }
                if (activityEdge.ClientID == targetEdge.ElementID && activityEdge.SupplierID == sourceEdge.ElementID)
                {
                    eaObject = activityEdge;
                }
            }
            return(eaObject);
        }
        public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (eaElement.Stereotype == TGGModelingMain.TggRuleStereotype)
            {
                SQLPackage rulesPackage     = repository.GetPackageByID(eaElement.PackageID);
                SQLPackage tggSchemaPackage = repository.GetPackageByID(rulesPackage.ParentID);
                foreach (SQLElement corrType in tggSchemaPackage.Elements)
                {
                    if (corrType.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype)
                    {
                        if (corrType.Name == eaElement.Name)
                        {
                            results.Add("TGG Rule name shouldnt be equal to TGG CorrespondenceType name");
                        }
                    }
                }

                if (!ConsistencyUtil.isValidTGGRuleName(eaElement.Name))
                {
                    results.Add("TGG Rule name should consist of the following letters: a-z,A-Z,0-9,_,-");
                }
            }
            return(results);
        }
Beispiel #17
0
        private static Object computeLinkVariable(Object parent, SQLRepository repository, String pathEntry)
        {
            Object     eaObject = parent;
            SQLElement source   = null;
            SQLElement target   = null;

            foreach (SQLElement objectVariables in (eaObject as SQLElement).Elements)
            {
                if (objectVariables.Name == getNameOfConnectorEntry(pathEntry, "source"))
                {
                    source = objectVariables;
                }
                if (objectVariables.Name == getNameOfConnectorEntry(pathEntry, "target"))
                {
                    target = objectVariables;
                }
            }
            foreach (SQLConnector linkvariable in source.Connectors)
            {
                if (linkvariable.ClientID == source.ElementID && linkvariable.SupplierID == target.ElementID)
                {
                    eaObject = linkvariable;
                }
                if (linkvariable.ClientID == target.ElementID && linkvariable.SupplierID == source.ElementID)
                {
                    eaObject = linkvariable;
                }
            }
            return(eaObject);
        }
        public override void doRuleQuickFix(SQLElement sqlElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage)
        {
            EA.Element realElement = sqlElement.getRealElement();
            if (errorMessage == "TGG Rule name shouldnt be equal to TGG CorrespondenceType name")
            {
                if (i == 0)
                {
                    realElement.Name = "Rule" + realElement.Name;
                    realElement.Update();

                    TGGRule tggRule = new TGGRule(repository, sqlElement);
                    tggRule.saveTreeToEATaggedValue(true);
                }
            }
            else if (errorMessage == "TGG Rule name must not contain spaces")
            {
                if (i == 0)
                {
                    realElement.Name = realElement.Name.Replace(" ", "");
                    realElement.Update();

                    TGGRule tggRule = new TGGRule(repository, sqlElement);
                    tggRule.saveTreeToEATaggedValue(true);
                }
            }
        }
Beispiel #19
0
        private static bool checkMethodCallExpression(SQLElement containingElement, SQLRepository sqlRepository, MethodCallExpression mCe)
        {
            SQLMethod method = sqlRepository.GetMethodByGuid(mCe.MethodGuid);
            Boolean   valid  = checkExpression(containingElement, mCe.Target, sqlRepository);

            if (method == null)
            {
                return(false);
            }

            if (mCe.MethodName != mCe.MethodNameOld || mCe.OwnedParameterBinding.Count != method.Parameters.Count)
            {
                return(false);
            }

            foreach (ParameterBinding paramBinding in mCe.OwnedParameterBinding)
            {
                SQLParameter parameter = sqlRepository.GetParameterByGuid(paramBinding.ParameterGuid);
                if (parameter == null)
                {
                    valid = false;
                }
                if (!checkExpression(containingElement, paramBinding.ValueExpression, sqlRepository))
                {
                    valid = false;
                }
            }

            return(valid);
        }
Beispiel #20
0
        public override List <String> doRule(SQLConnector eaConnector, SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (eaConnector.Type == ECOREModelingMain.EReferenceConnectorType)
            {
                SQLElement source = repository.GetElementByID(eaConnector.ClientID);
                SQLElement target = repository.GetElementByID(eaConnector.SupplierID);

                if (source.Stereotype == ECOREModelingMain.EClassStereotype || source.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype ||
                    target.Stereotype == ECOREModelingMain.EClassStereotype || target.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype)
                {
                    SQLConnectorEnd targetEnd = eaConnector.SupplierEnd;
                    SQLConnectorEnd sourceEnd = eaConnector.ClientEnd;
                    if (targetEnd.Navigable == "Navigable" && targetEnd.Role == "")
                    {
                        results.Add("EReference: Navigable end must have a role name");
                    }
                    if (sourceEnd.Navigable == "Navigable" && sourceEnd.Role == "")
                    {
                        results.Add("EReference: Navigable end must have a role name");
                    }
                }
            }
            return(results);
        }
Beispiel #21
0
        public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (Serialization.MocaTaggableElement.isIgnored(eaElement))
            {
                return(results);
            }

            if (eaElement.Stereotype == SDMModelingMain.StartNodeStereotype)
            {
                checkStartNode(eaElement, results);
            }

            else if (eaElement.Stereotype == SDMModelingMain.StopNodeStereotype)
            {
                checkStopNode(eaElement, results);
            }

            else if (eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype)
            {
                checkStatementNode(eaElement, results);
            }

            else if (eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype)
            {
                checkStoryNode(eaElement, repository, results);
            }
            return(results);
        }
 public StoryPattern(SQLRepository repository, SQLElement storyPattern)
 {
     this.StoryPatternElement = storyPattern;
     this.Repository          = repository;
     this.LinkVariable        = new ArrayList();
     this.ObjectVariable      = new ArrayList();
 }
Beispiel #23
0
        public SQLMethod findMethodFromMocaNode(SQLElement parent, MocaNode methodNode)
        {
            SQLMethod found = null;

            foreach (SQLMethod method in parent.Methods)
            {
                int validCount = 0;
                if (method.Name == methodNode.getAttributeOrCreate("name").Value)
                {
                    foreach (SQLParameter param in method.Parameters)
                    {
                        foreach (MocaNode paramNode in methodNode.getChildNodeWithName(EOperation.ParametersChildNodeName).Children)
                        {
                            if (paramNode.getAttributeOrCreate("name").Value == param.Name)
                            {
                                validCount++;
                            }
                        }
                    }
                    if (validCount == method.Parameters.Count && validCount == methodNode.getChildNodeWithName(EOperation.ParametersChildNodeName).Children.Count)
                    {
                        found = method;
                    }
                }
            }
            return(found);
        }
Beispiel #24
0
        public MocaNode processEClass(SQLElement eaClass)
        {
            SQLTaggedValue changesTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonChangesTreeTaggedValueName);

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

                eClass.addMocaAttributesDuringExport(eClassMocaNode);

                this.currentNode.appendChildNode(eClassMocaNode);

                if (eClassMocaNode.hasAllAttributes(new List <string>(
                                                        new string[] { ChangesTreeConstants.ATTRIBUTE_KEY_PACKAGE_NAME, ChangesTreeConstants.ATTRIBUTE_KEY_PROJECT_NAME })))
                {
                    String packageName = eClassMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PACKAGE_NAME).Value;
                    String projectName = eClassMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PROJECT_NAME).Value;

                    CachedClass temp = new CachedClass();
                    temp.getElement(eaClass.ElementGUID, repository);
                    temp.name         = eClass.Name;
                    temp.previousName = eClass.Name;
                    temp.packageName  = packageName;
                    temp.projectName  = projectName;
                    temp.saveElementToEATaggedValue(true);

                    return(eClassMocaNode);
                }
            }
            return(null);
        }
Beispiel #25
0
 public ObjectVariableExpression(SQLElement objectVariableEAElement, SQLRepository repository)
 {
     this.Repository         = repository;
     this.ObjectVariableGUID = objectVariableEAElement.ElementGUID;
     this.ObjectVariableName = objectVariableEAElement.Name;
     this.Type = DESCRIPTION;
 }
        public Boolean EA_OnPreNewConnector(EA.Repository repository, EA.EventProperties info)
        {
            if (info.Get("Stereotype").Value.Equals(SDMModelingMain.LinkVariableStereotype))
            {
                EA.Element client   = repository.GetElementByID(Int32.Parse(info.Get("ClientID").Value as String));
                EA.Element supplier = repository.GetElementByID(Int32.Parse(info.Get("SupplierID").Value as String));
                if (client != null && supplier != null)
                {
                    List <SQLConnector> clientToSupplierAssociations = new List <SQLConnector>();
                    List <SQLConnector> supplierToClientAssociations = new List <SQLConnector>();

                    SQLRepository sqlRepository      = new SQLRepository(repository, false);
                    SQLElement    clientClassifier   = sqlRepository.GetElementByID(client.ClassfierID);
                    SQLElement    supplierClassifier = sqlRepository.GetElementByID(supplier.ClassfierID);

                    LinkVariablePropertiesForm.collectPossibleAssociations(ref clientClassifier, ref supplierClassifier, ref clientToSupplierAssociations, ref supplierToClientAssociations, ref sqlRepository);
                    if (clientToSupplierAssociations.Count == 0 && supplierToClientAssociations.Count == 0)
                    {
                        System.Windows.Forms.MessageBox.Show("There is no Association between these two elements");
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #27
0
        private void processTggRule(SQLElement ruleClass)
        {
            //this.exportProgressBar.invokePerformNext("exporting EClass: " + eaClass.Name);
            SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(ruleClass, Main.MoflonExportTreeTaggedValueName);
            TGGRule        tggRule     = new TGGRule(repository, ruleClass);

            tggRule.loadTreeFromTaggedValue();
            MocaNode tggRuleMocaNode = new MocaNode();

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

            tggRule.additionalAttributesDuringExport(tggRuleMocaNode);

            foreach (SQLElement element in ruleClass.Elements)
            {
                //handle tgg rule pattern

                if (element.Stereotype == TGGModelingMain.TggObjectVariableStereotype || element.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
                {
                    this.currentNode = tggRuleMocaNode.getChildNodeWithName(StoryPattern.ObjectVariablesChildNodeName);
                    processTggObjectVariable(element);
                }
                //handle sdms of tgg rule class
                else if (element.Stereotype == SDMModelingMain.SdmContainerStereotype)
                {
                    String   associatedMethodguid = EAEcoreAddin.Util.EAUtil.findTaggedValue(element, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value;
                    MocaNode operationsNode       = tggRuleMocaNode.getChildNodeWithName(EClass.OperationsChildNodeName);
                    MocaNode owningOperationNode  = null;

                    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.ExportMain.ecoreExport.sdmExport.processActivity(element);
                        owningOperationNode.appendChildNode(sdmActivityNode);
                    }
                }
                else if (element.Stereotype == TGGModelingMain.CSPConstraintStereotype || element.Stereotype == "TGGCsp")
                {
                    MocaNode cspsNode = tggRuleMocaNode.getChildNodeWithName(TGGRule.CspsChildNodeName);
                    if (cspsNode == null)
                    {
                        cspsNode = tggRuleMocaNode.appendChildNode(TGGRule.CspsChildNodeName);
                    }
                    this.currentNode = cspsNode;
                    processTGGCSP(element);


                    tggRuleMocaNode.getAttributeOrCreate(TGGRule.CspSpecAttributeName).Value += element.Notes.Replace(Environment.NewLine, "");
                }
            }
        }
        public void EA_OnNotifyContextItemModified(EA.Repository Repository, String GUID, EA.ObjectType ot)
        {
            SQLRepository sqlRepository = new SQLRepository(Repository, false);



            if (ot == EA.ObjectType.otElement)
            {
                EA.Element eaElement2 = Repository.GetElementByGuid(GUID);
                SQLElement sqlElement = sqlRepository.GetElementByID(eaElement2.ElementID);
                if (sqlElement.Stereotype.ToLower() == SDMModelingMain.SdmContainerStereotype.ToLower())
                {
                    Activity activity = new Activity(sqlElement, sqlRepository);
                    activity.saveTreeToEATaggedValue(true);
                }
                else if (sqlElement.MetaType == SDMModelingMain.ActivityNodeMetatype)
                {
                    ActivityNode aNode = SDMUtil.createCorrectActivityNode(sqlRepository, sqlElement);
                    if (aNode != null)
                    {
                        aNode.loadTreeFromTaggedValue();
                        aNode.Name = sqlElement.Name;
                        aNode.saveTreeToEATaggedValue(true);
                    }
                }
            }
        }
Beispiel #29
0
 private void processTGGPackageFeatures(MocaNode ePackageMocaNode, SQLElement childClass)
 {
     if (childClass.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype)
     {
         this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.ClassesChildNodeName);
         processTGGCorrespondenceType(childClass);
     }
     else if (childClass.Stereotype == TGGModelingMain.TggRuleSetStereotype)
     {
         foreach (SQLElement childElement in childClass.Elements)
         {
             processTGGPackageFeatures(ePackageMocaNode, childElement);
         }
     }
     else if (childClass.Stereotype == TGGModelingMain.TggRuleStereotype)
     {
         MocaNode rulesNode = ePackageMocaNode.getChildNodeWithName(TGGRulePackage.RulesChildNodeName);
         if (rulesNode == null)
         {
             rulesNode = ePackageMocaNode.appendChildNode(TGGRulePackage.RulesChildNodeName);
         }
         this.currentNode = rulesNode;
         processTggRule(childClass);
     }
     else if (childClass.Stereotype == ECOREModelingMain.EClassStereotype)
     {
         ExportMain.ecoreExport.currentNode = new MocaNode();
         this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.ClassesChildNodeName);
         currentNode.appendChildNode(ExportMain.ecoreExport.processEClass(childClass));
     }
 }
        private void addEntry(SQLElement selectedClassifier, SQLElement selectedObject)
        {
            String type      = selectedClassifier.Name;
            String paramName = selectedObject.Name;

            //String paramName = type.Substring(0, 1).ToLower() + type.Substring(1);
            parameterNames.Add(paramName);
            CheckBox newCheckBox = new CheckBox();

            newCheckBox.Text    = paramName + ": " + type;
            newCheckBox.Dock    = DockStyle.Top;
            newCheckBox.Checked = true;

            this.checkBoxToElement.Add(newCheckBox, selectedClassifier);

            Label newTextBox = new Label();

            newTextBox.Text = "";
            newTextBox.Dock = DockStyle.Top;

            if (this.tableEntries.RowCount <= rowIndex)
            {
                this.tableEntries.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                this.tableEntries.RowCount++;
            }
            this.tableEntries.Controls.Add(newCheckBox, 0, rowIndex);
            this.tableEntries.Controls.Add(newTextBox, 1, rowIndex);

            rowIndex++;
        }