public void CollectEnumValue(EA.Attribute l_Attr, EAPEnumeration en)
        {
            EAPEnumValue enValue = new EAPEnumValue();

            enValue.Name        = l_Attr.Name;
            enValue.Description = l_Attr.Notes;

            enValue.Value = ReturnValue(enValue, l_Attr, en);

            if (enValue.Description.Split(':').Length > 1)
            {
                enValue.Title       = enValue.Description.Split(':')[0];
                enValue.Description = enValue.Description.Remove(0, enValue.Title.Length + 1).Trim();
            }
            else
            {
                enValue.Title       = "";
                enValue.Description = enValue.Description.Trim();
            }
            enValue.Title       = enValue.Title.Replace("<b>", "").Replace("</b>", "").Replace("<i>", "").Replace("</i>", "").Trim();
            enValue.Description = enValue.Description.Replace("<b>", "").Replace("</b>", "").Replace("<i>", "").Replace("</i>", "").Trim();

            //enValue.Value = (long)Convert.ChangeType(Enum.Parse(proba, enValue.Name), typeof(long));
            if (!(en.AddEnumValue(enValue)))
            {
                if (Validate)
                {
                    tw.WriteLine("Enum value name:" + l_Attr.Name + ",  already exists in Enum name: " + en.Name + ". (Look at EAP)");

                    tw.WriteLine("*************************************************************************");
                    tw.WriteLine("\n\n");
                }
            }
        }
        public int GetCardinality(EA.Attribute l_Attr, EAPAttribute l_MyAttr)
        {
            int cardinality = 0;

            foreach (EA.AttributeConstraint str in l_Attr.Constraints)
            {
                if (str.Name.ToLower() == "cardinality")
                {
                    try
                    {
                        cardinality = Convert.ToInt32(str.Notes.Trim());
                        return(cardinality);
                    }
                    catch
                    {
                        if (Validate)
                        {
                            tw.WriteLine("Model Code: {0},", l_MyAttr.Code);
                            tw.WriteLine("Name: {0},", l_MyAttr.Name);
                            tw.WriteLine("Cardinality: {0},\n", str.Notes);
                            tw.WriteLine(str + "cardinality value can not be converted  in int.");

                            tw.WriteLine("*************************************************************************");
                            tw.WriteLine("\n\n");
                        }
                    }
                }
            }
            return(cardinality);
        }
        public static AttributeTag AddTaggedValue(this Attribute attribute, string name)
        {
            var taggedValue = (AttributeTag)attribute.TaggedValues.AddNew(name, string.Empty);

            taggedValue.Value = string.Empty;
            taggedValue.Update();
            return(taggedValue);
        }
 /// <summary>
 /// Execute the given actions for the attribute (e.g. setting its tagged value, ...) and save the attribute to the EA.Repository.
 /// </summary>
 /// <param name="attribute"></param>
 /// <param name="doSomethingWith"></param>
 /// <returns></returns>
 public static Attribute With(this Attribute attribute, params Action <Attribute>[] doSomethingWith)
 {
     foreach (var action in doSomethingWith)
     {
         action(attribute);
     }
     attribute.Update();
     return(attribute);
 }
        public bool GetAttribute(out EA.Attribute attribute)
        {
            attribute = null;
            int attributeId;

            if (GetEAObjectId(AttributeID, out attributeId))
            {
                attribute = repository.GetAttributeByID(attributeId);
                return(attribute != null);
            }
            return(false);
        }
 /// <summary>
 /// GUIDを指定してEA上の属性オブジェクトを取得する
 /// </summary>
 /// <param name="attributeGuid">検索対象属性のGUID</param>
 /// <returns>合致するGUIDでヒットした属性オブジェクト。ヒットしなかったらnull</returns>
 private static 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);
     }
 }
        /// <summary>
        /// 属性の更新前、更新後の情報をログファイルに出力
        /// </summary>
        /// <param name="attr">対象のEA.Attributeオブジェクト</param>
        /// <param name="afterUpdateFlag">更新前/更新後を示す(true=後)</param>
        private static void writeUpdateLogAttribute(EA.Attribute attr, bool afterUpdateFlag)
        {
            try
            {
                StreamWriter sw = new StreamWriter(@"C:\ea-artifacts\DiffViewerUpdate.log", true);

                if (afterUpdateFlag)
                {
                    sw.WriteLine("■属性の書き込みが完了しました(ID={0}, GUID={1})。", attr.AttributeID, attr.AttributeGUID);
                }
                else
                {
                    sw.WriteLine("〇属性の更新前情報を表示します(ID={0}, GUID={1})。", attr.AttributeID, attr.AttributeGUID);
                }

                sw.WriteLine("  AttributeID = " + attr.AttributeID);
                sw.WriteLine("  AttributeGUID = " + attr.AttributeGUID);
                sw.WriteLine("  Name = " + attr.Name);
                sw.WriteLine("  Alias = " + attr.Alias);
                sw.WriteLine("  StereotypeEx = " + attr.StereotypeEx);
                sw.WriteLine("  Notes = " + attr.Notes);
                sw.WriteLine("  AllowDuplicate = " + attr.AllowDuplicates);
                sw.WriteLine("  ClassifierID = " + attr.ClassifierID);
                sw.WriteLine("  Container = " + attr.Container);
                sw.WriteLine("  Containment = " + attr.Containment);
                sw.WriteLine("  Default = " + attr.Default);
                sw.WriteLine("  IsCollection = " + attr.IsCollection);
                sw.WriteLine("  IsConst = " + attr.IsConst);
                sw.WriteLine("  IsDerived = " + attr.IsDerived);
                sw.WriteLine("  IsOrdered = " + attr.IsOrdered);
                sw.WriteLine("  IsStatic = " + attr.IsStatic);
                sw.WriteLine("  Length = " + attr.Length);
                sw.WriteLine("  LowerBound = " + attr.LowerBound);
                sw.WriteLine("  Precision = " + attr.Precision);
                sw.WriteLine("  Pos = " + attr.Pos);
                sw.WriteLine("  Scale = " + attr.Scale);
                sw.WriteLine("  Stereotype = " + attr.Stereotype);
                sw.WriteLine("  StyleEx = " + attr.StyleEx);
                sw.WriteLine("  Type = " + attr.Type);
                sw.WriteLine("  UpperBound = " + attr.UpperBound);
                sw.WriteLine("  Visibility = " + attr.Visibility);
                sw.WriteLine("");

                sw.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        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にアタッチしていないため、選択できません");
            }
        }
 public static void AttributesAreEqual(Attribute expectedAttribute, Attribute actualAttribute, Path path)
 {
     if (expectedAttribute == null)
     {
         Assert.IsNull(actualAttribute);
     }
     else
     {
         Assert.IsNotNull(actualAttribute,
                          "Target attribute for " + expectedAttribute.Name + " is null at /" + path);
         Path attributePath = path / expectedAttribute.Name;
         attributePropertiesAreEqual.AssertFor(expectedAttribute, actualAttribute, attributePath);
         AssertCollectionsAreEqual <AttributeTag>(expectedAttribute.TaggedValues, actualAttribute.TaggedValues,
                                                  attributePath, AttributeTagsAreEqual);
     }
 }
