예제 #1
0
 /// <summary>
 /// method handles scenario change during synchronization
 /// </summary>
 /// <param name="scenarioChange">instance of step change carrying information about scenario change</param>
 /// <param name="repository">EA repository</param>
 public void handleScenarioChange(StepChange scenarioChange, EA.Repository repository)
 {
     if (scenarioChange.status == 2)
     {
         synchronizationChanges.changeScenario(repository, scenarioChange.scenarioGUID, scenarioChange.itemGUID, scenarioChange.name,
             scenarioChange.stepType, scenarioChange.state, scenarioChange.elementType);
     }
     else if (scenarioChange.status == 0)
     {
         synchronizationDeletions.deleteScenario(repository, scenarioChange.scenarioGUID, scenarioChange.itemGUID, scenarioChange.elementType);
     }
 }
예제 #2
0
 /// <summary>
 /// method handles scenario addition during synchronization
 /// </summary>
 /// <param name="scenarioChange">instance of step change carrying information about scenario addition</param>
 /// <param name="repository">EA repository</param>
 /// <returns>GUID of new scenario</returns>
 public string handleScenarioAddition(StepChange scenarioChange, EA.Repository repository)
 {
     return synchronizationAdditions.addScenario(repository, scenarioChange.itemGUID, scenarioChange.name, scenarioChange.stepType, scenarioChange.state, scenarioChange.elementType);
 }
