Search in sources :

Example 16 with Measurable

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;
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable)

Example 17 with Measurable

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());
}
Also used : TaxonomyManagementUtilities.validatePrimaryMeasurable(org.finos.waltz.service.taxonomy_management.TaxonomyManagementUtilities.validatePrimaryMeasurable) Measurable(org.finos.waltz.model.measurable.Measurable)

Example 18 with Measurable

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();
}
Also used : TaxonomyManagementUtilities.validatePrimaryMeasurable(org.finos.waltz.service.taxonomy_management.TaxonomyManagementUtilities.validatePrimaryMeasurable) Measurable(org.finos.waltz.model.measurable.Measurable)

Example 19 with Measurable

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());
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable)

Example 20 with Measurable

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();
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable)

Aggregations

Measurable (org.finos.waltz.model.measurable.Measurable)26 MeasurableDao (org.finos.waltz.data.measurable.MeasurableDao)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 EntityKind (org.finos.waltz.model.EntityKind)6 Collectors (java.util.stream.Collectors)5 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)5 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)5 DIConfiguration (org.finos.waltz.service.DIConfiguration)5 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 IOException (java.io.IOException)4 InputStreamReader (java.io.InputStreamReader)4 Collection (java.util.Collection)4 Map (java.util.Map)4 Checks.checkTrue (org.finos.waltz.common.Checks.checkTrue)4 MapUtilities.indexBy (org.finos.waltz.common.MapUtilities.indexBy)4 StringUtilities.lower (org.finos.waltz.common.StringUtilities.lower)4 ApplicationDao (org.finos.waltz.data.application.ApplicationDao)4 RatingSchemeDAO (org.finos.waltz.data.rating_scheme.RatingSchemeDAO)4 RoadmapDao (org.finos.waltz.data.roadmap.RoadmapDao)4