示例#1
0
 public override bool OnPostNewElement(IEAElement element)
 {
     if (EAMain.IsDecision(element))
     {
         element.AddTaggedValue(EATaggedValueKeys.DecisionState, element.Stereotype);
         element.AddTaggedValue(EATaggedValueKeys.IsHistoryDecision, false.ToString());
     }
     if (EAMain.IsDecision(element) || EAMain.IsTopic(element))
     {
         element.AddTaggedValue(EATaggedValueKeys.DecisionStateModifiedDate,
                                element.Modified.ToString(CultureInfo.InvariantCulture));
     }
     return(true);
 }
示例#2
0
        private IEnumerable <IEAElement> GetHistory()
        {
            IEnumerable <IEAElement> allDecisionsInPackage = _decisions;

            IEnumerable <IHistoryEntry> history = allDecisionsInPackage.SelectMany(d => Decision.Load(d).History);

            IEnumerable <IEAElement> exisitingHistoryDecisions = _historyPackage.Elements.Where(e => EAMain.IsDecision(e));

            //create non existing and update existing (name)
            var pastDecisions = new List <IEAElement>();

            foreach (IHistoryEntry item in history.ToList())
            {
                string name = string.Format(Messages.ChronologyDecisionName, item.Decision.Name,
                                            item.Modified.ToShortDateString());
                string       stereotype   = item.State;
                DateTime     modified     = item.Modified;
                const string type         = EAConstants.ActionMetaType;
                string       originalGUID = item.Decision.GUID;

                IEAElement pastDecision =
                    exisitingHistoryDecisions.FirstOrDefault(
                        hd => originalGUID.Equals(hd.GetTaggedValueByName(EATaggedValueKeys.OriginalDecisionGuid)) &&
                        modified.ToString(CultureInfo.InvariantCulture)
                        .Equals(hd.GetTaggedValueByName(EATaggedValueKeys.DecisionStateModifiedDate)) &&
                        stereotype.Equals(hd.Stereotype));
                if (pastDecision == null)
                {
                    pastDecision = _historyPackage.CreateElement(name, stereotype, type);
                }
                pastDecision.MetaType = EAConstants.DecisionMetaType;
                pastDecision.Modified = modified;
                pastDecision.AddTaggedValue(EATaggedValueKeys.DecisionStateModifiedDate,
                                            modified.ToString(CultureInfo.InvariantCulture));
                pastDecision.AddTaggedValue(EATaggedValueKeys.DecisionState, stereotype);
                pastDecision.AddTaggedValue(EATaggedValueKeys.IsHistoryDecision, true.ToString());
                pastDecision.AddTaggedValue(EATaggedValueKeys.OriginalDecisionGuid, originalGUID);

                pastDecisions.Add(pastDecision);
            }


            //add topics  and original decisions

            return
                (pastDecisions.Union(
                     _decisions.Select(d => Decision.Load(d))
                     .Where(d => d.HasTopic())
                     .Select(d => EAMain.Repository.GetElementByGUID(d.Topic.GUID))).Union(_decisions));
        }
        public static void CreateAndTraceTopic()
        {
            IEARepository repository = EAMain.Repository;

            if (repository.GetContextItemType() == EANativeType.Element)
            {
                var eaelement = repository.GetContextObject <IEAElement>();
                if (eaelement != null && !EAMain.IsDecision(eaelement) && !EAMain.IsTopic(eaelement))
                {
                    string nameSuggestion  = string.Format(Messages.NameSuggestionTopic, eaelement.Name);
                    var    createTopicView = new CreateTopicDialog(nameSuggestion);
                    if (createTopicView.ShowDialog() == DialogResult.OK)
                    {
                        IEAPackage dvPackage = createTopicView.GetDecisionViewPackage();
                        IEAElement topic     = dvPackage.CreateElement(createTopicView.GetName(),
                                                                       EAConstants.TopicStereoType,
                                                                       EAConstants.ActivityMetaType);
                        topic.MetaType = EAConstants.TopicMetaType;
                        topic.AddTaggedValue(EATaggedValueKeys.DecisionStateModifiedDate,
                                             DateTime.Now.ToString(CultureInfo.InvariantCulture));
                        eaelement.ConnectTo(topic, EAConstants.AbstractionMetaType, EAConstants.RelationTrace);
                        topic.Update();

                        dvPackage.RefreshElements();
                        repository.RefreshModelView(dvPackage.ID);
                        topic.ShowInProjectView();
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Add a new force for each concern if the combination not exists already
        /// </summary>
        /// <param name="force"></param>
        private void AddForceConcerns(IEAElement force)
        {
            IEARepository repository  = EAFacade.EA.Repository;
            string        diagramGuid = _controller.Model.DiagramGUID;
            IEADiagram    diagram     = repository.GetDiagramByGuid(diagramGuid);

            //Add the force for each selected concern
            foreach (var item in _lbConcern.SelectedItems)
            {
                var        selectedItem = (KeyValuePair <string, string>)item;
                IEAElement concern      = repository.GetElementByGUID(selectedItem.Key);

                diagram.AddElement(concern);

                IEAConnector connector = force.ConnectTo(concern, EAConstants.ForcesConnectorType, EAConstants.RelationClassifiedBy);
                if (!connector.TaggedValueExists(EATaggedValueKeys.IsForceConnector, diagramGuid))
                {
                    // Add TaggedValue for new force and concern (having multiple TaggedValues of the same name/data is possible).
                    // The amount of TaggedValues with the same name and data is the amount of forces/concerns in the table.
                    force.AddTaggedValue(EATaggedValueKeys.IsForceElement, diagramGuid);
                    concern.AddTaggedValue(EATaggedValueKeys.IsConcernElement, diagramGuid);

                    // Add the diagramGuid as a TaggedValue (ConnectorTag) to the connector
                    connector.AddTaggedValue(EATaggedValueKeys.IsForceConnector, diagramGuid);
                    _closeWindow = true;
                }
                else //Force concern combination (connector) already exists
                {
                    MessageBox.Show(string.Format(Messages.ForcesViewForceExists, force.Name, concern.Name),
                                    "Force already exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        /// <summary>
        ///     Add deicsion to the diagram and TaggedValue to the decision if it doesn't exist already
        /// </summary>
        /// <param name="element"></param>
        private void AddDecisionToDiagram(IEAElement element)
        {
            if (_listener != null)
            {
                _listener.OnDecisionSelected(element);
                return;
            }

            IEARepository repository = EAMain.Repository;

            string     diagramGuid = _controller.Model.DiagramGUID;
            IEADiagram diagram     = repository.GetDiagramByGuid(diagramGuid);

            diagram.AddElement(element);

            // Only add the TaggedValue once, because the element is already a decision
            if (!element.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, diagramGuid))
            {
                element.AddTaggedValue(EATaggedValueKeys.IsDecisionElement, diagramGuid);
                _closeWindow = true;
            }
            else
            {
                MessageBox.Show(string.Format(Messages.ForcesViewDecisionExists, element.Name),
                                Messages.ForcesViewDecisionExistsTitle,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public void SaveRatings(IEnumerable <Rating> data)
        {
            IEARepository repository = EAMain.Repository;

            foreach (Rating rating in data)
            {
                IEAElement decision = repository.GetElementByGUID(rating.DecisionGUID);
                if (decision == null)
                {
                    continue;
                }
                string forcesTaggedValue = Rating.ConstructForcesTaggedValue(rating.ForceGUID, rating.ConcernGUID);
                if (decision.GetTaggedValueByName(forcesTaggedValue) != null)
                {
                    decision.UpdateTaggedValue(forcesTaggedValue, rating.Value);
                }
                else
                {
                    decision.AddTaggedValue(forcesTaggedValue, rating.Value);
                }
            }
        }
        public bool SaveChanges()
        {
            IEARepository repository = EAMain.Repository;

            //should not happen, need to know where the evaluation result should be saved.
            if (null == _decisionGUID)
            {
                throw new Exception();
            }

            //detect if it is a new rating entry
            if ("".Equals(TaggedValueGUID))
            {
                IEAElement element = repository.GetElementByGUID(_decisionGUID);
                element.AddTaggedValue(SerializeName(), Result);
            }
            else
            {
                //only update
                IEAElement element = repository.GetElementByGUID(_decisionGUID);
                return(element.UpdateTaggedValue(TaggedValueGUID, SerializeName(), Result));
            }
            return(true);
        }
        public bool SaveChanges()
        {
            IEARepository repository = EAMain.Repository;

            //should not happen, need to know where the History Entry should be saved.
            if (null == Decision)
            {
                throw new Exception();
            }

            //detect if it is a new history entry
            if ("".Equals(TaggedValueGUID))
            {
                IEAElement element = repository.GetElementByGUID(Decision.GUID);
                element.AddTaggedValue(EATaggedValueKeys.DecisionStateChange, Serialize());
            }
            else
            {
                //only update
                IEAElement element = repository.GetElementByGUID(Decision.GUID);
                return(element.UpdateTaggedValue(TaggedValueGUID, EATaggedValueKeys.DecisionStateChange, Serialize()));
            }
            return(true);
        }