Exemple #10
0
        public static bool isLiteralValue(Attribute eaAttribute, EaUmlClassifier owner)
        {
            //if the field StyleEx contains "IsLiteral=1" then it is a literal value
            //of if the StyleEx field is empty and the owner of this attribute is of type Enumeration
            var styleEx = eaAttribute.StyleEx;

            if (styleEx.Contains("IsLiteral=1"))
            {
                return(true);
            }
            if (styleEx.Contains("IsLiteral=0"))
            {
                return(false);
            }
            //no information in the StyleEx, check the owner
            return(owner.isEnumeration);
        }
 public void FindType(EAPClass l_Class, EAPAttribute l_MyAttr, EA.Attribute l_Attr)
 {
     //PropertyType type = 0;
     if ((l_MyAttr.Code != null && l_MyAttr.Code != "") || true)
     {
         if (Enum.IsDefined(typeof(MeasurementType), l_Attr.Type.ToUpper()))
         {
             l_MyAttr.MeasurementType = l_Attr.Type;
         }
         else
         {
             List <string> typeStr = new List <string>()
             {
                 "bool", "int", "long", "string", "short", "double", "float",
                 "byte", "modelcode", "lid", "gid"
             };
             if (l_Attr.Type.Split('<').Length > 1)
             {
                 string helpString = l_Attr.Type.Remove(0, (l_Attr.Type.IndexOf('<') + 1));
                 // l_MyAttr.MeasurementType = helpString.Remove(helpString.IndexOf('>'));
                 l_MyAttr.MeasurementType = l_Attr.Type;
                 if (Enum.IsDefined(typeof(MeasurementType), helpString.Remove(helpString.IndexOf('>'))))
                 {
                     l_MyAttr.MeasurementType = helpString.Remove(helpString.IndexOf('>'));
                 }
                 else
                 {
                     l_MyAttr.MeasurementType = l_Attr.Type;
                 }
             }
             else
             {
                 if (!typeStr.Contains(l_Attr.Type.ToLower()))
                 {
                     l_MyAttr.MeasurementType = l_Attr.Type;
                 }
                 else if (typeStr.Contains(l_Attr.Type.ToLower()))
                 {
                     //GenerateUIControlsBasedOnPropType(l_Attr.Type.ToLower(), l_MyAttr, false);
                 }
             }
         }
     }
 }
        public string ReturnValue(MetaEntity obj, EA.Attribute l_Attr, EAPEnumeration en = null)
        {
            if (l_Attr.Default != null && (l_Attr.Default != ""))
            {
                if (!l_Attr.Default.StartsWith("0x", true, CultureInfo.InvariantCulture))
                {
                    return(l_Attr.Default);
                }
                else
                {
                    string helpString = l_Attr.Default.Remove(0, 2).Trim();

                    try
                    {
                        long val = Convert.ToInt64(helpString, 16);
                        return(val.ToString());
                    }
                    catch
                    {
                        if (Validate)
                        {
                            if (en != null)
                            {
                                tw.WriteLine("Model Code for enum: {0},", en.Code);
                                tw.WriteLine("Name for enum: {0},", en.Name);
                            }
                            else
                            {
                                tw.WriteLine("Model Code: {0},", obj.Code);
                            }

                            tw.WriteLine("Name: {0},", obj.Name);
                            tw.WriteLine("Value Default {0},\n", l_Attr.Default);
                            tw.WriteLine(l_Attr.Default + " value can not be converted  in number.");

                            tw.WriteLine("*************************************************************************");
                            tw.WriteLine("\n\n");
                        }
                    }
                }
            }
            return(null);
        }
        private void AddMissingTaggedValues(Path path, Attribute attribute, params string[] requiredTaggedValues)
        {
            IEnumerable <string> existingTaggedValues = AsEnumerable <AttributeTag>(attribute.TaggedValues).Convert(tv => tv.Name);

            foreach (string missingTaggedValue in requiredTaggedValues.Except(existingTaggedValues))
            {
                var taggedValue = (AttributeTag)attribute.TaggedValues.AddNew(missingTaggedValue, string.Empty);
                taggedValue.Value = string.Empty;
                taggedValue.Update();
                TaggedValueFixed(path / missingTaggedValue);
            }
            if (removeUndefinedTaggedValues)
            {
                foreach (string unneededTaggedValue in existingTaggedValues.Except(requiredTaggedValues))
                {
                    attribute.TaggedValues.Delete(indexOf(attribute.TaggedValues, unneededTaggedValue));
                }
            }
            attribute.TaggedValues.Refresh();
        }
        public static AttributeVO getAttributeFromEAObject(EA.Attribute eaAttributeObj)
        {
            AttributeVO attvo = new AttributeVO();

            attvo.name  = excludeSpecialChar(eaAttributeObj.Name);
            attvo.alias = excludeSpecialChar(eaAttributeObj.Alias);
            if (eaAttributeObj.StereotypeEx != null && !"".Equals(eaAttributeObj.StereotypeEx))
            {
                attvo.stereoType = excludeSpecialChar(eaAttributeObj.StereotypeEx);
            }
            else
            {
                attvo.stereoType = null;
            }
            attvo.eaType          = eaAttributeObj.Type;
            attvo.notes           = eaAttributeObj.Notes;
            attvo.guid            = eaAttributeObj.AttributeGUID;
            attvo.pos             = eaAttributeObj.Pos;
            attvo.allowDuplicates = eaAttributeObj.AllowDuplicates;
            attvo.length          = convStringToInt(eaAttributeObj.Length);
            attvo.classifierID    = eaAttributeObj.ClassifierID.ToString();
            attvo.container       = eaAttributeObj.Container;
            attvo.containment     = eaAttributeObj.Containment;
            attvo.isDerived       = eaAttributeObj.IsDerived;
            attvo.isID            = eaAttributeObj.IsID;
            attvo.lowerBound      = convStringToInt(eaAttributeObj.LowerBound);
            attvo.upperBound      = convStringToInt(eaAttributeObj.UpperBound);
            attvo.precision       = convStringToInt(eaAttributeObj.Precision);
            attvo.scale           = convStringToInt(eaAttributeObj.Scale);
            attvo.visibility      = excludeSpecialChar(eaAttributeObj.Visibility);

            List <TaggedValueVO> outTagList = new List <TaggedValueVO>();

            foreach (EA.AttributeTag atag in eaAttributeObj.TaggedValuesEx)
            {
                outTagList.Add(getAttributeTagFromEAObject(atag));
            }
            attvo.taggedValues = outTagList;

            return(attvo);
        }
