public override void Load(EA.Repository rep)
 {
     _attr       = rep.GetAttributeByGuid(Guid);
     Name        = _attr.Name;
     Description = _attr.Notes;
     Stereotype  = _attr.StereotypeEx;
 }
Пример #2
0
        /// <summary>
        /// The dictionary entry name tagged value of a SUP shall be unique for a given CDT.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        /// <param name="cdts"></param>
        private void checkC534n(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> cdts)
        {
            Dictionary <string, string> values = new Dictionary <string, string>();

            foreach (KeyValuePair <Int32, EA.Element> e in cdts)
            {
                //Fetch all attributes of the given element
                Dictionary <string, EA.Attribute> attributes = Utility.fetchAllAttributesFromElement(e.Value, UPCC.SUP.ToString());

                foreach (KeyValuePair <string, EA.Attribute> a in attributes)
                {
                    EA.AttributeTag tv = Utility.getTaggedValue(a.Value, UPCC_TV.dictionaryEntryName.ToString());

                    if (tv != null)
                    {
                        //Has this unique identifier already been used?
                        if (values.ContainsValue(tv.Value))
                        {
                            //Get the other attribute with the same unique identifier
                            EA.Attribute duplicateAttribute = context.Repository.GetAttributeByGuid(Utility.findKey(values, tv.Value));

                            context.AddValidationMessage(new ValidationMessage("Two identical dictionary entry name tagged values of a SUP in a CDT detected.", "The dictionary entry name tagged value of a SUP shall be unique for a given CDT. The supplementary components " + a.Value.Name + " and " + duplicateAttribute.Name + " of the CDT " + e.Value.Name + " have the same dictionary entry name.", "CDTLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                        }

                        values.Add(a.Value.AttributeGUID, tv.Value);
                    }
                }
                values = new Dictionary <string, string>();
            }
        }
Пример #3
0
        public void TestUpdateClassFromInstance()
        {
            DiagramCache diagramCache = new DiagramCache();
            EAMetaModel  meta         = new EAMetaModel().setupSchemaPackage();
            EAFactory    rootClass    = new EAFactory();

            rootClass.setupClient("SomeClass", RoundTripAddInClass.EA_TYPE_CLASS, RoundTripAddInClass.EA_STEREOTYPE_REQUEST, 0, null);
            EA.Element el = rootClass.clientElement;

            object o = el.Attributes.AddNew("SomeAttribute", "Attribute");

            EA.Attribute attr = (EA.Attribute)o;

            EA.Package pkg = SchemaManager.generateSample(EARepository.Repository, diagramCache);

            object os = pkg.Elements.GetAt(0);

            EA.Element sample = (EA.Element)os;

            string nrs = ObjectManager.addRunState(sample.RunState, "SomeAttribute", "foobar", 0);

            sample.RunState = nrs;

            SchemaManager.updateClassFromSample(EARepository.Repository, sample);

            Assert.AreEqual("foobar", attr.Default);
        }
Пример #4
0
 public override void load(EA.Repository rep)
 {
     _attr        = rep.GetAttributeByGuid(GUID);
     _Name        = _attr.Name;
     _Description = _attr.Notes;
     _Stereotype  = _attr.StereotypeEx;
 }
Пример #5
0
        /// <summary>
        /// For a given ACC there shall not be two BCCs with the same unique identifier tagged value.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        /// <param name="accs"></param>
        private void checkC524i(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> accs)
        {
            Dictionary <string, string> values = new Dictionary <string, string>();

            foreach (KeyValuePair <Int32, EA.Element> e in accs)
            {
                foreach (EA.Attribute bcc in e.Value.AttributesEx)
                {
                    EA.AttributeTag tv = Utility.getTaggedValue(bcc, UPCC_TV.uniqueIdentifier.ToString());
                    if (tv != null)
                    {
                        //Has this unique identifier already been used?
                        if (values.ContainsValue(tv.Value))
                        {
                            //Get the other element with the same unique identifier
                            EA.Attribute duplicateDENAttribute = context.Repository.GetAttributeByGuid(Utility.findKey(values, tv.Value));

                            context.AddValidationMessage(new ValidationMessage("Two identical unique identifiers of a BCC detected.", "For a given ACC there shall not be two BCCs with the same unique identifier tagged value. " + bcc.Name + " and " + duplicateDENAttribute.Name + " of ACC " + e.Value.Name + " have the same unique identifier.", "CCLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                        }

                        values.Add(bcc.AttributeGUID, tv.Value);
                    }
                }
                values = new Dictionary <string, string>();
            }
        }
Пример #6
0
        private void setClassifierAttributes()
        {
            int counter = 0;

            foreach (Object objectToBeTyped in this.ObjectToTypeGuid.Keys)
            {
                String typeElementGuid = this.ObjectToTypeGuid[objectToBeTyped];
                if (hasGui)
                {
                    ImportWorker.ReportProgress(4, new ProgressObject(ProgressBarType.Current, "Set Classifiers", ObjectToTypeGuid.Count));
                }
                else
                {
                    Console.Out.WriteLine("SCALE:Set Classifiers for '" + typeElementGuid + "' %" + counter + "/" + ObjectToTypeGuid.Count + "#");
                    counter++;
                }


                if (OldGuidToNewGuid.ContainsKey(typeElementGuid))
                {
                    String     newTypeElementGuid = this.OldGuidToNewGuid[typeElementGuid];
                    EA.Element typeElement        = ElementGuidToElement[newTypeElementGuid];
                    if (objectToBeTyped is EA.Element)
                    {
                        EA.Element elem = objectToBeTyped as EA.Element;
                        elem.ClassifierID = typeElement.ElementID;
                        elem.Update();
                    }
                    else if (objectToBeTyped is EA.Method)
                    {
                        EA.Method meth = objectToBeTyped as EA.Method;
                        meth.ReturnType   = typeElement.Name;
                        meth.ClassifierID = typeElement.ElementID.ToString();
                        meth.Update();
                    }
                    else if (objectToBeTyped is EA.Attribute)
                    {
                        EA.Attribute attr = objectToBeTyped as EA.Attribute;
                        attr.Type         = typeElement.Name;
                        attr.ClassifierID = typeElement.ElementID;
                        attr.Update();
                    }
                    else if (objectToBeTyped is EA.Parameter)
                    {
                        EA.Parameter param = objectToBeTyped as EA.Parameter;
                        param.Type         = typeElement.Name;
                        param.ClassifierID = typeElement.ElementID.ToString();
                        param.Update();
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                else
                {
                }
            }
        }
Пример #7
0
        /// <summary>
        /// The cardinality of a BBIE shall not be an extension (i.e. be higher than) of the cardinality of the BCC, the BBIE is based on. A BBIE is based on another BCC if their names are the same and the ACC/ABIE they are properties of have, a basedOn dependency.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        /// <param name="bdts"></param>
        private void checkC574o(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bies)
        {
            foreach (KeyValuePair <Int32, EA.Element> e in bies)
            {
                EA.Element ACC_base = Utility.getTargetOfisbasedOnDependency(e.Value, context.Repository);
                if (ACC_base != null)
                {
                    //Get a collection of the attribute names of the base ACC
                    Dictionary <String, String> bccs = Utility.getAttributesOfElementAsDictionary(ACC_base, UPCC.BCC.ToString());


                    //Every BBIE name of this ABIE must also be contained in the underlying ACC
                    foreach (EA.Attribute a in e.Value.Attributes)
                    {
                        if (a.Stereotype == UPCC.BBIE.ToString())
                        {
                            if (bccs.ContainsValue(a.Name))
                            {
                                //Get the BCC
                                EA.Attribute bcc            = context.Repository.GetAttributeByGuid(Utility.findKey(bccs, a.Name));
                                String       bcc_lowerBound = bcc.LowerBound;
                                String       bcc_upperBound = bcc.UpperBound;

                                //Check whether the lower bound is O.K.
                                if (Utility.isValidCardinality(bcc_lowerBound) && Utility.isValidCardinality(a.LowerBound))
                                {
                                    //Raise an error if the lowerbound of the underlying BCC is higher than the lower bound of the
                                    if (Utility.isLowerBound(bcc_lowerBound, a.LowerBound))
                                    {
                                        context.AddValidationMessage(new ValidationMessage("BBIE has higher lower bound cardinality than underlying BCC.", "The cardinality of a BBIE shall not be an extension (i.e. be higher than) of the cardinality of the BCC, the BBIE is based on. A BBIE is based on another BCC if their names are the same and the ACC/ABIE they are properties of have, a basedOn dependency. \n\nLower bound cardinality of the underlying BCC " + bcc.Name + " of BBIE " + a.Name + " in ABIE " + e.Value.Name + " in BIELibrary " + p.Name + " is higher than the cardinality of the BBIE.", "BIELibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                                    }
                                }
                                //Invalid cardinality - raise an error
                                else
                                {
                                    context.AddValidationMessage(new ValidationMessage("Unable to determine cardinality of BBIE/underlying BCC.", "The cardinality of a BBIE shall not be an extension (i.e. be higher than) of the cardinality of the BCC, the BBIE is based on. A BBIE is based on another BCC if their names are the same and the ACC/ABIE they are properties of have, a basedOn dependency. \n\nUnable to determine the lower bound cardinality of the BBIE/underlying BCC " + bcc.Name + " of BBIE " + a.Name + " in ABIE " + e.Value.Name + " in BIELibrary " + p.Name + ".", "BIELibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                                }



                                if (Utility.isValidCardinality(bcc_upperBound) && Utility.isValidCardinality(a.UpperBound))
                                {
                                    //Raise an error if the higher bound of the underlying BCC is higher than the lower bound of the
                                    if (Utility.isHigherBound(a.UpperBound, bcc_upperBound))
                                    {
                                        context.AddValidationMessage(new ValidationMessage("BBIE has higher upper bound cardinality than underlying BCC.", "The cardinality of a BBIE shall not be an extension (i.e. be higher than) of the cardinality of the BCC, the BBIE is based on. A BBIE is based on another BCC if their names are the same and the ACC/ABIE they are properties of have, a basedOn dependency. \n\nHigher bound cardinality of of BBIE " + a.Name + " in ABIE " + e.Value.Name + " in BIELibrary " + p.Name + " is higher than the cardinality of the underlying BCC.", "BIELibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                                    }
                                }
                                //Invalid cardinality - raise an error
                                else
                                {
                                    context.AddValidationMessage(new ValidationMessage("Unable to determine cardinality of BBIE/underlying BCC.", "The cardinality of a BBIE shall not be an extension (i.e. be higher than) of the cardinality of the BCC, the BBIE is based on. A BBIE is based on another BCC if their names are the same and the ACC/ABIE they are properties of have, a basedOn dependency. \n\nUnable to determine the higher bound cardinality of the BBIE/underlying BCC " + bcc.Name + " of BBIE " + a.Name + " in ABIE " + e.Value.Name + " in BIELibrary " + p.Name + ".", "BIELibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
 public EA.Attribute getRealAttribute()
 {
     if (realAttribute == null)
     {
         realAttribute = repository.GetOriginalRepository().GetAttributeByID(AttributeID);
     }
     return(realAttribute);
 }
 public override void load(EA.Repository rep)
 {
     _attr = rep.GetAttributeByGuid(GUID);
     _Name = _attr.Name;
     _Description = _attr.Notes;
     _Stereotype = _attr.StereotypeEx;
  
 }
Пример #10
0
 public void updateEaGui()
 {
     EA.Attribute realElement = enumLiteral.getRealAttribute();
     realElement.Name    = this.Name;
     realElement.Default = this.Value;
     realElement.Alias   = this.Literal;
     realElement.Update();
 }
Пример #11
0
        public void showObjectProperties(EA.Repository Repository, string GUID, EA.ObjectType ot)
        {
            eaObjectType.Text = ot.ToString();
            eaObjectName.Text = "?";
            switch (ot)
            {
            case EA.ObjectType.otAttribute:
                EA.Attribute attribute = Repository.GetAttributeByGuid(GUID);
                currentEaObject             = attribute;
                currentEaObjectCollections  = null;
                eaObjectName.Text           = attribute.Name;
                showEmbeddedObjects.Enabled = false;
                showEmbeddedObjects.Checked = false;
                break;

            case EA.ObjectType.otElement:
                EA.Element element = Repository.GetElementByGuid(GUID);
                currentEaObject             = element;
                currentEaObjectCollections  = new EAElementCollections(element);
                eaObjectName.Text           = element.Name;
                showEmbeddedObjects.Enabled = true;
                break;

            case EA.ObjectType.otMethod:
                EA.Method method = Repository.GetMethodByGuid(GUID);
                currentEaObject             = method;
                currentEaObjectCollections  = null;
                eaObjectName.Text           = method.Name;
                showEmbeddedObjects.Enabled = false;
                showEmbeddedObjects.Checked = false;
                break;

            case EA.ObjectType.otPackage:
                EA.Package package = Repository.GetPackageByGuid(GUID);
                currentEaObject             = package;
                currentEaObjectCollections  = new EAPackageCollections(package);
                eaObjectName.Text           = package.Name;
                showEmbeddedObjects.Enabled = true;
                break;

            case EA.ObjectType.otConnector:
                EA.Connector connector = Repository.GetConnectorByGuid(GUID);
                currentEaObject             = connector;
                currentEaObjectCollections  = null;
                showEmbeddedObjects.Enabled = false;
                showEmbeddedObjects.Checked = false;
                break;

            default:
                currentEaObject             = null;
                currentEaObjectCollections  = null;
                propertyGrid.SelectedObject = null;
                showEmbeddedObjects.Enabled = false;
                showEmbeddedObjects.Checked = false;
                break;
            }
            SynchPropertyGridSelection();
        }
Пример #12
0
 public EA.Attribute Add(EA.Element element, string name, string type)
 {
     EA.Attribute result = null;
     result       = element.Attributes.AddNew(name, type);
     result.Notes = this.notes;
     new EAElementsUpdaterHandler(result).DoWork();
     new EAElementsUpdaterHandler(element).DoWork();
     element.Methods.Refresh();
     return(result);
 }
        private bool Update(EA.Attribute atr)
        {
            bool result = atr.Update();

            if (result == false)
            {
                throw new Exception("Update Didn't work out properlly!!!");
            }
            return(result);
        }
Пример #14
0
        public EA.Attribute GetById(string id)
        {
            EA.Attribute result = null;

            foreach (EA.Package package in repository.Models)
            {
                result = getById(package, id);
            }

            return(result);
        }
Пример #15
0
        public EAFactory addAttribute(string name, string eatype, string lowerBound = "0", string upperBound = "1", string def = "Value")
        {
            object a = this.clientElement.Attributes.AddNew(name, APIAddinClass.EA_TYPE_ATTRIBUTE);

            EA.Attribute attr = (EA.Attribute)a;
            attr.Type       = eatype;
            attr.LowerBound = lowerBound;
            attr.UpperBound = upperBound;
            attr.Default    = def;
            return(this);
        }
Пример #16
0
        private static Dictionary <string, string> CreateTaggedValues(EA.Attribute a)
        {
            var nname  = a.Name;
            var result = new Dictionary <string, string>();

            foreach (var tv in a.TaggedValues.OfType <EA.AttributeTag>())
            {
                var name  = tv.Name;
                var value = tv.Value;
                result[name] = value;
            }
            return(result);
        }
Пример #17
0
 /// <summary>
 /// GUIDによりEAから属性オブジェクトを取得
 /// </summary>
 /// <param name="attributeGuid"></param>
 /// <returns></returns>
 private EA.Attribute getAttributeByGuid(string attributeGuid)
 {
     EA.Repository repo    = ProjectSetting.getVO().eaRepo;
     EA.Attribute  attrObj = (EA.Attribute)repo.GetAttributeByGuid(attributeGuid);
     if (attrObj != null)
     {
         return(attrObj);
     }
     else
     {
         return(null);
     }
 }
Пример #18
0
 private void updateClassAttributeType()
 {
     foreach (string key in eaIdAttibuteIdMap.Keys)
     {
         EA.Attribute attribute = this.repository.GetAttributeByID(eaIdAttibuteIdMap[key]);
         if (eAIdElementIdMap.ContainsKey(attribute.Type))
         {
             attribute.ClassifierID = this.repository.GetElementByID(eAIdElementIdMap[attribute.Type]).ElementID;
             attribute.Type         = this.repository.GetElementByID(attribute.ClassifierID).Name;
         }
         attribute.Update();
     }
 }
Пример #19
0
        internal void EA_OnNotifyContextItemModified(EA.Repository Repository, string GUID, EA.ObjectType ot)
        {
            if (!initialConnectionAvailable)
            {
                return;
            }

            //EA_OnNotifyContextItemModified notifies Add-Ins that the current context item has been modified.
            //This event occurs when a user has modified the context item. Add-Ins that require knowledge of when
            // an item has been modified can subscribe to this broadcast function.
            // See also: http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/ea_onnotifycontextitemmodified.html

            ModificationChange change = new ModificationChange();

            change.internalID = GUID;

            switch (ot)
            {
            case EA.ObjectType.otPackage:
                EA.Package eaPackage = Repository.GetPackageByGuid(GUID);
                change.elementType = ElementType.PACKAGE;
                change.name        = eaPackage.Name;
                break;

            case EA.ObjectType.otElement:
                EA.Element eaElement = Repository.GetElementByGuid(GUID);
                change.elementType = ElementType.ELEMENT;
                change.name        = eaElement.Name;
                break;

            case EA.ObjectType.otConnector:
                EA.Connector eaConnector = Repository.GetConnectorByGuid(GUID);
                change.elementType = ElementType.CONNECTOR;
                change.name        = eaConnector.Name;
                break;

            case EA.ObjectType.otAttribute:
                EA.Attribute method = Repository.GetAttributeByGuid(GUID);
                change.elementType = ElementType.ATTRIBUTE;
                change.name        = method.Name;
                break;

            case EA.ObjectType.otMethod:
                EA.Method attribute = Repository.GetMethodByGuid(GUID);
                change.elementType = ElementType.METHOD;
                change.name        = attribute.Name;
                break;
            }

            sendObject(change);
        }
Пример #20
0
        public EA.Attribute getOrCreateAttribute(SQLElement parentClass, MocaNode attributeNode)
        {
            String oldGuid = attributeNode.getAttributeOrCreate(Main.GuidStringName).Value;

            EA.Attribute attribute = repository.GetAttributeByGuid(oldGuid);
            if (attribute == null)
            {
                attribute = parentClass.getRealElement().Attributes.AddNew(attributeNode.getAttributeOrCreate("name").Value, "") as EA.Attribute;
                attribute.Update();
                repository.Execute("update t_attribute set ea_guid = '" + oldGuid + "' where ea_guid = '" + attribute.AttributeGUID + "'");
                attribute = repository.GetAttributeByGuid(oldGuid);
            }
            return(attribute);
        }
Пример #21
0
        private void addClass(EA.Package p, XmlNode xmlNode)
        {
            EA.Element ele = p.Elements.AddNew(xmlNode.Attributes.GetNamedItem("name").Value, "Class");
            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                string name = node.Attributes.GetNamedItem("name") != null?node.Attributes.GetNamedItem("name").Value : "";

                if (name == "")
                {
                    continue;
                }
                string type = node.Attributes.GetNamedItem("xmi:type").Value;
                if (type.Contains("Property"))
                {
                    string visibility = node.Attributes.GetNamedItem("visibility") != null?node.Attributes.GetNamedItem("visibility").Value : "";

                    EA.Attribute attribute = ele.Attributes.AddNew(name, "Property");
                    attribute.Visibility = visibility;
                    foreach (XmlNode att in node.ChildNodes)
                    {
                        string tagName = att.Name;
                        if (tagName == "lowerValue")
                        {
                            attribute.LowerBound = att.Attributes.GetNamedItem("value").Value;
                        }
                        else if (tagName == "upperValue")
                        {
                            attribute.UpperBound = att.Attributes.GetNamedItem("value").Value;
                        }
                        else if (tagName == "type")
                        {
                            attribute.Type = att.Attributes.GetNamedItem("xmi:idref").Value;
                        }
                    }
                    attribute.Update();
                    eaIdAttibuteIdMap[node.Attributes.GetNamedItem("xmi:id").Value] = attribute.AttributeID;
                }
                else if (type.Contains("Port"))
                {
                    EA.Element portEle = ele.EmbeddedElements.AddNew(name, "Port");
                    portEle.Update();
                    eAIdElementIdMap[node.Attributes.GetNamedItem("xmi:id").Value] = portEle.ElementID;
                }
            }
            ele.Stereotype = this.repository.GetPackageByID(ele.PackageID).Element.Stereotype;
            ele.Update();
            eAIdElementIdMap[xmlNode.Attributes.GetNamedItem("xmi:id").Value] = ele.ElementID;
            ElementId2EAId[ele.ElementID] = xmlNode.Attributes.GetNamedItem("xmi:id").Value;
        }
Пример #22
0
        void EASelectObjectToolStripMenuItemClick(object sender, EventArgs e)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            if (repo != null)
            {
                // 選択された属性に対する更新処理
                if (selectedAttribute != null)
                {
                    EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);
                    if (attr != null)
                    {
                        repo.ShowInProjectView(attr);
                    }
                    else
                    {
                        // 属性がGUIDで空振りしたら要素GUIDで再検索
                        EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                        if (elem != null)
                        {
                            repo.ShowInProjectView(elem);
                        }
                    }
                }

                // 選択された操作に対する更新処理
                if (selectedMethod != null)
                {
                    EA.Method mth = (EA.Method)repo.GetMethodByGuid(selectedMethod.guid);
                    if (mth != null)
                    {
                        repo.ShowInProjectView(mth);
                    }
                    else
                    {
                        // 操作がGUIDで空振りしたら要素GUIDで再検索
                        EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                        if (elem != null)
                        {
                            repo.ShowInProjectView(elem);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("EAにアタッチしていないため、選択できません");
            }
        }
Пример #23
0
        private static Attribute CreateAttribute(EA.Attribute a)
        {
            var name = a.Name;

            return(new Attribute
            {
                Id = a.AttributeID,
                Name = a.Name,
                Type = a.Type,
                Length = string.IsNullOrEmpty(a.Length) ? 0 : int.Parse(a.Length),
                Nullable = !a.AllowDuplicates,
                DefaultValue = a.Default,
                TaggedValues = CreateTaggedValues(a),
                Notes = a.Notes.FixNewlines()
            });
        }
Пример #24
0
        internal bool EA_OnPostNewAttribute(EA.Repository Repository, EA.EventProperties Info)
        {
            if (!initialConnectionAvailable)
            {
                return(true);
            }

            EA.Attribute        attribute = Repository.GetAttributeByID(int.Parse((string)Info.Get(0).Value));
            CreateElementChange change    = new CreateElementChange();

            change.elementType = ElementType.PACKAGE;
            change.internalID  = attribute.AttributeGUID;
            change.name        = attribute.Name;
            return(sendObject(change));
            //return sendEvent(Repository, Info);
        }
Пример #25
0
 /// <summary>
 /// 属性をEAに向けて更新実行する
 /// </summary>
 /// <param name="repo"></param>
 /// <param name="selectedAttribute"></param>
 void execUpdateAttribute(EA.Repository repo, AttributeVO selectedAttribute)
 {
     EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);
     if (attr == null)
     {
         EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
         if (elem == null)
         {
             return;
         }
         attr = (EA.Attribute)elem.Attributes.AddNew(selectedAttribute.name, "String");
     }
     attr.AttributeGUID = selectedAttribute.guid;
     attr.Alias         = selectedAttribute.alias;
     attr.StereotypeEx  = selectedAttribute.stereoType;
     attr.Notes         = selectedAttribute.notes;
     attr.Update();
 }
Пример #26
0
        static public string getBasicType(EA.Repository repository, EA.Attribute attribute)
        {
            string basicType = isBasicType(attribute.Type);

            if (basicType != "")
            {
                return(basicType);
            }

            if (attribute.ClassifierID != 0)
            {
                EA.Element typeClass = repository.GetElementByID(attribute.ClassifierID);

                return(isBasicType(repository, typeClass));
            }
            else
            {
                return("");
            }
        }
Пример #27
0
 public static bool UpdateAttribute(EA.Repository rep, EA.Attribute a)
 {
     // no classifier defined
     if (a.ClassifierID == 0)
     {
         // find type from type_name
         int id = GetTypeId(rep, a.Type);
         if (id > 0)
         {
             a.ClassifierID = id;
             bool error = a.Update();
             if (!error)
             {
                 MessageBox.Show("Error write Attribute", a.GetLastError());
                 // Error occurred
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #28
0
        private EA.Attribute getByEALocalId(EA.Package package, int id)
        {
            EA.Attribute result = null;

            foreach (EA.Element element in package.Elements)
            {
                if (element.Attributes.Cast <EA.Attribute>().Where(w => w.AttributeID == id).Count() > 0)
                {
                    result = element.Attributes.Cast <EA.Attribute>().Where(w => w.AttributeID == id).FirstOrDefault();
                    break;
                }
            }
            if (result == null)
            {
                foreach (EA.Package subPackage in package.Packages)
                {
                    result = getByEALocalId(subPackage, id);
                }
            }
            return(result);
        }
        /// <summary>
        /// Get Tagged Value with 'Name'. If TV not exists return "".
        /// </summary>
        /// <param name="attr"></param>
        /// <param name="name"></param>
        /// <param name="caseSensitive"></param>
        /// <returns></returns>
        public static string GetTaggedValue(EA.Attribute attr, string name, bool caseSensitive = true)
        {
            foreach (EA.AttributeTag taggedValue in attr.TaggedValues)
            {
                if (caseSensitive)
                {
                    if (taggedValue.Name == name)
                    {
                        return(GetTaggedValue(taggedValue));
                    }
                }
                else
                {
                    if (taggedValue.Name.ToLower() == name.ToLower())
                    {
                        return(GetTaggedValue(taggedValue));
                    }
                }
            }

            return("");
        }
Пример #30
0
        private void importEEnum(SQLPackage parentPackage, MocaNode eEnumNode)
        {
            EA.Element eenumElement = getOrCreateElement(parentPackage, eEnumNode, "Enumeration");

            foreach (MocaNode literalNode in eEnumNode.getChildNodeWithName("literals").Children)
            {
                String literalName = literalNode.getAttributeOrCreate("name").Value;
                if (literalName != "" && !literalExist(eenumElement, literalName))
                {
                    EA.Attribute literalAtt = eenumElement.Attributes.AddNew(literalName, "") as EA.Attribute;
                    literalAtt.Update();
                }
            }
            eenumElement.Attributes.Refresh();
            EEnum eenum = new EEnum(sqlRep.GetElementByID(eenumElement.ElementID), sqlRep);

            eenum.deserializeFromMocaTree(eEnumNode);

            MainImport.getInstance().ElementGuidToElement.Add(eenumElement.ElementGUID, eenumElement);
            MainImport.getInstance().MocaTaggableElements.Add(eenum);
            MainImport.getInstance().OldGuidToNewGuid.Add(eenum.Guid, eenumElement.ElementGUID);
        }
Пример #31
0
        public void TestUpdateInstanceFromClass()
        {
            DiagramCache diagramCache = new DiagramCache();
            EAMetaModel  meta         = new EAMetaModel().setupSchemaPackage();
            EAFactory    rootClass    = new EAFactory();

            rootClass.setupClient("SomeClass", RoundTripAddInClass.EA_TYPE_CLASS, RoundTripAddInClass.EA_STEREOTYPE_REQUEST, 0, null);
            EA.Element el = rootClass.clientElement;

            object o = el.Attributes.AddNew("SomeAttribute", "Attribute");

            EA.Attribute attr = (EA.Attribute)o;

            EAFactory anotherAttribute = rootClass.addSupplier("anotherAttribute", RoundTripAddInClass.EA_TYPE_CLASS, 0, RoundTripAddInClass.EA_STEREOTYPE_DATAITEM, null, "", RoundTripAddInClass.CARDINALITY_0_TO_ONE, "");

            EA.Element attrClass = anotherAttribute.clientElement;

            EA.Package pkg = SchemaManager.generateSample(EARepository.Repository, diagramCache);

            object os = pkg.Elements.GetAt(0);

            EA.Element sample = (EA.Element)os;

            string nrs = ObjectManager.addRunState(sample.RunState, "SomeAttribute", "foobar", 0);

            sample.RunState = nrs;

            nrs             = ObjectManager.addRunState(sample.RunState, "anotherAttribute", "foobar2", 0);
            sample.RunState = nrs;

            attr.Name      = "SomeAttribute2";//We update the attribute name to test that this update gets reflected onto the object
            attrClass.Name = "anotherAttribute2";

            SchemaManager.updateSampleFromClass(EARepository.Repository, sample);

            Assert.IsTrue(ObjectManager.parseRunState(sample.RunState).ContainsKey("SomeAttribute2"));
            Assert.IsTrue(ObjectManager.parseRunState(sample.RunState).ContainsKey("anotherAttribute2"));
        }
 public  FindAndReplaceItemAttribute(EA.Repository rep, string GUID)  :base(rep, GUID)
 {
     this._attr = rep.GetAttributeByGuid(GUID);
     this.load(rep);
 }