fixed transform node
This commit is contained in:
parent
acba980ea4
commit
eb63e6fbc6
|
@ -165,7 +165,7 @@ public class ApiController extends DnetRestController {
|
|||
public WfRunningJob startRepoHi(@PathVariable final String id, @RequestBody final WfRepoHiParams params) throws WorkflowManagerException {
|
||||
final WfTemplate wfTmpl = this.clientFactory
|
||||
.getClient(SimpleResourceClient.class)
|
||||
.findResourceContent(WorkflowsConstants.WF_TEMPLATE, id, WfTemplate.class);
|
||||
.findResourceContent(SimpleResourceClient.ResourceType.wf_template, id, WfTemplate.class);
|
||||
|
||||
final List<Node> graph = wfTmpl.getGraph();
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class ApiController extends DnetRestController {
|
|||
final SimpleResourceClient client = this.clientFactory.getClient(SimpleResourceClient.class);
|
||||
|
||||
for (final String wf : workflows) {
|
||||
for (final WfParam p : client.findResourceContent(WorkflowsConstants.WF_TEMPLATE, wf, WfTemplate.class).getParameters()) {
|
||||
for (final WfParam p : client.findResourceContent(SimpleResourceClient.ResourceType.wf_template, wf, WfTemplate.class).getParameters()) {
|
||||
|
||||
if (p.getValidTermsSupplier() != null) {
|
||||
p.setValidTerms(this.validTermsSupplierFactory.findTerms(p.getValidTermsSupplier()));
|
||||
|
|
|
@ -102,7 +102,7 @@ public class WorkflowManagerService {
|
|||
|
||||
final List<ImmutablePair<String, WfTemplate>> wfTemplates = conf.getWorkflows()
|
||||
.stream()
|
||||
.map(wf -> new ImmutablePair<>(wf, client.findResourceContent(WorkflowsConstants.WF_TEMPLATE, wf, WfTemplate.class)))
|
||||
.map(wf -> new ImmutablePair<>(wf, client.findResourceContent(SimpleResourceClient.ResourceType.wf_template, wf, WfTemplate.class)))
|
||||
.toList();
|
||||
|
||||
conf.setConfigured(WfConfigurationUtils.isConfigured(wfTemplates, conf));
|
||||
|
@ -113,8 +113,8 @@ public class WorkflowManagerService {
|
|||
|
||||
public WfTemplateDesc findWfTemplateDesc(final String name) {
|
||||
final SimpleResourceClient client = this.clientFactory.getClient(SimpleResourceClient.class);
|
||||
final SimpleResource metadata = client.findResource(WorkflowsConstants.WF_TEMPLATE, name);
|
||||
final WfTemplate tmpl = client.findResourceContent(WorkflowsConstants.WF_TEMPLATE, name, WfTemplate.class);
|
||||
final SimpleResource metadata = client.findResource(SimpleResourceClient.ResourceType.wf_template, name);
|
||||
final WfTemplate tmpl = client.findResourceContent(SimpleResourceClient.ResourceType.wf_template, name, WfTemplate.class);
|
||||
|
||||
final WfTemplateDesc res = new WfTemplateDesc();
|
||||
res.setId(metadata.getName());
|
||||
|
@ -157,7 +157,7 @@ public class WorkflowManagerService {
|
|||
final SimpleResourceClient client = this.clientFactory.getClient(SimpleResourceClient.class);
|
||||
|
||||
final List<ImmutablePair<String, WfTemplate>> wfTemplates = Arrays.stream(wfTemplateIds)
|
||||
.map(wf -> new ImmutablePair<>(wf, client.findResourceContent(WorkflowsConstants.WF_TEMPLATE, wf, WfTemplate.class)))
|
||||
.map(wf -> new ImmutablePair<>(wf, client.findResourceContent(SimpleResourceClient.ResourceType.wf_template, wf, WfTemplate.class)))
|
||||
.toList();
|
||||
|
||||
final List<Node> graph = WfConfigurationUtils.compositeGraph(wfTemplates);
|
||||
|
@ -241,7 +241,7 @@ public class WorkflowManagerService {
|
|||
public List<WfRepoHiDesc> listRepoHis() {
|
||||
final SimpleResourceClient client = this.clientFactory.getClient(SimpleResourceClient.class);
|
||||
|
||||
return client.findResources(WorkflowsConstants.WF_TEMPLATE, WorkflowsConstants.REPO_HI_FAMILY)
|
||||
return client.findResources(SimpleResourceClient.ResourceType.wf_template, WorkflowsConstants.REPO_HI_FAMILY)
|
||||
.stream()
|
||||
.map(r -> {
|
||||
final WfTemplate tmpl = client.findResourceContent(r.getId(), WfTemplate.class);
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ValidTermsSupplierFactory {
|
|||
|
||||
private List<String> listTransformationRules() {
|
||||
return this.clientFactory.getClient(SimpleResourceClient.class)
|
||||
.findResources("transformation_rule_xslt", null)
|
||||
.findResources(SimpleResourceClient.ResourceType.transformation_rule_xslt, null)
|
||||
.stream()
|
||||
.map(SimpleResource::getName)
|
||||
.toList();
|
||||
|
|
|
@ -11,7 +11,12 @@ import eu.dnetlib.domain.resource.SimpleResource;
|
|||
|
||||
public class SimpleResourceClient extends DnetServiceClient {
|
||||
|
||||
public List<String> listResources(final String type) {
|
||||
public static enum ResourceType {
|
||||
wf_template,
|
||||
transformation_rule_xslt
|
||||
}
|
||||
|
||||
public List<String> listResources(final ResourceType type) {
|
||||
return Arrays.asList(httpGet("/api/resources/byType/{type}", String[].class, Map.of("type", type)));
|
||||
}
|
||||
|
||||
|
@ -23,7 +28,7 @@ public class SimpleResourceClient extends DnetServiceClient {
|
|||
return httpGet("/api/resources/{id}/metadata", SimpleResource.class, Map.of("id", id));
|
||||
}
|
||||
|
||||
public SimpleResource findResource(final String type, final String name) {
|
||||
public SimpleResource findResource(final ResourceType type, final String name) {
|
||||
return httpGet("/api/resources/byType/{type}/{name}/metadata", SimpleResource.class, Map.of("type", type, "name", name));
|
||||
}
|
||||
|
||||
|
@ -31,7 +36,7 @@ public class SimpleResourceClient extends DnetServiceClient {
|
|||
return httpGet("/api/resources/{id}/content", clazz, Map.of("id", id));
|
||||
}
|
||||
|
||||
public <T> T findResourceContent(final String type, final String name, final Class<T> clazz) {
|
||||
public <T> T findResourceContent(final ResourceType type, final String name, final Class<T> clazz) {
|
||||
return httpGet("/api/resources/byType/{type}/{name}/content", clazz, Map.of("type", type, "name", name));
|
||||
}
|
||||
|
||||
|
@ -49,7 +54,7 @@ public class SimpleResourceClient extends DnetServiceClient {
|
|||
|
||||
public SimpleResource prepareNewResource(final String name,
|
||||
final String desc,
|
||||
final String type,
|
||||
final ResourceType type,
|
||||
final String subtype,
|
||||
final String description,
|
||||
final Object content) {
|
||||
|
@ -62,7 +67,7 @@ public class SimpleResourceClient extends DnetServiceClient {
|
|||
return httpPostParams("/api/resources/", params, SimpleResource.class, Map.of());
|
||||
}
|
||||
|
||||
public List<SimpleResource> findResources(final String type, final String subType) {
|
||||
public List<SimpleResource> findResources(final ResourceType type, final String subType) {
|
||||
|
||||
final String path = "/api/resources/byType/{type}";
|
||||
|
||||
|
|
|
@ -22,9 +22,11 @@ public class XsltTransformFactory {
|
|||
|
||||
public RecordTransformer<String, String> getTransformer(final String ruleId, final Map<String, Object> initialParams) throws TransformationException {
|
||||
try {
|
||||
final String xsltText = clientFactory.getClient(SimpleResourceClient.class).findResourceContent(ruleId, String.class);
|
||||
final String xsltText =
|
||||
this.clientFactory.getClient(SimpleResourceClient.class)
|
||||
.findResourceContent(SimpleResourceClient.ResourceType.transformation_rule_xslt, ruleId, String.class);
|
||||
|
||||
return XsltUtils.newTransformer(xsltText, initialParams, xsltFunctions);
|
||||
return XsltUtils.newTransformer(xsltText, initialParams, this.xsltFunctions);
|
||||
|
||||
} catch (final Throwable e) {
|
||||
throw new TransformationException("error preparing xslt transfomer", e);
|
||||
|
|
|
@ -39,8 +39,6 @@ public class WorkflowsConstants {
|
|||
|
||||
public static final String MAIN_LOG_PREFIX = "mainlog:";
|
||||
|
||||
public static final String WF_TEMPLATE = "wf_template";
|
||||
|
||||
public static final String REPO_HI_FAMILY = "REPO-HI";
|
||||
public static final String REPO_BYE_FAMILY = "REPO-BYE";
|
||||
public static final String GENERIC_DESTROY_WF_FAMILY = "DESTROY-WF";
|
||||
|
|
|
@ -93,7 +93,7 @@ public class RegisterWfConfigurationNode extends ProcessNode {
|
|||
final SimpleResourceClient client = this.clientFactory.getClient(SimpleResourceClient.class);
|
||||
|
||||
final List<ImmutablePair<String, WfTemplate>> wfTemplates = wfList.stream()
|
||||
.map(wf -> new ImmutablePair<>(wf, client.findResourceContent(WorkflowsConstants.WF_TEMPLATE, wf, WfTemplate.class)))
|
||||
.map(wf -> new ImmutablePair<>(wf, client.findResourceContent(SimpleResourceClient.ResourceType.wf_template, wf, WfTemplate.class)))
|
||||
.toList();
|
||||
|
||||
conf.setConfigured(WfConfigurationUtils.isConfigured(wfTemplates, conf));
|
||||
|
|
Loading…
Reference in New Issue