Пример #1
0
        internal static ISet <MatchDomainAlP> CheckDomainAlP(LL.MDE.DataModels.EnAr.Package alP)
        {
            ISet <MatchDomainAlP> result = new HashSet <MatchDomainAlP>();

            LL.MDE.DataModels.EnAr.Element alPE     = alP.Element;
            LL.MDE.DataModels.EnAr.Package projectP = alP.ParentPackage();
            if (alPE.Stereotype == "abstraction level" && alPE.ElementPackage() == alP)
            {
                string projectName = projectP.Name;
                LL.MDE.DataModels.EnAr.Element projectPE = projectP.Element;
                if (projectPE.Stereotype == "fctsys" && projectPE.ElementPackage() == projectP)
                {
                    MatchDomainAlP match = new MatchDomainAlP()
                    {
                        alP         = alP,
                        alPE        = alPE,
                        projectP    = projectP,
                        projectName = projectName,
                        projectPE   = projectPE,
                    };
                    result.Add(match);
                }
            }
            return(result);
        }
Пример #2
0
        internal static ISet <CheckResultRelation1> Check(LL.MDE.DataModels.EnAr.Package p, string someString, LL.MDE.DataModels.EnAr.Package p2)
        {
            ISet <CheckResultRelation1> result = new HashSet <CheckResultRelation1>(); ISet <MatchDomainP> matchDomainPs = CheckDomainP(p); ISet <MatchDomainP2> matchDomainP2s = CheckDomainP2(p2); foreach (MatchDomainP matchDomainP in matchDomainPs)

            {
                foreach (MatchDomainP2 matchDomainP2 in matchDomainP2s)
                {
                    string s = matchDomainP.s;

                    LL.MDE.DataModels.EnAr.Element   pe = matchDomainP.pe;
                    LL.MDE.DataModels.EnAr.Connector c  = matchDomainP.c;
                    int target = matchDomainP.target;
                    int source = matchDomainP.source;
                    if (p2.Name == (s + "Other"))
                    {
                        CheckResultRelation1 checkonlysMatch = new CheckResultRelation1()
                        {
                            matchDomainP = matchDomainP, matchDomainP2 = matchDomainP2,
                        };
                        result.Add(checkonlysMatch);
                    }                             // End if
                }                                 // End foreach
            }                                     // End foreach
            return(result);
        }
Пример #3
0
        internal void Enforce(ISet <CheckResultEA2FMEA_Start> result, LL.MDE.DataModels.XML.XMLFile fmeaFile)
        {
            foreach (CheckResultEA2FMEA_Start match in result)
            {
                // Extracting variables binded in source domains
                LL.MDE.DataModels.EnAr.Package alP      = match.matchDomainAlP.alP;
                LL.MDE.DataModels.EnAr.Element alPE     = match.matchDomainAlP.alPE;
                LL.MDE.DataModels.EnAr.Package projectP = match.matchDomainAlP.projectP;
                string projectName = match.matchDomainAlP.projectName;
                LL.MDE.DataModels.EnAr.Element projectPE = match.matchDomainAlP.projectPE;

                // Assigning variables binded in the where clause

                // Enforcing each enforced domain
                MatchDomainFmeaFile targetMatchDomainFmeaFile = EnforceFmeaFile(projectName, fmeaFile);

                // Retrieving variables binded in the enforced domains
                LL.MDE.DataModels.XML.Tag       msrfmea                = targetMatchDomainFmeaFile.msrfmea;
                LL.MDE.DataModels.XML.Tag       fmProjectsTag          = targetMatchDomainFmeaFile.fmProjectsTag;
                LL.MDE.DataModels.XML.Tag       fmProjectTag           = targetMatchDomainFmeaFile.fmProjectTag;
                LL.MDE.DataModels.XML.Tag       fmStructureRefs        = targetMatchDomainFmeaFile.fmStructureRefs;
                LL.MDE.DataModels.XML.Tag       longName1              = targetMatchDomainFmeaFile.longName1;
                LL.MDE.DataModels.XML.Tag       l41                    = targetMatchDomainFmeaFile.l41;
                LL.MDE.DataModels.XML.Attribute lAttr1                 = targetMatchDomainFmeaFile.lAttr1;
                LL.MDE.DataModels.XML.Tag       fmStructureElementsTag = targetMatchDomainFmeaFile.fmStructureElementsTag;
                LL.MDE.DataModels.XML.Tag       fmStructures           = targetMatchDomainFmeaFile.fmStructures;

                // Calling other relations as defined in the where clause
                new RelationProduct2Structure(editor, transformation).CheckAndEnforce(alP, fmStructureRefs, fmStructureElementsTag, fmStructures);
            }
        }
