Search in sources :

Example 1 with Operation

use of org.finos.waltz.model.Operation in project waltz by khartec.

the class MeasurableRatingReplacementService method save.

public Set<MeasurableRatingReplacement> save(long decommId, EntityReference entityReference, Date commissionDate, String username) {
    Tuple2<Operation, Boolean> operation = measurableRatingReplacementDao.save(decommId, entityReference, commissionDate, username);
    MeasurableRatingReplacement measurableRatingReplacement = measurableRatingReplacementDao.fetchByDecommissionIdAndEntityRef(decommId, entityReference);
    MeasurableRatingPlannedDecommission plannedDecomm = measurableRatingPlannedDecommissionDao.getById(decommId);
    if (!operation.v2) {
        throw new UpdateFailedException("REPLACEMENT_SAVE_FAILED", format("Failed to store measurable rating replacement %s:%d for entity %s:%d and measurable %d", measurableRatingReplacement.entityReference().kind(), measurableRatingReplacement.entityReference().id(), plannedDecomm.entityReference().kind(), plannedDecomm.entityReference().id(), plannedDecomm.measurableId()));
    } else {
        changeLogService.writeChangeLogEntries(measurableRatingReplacement, username, format("%s with planned commission date: %s", (operation.v1.equals(Operation.ADD) ? "Added" : "Updated"), commissionDate), operation.v1);
        return measurableRatingReplacementDao.fetchByDecommissionId(decommId);
    }
}
Also used : MeasurableRatingReplacement(org.finos.waltz.model.measurable_rating_replacement.MeasurableRatingReplacement) MeasurableRatingPlannedDecommission(org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission) Operation(org.finos.waltz.model.Operation) UpdateFailedException(org.finos.waltz.common.exception.UpdateFailedException)

Example 2 with Operation

use of org.finos.waltz.model.Operation in project waltz by khartec.

the class MeasurableRatingPlannedDecommissionService method save.

public MeasurableRatingPlannedDecommission save(EntityReference entityReference, long measurableId, DateFieldChange dateChange, String userName) {
    Tuple2<Operation, Boolean> operation = measurableRatingPlannedDecommissionDao.save(entityReference, measurableId, dateChange, userName);
    if (!operation.v2) {
        throw new UpdateFailedException("DECOM_DATE_SAVE_FAILED", format("Failed to store date change for entity %s:%d and measurable %d", entityReference.kind(), entityReference.id(), measurableId));
    } else {
        MeasurableRatingPlannedDecommission plannedDecommission = measurableRatingPlannedDecommissionDao.getByEntityAndMeasurable(entityReference, measurableId);
        String logMessage = operation.v1.equals(Operation.UPDATE) ? String.format("Updated planned decommission date: from %s to %s", dateChange.oldVal(), plannedDecommission.plannedDecommissionDate()) : String.format("Added planned decommission date:%s", plannedDecommission.plannedDecommissionDate());
        changeLogService.writeChangeLogEntries(plannedDecommission, userName, logMessage, operation.v1);
        return plannedDecommission;
    }
}
Also used : MeasurableRatingPlannedDecommission(org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission) Operation(org.finos.waltz.model.Operation) UpdateFailedException(org.finos.waltz.common.exception.UpdateFailedException)

Aggregations

UpdateFailedException (org.finos.waltz.common.exception.UpdateFailedException)2 Operation (org.finos.waltz.model.Operation)2 MeasurableRatingPlannedDecommission (org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission)2 MeasurableRatingReplacement (org.finos.waltz.model.measurable_rating_replacement.MeasurableRatingReplacement)1