Adding wildcard input support
@@ -93,7 +93,7 @@ public class ParserWorkflowManager extends WorkflowManager {
List<ParsingTemplate> parsingTemplates = registryClient.getParsingTemplatesForExperiment(completionMessage.getExperimentId(),
completionMessage.getGatewayId());
- logger.info("Found " + parsingTemplates.size() + " parsing templated for experiment " + completionMessage.getExperimentId());
+ logger.info("Found " + parsingTemplates.size() + " parsing template for experiment " + completionMessage.getExperimentId());
Map<String, Map<String, Set<ParserConnector>>> parentToChildParsers = new HashMap<>();
@@ -212,9 +212,14 @@ public class ParserWorkflowManager extends WorkflowManager {
String applicationOutputName = templateInput.getApplicationOutputName();
try {
ExperimentModel experiment = registryClient.getExperiment(completionMessage.getExperimentId());
- Optional<OutputDataObjectType> expOutputData = experiment.getExperimentOutputs().stream()
+ Optional<OutputDataObjectType> expOutputData;
+ if (applicationOutputName.contains("*")) {
+ expOutputData = experiment.getExperimentOutputs().stream()
+ .filter(outputDataObjectType -> isWildcardMatch(outputDataObjectType.getName(),applicationOutputName)).findFirst();
+ } else {
+ expOutputData = experiment.getExperimentOutputs().stream()
.filter(outputDataObjectType -> outputDataObjectType.getName().equals(applicationOutputName)).findFirst();
-
+ }
if (expOutputData.isPresent()) {
input.setValue(expOutputData.get().getValue());
} else {
@@ -246,6 +251,34 @@ public class ParserWorkflowManager extends WorkflowManager {
return parsingTask;
}
+ private boolean isWildcardMatch(String s, String p) {
+ int i = 0;
+ int j = 0;
+ int starIndex = -1;
+ int iIndex = -1;
+
+ while (i < s.length()) {
+ if (j < p.length() && (p.charAt(j) == '?' || p.charAt(j) == s.charAt(i))) {
+ ++i;
+ ++j;
+ } else if (j < p.length() && p.charAt(j) == '*') {
+ starIndex = j;
+ iIndex = i;
+ j++;
+ } else if (starIndex != -1) {
+ j = starIndex + 1;
+ i = iIndex+1;
+ iIndex++;
+ } else {
+ return false;
+ }
+ }
+ while (j < p.length() && p.charAt(j) == '*') {
+ ++j;
+ }
+ return j == p.length();
+ }
+
private String processExpression(String expression, ProcessCompletionMessage completionMessage) throws Exception {
RegistryService.Client registryClient = getRegistryClientPool().getResource();
