use of org.finos.waltz.model.roadmap.Roadmap in project waltz by khartec.
the class ScenarioRatingImporter method addMissingColumns.
private void addMissingColumns(List<Measurable> measurables, List<ScenarioRatingRow> ratingRows, Roadmap roadmap, ScenarioAxisItemDao scenarioAxisItemDao, Map<String, ScenarioAxisItem> scenarioAxesByName, Scenario scenario) {
List<String> columns = ratingRows.stream().map(r -> lower(r.column())).distinct().collect(toList());
Map<String, Measurable> allColumnMeasurables = measurables.stream().filter(m -> m.categoryId() == roadmap.columnType().id()).collect(toMap(m -> lower(m.name()), m -> m, (m1, m2) -> m2.concrete() ? m2 : m1));
for (String column : columns) {
if (!scenarioAxesByName.containsKey(column)) {
Measurable measurable = allColumnMeasurables.get(column);
checkNotNull(measurable, String.format("measurable with name [%s] not found", column));
scenarioAxisItemDao.add(scenario.id().get(), AxisOrientation.COLUMN, measurable.entityReference(), 0);
}
}
}
use of org.finos.waltz.model.roadmap.Roadmap in project waltz by khartec.
the class RoadmapGenerator method mkScenario.
private void mkScenario(ApplicationContext ctx, long roadmapId) {
ScenarioDao scenarioDao = getScenarioDao(ctx);
RoadmapDao roadmapDao = getRoadmapDao(ctx);
Roadmap roadmap = roadmapDao.getById(roadmapId);
Scenario scenario = scenarioDao.add(roadmapId, "Current", "admin");
mkAxisItems(ctx, scenario, roadmap);
populateScenario(ctx, scenario);
}
use of org.finos.waltz.model.roadmap.Roadmap in project waltz by khartec.
the class ScenarioRatingImporter method addMissingRows.
private void addMissingRows(List<Measurable> measurables, List<ScenarioRatingRow> ratingRows, Roadmap roadmap, ScenarioAxisItemDao scenarioAxisItemDao, Map<String, ScenarioAxisItem> scenarioAxesByName, Scenario scenario) {
List<String> rows = ratingRows.stream().map(r -> lower(r.row())).distinct().collect(toList());
Map<String, Measurable> allRowMeasurables = measurables.stream().filter(m -> m.categoryId() == roadmap.rowType().id()).collect(toMap(m -> lower(m.name()), m -> m, (m1, m2) -> m2.concrete() ? m2 : m1));
for (String row : rows) {
if (!scenarioAxesByName.containsKey(row)) {
Measurable measurable = allRowMeasurables.get(row);
checkNotNull(measurable, String.format("measurable with name [%s] not found", row));
scenarioAxisItemDao.add(scenario.id().get(), AxisOrientation.ROW, measurable.entityReference(), 0);
}
}
}
use of org.finos.waltz.model.roadmap.Roadmap in project waltz by khartec.
the class ScenarioRatingImporter method importScenarioRatings.
public void importScenarioRatings(String filename) throws IOException {
List<Application> allApps = dsl.select().from(APPLICATION).fetch(ApplicationDao.TO_DOMAIN_MAPPER);
assetCodeToApplicationMap = indexBy(a -> ExternalIdValue.orElse(a.assetCode(), null), allApps);
List<ScenarioRatingRow> ratingRows = parseData(filename);
Map<String, Map<String, List<ScenarioRatingRow>>> rowsGroupedByRoadmapByScenario = ratingRows.stream().collect(groupingBy(ScenarioRatingRow::roadmap, groupingBy(ScenarioRatingRow::scenario)));
// get roadmap id
Map<String, Roadmap> roadmapNameToIdMap = getNameToRoadmapMap(roadmapDao);
List<Measurable> measurables = measurableDao.findAll();
rowsGroupedByRoadmapByScenario.forEach((String roadmapName, Map<String, List<ScenarioRatingRow>> scenarioAndRows) -> {
// get roadmap
Roadmap roadmap = roadmapNameToIdMap.get(lower(roadmapName));
checkNotNull(roadmap, "roadmap [" + roadmapName + "] cannot be null");
// get rating scheme
RatingScheme ratingScheme = ratingSchemeDao.getById(roadmap.ratingSchemeId());
checkNotNull(ratingScheme, "ratingScheme cannot be null");
Map<String, RatingSchemeItem> ratingsByName = indexBy(r -> lower(r.name()), ratingScheme.ratings());
// index available scenarios
Map<String, Scenario> scenariosByName = indexBy(s -> lower(s.name()), scenarioDao.findForRoadmapId(roadmap.id().get()));
scenarioAndRows.forEach((scenarioName, rows) -> updateRatingsForScenario(measurables, roadmap, ratingsByName, rows, scenariosByName, scenarioName));
});
}
Aggregations