Exemple #15
0
        private string FormAttributeModificators(Attribute attribute)
        {
            var sb = new StringBuilder();

            if (attribute.IsCollection)
            {
                sb.Append("Collection");
            }

            if (attribute.IsStatic)
            {
                if (sb.Length != 0)
                {
                    sb.Append(',');
                }

                sb.Append("Static");
            }

            if (attribute.IsOrdered)
            {
                if (sb.Length != 0)
                {
                    sb.Append(',');
                }

                sb.Append("Ordered");
            }

            if (!string.IsNullOrWhiteSpace(attribute.Scale))
            {
                if (sb.Length != 0)
                {
                    sb.Append(',');
                }

                sb.Append("Scale");
            }

            return(sb.ToString());
        }
Exemple #16
0
        private string FormAttributeName(Attribute attribute)
        {
            var sb = new StringBuilder();

            switch (attribute.Visibility)
            {
            case "Public":
                sb.Append('+');
                break;

            case "Private":
                sb.Append('-');
                break;

            case "Protected":
                sb.Append('#');
                break;
            }

            sb.Append(attribute.Name);
            sb.Append(": ");
            if (attribute.IsConst)
            {
                sb.Append("const ");
            }
            sb.Append(attribute.Type);

            if (attribute.LowerBound != "1" || attribute.UpperBound != "1")
            {
                sb.Append($"[{attribute.LowerBound}..{attribute.UpperBound}]");
            }

            if (!string.IsNullOrWhiteSpace(attribute.Default))
            {
                sb.Append("=");
                sb.Append(attribute.Default);
            }

            return(sb.ToString());
        }
        public bool GetSearchable(EA.Attribute l_Attr, EAPAttribute l_MyAttr)
        {
            bool searchable = false;

            foreach (EA.AttributeConstraint str in l_Attr.Constraints)
            {
                if (str.Name.ToLower() == "searchable")
                {
                    try
                    {
                        if (str.Notes.Trim() == "0")
                        {
                            return(false);
                        }
                        else if (str.Notes.Trim() == "1")
                        {
                            return(true);
                        }

                        searchable = Convert.ToBoolean(str.Notes.Trim());
                        return(searchable);
                    }
                    catch
                    {
                        if (Validate)
                        {
                            tw.WriteLine("Model Code: {0},", l_MyAttr.Code);
                            tw.WriteLine("Name: {0},", l_MyAttr.Name);
                            tw.WriteLine("Searchable: {0},\n", str.Notes);
                            tw.WriteLine(str.Notes + "searchable value can not be converted  in bool.");

                            tw.WriteLine("*************************************************************************");
                            tw.WriteLine("\n\n");
                        }
                    }
                }
            }
            return(searchable);
        }
        public bool GetAggregated(EA.Attribute l_Attr, EAPAttribute l_MyAttr)
        {
            bool aggregated = false;

            foreach (EA.AttributeConstraint str in l_Attr.Constraints)
            {
                if (str.Name.ToLower() == "aggregated")
                {
                    try
                    {
                        if (str.Notes.Trim() == "0")
                        {
                            return(false);
                        }
                        else if (str.Notes.Trim() == "1")
                        {
                            return(true);
                        }

                        aggregated = Convert.ToBoolean(str.Notes.Trim());
                        return(aggregated);
                    }
                    catch
                    {
                        if (Validate)
                        {
                            tw.WriteLine("Model Code: {0},", l_MyAttr.Code);
                            tw.WriteLine("Name: {0},", l_MyAttr.Name);
                            tw.WriteLine("Aggregated: {0},\n", str.Notes);
                            tw.WriteLine(str + "aggregated value can not be converted  in bool.");

                            tw.WriteLine("*************************************************************************");
                            tw.WriteLine("\n\n");
                        }
                    }
                }
            }
            return(aggregated);
        }
        /// <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("");
        }
        /// <summary>
        /// EAのAttributeを上書きもしくは追加する
        /// </summary>
        internal static void updateEaAttributeObject(ElementVO myElement, AttributeVO selectedAttribute)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            EA.Element    elem = null;
            int           tmp  = -1;

            // EAのAPIを使って属性をGUIDより検索
            EA.Attribute attrObj = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);

            // 取得できなかったら(該当するGUIDの属性が存在しなかったら)
            if (attrObj == null)
            {
                // この属性を持っているはずの要素をGUIDより検索
                elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                if (elem == null)
                {
                    return;
                }
                attrObj = (EA.Attribute)elem.Attributes.AddNew(selectedAttribute.name, selectedAttribute.eaType);
            }

            // 更新前後で更新ログ出力
            writeUpdateLogAttribute(attrObj, false);

            attrObj.Name          = selectedAttribute.name;
            attrObj.AttributeGUID = selectedAttribute.guid;
            attrObj.Alias         = selectedAttribute.alias;
            attrObj.StereotypeEx  = selectedAttribute.stereoType;
            attrObj.Notes         = selectedAttribute.notes;

            attrObj.AllowDuplicates = selectedAttribute.allowDuplicates;
            if ("".Equals(selectedAttribute.classifierID) || !Int32.TryParse(selectedAttribute.classifierID, out tmp))
            {
                selectedAttribute.classifierID = "0";
            }
            else
            {
                attrObj.ClassifierID = tmp;
            }

            attrObj.Container    = selectedAttribute.container;
            attrObj.Containment  = selectedAttribute.containment;
            attrObj.Default      = selectedAttribute.defaultValue;
            attrObj.IsCollection = selectedAttribute.isCollection;
            attrObj.IsConst      = selectedAttribute.isConst;
            attrObj.IsDerived    = selectedAttribute.isDerived;
            // attr.IsID = selectedAttribute.;
            attrObj.IsOrdered  = selectedAttribute.isOrdered;
            attrObj.IsStatic   = selectedAttribute.isStatic;
            attrObj.Length     = selectedAttribute.length.ToString();
            attrObj.LowerBound = selectedAttribute.lowerBound.ToString();
            attrObj.Precision  = selectedAttribute.precision.ToString();
            attrObj.Pos        = selectedAttribute.pos;
            // attr.RedefinedProperty = selectedAttribute.;
            attrObj.Scale      = selectedAttribute.scale.ToString();
            attrObj.Stereotype = selectedAttribute.stereoType;
            // attr.Style = selectedAttribute.;
            // attr.SubsettedProperty = selectedAttribute.;
            attrObj.StyleEx    = selectedAttribute.styleEx;
            attrObj.Type       = selectedAttribute.eaType;
            attrObj.UpperBound = selectedAttribute.upperBound.ToString();
            attrObj.Visibility = selectedAttribute.visibility;

            attrObj.Update();
            //						elem.Update();

            // 更新前後で更新ログ出力
            writeUpdateLogAttribute(attrObj, true);
        }
 public EaUmlAttribute(Repository eaRepository, Attribute eaAttribute)
 {
     this.eaRepository = eaRepository;
     this.eaAttribute  = eaAttribute;
     this.repository   = EaUmlRepository.getRepository(eaRepository);
 }
        public void CollectAttribute(EAPModel model, EA.Attribute l_Attr, EAPClass l_Class, bool group, EAPClass l_ClassGroup = null)
        {
            EAPAttribute l_MyAttr = new EAPAttribute();

            l_MyAttr.Description = l_Attr.Notes;
            l_MyAttr.Settable    = !l_Attr.IsConst;
            l_MyAttr.Max         = l_Attr.UpperBound;
            l_MyAttr.Min         = l_Attr.LowerBound;
            l_MyAttr.Index       = l_Attr.Pos;
            l_MyAttr.Default     = ReturnValue(l_MyAttr, l_Attr);
            l_MyAttr.Visible     = !l_Attr.IsStatic;

            if (model.Enums.ContainsKey(l_Attr.Type))
            {
                l_MyAttr.TypeCode = "Enum";
            }
            if (model.Classes.ContainsKey(l_Attr.Type))
            {
                l_MyAttr.TypeCode = "Class";
            }

            if (group)
            {
                if (l_ClassGroup == null)
                {
                    l_MyAttr.Group = l_Class.Code;
                }
                else
                {
                    l_MyAttr.Group = l_ClassGroup.Code;
                }
            }

            if (l_MyAttr.Description.Split(':').Length > 1)
            {
                l_MyAttr.Title       = l_MyAttr.Description.Split(':')[0];
                l_MyAttr.Description = l_MyAttr.Description.Remove(0, l_MyAttr.Title.Length + 1);
            }
            else
            {
                l_MyAttr.Title       = "";
                l_MyAttr.Description = l_MyAttr.Description.Trim();
            }

            l_MyAttr.Title       = l_MyAttr.Title.Replace("<b>", "").Replace("</b>", "").Replace("<i>", "").Replace("</i>", "").Trim();
            l_MyAttr.Description = l_MyAttr.Description.Replace("<b>", "").Replace("</b>", "").Replace("<i>", "").Replace("</i>", "").Trim();

            l_MyAttr.Code = l_Attr.Style;
            l_MyAttr.Name = l_Attr.Name;

            FindType(l_Class, l_MyAttr, l_Attr);

            l_MyAttr.Aggregated  = GetAggregated(l_Attr, l_MyAttr);
            l_MyAttr.Searchable  = GetSearchable(l_Attr, l_MyAttr);
            l_MyAttr.Cardinality = GetCardinality(l_Attr, l_MyAttr) == 0 ? null : GetCardinality(l_Attr, l_MyAttr).ToString();


            if (!(l_Class.AddAttribute(l_MyAttr)))
            {
                if (Validate)
                {
                    tw.WriteLine("Attribute Model Code:" + l_Attr.Style + ",  already exists in Class name: " + l_Class.Name + ". (Look at EAP)");

                    tw.WriteLine("*************************************************************************");
                    tw.WriteLine("\n\n");
                }
            }
        }
        void ReflectToEAToolStripMenuItemClick(object sender, EventArgs e)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            EA.Element    elem = null;
            int           tmp  = -1;

            if (repo != null)
            {
                // 選択された属性に対する更新処理
                if (selectedAttribute != null)
                {
                    //メッセージボックスを表示する
                    DialogResult result = MessageBox.Show("EAのリポジトリの属性を上書き、もしくは追加します。よろしいですか?",
                                                          "質問",
                                                          MessageBoxButtons.YesNoCancel,
                                                          MessageBoxIcon.Exclamation,
                                                          MessageBoxDefaultButton.Button1);

                    //何が選択されたか調べる
                    if (result == DialogResult.Yes)
                    {
                        EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);
                        if (attr == null)
                        {
                            elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                            if (elem == null)
                            {
                                return;
                            }
                            attr = (EA.Attribute)elem.Attributes.AddNew(selectedAttribute.name, "String");
                        }

                        attr.Name          = selectedAttribute.name;
                        attr.AttributeGUID = selectedAttribute.guid;
                        attr.Alias         = selectedAttribute.alias;
                        attr.StereotypeEx  = selectedAttribute.stereoType;
                        attr.Notes         = selectedAttribute.notes;

                        attr.AllowDuplicates = selectedAttribute.allowDuplicates;
                        if ("".Equals(selectedAttribute.classifierID) || !Int32.TryParse(selectedAttribute.classifierID, out tmp))
                        {
                            selectedAttribute.classifierID = "0";
                        }
                        else
                        {
                            attr.ClassifierID = tmp;
                        }
//						attr.ClassifierID =  Int32.Parse( selectedAttribute.classifierID );

                        attr.Container    = selectedAttribute.container;
                        attr.Containment  = selectedAttribute.containment;
                        attr.Default      = selectedAttribute.defaultValue;
                        attr.IsCollection = selectedAttribute.isCollection;
                        attr.IsConst      = selectedAttribute.isConst;
                        attr.IsDerived    = selectedAttribute.isDerived;
                        // attr.IsID = selectedAttribute.;
                        attr.IsOrdered  = selectedAttribute.isOrdered;
                        attr.IsStatic   = selectedAttribute.isStatic;
                        attr.Length     = selectedAttribute.length.ToString();
                        attr.LowerBound = selectedAttribute.lowerBound.ToString();
                        attr.Precision  = selectedAttribute.precision.ToString();
                        // attr.RedefinedProperty = selectedAttribute.;
                        attr.Scale = selectedAttribute.scale.ToString();
                        // attr.Stereotype = ;
                        // attr.Style = selectedAttribute.;
                        // attr.SubsettedProperty = selectedAttribute.;
                        // attr.StyleEx = selectedAttribute.;
                        attr.Type       = selectedAttribute.eaType;
                        attr.UpperBound = selectedAttribute.upperBound.ToString();
                        attr.Visibility = selectedAttribute.visibility;

                        attr.Update();
//						elem.Update();
                    }
                    else
                    {
                        return;
                    }
                }


                // 選択された操作に対する更新処理
                if (selectedMethod != null)
                {
                    //メッセージボックスを表示する
                    DialogResult result = MessageBox.Show("EAのリポジトリの操作を上書き、もしくは追加します。よろしいですか?",
                                                          "質問",
                                                          MessageBoxButtons.YesNoCancel,
                                                          MessageBoxIcon.Exclamation,
                                                          MessageBoxDefaultButton.Button1);

                    //何が選択されたか調べる
                    if (result == DialogResult.Yes)
                    {
                        EA.Method mth = getMethodByGuid(selectedMethod.guid);

                        if (mth == null)
                        {
                            elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                            if (elem == null)
                            {
                                return;
                            }

                            mth = (EA.Method)elem.Methods.AddNew(selectedMethod.name, selectedMethod.returnType);
                        }

                        mth.Name         = selectedMethod.name;
                        mth.MethodGUID   = selectedMethod.guid;
                        mth.Alias        = selectedMethod.alias;
                        mth.StereotypeEx = selectedMethod.stereoType;
                        mth.Notes        = selectedMethod.notes;
                        mth.Behavior     = selectedMethod.behavior;

                        mth.Abstract     = selectedMethod.isAbstract;
                        mth.ClassifierID = selectedMethod.classifierID;
                        mth.Code         = selectedMethod.code;
                        mth.Concurrency  = selectedMethod.concurrency;
                        mth.IsConst      = selectedMethod.isConst;
                        mth.IsLeaf       = selectedMethod.isLeaf;
                        mth.IsPure       = selectedMethod.isPure;
                        mth.IsQuery      = selectedMethod.isQuery;
                        mth.IsRoot       = selectedMethod.isRoot;
                        mth.IsStatic     = selectedMethod.isStatic;
                        // mth.IsSynchronized = selectedMethod.s isSynchronized;
                        mth.Pos           = selectedMethod.pos;
                        mth.ReturnIsArray = selectedMethod.returnIsArray;
                        mth.ReturnType    = selectedMethod.returnType;
                        mth.StateFlags    = selectedMethod.stateFlags;
                        // mth.StyleEx = selectedMethod.StyleEx;
                        mth.Throws     = selectedMethod.throws;
                        mth.Visibility = selectedMethod.visibility;
                        mth.Update();

                        // 既にパラメータが設定されている場合は一旦削除
                        for (short i = 0; i < mth.Parameters.Count; i++)
                        {
                            mth.Parameters.Delete(i);
                        }

                        // XMLから読み込まれたパラメータの値を設定する
                        foreach (ParameterVO prm in selectedMethod.parameters)
                        {
                            EA.Parameter paramObj = (EA.Parameter)mth.Parameters.AddNew(prm.name, prm.eaType);
                            paramObj.Alias         = prm.alias;
                            paramObj.ClassifierID  = prm.classifierID;
                            paramObj.Default       = prm.defaultValue;
                            paramObj.IsConst       = prm.isConst;
                            paramObj.Kind          = prm.kind;
                            paramObj.Name          = prm.name;
                            paramObj.Notes         = prm.notes;
                            paramObj.ParameterGUID = prm.guid;
                            paramObj.Position      = prm.pos;
                            paramObj.StereotypeEx  = prm.stereoType;
                            // paramObj.Style = prm.Style ;
                            // paramObj.StyleEx = prm.StyleEx ;
                            paramObj.Type = prm.eaType;
                            paramObj.Update();
                        }

//						elem.Update();
                    }
                    else
                    {
                        return;
                    }
                }
            }
            else
            {
                MessageBox.Show("EAにアタッチしていないため、反映できません");
            }
        }
Exemple #24
0
 public EaUmlEnumerationLiteral(Repository eaRepository, Attribute eaAttribute, IUmlClassifier owner)
 {
     this.eaAttribute  = eaAttribute;
     this.eaRepository = eaRepository;
     this.Owner        = owner;
 }
 public EaUmlEnumerationLiteral(Attribute eaAttribute)
 {
     this.eaAttribute = eaAttribute;
 }
 public EaUmlAttribute(Repository eaRepository, Attribute eaAttribute)
 {
     this.eaRepository = eaRepository;
     this.eaAttribute  = eaAttribute;
 }