use of org.finos.waltz.data.scenario.ScenarioAxisItemDao in project waltz by khartec.
the class RoadmapGenerator method addAxisItems.
private void addAxisItems(ApplicationContext ctx, List<Measurable> categories, Long scenarioId, AxisOrientation row) {
ScenarioAxisItemDao scenarioAxisItemDao = getScenarioAxisItemDao(ctx);
categories.forEach(c -> scenarioAxisItemDao.add(scenarioId, // orientation
row, c.entityReference(), 10));
}
use of org.finos.waltz.data.scenario.ScenarioAxisItemDao 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.data.scenario.ScenarioAxisItemDao in project waltz by khartec.
the class RoadmapGenerator method populateScenario.
private void populateScenario(ApplicationContext ctx, Scenario scenario) {
ScenarioAxisItemDao scenarioAxisItemDao = getScenarioAxisItemDao(ctx);
MeasurableRatingService measurableRatingService = getMeasurableRatingService(ctx);
scenario.id().ifPresent(scenarioId -> {
Collection<ScenarioAxisItem> axisItems = scenarioAxisItemDao.findForScenarioId(scenarioId);
Map<AxisOrientation, Collection<ScenarioAxisItem>> byOrientation = groupBy(ScenarioAxisItem::axisOrientation, axisItems);
IdSelectionOptions options = mkOpts(scenario.entityReference());
Map<Long, Collection<MeasurableRating>> ratingsByMeasurableId = groupBy(MeasurableRating::measurableId, measurableRatingService.findByMeasurableIdSelector(options));
List<ScenarioRatingItemRecord> scenarioRatingItems = IntStream.range(0, randomIntBetween(10, 300)).mapToObj(i -> tuple(randomPick(byOrientation.get(AxisOrientation.COLUMN)), randomPick(byOrientation.get(AxisOrientation.ROW)))).map(t -> t.map1(d -> d.domainItem().id()).map2(d -> d.domainItem().id())).map(t -> t.concat(tuple(randomPick(ratingsByMeasurableId.get(t.v1)), randomPick(ratingsByMeasurableId.get(t.v2))))).map(t -> {
MeasurableRating rating = t.v3 != null ? t.v3 : t.v4;
ScenarioRatingItemRecord record = getDsl(ctx).newRecord(SCENARIO_RATING_ITEM);
record.setScenarioId(scenarioId);
record.setColumnId(t.v1);
record.setColumnKind(EntityKind.MEASURABLE.name());
record.setRowId(t.v2);
record.setRowKind(EntityKind.MEASURABLE.name());
record.setDomainItemId(rating.entityReference().id());
record.setDomainItemKind(rating.entityReference().kind().name());
record.setRating(String.valueOf(rating.rating()));
record.setLastUpdatedBy("admin");
record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
return record;
}).collect(Collectors.toList());
getDsl(ctx).batchInsert(scenarioRatingItems).execute();
});
}
use of org.finos.waltz.data.scenario.ScenarioAxisItemDao in project waltz by khartec.
the class ScenarioHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
ScenarioService scenarioService = ctx.getBean(ScenarioService.class);
ScenarioAxisItemDao scenarioAxisItemDao = ctx.getBean(ScenarioAxisItemDao.class);
int[] result = scenarioAxisItemDao.reorder(22L, AxisOrientation.ROW, newArrayList(118L, 161L));
System.out.println(Arrays.toString(result));
}
use of org.finos.waltz.data.scenario.ScenarioAxisItemDao 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);
}
}
}
Aggregations