public void Render(KAOSModel model) { var goals = model.Exceptions().SelectMany(x => new[] { x.AnchorGoal(), x.ResolvingGoal() }); goals = goals.Union(model.ObstacleAssumptions().SelectMany(x => new[] { x.Anchor() })).Distinct(); var obstacles = model.ObstacleAssumptions().SelectMany(x => new[] { x.Obstacle() }); foreach (var g in goals) { Render(g); } foreach (var o in obstacles) { Render(o); } foreach (var e in model.Exceptions()) { Render(e); } foreach (var e in model.ObstacleAssumptions()) { Render(e); } }
void PropagateRemove(Goal anchor_goal, Obstacle obstacle) { IEnumerable <Goal> goals = GetGoalsToPropagate(anchor_goal, obstacle); foreach (var goal in goals) { var assumptions = _model.ObstacleAssumptions().Where(x => x.AnchorGoalIdentifier == goal.Identifier & x.ResolvedObstacleIdentifier == obstacle.Identifier).ToArray(); foreach (var a in assumptions) { _model.obstacleRepository.Remove(a); } } }
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); }