use of org.finos.waltz.model.physical_flow.PhysicalFlow in project waltz by khartec.
the class DataTypeChangeCommandProcessor method apply.
@Override
public boolean apply(AttributeChange attributeChange, ChangeUnit changeUnit, String userName) {
doBasicValidation(attributeChange, changeUnit, userName);
checkTrue(changeUnit.subjectEntity().kind() == EntityKind.PHYSICAL_FLOW, "Change Subject should be a Physical Flow");
// get physical flow
PhysicalFlow physicalFlow = physicalFlowService.getById(changeUnit.subjectEntity().id());
// update the specs data types
Set<Long> oldValues = readValue(attributeChange.oldValue());
Set<Long> newValues = readValue(attributeChange.newValue());
EntityReference specificationEntityRef = EntityReference.mkRef(EntityKind.PHYSICAL_SPECIFICATION, physicalFlow.specificationId());
Set<Long> existing = dataTypeDecoratorService.findByEntityId(specificationEntityRef).stream().map(a -> a.dataTypeId()).collect(toSet());
Set<Long> toAdd = minus(newValues, oldValues, existing);
Set<Long> toRemove = minus(oldValues, newValues);
int removedCount = dataTypeDecoratorService.removeDataTypeDecorator(userName, specificationEntityRef, toRemove);
int[] addedCount = dataTypeDecoratorService.addDecorators(userName, specificationEntityRef, toAdd);
return removedCount == toRemove.size() && addedCount.length == toAdd.size();
}
use of org.finos.waltz.model.physical_flow.PhysicalFlow in project waltz by khartec.
the class RetireCommandProcessor method retirePhysicalFlow.
private ImmutableCommandResponse<UpdateExecutionStatusCommand> retirePhysicalFlow(UpdateExecutionStatusCommand command, ChangeUnit changeUnit, String userName) {
PhysicalFlow subject = physicalFlowService.getById(changeUnit.subjectEntity().id());
checkNotNull(subject, "subject not found: " + changeUnit.subjectEntity());
checkTrue(subject.entityLifecycleStatus().equals(changeUnit.subjectInitialStatus()), "current subject status does not match initial change unit status: " + subject);
SetAttributeCommand setAttributeCommand = ImmutableSetAttributeCommand.builder().entityReference(subject.entityReference()).name("entity_lifecycle_status").value(EntityLifecycleStatus.REMOVED.name()).build();
int i = physicalFlowService.updateAttribute(userName, setAttributeCommand);
return ImmutableCommandResponse.<UpdateExecutionStatusCommand>builder().entityReference(subject.entityReference()).originalCommand(command).outcome(i == 1 ? CommandOutcome.SUCCESS : CommandOutcome.FAILURE).message("Updated status of physical flow: " + subject + " to " + EntityLifecycleStatus.REMOVED).build();
}
Aggregations