use of org.finos.waltz.model.external_identifier.ExternalIdentifier in project waltz by khartec.
the class PhysicalFlowService method copyExternalIdFromFlowAndSpecification.
private void copyExternalIdFromFlowAndSpecification(String username, EntityReference toRef, PhysicalFlow sourcePhysicalFlow) {
PhysicalFlow targetPhysicalFlow = physicalFlowDao.getById(toRef.id());
Set<String> externalIdentifiers = externalIdentifierService.findByEntityReference(toRef).stream().map(ExternalIdentifier::externalId).collect(Collectors.toSet());
sourcePhysicalFlow.externalId().filter(id -> !isEmpty(id)).ifPresent(sourceExtId -> {
if (isEmpty(targetPhysicalFlow.externalId())) {
physicalFlowDao.updateExternalId(toRef.id(), sourceExtId);
} else if (!externalIdentifiers.contains(sourceExtId)) {
externalIdentifierService.create(toRef, sourceExtId, username);
externalIdentifiers.add(sourceExtId);
}
});
PhysicalSpecification sourceSpec = physicalSpecificationService.getById(sourcePhysicalFlow.specificationId());
sourceSpec.externalId().filter(id -> !isEmpty(id)).ifPresent(sourceExtId -> {
PhysicalSpecification targetSpec = physicalSpecificationService.getById(targetPhysicalFlow.specificationId());
if (isEmpty(targetSpec.externalId())) {
targetSpec.id().ifPresent(id -> physicalSpecificationService.updateExternalId(id, sourceExtId));
} else if (!externalIdentifiers.contains(sourceExtId)) {
externalIdentifierService.create(toRef, sourceExtId, username);
}
});
}
Aggregations