Search in sources :

Example 1 with MeasurableRatingReplacement

use of org.finos.waltz.model.measurable_rating_replacement.MeasurableRatingReplacement 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 MeasurableRatingReplacement

use of org.finos.waltz.model.measurable_rating_replacement.MeasurableRatingReplacement in project waltz by khartec.

the class ChangeLogService method writeChangeLogEntries.

public void writeChangeLogEntries(EntityReference ref, String userId, String postamble, Operation operation) {
    switch(ref.kind()) {
        case PHYSICAL_FLOW:
            PhysicalFlow physicalFlow = physicalFlowDao.getById(ref.id());
            writeChangeLogEntries(physicalFlow, userId, postamble, operation);
            break;
        case LOGICAL_DATA_FLOW:
            LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(ref.id());
            writeChangeLogEntries(logicalFlow, userId, postamble, operation);
            break;
        case MEASURABLE_RATING_REPLACEMENT:
            MeasurableRatingReplacement measurableRatingReplacement = measurableRatingReplacementdao.getById(ref.id());
            writeChangeLogEntries(measurableRatingReplacement, userId, postamble, operation);
            break;
        case MEASURABLE_RATING_PLANNED_DECOMMISSION:
            MeasurableRatingPlannedDecommission measurableRatingPlannedDecommission = measurableRatingPlannedDecommissionDao.getById(ref.id());
            writeChangeLogEntries(measurableRatingPlannedDecommission, userId, postamble, operation);
        default:
    }
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) MeasurableRatingReplacement(org.finos.waltz.model.measurable_rating_replacement.MeasurableRatingReplacement) MeasurableRatingPlannedDecommission(org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow)

Aggregations

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