private void SaveRelations(IEAElement element) { IEARepository repository = EAMain.Repository; IEnumerable <string> deleted = element.FindConnectors(EAConstants.RelationMetaType, EAConstants.RelationDependsOn, EAConstants.RelationExcludedBy, EAConstants.RelationCausedBy, EAConstants.RelationReplaces) .Select(c => c.GUID) .Except(RelatedDecisions.Select(a => a.RelationGUID)); foreach (string connector in deleted) { element.RemoveConnector(repository.GetConnectorByGUID(connector)); } foreach (IDecisionRelation connector in RelatedDecisions) { if ("".Equals(connector.RelationGUID) || null == connector.RelationGUID) { IEAElement client = repository.GetElementByGUID(connector.Decision.GUID); IEAElement supplier = repository.GetElementByGUID(connector.RelatedDecision.GUID); client.ConnectTo(supplier, EAConstants.RelationMetaType, connector.Type); } } }
private void LoadAlternatives(IEAElement element) { Alternatives.Clear(); IEnumerable <IDecisionRelation> alternatives = element.FindConnectors(EAConstants.RelationMetaType, EAConstants.RelationAlternativeFor) .Select(a => (IDecisionRelation) new DecisionRelation(this, a)); foreach (IDecisionRelation alternative in alternatives) { Alternatives.Add(alternative); } }
private void LoadTraces(IEAElement element) { Traces.Clear(); IEnumerable <ITraceLink> traces = element.FindConnectors("", EAConstants.RelationTrace) .Select(a => (ITraceLink) new TraceLink(this, a)); foreach (ITraceLink trace in traces) { Traces.Add(trace); } }
private void LoadRelations(IEAElement element) { RelatedDecisions.Clear(); IEnumerable <IDecisionRelation> relations = element.FindConnectors(EAConstants.RelationMetaType, EAConstants.RelationDependsOn, EAConstants.RelationExcludedBy, EAConstants.RelationCausedBy, EAConstants.RelationReplaces) .Select( a => (IDecisionRelation) new DecisionRelation(this, a)); foreach (IDecisionRelation relation in relations) { RelatedDecisions.Add(relation); } }
/// <summary> /// Removes a force/concern from the table and diagram (if necessary). Diagram should be update afterwards /// </summary> /// <param name="rowIndex">The element to be removed</param> private void RemoveForceFromDiagram(int rowIndex) { //Get the GUIDs from the diagram, force and concern string diagramGuid = _controller.Model.DiagramGUID; string forceGuid = _forcesTable.Rows[rowIndex].Cells[ForcesTableContext.ForceGUIDColumnIndex].Value.ToString(); string concernGuid = _forcesTable.Rows[rowIndex].Cells[ForcesTableContext.ConcernGUIDColumnIndex].Value.ToString(); //Get the diagram, force and concern objects IEARepository repository = EAMain.Repository; IEADiagram diagram = repository.GetDiagramByGuid(diagramGuid); IEAElement force = repository.GetElementByGUID(forceGuid); IEAElement concern = repository.GetElementByGUID(concernGuid); foreach ( IEAConnector connector in force.FindConnectors(concern, EAConstants.RelationClassifiedBy, EAConstants.ForcesConnectorType)) { if (connector.TaggedValueExists(EATaggedValueKeys.IsForceConnector, diagramGuid)) { connector.RemoveTaggedValue(EATaggedValueKeys.IsForceConnector, diagramGuid); if (!connector.TaggedValueExists(EATaggedValueKeys.IsForceConnector)) { force.RemoveConnector(connector); concern.RemoveConnector(connector); } break; } } //Remove the TaggedValue of the force and concern force.RemoveTaggedValue(EATaggedValueKeys.IsForceElement, diagramGuid); concern.RemoveTaggedValue(EATaggedValueKeys.IsConcernElement, diagramGuid); //Delete the element if it is not used in the diagram/table anymore if (!ElementExistsInDiagram(force, diagramGuid)) { diagram.RemoveElement(force); } if (!ElementExistsInDiagram(concern, diagramGuid)) { diagram.RemoveElement(concern); } }
public void EA_ElementTests() { // Properties { Element element = _e.GetDecisionPackageElement(); Assert.IsTrue("" != element.Abstract); Assert.IsTrue("" == element.ActionFlags); Assert.IsTrue("" == element.Alias); Assert.IsTrue(0 == element.AssociationClassConnectorID); Assert.IsTrue(0 == element.Attributes.Count); Assert.IsTrue(0 == element.AttributesEx.Count); Assert.IsTrue("" != element.Author); Assert.IsTrue(0 == element.BaseClasses.Count); Assert.IsTrue(0 == element.ClassfierID); Assert.IsTrue(0 == element.ClassifierID); Assert.IsTrue("" == element.ClassifierName); Assert.IsTrue("" == element.ClassifierType); Assert.IsTrue("" != element.Complexity); Assert.IsNull(element.CompositeDiagram); Assert.IsTrue(0 < element.Connectors.Count); Assert.IsTrue(0 == element.Constraints.Count); Assert.IsTrue(0 == element.ConstraintsEx.Count); Assert.IsTrue(DateTime.Now > element.Created); Assert.IsTrue(0 < element.CustomProperties.Count); Assert.IsTrue(0 < element.Diagrams.Count); Assert.IsTrue("" == element.Difficulty); Assert.IsTrue(0 == element.Efforts.Count); Assert.IsTrue("" != element.ElementGUID); Assert.IsTrue(0 < element.ElementID); Assert.IsTrue(0 < element.Elements.Count); Assert.IsTrue(0 == element.EmbeddedElements.Count); Assert.IsTrue("" == element.EventFlags); Assert.IsTrue("" == element.ExtensionPoints); Assert.IsTrue(0 == element.Files.Count); Assert.IsTrue("" == element.Genfile); Assert.IsTrue("" == element.Genlinks); Assert.IsTrue("" != element.Gentype); Assert.IsTrue("" == element.Header1); Assert.IsTrue("" == element.Header2); Assert.IsFalse(element.IsActive); Assert.IsFalse(element.IsComposite); Assert.IsFalse(element.IsLeaf); Assert.IsTrue(element.IsNew); Assert.IsFalse(element.IsSpec); Assert.IsTrue(0 == element.Issues.Count); Assert.IsFalse(element.Locked); Assert.IsTrue("" != element.MetaType); Assert.IsTrue(0 == element.Methods.Count); Assert.IsTrue(0 == element.MethodsEx.Count); Assert.IsTrue(0 == element.Metrics.Count); Assert.IsTrue("" == element.MiscData[0]); Assert.IsTrue(DateTime.Now > element.Modified); Assert.IsTrue("" == element.Multiplicity); Assert.IsTrue("" != element.Name); Assert.IsTrue("" == element.Notes); Assert.IsTrue(ObjectType.otElement == element.ObjectType); Assert.IsTrue(0 < element.PackageID); Assert.IsTrue(0 == element.ParentID); Assert.IsTrue(0 == element.Partitions.Count); Assert.IsTrue("" == element.Persistence); Assert.IsTrue("" != element.Phase); Assert.IsTrue("" == element.Priority); Assert.IsNotNull(element.Properties); Assert.IsTrue(0 == element.PropertyType); Assert.IsTrue(0 == element.Realizes.Count); Assert.IsTrue(0 == element.Requirements.Count); Assert.IsTrue(0 == element.RequirementsEx.Count); Assert.IsTrue(0 == element.Resources.Count); Assert.IsTrue(0 == element.Risks.Count); Assert.IsTrue("" == element.RunState); Assert.IsTrue(0 == element.Scenarios.Count); Assert.IsTrue(0 == element.StateTransitions.Count); Assert.IsTrue("" != element.Status); Assert.IsTrue("" != element.Stereotype); Assert.IsTrue("" != element.StereotypeEx); Assert.IsTrue("" == element.StyleEx); Assert.IsTrue(0 == element.Subtype); Assert.IsTrue("" == element.Tablespace); Assert.IsTrue("" == element.Tag); Assert.IsTrue(0 < element.TaggedValues.Count); Assert.IsTrue(0 < element.TaggedValuesEx.Count); Assert.IsTrue(0 == element.Tests.Count); Assert.IsTrue(1 == element.TreePos); Assert.IsTrue("" != element.Type); Assert.IsTrue("" != element.Version); Assert.IsTrue("" != element.Visibility); } // Operations { // GetTracedElements (no traced elements in example model) IEAElement element = _e.GetForcesDecisionElement(); IEnumerable <IEAElement> elements = element.GetTracedElements(); Assert.IsTrue(!elements.Any()); } { // GetDiagrams IEAElement element = _e.GetForcesDecisionElement(); IEADiagram[] diagrams = element.GetDiagrams(); Assert.IsTrue(diagrams.Any()); } { // GetConnectors / ConnectTo / Update / Refresh / FindConnectors / RemoveConnector IEAElement element = _e.GetForcesDecisionElement(); const string myType = "Dependency"; const string mySterotype = "my stereotype"; List <IEAConnector> connectors = element.GetConnectors(); Assert.IsTrue(connectors.Any()); IEAConnector c = connectors.ElementAt(0); IEAElement client = c.GetClient(); IEAConnector nc = client.ConnectTo(element, myType, mySterotype); Assert.IsTrue(element.Update()); element.Refresh(); IList <IEAConnector> flows = client.FindConnectors(element, mySterotype, myType); Assert.IsNotNull(flows); Assert.IsTrue(flows.Any()); element.RemoveConnector(nc); Assert.IsTrue(element.Update()); element.Refresh(); flows = client.FindConnectors(element, mySterotype, myType); Assert.IsNotNull(flows); Assert.IsFalse(flows.Any()); } /* Disabled pending better understanding of Chronological view * { // GetElements * IEAElement element = _e.GetChronologyTopicElement(); * List<IEAElement> children = element.GetElements(); * Assert.IsTrue(0 < children.Count()); * } * * { // AddTaggedValue / TaggedValueExists / GetTaggedValue / RemoveTaggedValue * string taggedValueLabel = "MyTaggedValue"; * string taggedValueData = "my data"; * IEAElement element = _e.GetChronologyDecisionElement(); * Assert.IsFalse(element.TaggedValueExists(taggedValueLabel)); * element.AddTaggedValue(taggedValueLabel, taggedValueData); * Assert.IsTrue(element.TaggedValueExists(taggedValueLabel)); * Assert.IsTrue(element.TaggedValueExists(taggedValueLabel, taggedValueData)); * string myData = element.GetTaggedValueByName(taggedValueLabel); * Assert.IsTrue(myData == taggedValueData); * element.RemoveTaggedValue(taggedValueLabel, taggedValueData); * Assert.IsFalse(element.TaggedValueExists(taggedValueLabel)); * } */ }