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(); }
/// <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; } } }
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(); }
/// <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(); }
/// <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(); }
private void CopyTaggedValue(TaggedValue sourceTaggedValue, Collection targetCollection, int targetElementId) { var targetTaggedValue = (TaggedValue)targetCollection.AddNew(sourceTaggedValue.Name, ""); targetTaggedValue.ElementID = targetElementId; targetTaggedValue.Value = sourceTaggedValue.Value; targetTaggedValue.Update(); }
public EaTaggedValue(TaggedValue eaTaggedValue) { if (eaTaggedValue == null) { throw new NullReferenceException("tagged value is null"); } this.eaTaggedValue = eaTaggedValue; }
public static Mapping getMapping(MappingNode startNode, TaggedValue mappingTag, MappingNode targetRootNode) { var sourceMappingPath = getMappingPath(mappingTag, false); var targetMappingPath = getMappingPath(mappingTag, true); var targetElement = mappingTag.tagValue as Element; return(getMapping(mappingTag, targetElement, startNode, sourceMappingPath, targetMappingPath, targetRootNode)); }
public static IEATaggedValue Wrap(TaggedValue native) { if (null == native) { throw new ArgumentNullException("native"); } return(new EATaggedValue(native)); }
/// <summary> /// Copy TV to current element /// </summary> /// <param name="el"></param> public void ElTvCopy(EA.Element el) { foreach (EA.TaggedValue tv in _lTv) { var tvNew = TaggedValue.Add(el, tv.Name); TaggedValue.SetTaggedValue(tvNew, tv.Value); tv.Update(); } }
public void PutItem(KeyT key, ValueT item) { TaggedValue val = new TaggedValue() { tag = DateTime.UtcNow, value = item }; _cachedItems[key] = val; Trim(); }
public TaggedValueMapping(TaggedValue wrappedTaggedValue, MappingNode source, MappingNode target) : base(source, target) { this.wrappedTaggedValue = wrappedTaggedValue; //make sure the mappingset is defined for all tagged value mappings. if (!this.hasMappingSetDefined && !this.isReadOnly) { var temp = this.EAMappingLogics; //load mapping logics to make sure they get saved this.saveMe(); } }
private static List <string> getMappingPath(TaggedValue mappingTag, bool target) { var mappingPath = new List <String>(); var pathString = target ? KeyValuePairsHelper.getValueForKey(mappingTargetPathName, mappingTag.comment) : KeyValuePairsHelper.getValueForKey(mappingTargetPathName, mappingTag.comment); if (!string.IsNullOrEmpty(pathString)) { mappingPath = pathString.Split(',').ToList(); } return(mappingPath); }
public static void TaggedValuesAreEqual(TaggedValue expectedTag, TaggedValue actualTag, Path path) { if (expectedTag == null) { Assert.IsNull(actualTag); } else { Assert.IsNotNull(actualTag, "Target tagged value for " + expectedTag.Name + " is null at /" + path); Path tagPath = path / expectedTag.Name; taggedValuePropertiesAreEqual.AssertFor(expectedTag, actualTag, tagPath); } }
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(); }
private TaggedValue GetTaggedValue(Element element, string name) { TaggedValue tv = null; for (short idx = 0; idx < element.TaggedValues.Count; idx++) { tv = element.TaggedValues.GetAt(idx); if (tv.Name == name) { return(tv); } } return(null); }
/// <summary> /// Update import package with file properties/attributes of HEADER and MODULE /// </summary> private void UpdatePackage(XElement xElFile) { var fileAttres = (from attr in xElFile.Descendants(xmlModuleName).Elements() select new { Name = attr.Name, Value = attr.Value }) .Union (from attr in xElFile.Descendants(xmlHeaderName).Elements() select new { Name = attr.Name, Value = attr.Value }) ; foreach (var attr in fileAttres) { EA.Element el = Rep.GetElementByGuid(Pkg.PackageGUID); TaggedValue.SetUpdate(el, attr.Name.ToString(), attr.Value); } }
public int RemoveAllWithName(string name) { int count = 0; const short one = 1; for (var idx = (short)(_native.TaggedValues.Count - one); idx >= 0; idx--) { TaggedValue tv = _native.TaggedValues.GetAt(idx); if (tv.Name.StartsWith(name)) { _native.TaggedValues.DeleteAt(idx, true); count++; } } return(count); }
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); }
/// <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); }
// mark a column as included by adding it's GUID to "includes" TaggedValue public void markAsIncluded(Column column) { if (this.wrappedElement != null) { String guid = column._wrappedattribute.guid; TaggedValue tag = this.wrappedElement.getTaggedValue("includes"); if (tag == null) { this.wrappedElement.addTaggedValue("includes", guid); } else { this.wrappedElement.addTaggedValue( "includes", tag.tagValue.ToString() + "," + guid ); } } }
/// <summary> /// Add Tagged Values with Module Properties to Package/Object and /// Specification: LongName /// Specification: Identifier /// </summary> /// <param name="reqIf"></param> /// <param name="el"></param> private void GetModuleProperties(ReqIF reqIf, EA.Element el) { var moduleProperties = from obj in reqIf.CoreContent[0].Specifications[0].Values select new { Value = obj.ObjectValue.ToString(), Name = obj.AttributeDefinition.LongName, Type = obj.AttributeDefinition.GetType() }; foreach (var property in moduleProperties) { // if writable don't overwrite value, only create TV if (_exportFields.IsWritableValue(property.Value)) { TaggedValue.CreateTaggedValue(el, property.Value); // only create TV } else { TaggedValue.SetUpdate(el, property.Name, GetStringAttrValue(property.Value ?? "")); // update TV } } TaggedValue.SetUpdate(el, "LongName", reqIf.CoreContent[0].Specifications[0].LongName); TaggedValue.SetUpdate(el, "Identifier", reqIf.CoreContent[0].Specifications[0].Identifier); }
public TaggedValueMapping(Element source, Element target, string sourcePath, string targetPath, MappingSettings settings) : base(source, target, sourcePath, targetPath) { string tagName = settings.linkedAttributeTagName; if (target is ConnectorWrapper) { tagName = settings.linkedAssociationTagName; } string tagComments = string.Empty; if (!string.IsNullOrEmpty(sourcePath)) { tagComments = KeyValuePairsHelper.setValueForKey("mappingSourcePath", this.stripPathFromElementName(source, sourcePath), tagComments); } if (!string.IsNullOrEmpty(targetPath)) { tagComments = KeyValuePairsHelper.setValueForKey("mappingTargetPath", this.stripPathFromElementName(target, targetPath), tagComments); } this.wrappedTaggedValue = source.addTaggedValue(tagName, target.uniqueID, tagComments, true); }
private static List <string> getMappingPath(TaggedValue mappingTag, bool target) { var mappingPath = new List <String>(); try { //read from xml var xdoc = XDocument.Load(new StringReader(mappingTag.comment)); var pathString = target ? xdoc.Descendants(mappingTargetPathName).FirstOrDefault()?.Value : xdoc.Descendants(mappingSourcePathName).FirstOrDefault()?.Value; if (!string.IsNullOrEmpty(pathString)) { mappingPath = pathString.Split('.').ToList(); } } catch (System.Xml.XmlException) { //parse error. empty mapping path is returned } return(mappingPath); }
///<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(); }
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); }
/// <summary> /// Import and update ReqIF Requirements. You can set EA ObjectType like "Requirement" or EA Stereotype like "FunctionalRequirement" /// </summary> /// async Task public override bool ImportForFile(string eaObjectType = "Requirement", string eaStereotype = "", string stateNew = "", string stateChanged = "") { bool result = true; Rep.BatchAppend = true; Rep.EnableUIUpdates = false; // Deserialize var reqIf = DeSerializeReqIf(ImportModuleFile, validate: Settings.ValidateReqIF); if (reqIf == null) { return(false); } InitializeDoorsRequirementsTable(reqIf); //reqIf.CoreContent[0].Specifications.Dump(); // over all submodules Specification elModule = reqIf.CoreContent[0].Specifications[0]; AddRequirements(DtRequirements, elModule.Children, 1); base.ReadEaPackageRequirements(); CreateEaPackageDeletedObjects(); Count = 0; CountChanged = 0; CountNew = 0; List <int> parentElementIdsPerLevel = new List <int> { 0 }; int parentElementId = 0; int lastElementId = 0; int oldLevel = 0; foreach (DataRow row in DtRequirements.Rows) { Count += 1; string objectId = row["Id"].ToString(); string reqAbsNumber = objectId; //string reqAbsNumber = GetAbsoluteNumerFromDoorsId(objectId); int objectLevel = Int32.Parse(row["Object Level"].ToString()) - 1; string objectNumber = row["Object Number"].ToString(); string objectType = row["Object Type"].ToString(); string objectHeading = row["Object Heading"].ToString(); // Maintain parent ids of level // get parent id if (objectLevel > oldLevel) { if (parentElementIdsPerLevel.Count <= objectLevel) { parentElementIdsPerLevel.Add(lastElementId); } else { parentElementIdsPerLevel[objectLevel] = lastElementId; } parentElementId = lastElementId; } if (objectLevel < oldLevel) { parentElementId = parentElementIdsPerLevel[objectLevel]; } oldLevel = objectLevel; string name; string notes; // Estimate if header if (objectType == "headline" || !String.IsNullOrWhiteSpace(objectHeading)) { name = $"{objectNumber} {objectHeading}"; notes = row["Object Heading"].ToString(); } else { notes = row["Object Text"].ToString(); string objectShorttext = GetTextExtract(notes); objectShorttext = objectShorttext.Length > ShortNameLength?objectShorttext.Substring(0, ShortNameLength) : objectShorttext; name = objectShorttext; //name = $"{reqAbsNumber.PadRight(7)} {objectShorttext}"; } // Check if requirement with Doors ID already exists bool isExistingRequirement = DictPackageRequirements.TryGetValue(reqAbsNumber, out int elId); EA.Element el; if (isExistingRequirement) { el = (EA.Element)Rep.GetElementByID(elId); if (el.Alias != objectId || el.Name != name || el.Notes != notes || el.Type != eaObjectType || el.Stereotype != eaStereotype) { if (stateChanged != "") { el.Status = stateChanged; } CountChanged += 1; } } else { el = (EA.Element)Pkg.Elements.AddNew(name, "Requirement"); if (stateNew != "") { el.Status = stateNew; } CountChanged += 1; } el.Alias = objectId; el.Name = name; el.Multiplicity = reqAbsNumber; el.Notes = notes; el.TreePos = Count * 10; el.PackageID = Pkg.PackageID; el.ParentID = parentElementId; el.Type = eaObjectType; el.Stereotype = eaStereotype; el.Update(); Pkg.Elements.Refresh(); lastElementId = el.ElementID; // handle the remaining columns/ tagged values var cols = from c in DtRequirements.Columns.Cast <DataColumn>() where !ColumnNamesNoTaggedValues.Any(n => n == c.ColumnName) select new { Name = c.ColumnName, Value = row[c].ToString() } ; // Update/Create Tagged value foreach (var c in cols) { TaggedValue.SetUpdate(el, c.Name, c.Value); } } MoveDeletedRequirements(); UpdatePackage(); Rep.BatchAppend = false; Rep.EnableUIUpdates = true; Rep.ReloadPackage(Pkg.PackageID); return(result); }
public TaggedValueMapping(TaggedValue wrappedTaggedValue, string basePath, string targetBasePath) : base((Element)wrappedTaggedValue.owner, wrappedTaggedValue.tagValue as Element, basePath, targetBasePath) { this.wrappedTaggedValue = wrappedTaggedValue; }
public TaggedValueMapping(TaggedValue wrappedTaggedValue, MappingNode source, MappingNode target) : base(source, target) { this.wrappedTaggedValue = wrappedTaggedValue; }
/// <inheritdoc /> public override void Initialize() { SaveCommand = new SaveCommand(); CancelCommand = new CancelCommand(); AddCommand = new AddCommand(); RemoveCommand = new RemoveCommand(); Element = Repository.GetContextObject(); UMLNameValue = Element.Name; AliasValue = Element.Alias; TaggedValues = Element.TaggedValues; //Finalize list of stereotype tags to add switch (Element.Stereotype) { case "OwlClass": _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "EquivalentClass")); _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SubClassOf")); StereotypeString = (string)ResourceDictionary["OwlClassCharacteristics"]; break; case "RdfsClass": _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "EquivalentClass")); _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SubClassOf")); StereotypeString = (string)ResourceDictionary["RdfsClassCharacteristics"]; break; case "Individual": _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SameAs")); _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "Type")); StereotypeString = (string)ResourceDictionary["IndividualCharacteristics"]; break; } //Retrieve all tagged values and store them in a list //Tagged values are stored in a list to avoid iterating Collections multiple times, which is very costly //In a future iteration of the addin, avoid iterating the collection even once, instead using Repository.SQLQuery to retrieve //an XML-formatted list of every Tagged Value where the owner ID is Element.ElementID for (short i = 0; i < TaggedValues.Count; i++) { TaggedValue tv = TaggedValues.GetAt(i); _taggedValuesList.Add(tv); } // Retrieve URI tagged value and save it in URIViewmodelTaggedValue var result = RetrieveTaggedValues(_taggedValuesList, "URI"); URIViewmodelTaggedValue = new ViewModelTaggedValue(result.First()) { ResourceDictionary = ResourceDictionary, Key = Definitions.Find(ptv => ptv.Key == "URI").Key }; URIViewmodelTaggedValue.Initialize(); URIValue = URIViewmodelTaggedValue.Value; // Add tagged values to list of ViewmodelTaggedValues DanishViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddDanishTaggedValues, _taggedValuesList); EnglishViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddEnglishTaggedValues, _taggedValuesList); ProvenanceViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddProvenanceTaggedValues, _taggedValuesList); StereotypeViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddStereotypeTaggedValues, _taggedValuesList); }