Skip to content

Commit

Permalink
MAINT-33753 - backport the fix for proper job roles creation
Browse files Browse the repository at this point in the history
  • Loading branch information
olenac87 committed Dec 20, 2024
1 parent 8ba3f25 commit b643ecb
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.mapstruct.factory.Mappers;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -1228,11 +1229,26 @@ private Mono<JobRole> createJobRole(StreamTask streamTask, ServiceAgreement serv
presentationIngestFunctionGroup.setExternalServiceAgreementId(serviceAgreement.getExternalId());
presentationIngestFunctionGroup.setMetadata(jobRole.getMetadata());

//since ReferenceJobRole class was removed, now all job roles have the same class, and
//reference job role can be created only for MSA, for CSA it failed
if(BooleanUtils.isTrue(serviceAgreement.getIsMaster())) {
log.debug("Creating a Reference Job Role.");
presentationIngestFunctionGroup.setType(PresentationIngestFunctionGroup.TypeEnum.TEMPLATE);
if (CollectionUtils.isEmpty(jobRole.getFunctionGroups())) {
throw new IllegalArgumentException(
String.format("Unexpected no function groups for job role: %s", jobRole.getName()));
}
final var jobRoleType = jobRole.getFunctionGroups().getFirst().getType();
if (!ObjectUtils.isEmpty(jobRoleType)) {
switch (jobRoleType) {
case TEMPLATE:
presentationIngestFunctionGroup.setType(PresentationIngestFunctionGroup.TypeEnum.TEMPLATE);
break;
case DEFAULT:
presentationIngestFunctionGroup.setType(PresentationIngestFunctionGroup.TypeEnum.REGULAR);
break;
default:
throw new IllegalArgumentException(
String.format("Unexpected enum constant: %s for job role: %s", jobRoleType, jobRole.getName()));
}
} else {
log.debug("No function group job role type is provided, creating a Local Job Role");
presentationIngestFunctionGroup.setType(PresentationIngestFunctionGroup.TypeEnum.REGULAR);
}

// Removing constant from mapper and adding default APS here to avoid issues with apsName.
Expand Down
Loading

0 comments on commit b643ecb

Please sign in to comment.