Пример #4
0
        public List <EnAr.Element> GetChildrenElementsWithTypeAndStereotype(EnAr.Element element, string type,
                                                                            string stereotype)
        {
            List <EnAr.Element> childrenWithType = GetChildrenElementsWithType(element, type);

            return(childrenWithType.FindAll(e => EqualsNoCase(e.Stereotype, stereotype)));
        }
Пример #5
0
        internal static ISet <MatchDomainP> CheckDomainP(LL.MDE.DataModels.EnAr.Package p)
        {
            ISet <MatchDomainP> result = new HashSet <MatchDomainP>();
            string s = p.Name;

            LL.MDE.DataModels.EnAr.Element pe = p.Element;
            if (pe.Stereotype == "st1")
            {
                foreach (LL.MDE.DataModels.EnAr.Connector c  in pe.Connectors.OfType <LL.MDE.DataModels.EnAr.Connector>())
                {
                    int          target = c.SupplierID;
                    int          source = c.ClientID;
                    MatchDomainP match  = new MatchDomainP()
                    {
                        p      = p,
                        s      = s,
                        pe     = pe,
                        c      = c,
                        target = target,
                        source = source,
                    };
                    result.Add(match);
                }
            }
            return(result);
        }
Пример #6
0
        private void ConstructBasicRelation(QVTRelations.IRelationalTransformation transformation, EnAr.Element relationElement)
        {
            // First we check if an empty relation doesn't already exist
            QVTRelations.IRelation relation = FindRelation(transformation, relationElement.Name);

            // If not, we create it
            if (relation == null)
            {
                relation = new QVTRelations.Relation()
                {
                    Name = relationElement.Name
                };
                transformation.Rule.Add(relation);

                // We find the unique child EA elements with the stereotype "qvtTransformationNode"
                List <EnAr.Element> transformationNodeElements = explorer.GetChildrenElementsWithTypeAndStereotype(relationElement, "class", "qvtTransformationNode");
                EnAr.Element        transformationNodeElement  = transformationNodeElements.Single();

                bool isTopRelation = explorer.GetTaggedValue(relationElement, "isTopRelation").ToLower() == "true";

                relation.IsTopLevel     = isTopRelation;
                relation.Transformation = transformation;
                relation.Overrides      = null; // TODO

                // We browse the EA Connectors with the stereotype "qvtTransformationLink", from the qvtTransformationNode
                // We use the concrete syntax extension to order the domains
                foreach (EnAr.Connector qvtTransformationLinkConnector in explorer.GetConnectorsWithSourceWithStereotype(transformationNodeElement, "qvtTransformationLink").OrderBy(c => c.Name))
                {
                    ConstructRelationDomain(transformation, relation, qvtTransformationLinkConnector);
                }
            }
        }
        internal static ISet <CheckResultRootProperty2StructureElement> Check(LL.MDE.DataModels.EnAr.Package abstractionLevelP, LL.MDE.DataModels.XML.Tag parentSeDecomposition, LL.MDE.DataModels.XML.Tag stucture)
        {
            ISet <CheckResultRootProperty2StructureElement> result = new HashSet <CheckResultRootProperty2StructureElement>(); ISet <MatchDomainAbstractionLevelP> matchDomainAbstractionLevelPs = CheckDomainAbstractionLevelP(abstractionLevelP); ISet <MatchDomainParentSeDecomposition> matchDomainParentSeDecompositions = CheckDomainParentSeDecomposition(parentSeDecomposition); ISet <MatchDomainStucture> matchDomainStuctures = CheckDomainStucture(stucture); foreach (MatchDomainAbstractionLevelP matchDomainAbstractionLevelP in matchDomainAbstractionLevelPs)

            {
                foreach (MatchDomainParentSeDecomposition matchDomainParentSeDecomposition in matchDomainParentSeDecompositions)
                {
                    foreach (MatchDomainStucture matchDomainStucture in matchDomainStuctures)
                    {
                        LL.MDE.DataModels.EnAr.Package bpP = matchDomainAbstractionLevelP.bpP;

                        LL.MDE.DataModels.EnAr.Element bpPE    = matchDomainAbstractionLevelP.bpPE;
                        LL.MDE.DataModels.EnAr.Element childEl = matchDomainAbstractionLevelP.childEl;
                        string id     = matchDomainAbstractionLevelP.id;
                        string elName = matchDomainAbstractionLevelP.elName;
                        long   reid   = matchDomainAbstractionLevelP.reid;
                        LL.MDE.DataModels.EnAr.Element classifierEl = matchDomainAbstractionLevelP.classifierEl;
                        string classifierName = matchDomainAbstractionLevelP.classifierName;
                        CheckResultRootProperty2StructureElement checkonlysMatch = new CheckResultRootProperty2StructureElement()
                        {
                            matchDomainAbstractionLevelP = matchDomainAbstractionLevelP, matchDomainParentSeDecomposition = matchDomainParentSeDecomposition, matchDomainStucture = matchDomainStucture,
                        };
                        result.Add(checkonlysMatch);
                    }                             // End foreach
                }                                 // End foreach
            }                                     // End foreach
            return(result);
        }
