use of org.finos.waltz.model.changelog.ChangeLog in project waltz by khartec.
the class AssessmentRatingService method createChangeLogEntry.
private void createChangeLogEntry(SaveAssessmentRatingCommand command, String username, AssessmentDefinition assessmentDefinition) {
Optional<AssessmentRating> previousRating = assessmentRatingDao.findForEntity(command.entityReference()).stream().filter(r -> r.assessmentDefinitionId() == command.assessmentDefinitionId()).findAny();
Optional<RatingSchemeItem> previousRatingSchemeItem = previousRating.map(assessmentRating -> ratingSchemeDAO.getRatingSchemeItemById(assessmentRating.ratingId()));
Optional<String> messagePostfix = previousRatingSchemeItem.map(rn -> format(" from assessment %s as [%s - %s]", assessmentDefinition.name(), rn.name(), previousRating.get().comment()));
ChangeLog logEntry = ImmutableChangeLog.builder().message(format("Storing assessment %s as [%s - %s]%s", assessmentDefinition.name(), ratingSchemeDAO.getRatingSchemeItemById(command.ratingId()).name(), command.comment(), messagePostfix.orElse(""))).parentReference(mkRef(command.entityReference().kind(), command.entityReference().id())).userId(username).severity(Severity.INFORMATION).operation(Operation.UPDATE).build();
changeLogService.write(logEntry);
}
use of org.finos.waltz.model.changelog.ChangeLog in project waltz by khartec.
the class AssessmentRatingService method createChangeLogs.
private void createChangeLogs(long assessmentDefinitionId, String username, Set<AssessmentRating> ratingsToAdd, Operation operation) {
String messagePrefix = operation.equals(Operation.REMOVE) ? "Removed" : "Added";
AssessmentDefinition assessmentDefinition = assessmentDefinitionDao.getById(assessmentDefinitionId);
Map<Long, RatingSchemeItem> ratingItems = MapUtilities.indexBy(ratingSchemeDAO.findRatingSchemeItemsForAssessmentDefinition(assessmentDefinitionId), r -> r.id().orElse(0L));
Set<ChangeLog> logs = ratingsToAdd.stream().map(r -> ImmutableChangeLog.builder().message(messagePrefix + format(" assessment %s as [%s - %s] for %s", assessmentDefinition.name(), ratingItems.get(r.ratingId()).name(), StringUtilities.ifEmpty(r.comment(), ""), r.entityReference().name().orElse(""))).parentReference(r.entityReference()).userId(username).severity(Severity.INFORMATION).operation(operation).build()).collect(Collectors.toSet());
changeLogService.write(logs);
}
use of org.finos.waltz.model.changelog.ChangeLog in project waltz by khartec.
the class AssessmentRatingService method remove.
public boolean remove(RemoveAssessmentRatingCommand command, String username) {
ChangeLog logEntry = ImmutableChangeLog.builder().message(format("Removed %s", assessmentDefinitionDao.getById(command.assessmentDefinitionId()).name())).parentReference(mkRef(command.entityReference().kind(), command.entityReference().id())).userId(username).childKind(command.entityReference().kind()).severity(Severity.INFORMATION).operation(Operation.REMOVE).build();
changeLogService.write(logEntry);
return assessmentRatingDao.remove(command);
}
use of org.finos.waltz.model.changelog.ChangeLog in project waltz by khartec.
the class ChangeInitiativeService method addEntityRelationship.
public boolean addEntityRelationship(long changeInitiativeId, EntityRelationshipChangeCommand command, String username) {
checkNotNull(command, "command cannot be null");
EntityRelationshipKey key = mkEntityRelationshipKey(changeInitiativeId, command, true);
EntityRelationship entityRelationship = ImmutableEntityRelationship.builder().a(key.a()).b(key.b()).relationship(key.relationshipKind()).lastUpdatedBy(username).lastUpdatedAt(DateTimeUtilities.nowUtc()).build();
ChangeLog logEntry = ImmutableChangeLog.builder().message(String.format("Relationship to %s (%s) added", command.entityReference().name().orElse(""), command.entityReference().kind().name() + "/" + command.entityReference().id())).parentReference(mkRef(CHANGE_INITIATIVE, changeInitiativeId)).userId(username).childKind(command.entityReference().kind()).severity(Severity.INFORMATION).operation(Operation.ADD).build();
changeLogService.write(logEntry);
return relationshipDao.save(entityRelationship) == 1;
}
use of org.finos.waltz.model.changelog.ChangeLog in project waltz by khartec.
the class ChangeInitiativeService method removeEntityRelationship.
public boolean removeEntityRelationship(long changeInitiativeId, EntityRelationshipChangeCommand command, String username) {
checkNotNull(command, "command cannot be null");
EntityRelationshipKey key = mkEntityRelationshipKey(changeInitiativeId, command, false);
ChangeLog logEntry = ImmutableChangeLog.builder().message(String.format("Relationship to %s (%s) removed", command.entityReference().name().orElse(""), command.entityReference().kind().name() + "/" + command.entityReference().id())).parentReference(mkRef(CHANGE_INITIATIVE, changeInitiativeId)).userId(username).childKind(command.entityReference().kind()).severity(Severity.INFORMATION).operation(Operation.REMOVE).build();
changeLogService.write(logEntry);
return relationshipDao.remove(key);
}
Aggregations