This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch staging
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/staging by this push:
new e92590c Adding wildcard input support
e92590c is described below
commit e92590cef353daf3e790d2a554349771d1312f58
Author: Dimuthu Wannipurage <[email protected]>
AuthorDate: Fri Jul 26 11:10:08 2019 -0400
Adding wildcard input support
---
.../helix/impl/workflow/ParserWorkflowManager.java | 41 +++++++++++++++++++---
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git
a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/ParserWorkflowManager.java
b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/ParserWorkflowManager.java
index e9d52de..772206c 100644
---
a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/ParserWorkflowManager.java
+++
b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/ParserWorkflowManager.java
@@ -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()
- .filter(outputDataObjectType ->
outputDataObjectType.getName().equals(applicationOutputName)).findFirst();
-
+ 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();