Пример #8
0
        internal void Enforce(ISet <CheckResultBlockProperty2StructureElement> result, LL.MDE.DataModels.XML.Tag structureElements)
        {
            foreach (CheckResultBlockProperty2StructureElement match in result)
            {
                // Extracting variables binded in source domains
                LL.MDE.DataModels.EnAr.Element parentEl = match.matchDomainParentEl.parentEl;
                long sid = match.matchDomainParentEl.sid;
                LL.MDE.DataModels.EnAr.Connector aggregation = match.matchDomainParentEl.aggregation;
                int cid = match.matchDomainParentEl.cid;
                LL.MDE.DataModels.EnAr.Element childEl = match.matchDomainParentEl.childEl;
                string id     = match.matchDomainParentEl.id;
                string elName = match.matchDomainParentEl.elName;
                LL.MDE.DataModels.EnAr.Element classifierEl = match.matchDomainParentEl.classifierEl;
                string classifierName = match.matchDomainParentEl.classifierName;
                LL.MDE.DataModels.XML.Tag parentSeDecomposition = match.matchDomainParentSeDecomposition.parentSeDecomposition;

                // Assigning variables binded in the where clause
                string name = elName + ':' + classifierName;

                // Enforcing each enforced domain
                MatchDomainStructureElements targetMatchDomainStructureElements = EnforceStructureElements(name, id, structureElements);

                // Retrieving variables binded in the enforced domains
                LL.MDE.DataModels.XML.Tag       fmStructureelement = targetMatchDomainStructureElements.fmStructureelement;
                LL.MDE.DataModels.XML.Tag       fmSeDecomposition  = targetMatchDomainStructureElements.fmSeDecomposition;
                LL.MDE.DataModels.XML.Tag       longName1          = targetMatchDomainStructureElements.longName1;
                LL.MDE.DataModels.XML.Tag       l41         = targetMatchDomainStructureElements.l41;
                LL.MDE.DataModels.XML.Attribute lAttr1      = targetMatchDomainStructureElements.lAttr1;
                LL.MDE.DataModels.XML.Attribute structureId = targetMatchDomainStructureElements.structureId;

                // Calling other relations as defined in the where clause
                new RelationCreateDecompositionLink(editor, transformation).CheckAndEnforce(structureId, parentSeDecomposition); new RelationBlockProperty2StructureElement(editor, transformation).CheckAndEnforce(childEl, fmSeDecomposition, structureElements);
            }
        }
Пример #9
0
        private EnAr.Element ConstructPrimitiveType(Ecore.IEDataType eDataType)
        {
            if (!eclassifier2Class.ContainsKey(eDataType))
            {
                EnAr.Package parentPackage = ConstructMetamodelPackage(eDataType.EPackage);
                EnAr.Element primitiveType = (EnAr.Element)parentPackage.Elements.AddNew(eDataType.Name, "Class");
                eclassifier2Class[eDataType] = primitiveType;
                primitiveType.Stereotype     = "primitive";

                if (ecorePrimitiveToEnAr.ContainsKey(eDataType.Name))
                {
                    EnAr.TaggedValue tag =
                        (EnAr.TaggedValue)primitiveType.TaggedValues.AddNew("MOFPrimitiveType", "Tag");
                    tag.Value = ecorePrimitiveToEnAr[eDataType.Name];
                    tag.Update();
                    primitiveType.TaggedValues.Refresh();
                }

                parentPackage.Elements.Refresh();
                parentPackage.Update();
                parentPackage.Element.Update();
                primitiveType.Update();
                return(primitiveType);
            }
            return(eclassifier2Class[eDataType]);
        }
