/// <summary> /// adds a new tagged value to the element with the given name and value /// if a tagged value with that name already exists the value of the existing tagged value is updated./ /// </summary> /// <param name="name">the name of the tagged value to add</param> /// <param name="tagValue">the value of the tagged value</param> /// <param name = "comment">the comment to add to the tagged value</param> /// <param name = "addDuplicate"></param> /// <returns>the added (or updated) tagged value</returns> public virtual TaggedValue addTaggedValue(string name, string tagValue, string comment = null, bool addDuplicate = false) { TaggedValue newTaggedValue = null; if (!addDuplicate) { //we don't wan't any duplicates so we get the existing one newTaggedValue = this.getTaggedValue(name); } else { //we allow "duplicate" tagged values, but only if the value is different. newTaggedValue = this.taggedValues.FirstOrDefault(x => x.name.Equals(name, StringComparison.InvariantCultureIgnoreCase) && ((TaggedValue)x).eaStringValue.Equals(tagValue, StringComparison.InvariantCultureIgnoreCase)) as TaggedValue; } if (newTaggedValue == null) { //no existing tagged value found, or we need to create duplicates newTaggedValue = (TaggedValue)this.EAModel.factory.createNewTaggedValue(this, name); //add it to the local list of tagged values if (_taggedValues != null) { _taggedValues.Add(newTaggedValue); } } newTaggedValue.tagValue = tagValue; if (comment != null) { newTaggedValue.comment = comment; } newTaggedValue.save(); return(newTaggedValue); }
/// <summary> /// adds a new tagged value to the element with the given name and value /// if a tagged value with that name already exists the value of the existing tagged value is updated./ /// </summary> /// <param name="name">the name of the tagged value to add</param> /// <param name="tagValue">the value of the tagged value</param> /// <param name = "comment">the comment to add to the tagged value</param> /// <param name = "addDuplicate"></param> /// <returns>the added (or updated) tagged value</returns> public virtual TaggedValue addTaggedValue(string name, string tagValue, string comment = null, bool addDuplicate = false) { TaggedValue newTaggedValue = null; if (!addDuplicate) { //we don't wan't any duplicates so we get the existing one newTaggedValue = this.getTaggedValue(name); } if (newTaggedValue == null) { //no existing tagged value found, or we need to create duplicates newTaggedValue = (TaggedValue)this.model.factory.createNewTaggedValue(this, name); //add it to the local list of tagged values if (_taggedValues != null) { _taggedValues.Add(newTaggedValue); } } newTaggedValue.tagValue = tagValue; if (comment != null) { newTaggedValue.comment = comment; } newTaggedValue.save(); return(newTaggedValue); }
private void populateTreeForTable() { var tableNode = this.createTableNode(this.context, this.tree.Nodes); // TODO: I'm not using Table here, because that requires a Database // Unsure if having a DB is really a requirement // So just using the Class representation to work on. foreach (TSF_EA.Attribute attribute in this.context.attributes) { if (attribute.HasStereotype("column")) { var columnNode = this.createColumnNode(attribute, tableNode.Nodes); if (this.prevSelection != null && attribute.guid == this.prevSelection.guid) { this.tree.SelectedNode = columnNode; } TSF_EA.TaggedValue tv = attribute.getTaggedValue("EDD::dataitem"); if (tv != null) { var di = tv.tagValue as TSF_EA.Class; if (di != null) { this.createDataItemNode(di, columnNode.Nodes); // mark column if not in sync if (this.notInSync(attribute, di)) { columnNode.ForeColor = Color.Red; } } } } } }
protected string getTaggedValueString(string tagName) { TSF_EA.TaggedValue tv = null; if (this.Origin != null) { tv = this.Origin.getTaggedValue(tagName); } return(tv != null ? tv.eaStringValue : string.Empty); }
private TSF_EA.TaggedValue popTargetTaggedValue(List <TSF_EA.TaggedValue> targetTaggedValues, TSF_EA.TaggedValue sourceTaggedValue) { TSF_EA.TaggedValue targetTaggedValue = null; var nameMatches = targetTaggedValues.Where(x => x.name.Equals(sourceTaggedValue.name, StringComparison.InvariantCultureIgnoreCase)); if (!nameMatches.Any()) { return(null); } //found some matches by name //check if only one found if (nameMatches.Count() == 1) { targetTaggedValue = nameMatches.First(); } if (targetTaggedValue == null) { //multiple found, check if any of them as the same value var valueMatches = nameMatches.Where(x => x.eaStringValue == sourceTaggedValue.eaStringValue); if (!valueMatches.Any()) { targetTaggedValue = nameMatches.First(); } else { if (valueMatches.Count() == 1) { targetTaggedValue = valueMatches.First(); } else { //multiple value matches, check for comments var commentMatches = valueMatches.Where(x => x.comment == sourceTaggedValue.comment); if (!commentMatches.Any()) { targetTaggedValue = valueMatches.First(); } else { targetTaggedValue = commentMatches.First(); } } } } //pop from the list of target tagged values if (targetTaggedValue != null) { targetTaggedValues.Remove(targetTaggedValue); } //return return(targetTaggedValue); }
private DataItem getDataItem(TSF_EA.Attribute attribute) { if (attribute == null) { return(null); } TSF_EA.TaggedValue tv = attribute.getTaggedValue("EDD::dataitem"); if (tv == null || tv.tagValue == null) { return(null); } return(GlossaryItemFactory <DataItem> .FromClass(tv.tagValue as TSF_EA.Class)); }
/// <summary> /// adds a new tagged value to the element with the given name and value /// if a tagged value with that name already exists the value of the existing tagged value is updated./ /// </summary> /// <param name="name">the name fo the tagged value to add</param> /// <param name="tagValue">the value of the tagged value</param> /// <param name = "addDuplicate"></param> /// <returns>the added (or updated) tagged value</returns> public virtual TaggedValue addTaggedValue(string name, string tagValue, bool addDuplicate = false) { TaggedValue newTaggedValue = null; if (!addDuplicate) { //we don't wan't any duplicates so we get the existing one newTaggedValue = this.getTaggedValue(name); } if (newTaggedValue == null) { //no existing tagged value found, or we need to create duplicates newTaggedValue = (TaggedValue)this.model.factory.createNewTaggedValue(this, name); } newTaggedValue.tagValue = tagValue; newTaggedValue.save(); return(newTaggedValue); }
internal void removeTaggedValue(TaggedValue taggedValue) { //make sure the collection is current this.eaTaggedValuesCollection.Refresh(); //delete in EA for (short i = 0; i < this.eaTaggedValuesCollection.Count; i++) { var eaTag = eaTaggedValuesCollection.GetAt(i); //if the eaTag equals the wrapped tag then we delete it if (taggedValue.equalsTagObject(eaTag)) { eaTaggedValuesCollection.DeleteAt(i, false); break; } } // remove from list this._taggedValues?.Remove(taggedValue); }
private void populateTreeForDataItem() { var diNode = this.createDataItemNode(this.context, this.tree.Nodes); // find tables with columns that point to this DI // TODO: query beyond scope of Glossay Package?! foreach (TSF_EA.Class clazz in this.ui.Addin.managedPackage.ownedElements.OfType <TSF_EA.Class>()) { if (clazz.HasStereotype("table")) { TreeNode tableNode = null; foreach (TSF_EA.Attribute attribute in clazz.attributes) { if (attribute.HasStereotype("column")) { TSF_EA.TaggedValue tv = attribute.getTaggedValue("EDD::dataitem"); if (tv != null) { var di = tv.tagValue as TSF_EA.Class; if (di != null && di.guid == this.context.guid) { if (tableNode == null) { tableNode = this.createTableNode(clazz, diNode.Nodes); } var columnNode = this.createColumnNode(attribute, tableNode.Nodes); // mark column if not in sync if (this.notInSync(attribute, di)) { columnNode.ForeColor = Color.Red; } } } } } } } }
/// <summary> /// copies only the tagged values necesarry /// </summary> /// <param name="source">the source element</param> /// <param name="target">the target element</param> public void copyTaggedValues(UTF_EA.Element source, UTF_EA.Element target) { //copy tagged values foreach (UTF_EA.TaggedValue sourceTaggedValue in source.taggedValues) { bool updateTaggedValue = true; if (this.settings.ignoredTaggedValues.Contains(sourceTaggedValue.name)) { UTF_EA.TaggedValue targetTaggedValue = target.getTaggedValue(sourceTaggedValue.name); if (targetTaggedValue != null && targetTaggedValue.eaStringValue != string.Empty) { //don't update any of the tagged values of the ignoredTaggeValues if the value is already filled in. updateTaggedValue = false; } } if (updateTaggedValue) { target.addTaggedValue(sourceTaggedValue.name, sourceTaggedValue.eaStringValue); } } }
public TaggedValueMapping(TaggedValue wrappedTaggedValue,string basePath,string targetBasePath) : base((Element)wrappedTaggedValue.owner,wrappedTaggedValue.tagValue as Element,basePath,targetBasePath) { this.wrappedTaggedValue = wrappedTaggedValue; }