use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class TaxonomyChangeService method isMoveToSameParent.
private boolean isMoveToSameParent(TaxonomyChangeCommand command) {
String destinationId = command.params().get("destinationId");
if (isMovingToANode(command, destinationId)) {
long parentId = Long.parseLong(destinationId);
final Measurable parent = measurableService.getById(parentId);
return parent.parentId().isPresent() && command.primaryReference().id() == parent.parentId().get();
}
return false;
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class RemoveMeasurableCommandProcessor method apply.
public TaxonomyChangeCommand apply(TaxonomyChangeCommand cmd, String userId) {
doBasicValidation(cmd);
Measurable measurable = validatePrimaryMeasurable(measurableService, cmd);
IdSelectionOptions selectionOptions = mkOpts(cmd.primaryReference(), HierarchyQueryScope.CHILDREN);
removeBookmarks(selectionOptions);
removeInvolvements(selectionOptions);
removeAppMappings(selectionOptions);
removeMeasurables(selectionOptions);
removeFlowDiagrams(selectionOptions);
removeEntityRelationshipsDiagrams(selectionOptions);
String message = String.format("Measurable %s has been removed", measurable.name());
Optional<Long> measurableId = measurable.parentId().isPresent() ? measurable.parentId() : measurable.id();
measurableId.ifPresent(id -> measurableService.writeAuditMessage(id, userId, message));
return ImmutableTaxonomyChangeCommand.copyOf(cmd).withStatus(TaxonomyChangeLifecycleStatus.EXECUTED).withLastUpdatedBy(userId).withLastUpdatedAt(DateTimeUtilities.nowUtc());
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class RemoveMeasurableCommandProcessor method preview.
public TaxonomyChangePreview preview(TaxonomyChangeCommand cmd) {
doBasicValidation(cmd);
Measurable primaryMeasurable = validatePrimaryMeasurable(measurableService, cmd);
ImmutableTaxonomyChangePreview.Builder preview = ImmutableTaxonomyChangePreview.builder().command(ImmutableTaxonomyChangeCommand.copyOf(cmd).withPrimaryReference(primaryMeasurable.entityReference()));
IdSelectionOptions selectionOptions = mkOpts(cmd.primaryReference(), HierarchyQueryScope.CHILDREN);
previewChildNodeRemovals(preview, selectionOptions);
previewAppMappingRemovals(preview, selectionOptions);
previewBookmarkRemovals(preview, selectionOptions);
previewInvolvementRemovals(preview, selectionOptions);
previewFlowDiagramRemovals(preview, selectionOptions);
previewEntityRelationships(preview, selectionOptions);
return preview.build();
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class MeasurableRatingService method remove.
public Collection<MeasurableRating> remove(RemoveMeasurableRatingCommand command) {
checkNotNull(command, "command cannot be null");
Measurable measurable = measurableDao.getById(command.measurableId());
boolean success = measurableRatingDao.remove(command);
if (success && measurable != null) {
String entityName = getEntityName(command);
writeChangeLogEntry(command, format("Removed: %s for %s", measurable.name(), entityName), format("Removed: %s for %s", entityName, measurable.name()), Operation.REMOVE);
}
return findForEntity(command.entityReference());
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class UpdateMeasurableDescriptionCommandProcessor method preview.
public TaxonomyChangePreview preview(TaxonomyChangeCommand cmd) {
doBasicValidation(cmd);
Measurable m = TaxonomyManagementUtilities.validatePrimaryMeasurable(measurableService, cmd);
ImmutableTaxonomyChangePreview.Builder preview = ImmutableTaxonomyChangePreview.builder().command(ImmutableTaxonomyChangeCommand.copyOf(cmd).withPrimaryReference(m.entityReference()));
if (hasNoChange(m.description(), TaxonomyManagementUtilities.getDescriptionParam(cmd), "Description")) {
return preview.build();
}
TaxonomyManagementUtilities.addToPreview(preview, TaxonomyManagementUtilities.findCurrentRatingMappings(measurableRatingService, cmd), Severity.INFORMATION, "Current app mappings exist to item, these may be misleading if the description change alters the meaning of this item");
return preview.build();
}
Aggregations