Пример #10
0
        internal static ISet <CheckResultBlockProperty2StructureElement> Check(LL.MDE.DataModels.EnAr.Element parentEl, LL.MDE.DataModels.XML.Tag parentSeDecomposition)
        {
            ISet <CheckResultBlockProperty2StructureElement> result = new HashSet <CheckResultBlockProperty2StructureElement>(); ISet <MatchDomainParentEl> matchDomainParentEls = CheckDomainParentEl(parentEl); ISet <MatchDomainParentSeDecomposition> matchDomainParentSeDecompositions = CheckDomainParentSeDecomposition(parentSeDecomposition); foreach (MatchDomainParentEl matchDomainParentEl in matchDomainParentEls)

            {
                foreach (MatchDomainParentSeDecomposition matchDomainParentSeDecomposition in matchDomainParentSeDecompositions)
                {
                    long sid = matchDomainParentEl.sid;

                    LL.MDE.DataModels.EnAr.Connector aggregation = matchDomainParentEl.aggregation;
                    int cid = matchDomainParentEl.cid;
                    LL.MDE.DataModels.EnAr.Element childEl = matchDomainParentEl.childEl;
                    string id     = matchDomainParentEl.id;
                    string elName = matchDomainParentEl.elName;
                    LL.MDE.DataModels.EnAr.Element classifierEl = matchDomainParentEl.classifierEl;
                    string classifierName = matchDomainParentEl.classifierName;
                    CheckResultBlockProperty2StructureElement checkonlysMatch = new CheckResultBlockProperty2StructureElement()
                    {
                        matchDomainParentEl = matchDomainParentEl, matchDomainParentSeDecomposition = matchDomainParentSeDecomposition,
                    };
                    result.Add(checkonlysMatch);
                }                                 // End foreach
            }                                     // End foreach
            return(result);
        }
Пример #11
0
        private void ConstructTemplateBinding(Ecore.IEGenericType eGenericType,
                                              Ecore.IEGenericType ecoreTypeArgument, EA.Connector connectorEa)
        {
            int positionTypeArgument = eGenericType.ETypeArguments.IndexOf(ecoreTypeArgument);

            Ecore.IETypeParameter typeParameter =
                eGenericType.EClassifier.ETypeParameters[positionTypeArgument];

            string bindedName = ecoreTypeArgument.EClassifier.Name;

            EnAr.Element bindedClass     = ConstructClassifier(ecoreTypeArgument.EClassifier);
            dynamic      templateBinding = connectorEa.TemplateBindings.AddNew(bindedName, "");

            templateBinding.formalname = typeParameter.Name;
            templateBinding.ActualGUID = bindedClass.ElementGUID;
            try
            {
                templateBinding.Update();
            }
            catch (Exception)
            {
                // ignored
            }
            connectorEa.Update();
        }
        internal void Enforce(ISet <CheckResultProduct2Structure> result, LL.MDE.DataModels.XML.Tag fmStructures)
        {
            foreach (CheckResultProduct2Structure match in result)
            {
                // Extracting variables binded in source domains
                LL.MDE.DataModels.EnAr.Package productP = match.matchDomainProductP.productP;
                string productName = match.matchDomainProductP.productName;
                LL.MDE.DataModels.EnAr.Element productPE = match.matchDomainProductP.productPE;
                string productID = match.matchDomainProductP.productID;
                LL.MDE.DataModels.XML.Tag fmStructureRefs     = match.matchDomainFmStructureRefs.fmStructureRefs;
                LL.MDE.DataModels.XML.Tag fmStructureElements = match.matchDomainFmStructureElements.fmStructureElements;

                // Assigning variables binded in the where clause

                // Enforcing each enforced domain
                MatchDomainFmStructures targetMatchDomainFmStructures = EnforceFmStructures(productID, productName, fmStructures);

                // Retrieving variables binded in the enforced domains
                LL.MDE.DataModels.XML.Tag       fmStructure = targetMatchDomainFmStructures.fmStructure;
                LL.MDE.DataModels.XML.Attribute structureId = targetMatchDomainFmStructures.structureId;
                LL.MDE.DataModels.XML.Tag       longName1   = targetMatchDomainFmStructures.longName1;
                LL.MDE.DataModels.XML.Tag       l41         = targetMatchDomainFmStructures.l41;
                LL.MDE.DataModels.XML.Attribute lAttr1      = targetMatchDomainFmStructures.lAttr1;

                // Calling other relations as defined in the where clause
                new RelationCreateProjectStructureLink(editor, transformation).CheckAndEnforce(structureId, fmStructureRefs); new RelationAddStructureRoot(editor, transformation).CheckAndEnforce(productP, fmStructure, fmStructureElements);
            }
        }