예제 #3
0
        public void handleUseCaseChanges(string GUID, EA.Element changedElement)
        {
            if (changedElement.Type != "UseCase")
            {
                return;
            }

            // CONSTRAINTS
            EA.Collection changedConstraints = changedElement.Constraints;
            List<ConstraintWrapper> changedConstraintsList = new List<ConstraintWrapper>();

            foreach (EA.Constraint constraint in changedConstraints)
            {
                changedConstraintsList.Add(new ConstraintWrapper(constraint));
            }

            if (!((changedConstraintsList.Count == currentConstraintsList.Count)
                && !changedConstraintsList.Except(currentConstraintsList).Any()))
            {
                List<ConstraintWrapper> createdConstraints = changedConstraintsList.Except(currentConstraintsList).ToList();
                List<ConstraintWrapper> removedConstraints = currentConstraintsList.Except(changedConstraintsList).ToList();

                foreach (ConstraintWrapper constraintWrapper in removedConstraints)
                {
                    PropertyChange propertyChange = new PropertyChange();
                    propertyChange.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
                    propertyChange.itemGUID = GUID;
                    propertyChange.elementType = itemTypes.getElementType(GUID);
                    propertyChange.propertyType = 11;
                    propertyChange.propertyBody = constraintWrapper.constraint.Name;
                    propertyChange.oldPropertyBody = constraintWrapper.constraint.Type;
                    propertyChange.elementDeleted = 1;

                    changeService.saveChange(propertyChange);
                }

                foreach (ConstraintWrapper constraintWrapper in createdConstraints)
                {
                    PropertyChange propertyChange = new PropertyChange();
                    propertyChange.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
                    propertyChange.itemGUID = GUID;
                    propertyChange.elementType = itemTypes.getElementType(GUID);
                    propertyChange.propertyType = 10;
                    propertyChange.propertyBody = constraintWrapper.constraint.Name + ",notes:=" + constraintWrapper.constraint.Notes;
                    propertyChange.oldPropertyBody = constraintWrapper.constraint.Type;

                    changeService.saveChange(propertyChange);
                }
            }

            // SCENARIO
            EA.Collection changedScenarios = changedElement.Scenarios;
            List<ScenarioWrapper> changedScenariosList = new List<ScenarioWrapper>();

            foreach (EA.Scenario scenario in changedScenarios)
            {
                changedScenariosList.Add(new ScenarioWrapper(scenario));
            }

            Dictionary<string, ScenarioWrapper> changedDict = new Dictionary<string, ScenarioWrapper>();
            foreach (ScenarioWrapper wrapper in changedScenariosList)
            {
                if (!changedDict.ContainsKey(wrapper.getGUID()))
                {
                    changedDict.Add(wrapper.getGUID(), wrapper);
                }
            }

            Dictionary<string, ScenarioWrapper> currentDict = new Dictionary<string, ScenarioWrapper>();
            foreach (ScenarioWrapper wrapper in currentScenarioList)
            {
                if (!currentDict.ContainsKey(wrapper.getGUID()))
                {
                    currentDict.Add(wrapper.getGUID(), wrapper);
                }
            }

            if (!((changedScenariosList.Count == currentScenarioList.Count)
                && !changedScenariosList.Except(currentScenarioList).Any()))
            {
                // scenario delete
                foreach (KeyValuePair<string, ScenarioWrapper> scenario in currentDict)
                {
                    if (!changedDict.ContainsKey(scenario.Key))
                    {
                        EA.Scenario eaScenario = scenario.Value.scenario;
                        StepChange scenarioChange = new StepChange();
                        scenarioChange.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
                        scenarioChange.itemGUID = GUID;
                        scenarioChange.elementType = itemTypes.getElementType(GUID);
                        scenarioChange.status = 0;
                        scenarioChange.scenarioGUID = eaScenario.ScenarioGUID;

                        changeService.saveChange(scenarioChange);
                    }
                }

                // scenario add
                foreach (KeyValuePair<string, ScenarioWrapper> scenario in changedDict)
                {
                    if (!currentDict.ContainsKey(scenario.Key))
                    {
                        // pridaj scenar
                        EA.Scenario eaScenario = scenario.Value.scenario;
                        StepChange scenarioChange = new StepChange();
                        scenarioChange.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
                        scenarioChange.itemGUID = GUID;
                        scenarioChange.elementType = itemTypes.getElementType(GUID);
                        scenarioChange.name = eaScenario.Name;
                        scenarioChange.stepType = eaScenario.Type;
                        scenarioChange.status = 1;
                        scenarioChange.scenarioGUID = eaScenario.ScenarioGUID;
                        scenarioChange.state = eaScenario.XMLContent;

                        changeService.saveChange(scenarioChange);
                    }
                    else
                    {
                        try
                        {
                            // zisti zmeny v scenari
                            EA.Scenario eaChangedScenario = scenario.Value.scenario;
                            EA.Scenario eaCurrentScenario = currentDict[scenario.Key].scenario;
                            bool wasChanged = false;

                            StepChange changedScenario = new StepChange();
                            changedScenario.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
                            changedScenario.itemGUID = GUID;
                            changedScenario.elementType = itemTypes.getElementType(GUID);
                            changedScenario.status = 2;
                            changedScenario.scenarioGUID = eaChangedScenario.ScenarioGUID;
                            changedScenario.name = eaChangedScenario.Name;
                            changedScenario.stepType = eaChangedScenario.Type;
                            changedScenario.state = eaChangedScenario.XMLContent;

                            if (eaChangedScenario.Name != eaCurrentScenario.Name)
                            {
                                wasChanged = true;
                                changedScenario.name = eaChangedScenario.Name;
                            }

                            if (eaChangedScenario.Type != eaCurrentScenario.Type)
                            {
                                wasChanged = true;
                                changedScenario.stepType = eaChangedScenario.Type;
                            }

                            if (eaChangedScenario.XMLContent != eaCurrentScenario.XMLContent)
                            {
                                wasChanged = true;
                                changedScenario.state = eaChangedScenario.XMLContent;
                            }

                            if (wasChanged)
                            {
                                changeService.saveChange(changedScenario);
                            }
                        }
                        catch (Exception ex) { }
                    }
                }
            }

            // EXTENSION POINTS
            if (!currentItem.ExtensionPoints.Equals(changedElement.ExtensionPoints))
            {
                PropertyChange propertyChange = new PropertyChange();
                propertyChange.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
                propertyChange.itemGUID = GUID;
                propertyChange.elementType = itemTypes.getElementType(GUID);
                propertyChange.propertyType = 13;
                propertyChange.propertyBody = changedElement.ExtensionPoints;
                propertyChange.oldPropertyBody = currentItem.ExtensionPoints;

                changeService.saveChange(propertyChange);
            }
        }