Adding new parameter resolutions and bug fixed to parser wm
@@ -55,7 +55,7 @@ public class ParserWorkflowManager extends WorkflowManager {
private final static Logger logger = LoggerFactory.getLogger(ParserWorkflowManager.class);
- private String parserStorageResourceId = "pgadev.scigap.org_7ddf28fd-d503-4ff8-bbc5-3279a7c3b99e";
+ private String parserStorageResourceId = ServerSettings.getSetting("parser.storage.resource.id");
public ParserWorkflowManager() throws ApplicationSettingsException {
super(ServerSettings.getSetting("parser.workflow.manager.name"),
@@ -117,7 +117,10 @@ public class ParserWorkflowManager extends WorkflowManager {
for (ParsingTemplate template : parsingTemplates) {
logger.info("Launching parsing template " + template.getId());
- String parentParserId = null;
+ ParserInput parserInput = registryClient.getParserInput(template.getInitialInputs().get(0).getTargetInputId(), template.getGatewayId());
+ String parentParserId = parserInput.getParserId();
+
+ if (!parentToChildParsers.isEmpty()) {
for (String parentId : parentToChildParsers.get(template.getId()).keySet()) {
boolean found = false;
for (Set<ParserConnector> dagElements : parentToChildParsers.get(template.getId()).values()) {
@@ -132,6 +135,7 @@ public class ParserWorkflowManager extends WorkflowManager {
break;
}
}
+ }
if (parentParserId == null ) {
throw new Exception("Could not find a parent parser for template " + template.getId());
@@ -143,8 +147,10 @@ public class ParserWorkflowManager extends WorkflowManager {
List<AbstractTask> allTasks = new ArrayList<>();
allTasks.add(parentParserTask);
- createParserDagRecursively(allTasks, parentParser, parentParserTask, parentToChildParsers.get(template.getId()), completionMessage, registryClient);
+ if (parentToChildParsers.containsKey(template.getId())) {
+ createParserDagRecursively(allTasks, parentParser, parentParserTask, parentToChildParsers.get(template.getId()), completionMessage, registryClient);
+ }
String workflow = getWorkflowOperator().launchWorkflow("Parser-" + completionMessage.getProcessId() + UUID.randomUUID().toString(),
allTasks, true, false);
// TODO: figure out processId and register
@@ -234,20 +240,32 @@ public class ParserWorkflowManager extends WorkflowManager {
return parsingTask;
}
- private String processExpression(String expression, ProcessCompletionMessage completionMessage) {
+ private String processExpression(String expression, ProcessCompletionMessage completionMessage) throws Exception {
+ RegistryService.Client registryClient = getRegistryClientPool().getResource();
+
+ try {
if (expression != null) {
if (expression.startsWith("{{") && expression.endsWith("}}")) {
switch (expression) {
- case "{{experimentId}}":
+ case "{{experiment}}":
return completionMessage.getExperimentId();
- case "{{processId}}":
+ case "{{process}}":
return completionMessage.getProcessId();
case "{{gateway}}":
return completionMessage.getGatewayId();
+ case "{{user}}":
+ return registryClient.getProcess(completionMessage.getProcessId()).getUserName();
+ case "{{project}}":
+ return registryClient.getExperiment(completionMessage.getExperimentId()).getProjectId();
}
}
}
+ getRegistryClientPool().returnResource(registryClient);
return expression;
+ } catch (Exception e) {
+ getRegistryClientPool().returnBrokenResource(registryClient);
+ throw new Exception("Failed to resolve expression " + expression, e);
+ }
}
private void createParserDagRecursively(List<AbstractTask> allTasks, Parser parentParserInfo, DataParsingTask parentTask, Map<String, Set<ParserConnector>> parentToChild,