Пример #13
0
        private EnAr.Element ConstructEnumeration(Ecore.IEEnum eEnum)
        {
            if (eclassifier2Class.ContainsKey(eEnum))
            {
                return(eclassifier2Class[eEnum]);
            }

            EnAr.Package parentPackage = ConstructMetamodelPackage(eEnum.EPackage);
            EnAr.Element enumeration   = (EnAr.Element)parentPackage.Elements.AddNew(eEnum.Name, "Enumeration");
            eclassifier2Class[eEnum] = enumeration;

            foreach (Ecore.IEEnumLiteral eEnumLiteral in eEnum.ELiterals)
            {
                EnAr.Attribute attributeLiteral =
                    (EnAr.Attribute)enumeration.Attributes.AddNew(eEnumLiteral.Name, "Attribute");
                attributeLiteral.Stereotype   = "enum";
                attributeLiteral.LowerBound   = "1";
                attributeLiteral.UpperBound   = "1";
                attributeLiteral.IsCollection = false;
                attributeLiteral.Update();
            }
            enumeration.Attributes.Refresh();
            enumeration.Update();
            enumeration.Refresh();
            return(enumeration);
        }
Пример #14
0
        public QVTRelations.IRelationalTransformation ConstructRelationalTransformation(string transformatioName)
        {
            IList <EnAr.Element> transformationsElements = explorer.FindElementsWithTypeAndStereotype("component", "qvtTransformation");

            EnAr.Element transfo = transformationsElements.Single(e => e.Name == transformatioName);
            QVTRelations.IRelationalTransformation transformation = ConstructRelationalTransformation(transfo);
            return(transformation);
        }
Пример #15
0
        private EMOF.IClass ConstructClass(EnAr.Element classElement)
        {
            // We create a EMOF.Class
            EMOF.IClass clazz = new EMOF.Class()
            {
                IsAbstract = classElement.Abstract.ToLower() == "true", Name = classElement.Name
            };
            elementToType.Add(classElement, clazz);

            // We browse the attributes of the EMOF.Class element (~= ecore attributes)
            foreach (EnAr.Attribute attribute in explorer.GetAttributes(classElement))
            {
                EMOF.IProperty property = ConstructProperty(attribute);
                property.Class = clazz;
                clazz.OwnedAttribute.Add(property);
            }

            // We browse the connectors (~= ecore references + inheritance links)
            foreach (EnAr.Connector connector in explorer.GetConnectorsWithSource(classElement))
            {
                EnAr.Element targetElement = explorer.GetTargetElement(connector);
                if (targetElement.Type.ToLower() == "class")
                {
                    EMOF.IClass targetType = ConstructType(targetElement) as EMOF.Class;

                    if (targetType != null)
                    {
                        // Case super type
                        if (connector.Type.ToLower() == "generalization")
                        {
                            clazz.SuperClass.Add(targetType);
                        }
                        // Case reference(s)
                        else
                        {
                            EMOF.IProperty prop1 = ConstructProperty(clazz, targetType, connector.ClientEnd, connector.SupplierEnd);
                            EMOF.IProperty prop2 = ConstructProperty(targetType, clazz, connector.SupplierEnd, connector.ClientEnd);
                            if (prop1 != null && prop2 != null)
                            {
                                prop1.Opposite = prop2;
                                prop2.Opposite = prop1;
                            }
                        }
                    }
                }
            }

            // And finally the methods
            foreach (EnAr.Method method in explorer.GetMethods(classElement))
            {
                EMOF.IOperation operation = ConstructOperation(method);
                clazz.OwnedOperation.Add(operation);
                operation.Class = clazz;
            }

            return(clazz);
        }
