use of org.finos.waltz.service.measurable_rating.MeasurableRatingService in project waltz by khartec.
the class AllocationHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
AllocationSchemeService schemesService = ctx.getBean(AllocationSchemeService.class);
MeasurableService measurableService = ctx.getBean(MeasurableService.class);
MeasurableCategoryDao categoryDao = ctx.getBean(MeasurableCategoryDao.class);
MeasurableRatingService ratingService = ctx.getBean(MeasurableRatingService.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
Tuple4<Application, MeasurableCategory, List<Measurable>, AllocationScheme> stuff = setup(dsl, schemesService, measurableService, categoryDao, applicationService);
addRating(ratingService, stuff, 0);
addRating(ratingService, stuff, 1);
// addRating(ratingService, stuff, 2);
// addAllocation(dsl, stuff, 0, 50);
addAllocation(dsl, stuff, 1, 20);
Long measurableCategory = stuff.v2.id().get();
dumpRatings(dsl, stuff.v4);
dumpAllocs(dsl, stuff.v4);
doDiff(dsl, measurableCategory);
System.out.println(ratingService.findByCategory(measurableCategory));
}
use of org.finos.waltz.service.measurable_rating.MeasurableRatingService 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();
});
}
Aggregations