use of org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission 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);
}
}
use of org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission in project waltz by khartec.
the class ChangeLogService method preparePreambleAndEntitiesForChangeLogs.
private Tuple2<String, Set<EntityReference>> preparePreambleAndEntitiesForChangeLogs(MeasurableRatingReplacement measurableRatingReplacement) {
MeasurableRatingPlannedDecommission plannedDecommission = measurableRatingPlannedDecommissionDao.getById(measurableRatingReplacement.decommissionId());
String measurableName = resolveName(plannedDecommission.measurableId(), MEASURABLE);
String originalEntityName = resolveName(plannedDecommission.entityReference().id(), plannedDecommission.entityReference().kind());
String newEntityName = resolveName(measurableRatingReplacement.entityReference().id(), measurableRatingReplacement.entityReference().kind());
String messagePreamble = format("Replacement %s: %s [%d], for measurable: %s [%d] on: %s [%d]", measurableRatingReplacement.entityReference().kind().name().toLowerCase(), newEntityName, measurableRatingReplacement.entityReference().id(), measurableName, plannedDecommission.measurableId(), originalEntityName, plannedDecommission.entityReference().id());
return tuple(messagePreamble, asSet(measurableRatingReplacement.entityReference(), plannedDecommission.entityReference()));
}
use of org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission 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:
}
}
use of org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission 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;
}
}
Aggregations