Пример #16
0
        internal MatchDomainPo EnforcePo(CheckResultRelation1 checkresult, string s, string someString, int source, LL.MDE.DataModels.EnAr.Package po)
        {
            MatchDomainPo match = new MatchDomainPo(); LL.MDE.DataModels.EnAr.Package p = checkresult.matchDomainP.p;

            LL.MDE.DataModels.EnAr.Element   pe = checkresult.matchDomainP.pe;
            LL.MDE.DataModels.EnAr.Connector c = checkresult.matchDomainP.c;

            LL.MDE.DataModels.EnAr.Package p2 = checkresult.matchDomainP2.p2;

            // Contructing po
            editor.AddOrSetInField(po, "Name", s + "Out");
            LL.MDE.DataModels.EnAr.Element e = null;

            // Trying to resolve the object'e' globally using the transformation key
            transformation.ElementKeys.TryGetValue(new Tuple <string>(s + someString), out e);
            // If the object wasn't found globally, we try to find it locally
            if (e == null)
            {
                e = po.Elements.OfType <LL.MDE.DataModels.EnAr.Element>().FirstOrDefault(var865311109 => var865311109?.Name == s + someString);

                // If the object was found locally, we add it to the global cache
                if (e != null)
                {
                    transformation.ElementKeys[new Tuple <string>(e?.Name)] = e;
                }
                // If the object still doesn't exist, we create it
                else
                {
                    e = (LL.MDE.DataModels.EnAr.Element)editor.CreateNewObjectInField(po, "Elements");
                    // We add the created object to the global cache
                    if (transformation.ElementKeys.ContainsKey(new Tuple <string>(e?.Name)))
                    {
                        throw new Exception("Two objects cannot have the same key");
                    }
                    else
                    {
                        transformation.ElementKeys[new Tuple <string>(e?.Name)] = e;
                    }
                }
            }

            // Contructing e
            editor.AddOrSetInField(e, "Name", s + someString);
            editor.AddOrSetInField(e, "Type", "Component");
            LL.MDE.DataModels.EnAr.Connector con = null;
            con = (LL.MDE.DataModels.EnAr.Connector)editor.CreateNewObjectInField(e, "Connectors");

            // Contructing con
            editor.AddOrSetInField(con, "SupplierID", source);
            editor.AddOrSetInField(con, "Type", "Dependency");

            // Return newly binded variables
            match.po  = po;
            match.e   = e;
            match.con = con;
            return(match);
        }
Пример #17
0
 private EnAr.Connector ConstructGeneralization(Ecore.IEClass superEClass, EnAr.Element clazz)
 {
     EnAr.Element   superClass           = ConstructClassifier(superEClass);
     EnAr.Connector inheritanceConnector = (EnAr.Connector)clazz.Connectors.AddNew("", "Connector");
     inheritanceConnector.Type       = "Generalization";
     inheritanceConnector.ClientID   = clazz.ElementID;
     inheritanceConnector.SupplierID = superClass.ElementID;
     inheritanceConnector.Update();
     return(inheritanceConnector);
 }
Пример #18
0
        private void ConstructAttribute(EnAr.IElement clazz, Ecore.IEStructuralFeature eStructuralFeature)
        {
            EnAr.Attribute attribute = (EnAr.Attribute)clazz.Attributes.AddNew(eStructuralFeature.Name, "Attribute");

            // Case regular type without template
            if (eStructuralFeature.EType != null)
            {
                EnAr.Element attributeType = ConstructClassifier(eStructuralFeature.EType);
                attribute.ClassifierID = attributeType.ElementID;
                attribute.Type         = attributeType.Name;
            }

            else if (eStructuralFeature.EGenericType != null)
            {
                Ecore.IEGenericType eGenericType = eStructuralFeature.EGenericType;

                // Case templated type (eg. MyClass<T>)
                if (eGenericType.EClassifier != null)
                {
                    EnAr.Element attributeType = ConstructClassifier(eGenericType.EClassifier);
                    attribute.ClassifierID = attributeType.ElementID;
                    attribute.Type         = attributeType.Name;
                    foreach (Ecore.IEGenericType eTypeArgument in eGenericType.ETypeArguments)
                    {
                        //TODO impossible to manage local bindings with regular attribute in EA, needs to be a reference/association?
                    }
                }

                // Case template type (eg. T), we simply set the same name
                else if (eGenericType.ETypeParameter != null)
                {
                    // TODO can we do better than that in EA?
                    attribute.Type = eGenericType.ETypeParameter.Name;
                }
            }


            attribute.LowerBound = BoundToString(eStructuralFeature.LowerBound.GetValueOrDefault());
            attribute.UpperBound = BoundToString(eStructuralFeature.UpperBound.GetValueOrDefault());

            if (eStructuralFeature.UpperBound.GetValueOrDefault() == -1 ||
                eStructuralFeature.UpperBound.GetValueOrDefault() > 1)
            {
                attribute.IsOrdered = eStructuralFeature.Ordered.GetValueOrDefault();
            }

            attribute.AllowDuplicates = !eStructuralFeature.Unique.GetValueOrDefault();
            attribute.IsDerived       = eStructuralFeature.Derived.GetValueOrDefault();
            attribute.IsConst         = !eStructuralFeature.Changeable.GetValueOrDefault();
            attribute.IsCollection    = eStructuralFeature.UpperBound == -1 || eStructuralFeature.UpperBound > 1;
            attribute.Default         = eStructuralFeature.DefaultValueLiteral;

            clazz.Attributes.Refresh();
            attribute.Update();
        }
