evaluator config small change

This commit is contained in:
CITE\amentis 2024-10-11 18:08:56 +03:00
parent f50e229b30
commit b5a9202d6f
3 changed files with 21 additions and 6 deletions

View File

@ -8,6 +8,7 @@ public class EvaluatorSourceEntity {
private String clientId; private String clientId;
private String clientSecret; private String clientSecret;
private String scope; private String scope;
private String rdaTransformerId;
private int maxInMemorySizeInBytes; private int maxInMemorySizeInBytes;
public String getUrl() { public String getUrl() {
@ -58,6 +59,14 @@ public class EvaluatorSourceEntity {
this.scope = scope; this.scope = scope;
} }
public String getRdaTransformerId() {
return rdaTransformerId;
}
public void setRdaTransformerId(String rdaTransformerId) {
this.rdaTransformerId = rdaTransformerId;
}
public int getMaxInMemorySizeInBytes() { public int getMaxInMemorySizeInBytes() {
return maxInMemorySizeInBytes; return maxInMemorySizeInBytes;
} }

View File

@ -24,6 +24,7 @@ import org.opencdmp.commons.JsonHandlingService;
import org.opencdmp.commons.enums.*; import org.opencdmp.commons.enums.*;
import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.commons.types.deposit.DepositSourceEntity;
import org.opencdmp.commons.types.evaluator.EvaluatorSourceEntity; import org.opencdmp.commons.types.evaluator.EvaluatorSourceEntity;
import org.opencdmp.evaluatorbase.interfaces.EvaluatorClient; import org.opencdmp.evaluatorbase.interfaces.EvaluatorClient;
import org.opencdmp.evaluatorbase.interfaces.EvaluatorConfiguration; import org.opencdmp.evaluatorbase.interfaces.EvaluatorConfiguration;
@ -223,6 +224,7 @@ public class EvaluatorServiceImpl implements EvaluatorService {
for (EvaluatorSourceEntity source : sources){ for (EvaluatorSourceEntity source : sources){
EvaluatorSourceEntity item = new EvaluatorSourceEntity(); EvaluatorSourceEntity item = new EvaluatorSourceEntity();
item.setEvaluatorId(source.getEvaluatorId()); item.setEvaluatorId(source.getEvaluatorId());
item.setRdaTransformerId(source.getRdaTransformerId());
item.setUrl(source.getUrl()); item.setUrl(source.getUrl());
item.setIssuerUrl(source.getIssuerUrl()); item.setIssuerUrl(source.getIssuerUrl());
item.setClientId(source.getClientId()); item.setClientId(source.getClientId());
@ -282,15 +284,18 @@ public class EvaluatorServiceImpl implements EvaluatorService {
PlanEntity planEntity = this.queryFactory.query(PlanQuery.class).disableTracking().ids(planId).first(); 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())); 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(); FileEnvelopeModel jsonEnvelope = new FileEnvelopeModel();
if (source != null) {
org.opencdmp.model.file.FileEnvelope rda = this.fileTransformerService.exportPlan(planId, source.getRdaTransformerId(), "json", isPublic);
jsonEnvelope.setFilename(rda.getFilename()); jsonEnvelope.setFilename(rda.getFilename());
jsonEnvelope.setMimeType("application/json"); jsonEnvelope.setMimeType("application/json");
if (!repository.getConfiguration().isUseSharedStorage()) jsonEnvelope.setFile(rda.getFile()); if (!repository.getConfiguration().isUseSharedStorage()) jsonEnvelope.setFile(rda.getFile());
else jsonEnvelope.setFileRef(this.addFileToSharedStorage(rda)); 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())); 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()); this.accountingService.increase(UsageLimitTargetMetric.FILE_TRANSFORMER_EXPORT_PLAN_EXECUTION_COUNT.getValue());

View File

@ -9,6 +9,7 @@ evaluator:
maxInMemorySizeInBytes: 6554000 maxInMemorySizeInBytes: 6554000
- url: http://localhost:8083 - url: http://localhost:8083
evaluatorId: rda-maDMP evaluatorId: rda-maDMP
rdaTransformerId: rda-file-transformer
issuer-url: ${IDP_ISSUER_URI_TOKEN} issuer-url: ${IDP_ISSUER_URI_TOKEN}
client-id: ${IDP_APIKEY_CLIENT_ID} client-id: ${IDP_APIKEY_CLIENT_ID}
client-secret: ${IDP_APIKEY_CLIENT_SECRET} client-secret: ${IDP_APIKEY_CLIENT_SECRET}