use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class UpdateMeasurableNameCommandProcessor method preview.
public TaxonomyChangePreview preview(TaxonomyChangeCommand cmd) {
doBasicValidation(cmd);
Measurable m = validatePrimaryMeasurable(measurableService, cmd);
ImmutableTaxonomyChangePreview.Builder preview = ImmutableTaxonomyChangePreview.builder().command(ImmutableTaxonomyChangeCommand.copyOf(cmd).withPrimaryReference(m.entityReference()));
if (hasNoChange(m.name(), cmd.param(PARAM_NAME), "Name")) {
return preview.build();
}
addToPreview(preview, findCurrentRatingMappings(measurableRatingService, cmd), Severity.INFORMATION, "Current app mappings exist to item, these may be misleading if the name change alters the meaning of this item");
return preview.build();
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class UnionHarness method measurableIdSelectorFactory_mkForFlowDiagram.
private static void measurableIdSelectorFactory_mkForFlowDiagram(ApplicationContext ctx) {
Select<Record1<Long>> selector = new MeasurableIdSelectorFactory().apply(mkOpts(mkRef(EntityKind.FLOW_DIAGRAM, 12L)));
List<Measurable> measurables = ctx.getBean(MeasurableDao.class).findByMeasurableIdSelector(selector);
System.out.println(measurables.size());
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class ScenarioRatingImporter method mkScenarioRatingRecords.
private List<ScenarioRatingItemRecord> mkScenarioRatingRecords(List<Measurable> measurables, Map<String, RatingSchemeItem> ratingsByName, List<ScenarioRatingRow> rows, Scenario scenario) {
Collection<ScenarioAxisItem> scenarioAxes = scenarioAxisItemDao.findForScenarioId(scenario.id().get());
Map<Long, Measurable> measurablesById = indexBy(m -> m.id().get(), measurables);
Map<String, ScenarioAxisItem> scenarioAxesByName = scenarioAxes.stream().map(sa -> Tuple.tuple(lower(measurablesById.get(sa.domainItem().id()).name()), sa)).collect(toMap(t -> t.v1(), t -> t.v2()));
return rows.stream().map(r -> {
ScenarioAxisItem columnAxis = scenarioAxesByName.get(lower(r.column()));
checkNotNull(columnAxis, "columnAxis cannot be null");
checkTrue(columnAxis.axisOrientation().equals(AxisOrientation.COLUMN), "column does not match a oolumn axis");
ScenarioAxisItem rowAxis = scenarioAxesByName.get(lower(r.row()));
checkNotNull(rowAxis, "rowAxis cannot be null");
checkTrue(rowAxis.axisOrientation().equals(AxisOrientation.ROW), "row does not match a row axis");
Application app = assetCodeToApplicationMap.get(r.assetCode());
checkNotNull(app, String.format("Application with asset code[%s] cannot be null", r.assetCode()));
RatingSchemeItem rating = ratingsByName.get(lower(r.rating()));
checkNotNull(rating, String.format("rating [%s] cannot be null", r.rating()));
ScenarioRatingItemRecord record = new ScenarioRatingItemRecord();
record.setScenarioId(scenario.id().get());
record.setRating(rating.rating().toString());
record.setDomainItemKind(EntityKind.APPLICATION.name());
record.setDomainItemId(app.id().get());
record.setRowKind(rowAxis.domainItem().kind().name());
record.setRowId(rowAxis.domainItem().id());
record.setColumnKind(columnAxis.domainItem().kind().name());
record.setColumnId(columnAxis.domainItem().id());
record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
record.setLastUpdatedBy(r.providedBy());
record.setDescription(r.description());
return record;
}).collect(toList());
}
use of org.finos.waltz.model.measurable.Measurable 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.measurable.Measurable 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