Пример #19
0
 public List <EnAr.Element> GetChildrenElements(EnAr.Element element)
 {
     if (EqualsNoCase(element.Type, "package"))
     {
         return(GetChildrenElements(FindPackage(element)));
     }
     else
     {
         return(repository.AllElements.FindAll(e => e.ParentID == element.ElementID));
     }
 }
Пример #20
0
 public string GetTaggedValue(EnAr.Element element, String tagName)
 {
     foreach (EnAr.TaggedValue taggedValue2 in element.TaggedValues)
     {
         if (EqualsNoCase(taggedValue2.Name, tagName))
         {
             return(taggedValue2.Value);
         }
     }
     return(null);
 }
Пример #21
0
        public static List <RunStateField> GetRunState(EnAr.Element element)
        {
            List <RunStateField> result = new List <RunStateField>();

            string[] tokens = element.RunState.Split(';');

            const string variableString = "Variable";
            const string valueString    = "Value";
            const string opString       = "Op";
            const string noteString     = "Note";

            RunStateField currentRunStateField = null;

            foreach (string token in tokens)
            {
                if (token == "@VAR")
                {
                    currentRunStateField = new RunStateField();
                }
                else if (token == "@ENDVAR")
                {
                    result.Add(currentRunStateField);
                }
                else if (token.StartsWith(variableString))
                {
                    if (currentRunStateField != null)
                    {
                        currentRunStateField.Variable = token.Substring(variableString.Length + 1);
                    }
                }
                else if (token.StartsWith(valueString))
                {
                    if (currentRunStateField != null)
                    {
                        currentRunStateField.Value = token.Substring(valueString.Length + 1);
                    }
                }
                else if (token.StartsWith(opString))
                {
                    if (currentRunStateField != null)
                    {
                        currentRunStateField.Operator = token.Substring(opString.Length + 1);
                    }
                }
                else if (token.StartsWith(noteString))
                {
                    if (currentRunStateField != null)
                    {
                        currentRunStateField.Notes = token.Substring(noteString.Length + 1);
                    }
                }
            }
            return(result);
        }
Пример #22
0
 public EMOF.IType ConstructTypeOfTyped(EnAr.Attribute typedAttribute)
 {
     EnAr.Element typeElement = explorer.GetClassElement(typedAttribute);
     if (typeElement != null)
     {
         return(ConstructType(typeElement));
     }
     else
     {
         return(ConstructPrimitiveType(typedAttribute.Type));
     }
 }
Пример #23
0
        public List <EnAr.Attribute> GetAttributes(EnAr.Element classElement)
        {
            List <EnAr.Attribute> result = new List <EnAr.Attribute>();

            foreach (object attribute in classElement.Attributes)
            {
                if (attribute is EnAr.Attribute)
                {
                    result.Add(attribute as EnAr.Attribute);
                }
            }
            return(result);
        }
Пример #24
0
 public Tuple <EnAr.ConnectorEnd, EnAr.Element> GetElementOppositeTo(EnAr.Element oneElement,
                                                                     EnAr.Connector connector)
 {
     if (connector.ClientID == oneElement.ElementID)
     {
         return(new Tuple <EnAr.ConnectorEnd, EnAr.Element>(connector.SupplierEnd, GetTargetElement(connector)));
     }
     if (connector.SupplierID == oneElement.ElementID)
     {
         return(new Tuple <EnAr.ConnectorEnd, EnAr.Element>(connector.ClientEnd, GetSourceElement(connector)));
     }
     throw new Exception("The provided element is not connected to the provided connector.");
 }
