use of org.finos.waltz.model.measurable.Measurable 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.measurable.Measurable in project waltz by khartec.
the class TaxonomyManagementUtilities method validateMeasurableInCategory.
public static Measurable validateMeasurableInCategory(MeasurableService measurableService, long measurableId, long categoryId) {
Measurable measurable = measurableService.getById(measurableId);
checkNotNull(measurable, "Cannot find measurable [%d]", measurableId);
checkTrue(categoryId == measurable.categoryId(), "Measurable [%s / %d] is not in category [%d], instead it is in category [%d]", measurable.name(), measurable.id(), categoryId, measurable.categoryId());
return measurable;
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class AddMeasurableCommandProcessor method preview.
public TaxonomyChangePreview preview(TaxonomyChangeCommand cmd) {
doBasicValidation(cmd);
Measurable m = validatePrimaryMeasurable(measurableService, cmd);
return ImmutableTaxonomyChangePreview.builder().command(ImmutableTaxonomyChangeCommand.copyOf(cmd).withPrimaryReference(m.entityReference())).build();
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class AddMeasurableCommandProcessor method apply.
public TaxonomyChangeCommand apply(TaxonomyChangeCommand cmd, String userId) {
doBasicValidation(cmd);
validatePrimaryMeasurable(measurableService, cmd);
Measurable primaryReference = measurableService.getById(cmd.primaryReference().id());
Optional<Long> parentId = cmd.changeType() == TaxonomyChangeType.ADD_CHILD ? primaryReference.id() : primaryReference.parentId();
Measurable newMeasurable = ImmutableMeasurable.builder().categoryId(cmd.changeDomain().id()).parentId(parentId).name(getNameParam(cmd)).description(mkSafe(getDescriptionParam(cmd))).externalId(Optional.ofNullable(getExternalIdParam(cmd))).concrete(getConcreteParam(cmd, true)).lastUpdatedBy(userId).lastUpdatedAt(DateTimeUtilities.nowUtc()).build();
measurableService.create(newMeasurable, userId);
return ImmutableTaxonomyChangeCommand.copyOf(cmd).withLastUpdatedAt(DateTimeUtilities.nowUtc()).withLastUpdatedBy(userId).withStatus(TaxonomyChangeLifecycleStatus.EXECUTED);
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class MoveMeasurableCommandProcessor method apply.
public TaxonomyChangeCommand apply(TaxonomyChangeCommand cmd, String userId) {
Measurable measurableToMove = validate(cmd);
TaxonomyChangeLifecycleStatus outcome = measurableToMove.id().map(id -> measurableService.updateParentId(id, getDestination(cmd), userId)).map(success -> success ? TaxonomyChangeLifecycleStatus.EXECUTED : TaxonomyChangeLifecycleStatus.FAILED).orElse(TaxonomyChangeLifecycleStatus.FAILED);
return ImmutableTaxonomyChangeCommand.copyOf(cmd).withLastUpdatedAt(DateTimeUtilities.nowUtc()).withLastUpdatedBy(userId).withStatus(outcome);
}
Aggregations