Example #1
0
        protected void updateExtendedElements(CoreStereotype owner, CoreModelElement newExtendedElement)
        {
            List <object> extendedElements = (List <object>)owner.getExtendedElement();

            extendedElements.Add(newExtendedElement);
            owner.setExtendedElement(extendedElements);
        }
Example #2
0
        protected void updateStereotypes(CoreModelElement owner, CoreStereotype newStereotype)
        {
            List <CoreStereotype> stereotypes = owner.getTheStereotypes();

            stereotypes.Add(newStereotype);
            owner.setTheStereotypes(stereotypes);
        }
        public void createSpecificStereotype(CoreClassifier classifier, CoreFeature feature, String stereotypeName)
        {
            CorePackage mainPackage = (CorePackage)classifier.getModel().getMainPackage();

            CoreStereotype stereotype = null;
            //CoreStereotype stereotype = new CoreStereotypeImpl();

            //stereotype.setName(stereotypeName);
            //mainPackage.getFoundation().getExtensionMechanisms().getAStereotypeExtendedElement().add(stereotype, (CoreFeature) feature);
        }
Example #4
0
        private CoreAttribute createAttribute(CoreNamespace ownerNamespace, CoreModelElement owner, XElement xattribute, CoreStereotype coreStereotype)
        {
            CoreAttribute coreAttribute = new CoreAttributeImpl();

            coreAttribute.setName(xattribute.Attribute("name").Value);
            coreAttribute.setElemOwner(owner);
            updateElemOwnedElements(owner, coreAttribute);
            coreAttribute.setNamespace(ownerNamespace);
            updateNamespaceElemOwnedElements(ownerNamespace, coreAttribute);

            //coreAttribute.setOwnerScope(getScopeKind(xattribute.Attribute("ownerScope").Value));

            var id = xattribute.Attribute("Id").Value;

            lookup.Add(id, coreAttribute);
            var xtype = xattribute.Descendants(xnamespaceUmlModel + "referencedTypeMoniker").FirstOrDefault();

            if (xtype != null)
            {
                string xidref = xtype.Attribute("Id").Value;
                idToType.Add(id, xidref);
            }

            var isUnique = xattribute.Attribute("isUnique");

            if (isUnique == null || isUnique.Value == "true")
            {
                updateExtendedElements(coreStereotype, coreAttribute);
                updateStereotypes(coreAttribute, coreStereotype);
            }

            return(coreAttribute);
        }
Example #5
0
        private CoreClassifier createClassifier(XNamespace xnamespace, XElement xmodelClass, CoreNamespace ownerNamespace, CoreModelElement owner, CoreStereotype coreStereotype)
        {
            CoreClassifier modelClass = new CoreClassifierImpl();

            modelClass.setName(xmodelClass.Attribute("name").Value);

            modelClass.setElemOwner(owner);
            updateElemOwnedElements(owner, modelClass);
            modelClass.setNamespace(ownerNamespace);
            updateNamespaceElemOwnedElements(ownerNamespace, modelClass);

            var xoperations = xmodelClass.Descendants(xnamespace + "operation");

            foreach (var xoperation in xoperations)
            {
                createOperation(xnamespace, ownerNamespace, modelClass, xoperation);
            }

            var xattributes = xmodelClass.Descendants(xnamespace + "property");

            foreach (var xattribute in xattributes)
            {
                createAttribute(ownerNamespace, modelClass, xattribute, coreStereotype);
            }

            var id = xmodelClass.Attribute("Id").Value;

            lookup.Add(id, modelClass);

            return(modelClass);
        }
Example #6
0
 private void createModelClasses(XNamespace xnamespace, CoreNamespace ownerNamespace, CoreModelElement owner, IEnumerable <XElement> xmodelClasses, CoreStereotype coreStereotype)
 {
     if (xmodelClasses != null)
     {
         var iEnumerable = xmodelClasses as IList <XElement> ?? xmodelClasses.ToList();
         foreach (var xmodelClass in iEnumerable)
         {
             createClassifier(xnamespace, xmodelClass, ownerNamespace, owner, coreStereotype);
         }
         foreach (XElement xmodelClass in iEnumerable)
         {
             var xassociations = xmodelClass.Descendants(xnamespace + "association");
             foreach (var xassociation in xassociations)
             {
                 CoreAssociation coreAssociation = createAssociation(xnamespace, xassociation, new CoreAssociationImpl());
                 fillModelElementTypes();
                 updateElemOwnedElements(coreModel, coreAssociation);
             }
         }
     }
 }
Example #7
0
        private CoreClassifier createEnumeration(XNamespace xnamespace, CoreNamespace ownerNamespace, CoreModelElement owner, XElement xenumeration, CoreStereotype coreStereotype)
        {
            CoreClassifier modelClass = new CoreClassifierImpl();

            modelClass.setName(xenumeration.Attribute("name").Value);

            modelClass.setElemOwner(owner);
            updateElemOwnedElements(owner, modelClass);
            modelClass.setNamespace(ownerNamespace);
            updateNamespaceElemOwnedElements(ownerNamespace, modelClass);

            updateExtendedElements(coreStereotype, modelClass);
            updateStereotypes(modelClass, coreStereotype);

            var xattributes = xenumeration.Descendants(xnamespace + "enumerationLiteral");

            foreach (var xattribute in xattributes)
            {
                CoreAttribute coreAttribute = new CoreAttributeImpl();
                coreAttribute.setName(xattribute.Attribute("name").Value);
                coreAttribute.setElemOwner(modelClass);
                updateElemOwnedElements(modelClass, coreAttribute);
                coreAttribute.setNamespace(ownerNamespace);
                updateNamespaceElemOwnedElements(ownerNamespace, coreAttribute);

                var id2 = xattribute.Attribute("Id").Value;
                lookup.Add(id2, coreAttribute);
            }

            var id = xenumeration.Attribute("Id").Value;

            lookup.Add(id, modelClass);

            return(modelClass);
        }