use of org.finos.waltz.model.EntityKind.LOGICAL_DATA_FLOW in project waltz by khartec.
the class LogicalFlowService method addFlows.
public List<LogicalFlow> addFlows(List<AddLogicalFlowCommand> addCmds, String username) {
addCmds.forEach(this::rejectIfSelfLoop);
Set<AddLogicalFlowCommand> toAdd = fromCollection(addCmds);
List<ChangeLog> logEntries = toAdd.stream().flatMap(cmd -> {
ImmutableChangeLog addedSourceParent = ImmutableChangeLog.builder().parentReference(cmd.source()).severity(Severity.INFORMATION).userId(username).message(format("Flow %s between: %s and %s", "added", cmd.source().name().orElse(Long.toString(cmd.source().id())), cmd.target().name().orElse(Long.toString(cmd.target().id())))).childKind(LOGICAL_DATA_FLOW).operation(Operation.ADD).build();
ImmutableChangeLog addedTargetParent = addedSourceParent.withParentReference(cmd.target());
return Stream.of(addedSourceParent, addedTargetParent);
}).collect(Collectors.toList());
changeLogService.write(logEntries);
LocalDateTime now = nowUtc();
List<LogicalFlow> flowsToAdd = toAdd.stream().map(addCmd -> ImmutableLogicalFlow.builder().source(addCmd.source()).target(addCmd.target()).lastUpdatedAt(now).lastUpdatedBy(username).created(UserTimestamp.mkForUser(username, now)).provenance("waltz").build()).collect(toList());
return logicalFlowDao.addFlows(flowsToAdd, username);
}
Aggregations