void RemoveReplacement(Resolution resolution) { var e = _model.Replacements().Where(x => x.AnchorGoalIdentifier == resolution.AnchorIdentifier & x.ResolvedObstacleIdentifier == resolution.ObstacleIdentifier & x.ResolvingGoalIdentifier == resolution.ResolvingGoalIdentifier); _model.goalRepository.Remove(e); foreach (var ee in e) { var anchorRefinements = _model.GoalRefinements(x => x.ParentGoalIdentifier == resolution.AnchorIdentifier); if (anchorRefinements.Count() > 1) { throw new IntegrationException(IntegrationException.SINGLE_REFINEMENT_ONLY); } if (anchorRefinements.Count() == 0) { throw new IntegrationException(IntegrationException.ANCHOR_NO_REFINEMENT); } var anchorRefinement = anchorRefinements.Single(); // Remove replacing goal anchorRefinement.SubGoalIdentifiers = new HashSet <GoalRefinee> ( anchorRefinement.SubGoalIdentifiers.Where( x => x.Identifier != resolution.ResolvingGoalIdentifier)); // Add all replaced goals foreach (var item in ee.ReplacedGoals) { anchorRefinement.Add(item); } } }
public static Document ExportModel(KAOSModel _model) { mapping = new Dictionary <Omnigraffle.Sheet, Dictionary <string, Omnigraffle.ShapedGraphic> >(); var document = new Omnigraffle.Document(); var canvas = new Omnigraffle.Sheet(1, string.Format("Model")); var shapes = new Dictionary <string, IList <Graphic> >(); var u = new GoalModelGenerator(canvas, shapes); u.Render(_model); document.Canvas.Add(canvas); var s2 = new Omnigraffle.Sheet(1, "Goal and Obstacle Model"); var u2 = new GoalAndObstacleModelGenerator(s2, new Dictionary <string, IList <Graphic> >()); u2.Render(_model); document.Canvas.Add(s2); int i = 0; foreach (var o in _model.Obstructions().Select(x => x.Obstacle())) { i++; var s = new Omnigraffle.Sheet(1, string.Format($"Obstacle diagram for '{o.FriendlyName}'")); var u3 = new ObstacleDiagramGenerator(s, new Dictionary <string, IList <Graphic> >()); u3.Render(o, _model); document.Canvas.Add(s); } i = 0; foreach (var goalWithException in _model.Exceptions().Select(x => x.AnchorGoal()) .Union(_model.Replacements().Select(x => x.ResolvingGoal())) .Union(_model.ObstacleAssumptions().Select(x => x.Anchor())) .Distinct()) { i++; var s = new Omnigraffle.Sheet(1, string.Format($"Exception diagram for '{goalWithException.FriendlyName}'")); var u3 = new ExceptionDiagramGenerator(s, new Dictionary <string, IList <Graphic> >()); u3.Render(goalWithException, _model); document.Canvas.Add(s); } return(document); }