diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/evaluator/EvaluatorSourceEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/evaluator/EvaluatorSourceEntity.java index 2b922b567..71d3fec85 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/evaluator/EvaluatorSourceEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/evaluator/EvaluatorSourceEntity.java @@ -8,6 +8,7 @@ public class EvaluatorSourceEntity { private String clientId; private String clientSecret; private String scope; + private String rdaTransformerId; private int maxInMemorySizeInBytes; public String getUrl() { @@ -58,6 +59,14 @@ public class EvaluatorSourceEntity { this.scope = scope; } + public String getRdaTransformerId() { + return rdaTransformerId; + } + + public void setRdaTransformerId(String rdaTransformerId) { + this.rdaTransformerId = rdaTransformerId; + } + public int getMaxInMemorySizeInBytes() { return maxInMemorySizeInBytes; } diff --git a/backend/core/src/main/java/org/opencdmp/service/evaluator/EvaluatorServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/evaluator/EvaluatorServiceImpl.java index 1e0e8249a..a4518fe5b 100644 --- a/backend/core/src/main/java/org/opencdmp/service/evaluator/EvaluatorServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/evaluator/EvaluatorServiceImpl.java @@ -24,6 +24,7 @@ import org.opencdmp.commons.JsonHandlingService; import org.opencdmp.commons.enums.*; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.commons.types.deposit.DepositSourceEntity; import org.opencdmp.commons.types.evaluator.EvaluatorSourceEntity; import org.opencdmp.evaluatorbase.interfaces.EvaluatorClient; import org.opencdmp.evaluatorbase.interfaces.EvaluatorConfiguration; @@ -223,6 +224,7 @@ public class EvaluatorServiceImpl implements EvaluatorService { for (EvaluatorSourceEntity source : sources){ EvaluatorSourceEntity item = new EvaluatorSourceEntity(); item.setEvaluatorId(source.getEvaluatorId()); + item.setRdaTransformerId(source.getRdaTransformerId()); item.setUrl(source.getUrl()); item.setIssuerUrl(source.getIssuerUrl()); item.setClientId(source.getClientId()); @@ -282,15 +284,18 @@ public class EvaluatorServiceImpl implements EvaluatorService { PlanEntity planEntity = this.queryFactory.query(PlanQuery.class).disableTracking().ids(planId).first(); if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planId, PlanEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); - org.opencdmp.model.file.FileEnvelope rda = this.fileTransformerService.exportPlan(planId, "rda-file-transformer", "json", isPublic); + EvaluatorSourceEntity source = this.getEvaluatorSources().stream().filter(evaluatorSource -> !this.conventionService.isNullOrEmpty(evaluatorSource.getRdaTransformerId())).findFirst().orElse(null); FileEnvelopeModel jsonEnvelope = new FileEnvelopeModel(); - jsonEnvelope.setFilename(rda.getFilename()); - jsonEnvelope.setMimeType("application/json"); + if (source != null) { + org.opencdmp.model.file.FileEnvelope rda = this.fileTransformerService.exportPlan(planId, source.getRdaTransformerId(), "json", isPublic); + jsonEnvelope.setFilename(rda.getFilename()); + jsonEnvelope.setMimeType("application/json"); - if (!repository.getConfiguration().isUseSharedStorage()) jsonEnvelope.setFile(rda.getFile()); - else jsonEnvelope.setFileRef(this.addFileToSharedStorage(rda)); + if (!repository.getConfiguration().isUseSharedStorage()) jsonEnvelope.setFile(rda.getFile()); + else jsonEnvelope.setFileRef(this.addFileToSharedStorage(rda)); + } - PlanModel evaluatorModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setEvaluatorId(repository.getConfiguration().getEvaluatorId()).isPublic(isPublic).setRdaJsonFile(jsonEnvelope).authorize(AuthorizationFlags.All).build(planEntity); + PlanModel evaluatorModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setEvaluatorId(repository.getConfiguration().getEvaluatorId()).setRepositoryId(source != null && !this.conventionService.isNullOrEmpty(source.getRdaTransformerId()) ? source.getRdaTransformerId() : null).isPublic(isPublic).setRdaJsonFile(jsonEnvelope).authorize(AuthorizationFlags.All).build(planEntity); if(evaluatorModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planId, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.accountingService.increase(UsageLimitTargetMetric.FILE_TRANSFORMER_EXPORT_PLAN_EXECUTION_COUNT.getValue()); diff --git a/backend/web/src/main/resources/config/evaluator-devel.yml b/backend/web/src/main/resources/config/evaluator-devel.yml index 093d2fd66..c48f20790 100644 --- a/backend/web/src/main/resources/config/evaluator-devel.yml +++ b/backend/web/src/main/resources/config/evaluator-devel.yml @@ -9,6 +9,7 @@ evaluator: maxInMemorySizeInBytes: 6554000 - url: http://localhost:8083 evaluatorId: rda-maDMP + rdaTransformerId: rda-file-transformer issuer-url: ${IDP_ISSUER_URI_TOKEN} client-id: ${IDP_APIKEY_CLIENT_ID} client-secret: ${IDP_APIKEY_CLIENT_SECRET}