Пример #25
0
        public List <EnAr.Method> GetMethods(EnAr.Element e)
        {
            List <EnAr.Method> result = new List <EnAr.Method>();

            foreach (object method in e.Methods)
            {
                if (method is EnAr.Method)
                {
                    result.Add(method as EnAr.Method);
                }
            }
            return(result);
        }
Пример #26
0
 public EMOF.IType ConstructTypeOfParameter(EnAr.Parameter parameter)
 {
     if (parameter.Type == null)
     {
         return(null);
     }
     EnAr.Element returnType = explorer.repository.GetElementByGuid(parameter.Type);
     if (returnType != null)
     {
         return(ConstructType(returnType));
     }
     else
     {
         return(ConstructPrimitiveType(parameter.Type));
     }
 }
Пример #27
0
 public EMOF.IType ConstructTypeOfMethod(EnAr.Method method)
 {
     if (method.ReturnType == null)
     {
         return(null);
     }
     EnAr.Element returnType = explorer.repository.GetElementByGuid(method.ReturnType);
     if (returnType != null)
     {
         return(ConstructType(returnType));
     }
     else
     {
         return(ConstructPrimitiveType(method.ReturnType));
     }
 }
Пример #28
0
        internal void CheckAndEnforce(LL.MDE.DataModels.EnAr.Element parentEl, LL.MDE.DataModels.XML.Tag parentSeDecomposition, LL.MDE.DataModels.XML.Tag structureElements)
        {
            CheckOnlyDomains input  = new CheckOnlyDomains(parentEl, parentSeDecomposition);
            EnforceDomains   output = new EnforceDomains(structureElements);

            if (traceabilityMap.ContainsKey(input) && !traceabilityMap[input].Equals(output))
            {
                throw new Exception("This relation has already been used with different enforced parameters!");
            }
            if (!traceabilityMap.ContainsKey(input))
            {
                ISet <CheckResultBlockProperty2StructureElement> result = Check(parentEl, parentSeDecomposition);
                Enforce(result, structureElements);
                traceabilityMap[input] = output;
            }
        }
Пример #29
0
        internal static ISet <CheckResultEA2FMEA_Start> Check(LL.MDE.DataModels.EnAr.Package alP)
        {
            ISet <CheckResultEA2FMEA_Start> result = new HashSet <CheckResultEA2FMEA_Start>(); ISet <MatchDomainAlP> matchDomainAlPs = CheckDomainAlP(alP); foreach (MatchDomainAlP matchDomainAlP in matchDomainAlPs)

            {
                LL.MDE.DataModels.EnAr.Element alPE = matchDomainAlP.alPE;

                LL.MDE.DataModels.EnAr.Package projectP = matchDomainAlP.projectP;
                string projectName = matchDomainAlP.projectName;
                LL.MDE.DataModels.EnAr.Element projectPE       = matchDomainAlP.projectPE;
                CheckResultEA2FMEA_Start       checkonlysMatch = new CheckResultEA2FMEA_Start()
                {
                    matchDomainAlP = matchDomainAlP,
                };
                result.Add(checkonlysMatch);
            }                                                             // End foreach
            return(result);
        }
Пример #30
0
        private void ConstructRelationDomain(QVTRelations.IRelationalTransformation relationTransformation, QVTRelations.IRelation relation, EnAr.Connector qvtTransformationLinkConnector)
        {
            // We look in the EA "domain" Element pointed by the qvtTransformationLinkConnector
            EnAr.Element domainObjectElement = explorer.GetTargetElement(qvtTransformationLinkConnector);

            // We construct (or get) the typed model, if any
            QVTBase.ITypedModel candidateTypedModel = ConstructTypedModel(relationTransformation, qvtTransformationLinkConnector);

            // If no typed model, it must be a primitive type
            // TODO maybe check for a tag?
            if (candidateTypedModel == null)
            {
                ConstructPrimitiveRelationDomain(relation, qvtTransformationLinkConnector, domainObjectElement);
                return;
            }

            // Else, we construct a regular domain
            ConstructNonPrimitiveRelationDomain(relation, candidateTypedModel, qvtTransformationLinkConnector, domainObjectElement);
        }