/// <summary>
        /// Sets properties where parameters are not available at object creation.
        /// </summary>
        public void Initialize()
        {
            // Set PlusprofilTaggedValue field based on Key
            PlusprofilTaggedValue = PlusprofilTaggedValueDefinitions.Definitions.Find(ptv => ptv.Key == Key);

            // Set DisplayedNamed by retrieving localized string from ResourceDictionary using PlusprofilTaggedValue.Key
            DisplayedName = (string)ResourceDictionary[PlusprofilTaggedValue.Key];

            // Set Value based on ObjectType and PlusprofilTaggedValue
            switch (ObjectType)
            {
            case ObjectType.otTaggedValue:
            case ObjectType.otAttributeTag:
            {
                Value = PlusprofilTaggedValue.HasMemoField ? TaggedValue.Notes : TaggedValue.Value;
                break;
            }

            case ObjectType.otRoleTag:
            {
                // Ensure that TaggedValue.Value has format "{value}$ea_notes={notes}",
                // tokenize the string, then set Value = {notes} if HasMemoField, otherwise Value = {value}
                if (!TaggedValue.Value.Contains("$ea_notes"))
                {
                    TaggedValue.Value = string.Concat(TaggedValue.Value, "$ea_notes=");
                    TaggedValue.Update();
                }
                string[] tokens = TaggedValue.Value.Split(new[] { "$ea_notes=" }, StringSplitOptions.None);
                Value = PlusprofilTaggedValue.HasMemoField ? tokens[1] : tokens[0];
                break;
            }
            }
        }
        /// <summary>
        /// Updates the <c>Value</c> property of the <c>ViewModelTaggedValue.TaggedValue</c>, effectively saving changes made to the value in the add-in.
        /// </summary>
        public void UpdateTaggedValueValue()
        {
            switch (ObjectType)
            {
            case ObjectType.otTaggedValue:
            case ObjectType.otAttributeTag:
                if (PlusprofilTaggedValue.HasMemoField)
                {
                    TaggedValue.Notes = Value;
                }
                else
                {
                    TaggedValue.Value = Value;
                }
                break;

            case ObjectType.otRoleTag:
                // Ensure that TaggedValue.Value has format "{value}$ea_notes={notes}",
                // tokenize the string, then set Value = {notes} if HasMemoField, otherwise Value = {value}
                // TODO: "$ea_notes=" check may be superfluous, requires additional testing
                if (!TaggedValue.Value.Contains("$ea_notes"))
                {
                    TaggedValue.Value = string.Concat(TaggedValue.Value, "$ea_notes=");
                }
                string[] tokens = TaggedValue.Value.Split(new[] { "$ea_notes=" }, StringSplitOptions.None);
                TaggedValue.Value = PlusprofilTaggedValue.HasMemoField ? $"{tokens[0]}$ea_notes={Value}" : $"{Value}$ea_notes={tokens[1]}";
                break;
            }
            TaggedValue.Update();
        }
        private static void AddTaggedValueToElement(Element element, string valueName,
                                                    string valueType, string value)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            TaggedValue taggedValue =
                (TaggedValue)element.TaggedValues.AddNew(valueName, valueType);

            if (taggedValue == null)
            {
                throw new EnterpriseArchitectInteropFailure("Adding a tagged value '" + valueName + "' to an element failed.");
            }

            taggedValue.Value = value;

            if (!taggedValue.Update())
            {
                throw new EnterpriseArchitectInteropFailure(taggedValue.GetLastError());
            }

            element.TaggedValues.Refresh();
        }
        protected static void AddTaggedValueToElement(Element element, string valueName,
                                                      string valueType, string value)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element; Class: BasicReqIfFileImporter");
            }

            TaggedValue taggedValue =
                (TaggedValue)element.TaggedValues.AddNew(valueName, valueType);

            if (taggedValue == null)
            {
                throw new Exception("Adding a tagged value '" + valueName + "' to an element failed.");
            }

            taggedValue.Value = value;

            if (!taggedValue.Update())
            {
                throw new Exception(taggedValue.GetLastError());
            }

            element.TaggedValues.Refresh();
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Implements IEAElement.AddTaggedValue(string name, string data)
        /// </summary>
        /// <param name="name"></param>
        /// <param name="data"></param>
        public void AddTaggedValue(string name, string data)
        {
            TaggedValue taggedValue = _native.TaggedValues.AddNew(name, "");

            taggedValue.Value = data;
            taggedValue.Update();
            _native.TaggedValues.Refresh();
        }
Ejemplo n.º 6
0
 public override void Update(UmlTaggedValueSpec spec)
 {
     eaTaggedValue.Name = spec.Name;
     if (spec.Value != null)
     {
         eaTaggedValue.Value = spec.Value;
     }
     eaTaggedValue.Update();
 }
Ejemplo n.º 7
0
        public void UpdateTaggedValue(string name, string data)
        {
            TaggedValue taggedValue = _native.TaggedValues.GetByName(name);

            if (taggedValue == null)
            {
                throw new Exception("TaggedValue " + name + " does not exist.");
            }
            taggedValue.Value = data;
            taggedValue.Update();
            _native.TaggedValues.Refresh();
            Update();
        }
