use of org.finos.waltz.model.scenario.Scenario in project waltz by khartec.
the class ScenarioDao method add.
public Scenario add(long roadmapId, String name, String userId) {
Scenario scenario = ImmutableScenario.builder().roadmapId(roadmapId).name(name).description("").entityLifecycleStatus(EntityLifecycleStatus.PENDING).scenarioType(ScenarioType.INTERIM).releaseStatus(ReleaseLifecycleStatus.DRAFT).effectiveDate(today()).lastUpdatedAt(nowUtc()).lastUpdatedBy(userId).position(0).build();
ScenarioRecord record = TO_RECORD_MAPPER.apply(scenario, dsl);
record.store();
return ImmutableScenario.copyOf(scenario).withId(record.getId());
}
use of org.finos.waltz.model.scenario.Scenario 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.scenario.Scenario in project waltz by khartec.
the class ScenarioEndpoint method registerGetScenarioById.
private void registerGetScenarioById(String path) {
getForDatum(path, (request, resp) -> {
long scenarioId = getId(request);
Scenario scenario = scenarioService.getById(scenarioId);
return ImmutableFullScenario.builder().scenario(scenario).axisDefinitions(scenarioAxisItemService.findForScenarioId(scenarioId)).ratings(scenarioRatingItemService.findForScenarioId(scenarioId)).roadmap(roadmapService.getById(scenario.roadmapId())).build();
});
}
use of org.finos.waltz.model.scenario.Scenario in project waltz by khartec.
the class ScenarioRatingItemService method writeUpdateRatingLog.
private void writeUpdateRatingLog(ChangeScenarioCommand command, String userId) {
String message;
Application application = applicationService.getById(command.appId());
Scenario scenario = scenarioService.getById(command.scenarioId());
List<RatingSchemeItem> ratings = ratingSchemeService.getById(command.ratingSchemeId()).ratings();
message = String.format("Application %s (%s), moved from %s to %s for %s", ExternalIdValue.orElse(application.assetCode(), "Unknown"), application.name(), getRatingName(ratings, command.previousRating()), getRatingName(ratings, command.rating()), scenario.name());
changeLogService.write(mkBasicLogEntry(command.scenarioId(), message, userId));
}
use of org.finos.waltz.model.scenario.Scenario 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);
}
Aggregations