Search in sources :

Example 1 with Scenario

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());
}
Also used : ScenarioRecord(org.finos.waltz.schema.tables.records.ScenarioRecord) Scenario(org.finos.waltz.model.scenario.Scenario) ImmutableScenario(org.finos.waltz.model.scenario.ImmutableScenario)

Example 2 with Scenario

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);
        }
    }
}
Also used : ICsvMapReader(org.supercsv.io.ICsvMapReader) ScenarioAxisItemDao(org.finos.waltz.data.scenario.ScenarioAxisItemDao) APPLICATION(org.finos.waltz.schema.tables.Application.APPLICATION) EntityKind(org.finos.waltz.model.EntityKind) RatingScheme(org.finos.waltz.model.rating.RatingScheme) DIConfiguration(org.finos.waltz.service.DIConfiguration) StringUtilities.lower(org.finos.waltz.common.StringUtilities.lower) CsvPreference(org.supercsv.prefs.CsvPreference) Scenario(org.finos.waltz.model.scenario.Scenario) ArrayList(java.util.ArrayList) Checks.checkTrue(org.finos.waltz.common.Checks.checkTrue) Measurable(org.finos.waltz.model.measurable.Measurable) RatingSchemeItem(org.finos.waltz.model.rating.RatingSchemeItem) SCENARIO_RATING_ITEM(org.finos.waltz.schema.tables.ScenarioRatingItem.SCENARIO_RATING_ITEM) Map(java.util.Map) DSLContext(org.jooq.DSLContext) Application(org.finos.waltz.model.application.Application) MeasurableDao(org.finos.waltz.data.measurable.MeasurableDao) ScenarioDao(org.finos.waltz.data.scenario.ScenarioDao) Collection(java.util.Collection) IOException(java.io.IOException) AxisOrientation(org.finos.waltz.model.AxisOrientation) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MapUtilities.indexBy(org.finos.waltz.common.MapUtilities.indexBy) ScenarioRatingItemRecord(org.finos.waltz.schema.tables.records.ScenarioRatingItemRecord) CsvMapReader(org.supercsv.io.CsvMapReader) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) List(java.util.List) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) ScenarioAxisItem(org.finos.waltz.model.scenario.ScenarioAxisItem) Tuple(org.jooq.lambda.tuple.Tuple) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) RatingSchemeDAO(org.finos.waltz.data.rating_scheme.RatingSchemeDAO) RoadmapDao(org.finos.waltz.data.roadmap.RoadmapDao) Roadmap(org.finos.waltz.model.roadmap.Roadmap) Measurable(org.finos.waltz.model.measurable.Measurable)

Example 3 with Scenario

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();
    });
}
Also used : ImmutableFullScenario(org.finos.waltz.web.json.ImmutableFullScenario) Scenario(org.finos.waltz.model.scenario.Scenario)

Example 4 with Scenario

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));
}
Also used : Application(org.finos.waltz.model.application.Application) Scenario(org.finos.waltz.model.scenario.Scenario) RatingSchemeItem(org.finos.waltz.model.rating.RatingSchemeItem)

Example 5 with Scenario

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);
}
Also used : Roadmap(org.finos.waltz.model.roadmap.Roadmap) RoadmapDao(org.finos.waltz.data.roadmap.RoadmapDao) ScenarioDao(org.finos.waltz.data.scenario.ScenarioDao) Scenario(org.finos.waltz.model.scenario.Scenario)

Aggregations

Scenario (org.finos.waltz.model.scenario.Scenario)14 RoadmapDao (org.finos.waltz.data.roadmap.RoadmapDao)6 ScenarioDao (org.finos.waltz.data.scenario.ScenarioDao)6 Application (org.finos.waltz.model.application.Application)6 Roadmap (org.finos.waltz.model.roadmap.Roadmap)6 ScenarioRatingItemRecord (org.finos.waltz.schema.tables.records.ScenarioRatingItemRecord)6 Collectors (java.util.stream.Collectors)5 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)5 MeasurableDao (org.finos.waltz.data.measurable.MeasurableDao)5 ScenarioAxisItemDao (org.finos.waltz.data.scenario.ScenarioAxisItemDao)5 AxisOrientation (org.finos.waltz.model.AxisOrientation)5 EntityKind (org.finos.waltz.model.EntityKind)5 Measurable (org.finos.waltz.model.measurable.Measurable)5 RatingSchemeItem (org.finos.waltz.model.rating.RatingSchemeItem)5 ScenarioAxisItem (org.finos.waltz.model.scenario.ScenarioAxisItem)5 DSLContext (org.jooq.DSLContext)5 IOException (java.io.IOException)4 InputStreamReader (java.io.InputStreamReader)4 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4