Ejemplo n.º 8
0
        public bool UpdateTaggedValue(string guid, string name, string data)
        {
            TaggedValue taggedValue =
                _native.TaggedValues.Cast <TaggedValue>().FirstOrDefault(tv => tv.PropertyGUID.Equals(guid));

            if (taggedValue == null)
            {
                return(false);
            }
            taggedValue.Name  = name;
            taggedValue.Value = data;
            taggedValue.Update();
            _native.TaggedValues.Refresh();
            Update();
            return(true);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// EAのTaggedValueを上書きもしくは追加する
        /// </summary>
        internal static void updateEaTaggedValueObject(ElementVO myElement, TaggedValueVO selectedTag)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            EA.Element    elem = null;

            // この属性を持っているはずの要素をGUIDより検索
            elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
            if (elem == null)
            {
                return;
            }

            TaggedValue tvObj = null;

            if (elem.TaggedValues != null && elem.TaggedValues.Count > 0)
            {
                for (int i = 0; i < elem.TaggedValues.Count; i++)
                {
                    tvObj = elem.TaggedValues.GetAt((short)i);
                    if (selectedTag.guid == tvObj.PropertyGUID)
                    {
                        break;
                    }
                }
            }

            // 結果的に TaggedValue のオブジェクトが取得できなかったら、この要素の配下にタグ付き値を追加する
            if (tvObj == null)
            {
                tvObj = elem.TaggedValues.AddNew(selectedTag.name, "");
            }

            // 更新前後で更新ログ出力
            writeUpdateLogTaggedValue(tvObj, false);

            tvObj.Name  = selectedTag.name;
            tvObj.Notes = selectedTag.notes;
            // tvObj.ObjectType = selectedTag.name;
            tvObj.PropertyGUID = selectedTag.guid;
            tvObj.Value        = selectedTag.tagValue;

            // トランザクションのコミット
            tvObj.Update();

            // 更新前後で更新ログ出力
            writeUpdateLogTaggedValue(tvObj, true);
        }
        ///<summary>
        ///</summary>
        ///<param name="element"></param>
        ///<param name="key"></param>
        ///<param name="value"></param>
        public static void SetTaggedValue(this Element element, TaggedValues key, string value)
        {
            TaggedValue taggedValue = null;

            foreach (TaggedValue tv in element.TaggedValues)
            {
                if (tv.Name.Equals(key.ToString()))
                {
                    taggedValue = tv;
                    break;
                }
            }
            if (taggedValue == null)
            {
                taggedValue = (TaggedValue)element.TaggedValues.AddNew(key.ToString(), "");
            }
            taggedValue.Value = value;
            if (!taggedValue.Update())
            {
                throw new Exception(taggedValue.GetLastError());
            }
            element.TaggedValues.Refresh();
        }
Ejemplo n.º 11
0
        public void createModel(Package pkg, Vpc vpc, bool enableDnsSupport, bool enableDnsHostnames)
        {
            this.log.Debug("{");
            this.log.Debug("   VpcId = " + vpc.VpcId + ",");
            this.log.Debug("   CidrBlock = " + vpc.CidrBlock + ",");
            this.log.Debug("   EnableDnsSupport = " + enableDnsSupport + ",");
            this.log.Debug("   EnableDnsHostnames = " + enableDnsHostnames + ",");
            this.log.Debug("   InstanceTenancy = " + vpc.InstanceTenancy + ",");
            this.log.Debug("}");

            // Get the model identifier
            string vpcId = vpc.VpcId.ToString();

            // Create the element
            Element element = pkg.Elements.AddNew(vpcId, "SerAwsMdl::MDL_EC2_Vpc");

            element.Update();

            // Language - Default to C#
            element.Gentype = "C#";

            // Stereotype Tagged Values
            TaggedValue vpcIdTv = this.GetTaggedValue(element, "VpcId");

            vpcIdTv.Value = vpc.VpcId;
            vpcIdTv.Update();

            TaggedValue cidrBlockTv = this.GetTaggedValue(element, "CidrBlock");

            cidrBlockTv.Value = vpc.CidrBlock;
            cidrBlockTv.Update();

            TaggedValue enableDnsSupportTv = this.GetTaggedValue(element, "EnableDnsSupport");

            enableDnsSupportTv.Value = enableDnsSupport.ToString();
            enableDnsSupportTv.Update();

            TaggedValue enableDnsHostnamesTv = this.GetTaggedValue(element, "EnableDnsHostnames");

            enableDnsHostnamesTv.Value = enableDnsSupport.ToString();
            enableDnsHostnamesTv.Update();

            TaggedValue instanceTenancyTv = this.GetTaggedValue(element, "InstanceTenancy");

            instanceTenancyTv.Value = vpc.InstanceTenancy.ToString();
            instanceTenancyTv.Update();

            // AWS Tags
            List <Amazon.EC2.Model.Tag> tags = vpc.Tags;
            string name = null;

            for (var jdx = 0; jdx < tags.Count; jdx++)
            {
                // Set a corresponding tagged value
                Amazon.EC2.Model.Tag tag = tags[jdx];
                this.log.Debug("Key: " + tag.Key + ", Value: " + tag.Value);
                var tv = element.TaggedValues.AddNew(tag.Key, tag.Value);
                tv.Update();

                // Keep track of the name, as this is a special case
                if (tag.Key == "Name")
                {
                    name = tag.Value;
                }
            }

            // Set the name of the element to match "Name" tag
            if (name != null)
            {
                element.Name = name;
                element.Update();
            }

            // Keep it in the cache
            this.AwsModelCache.Add(vpcId, element);
        }
 public static TaggedValue WithValue(this TaggedValue taggedValue, string value)
 {
     taggedValue.Value = value;
     taggedValue.Update();
     return(taggedValue);
 }