airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramin...@apache.org
Subject svn commit: r1382838 - in /incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac: provider/impl/GramProvider.java utils/OutputUtils.java
Date Mon, 10 Sep 2012 13:46:25 GMT
Author: raminder
Date: Mon Sep 10 13:46:25 2012
New Revision: 1382838

URL: http://svn.apache.org/viewvc?rev=1382838&view=rev
Log:
AIRAVATA-548. Added stringarray to handle multiple outputs in STDOUT

Modified:
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java?rev=1382838&r1=1382837&r2=1382838&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java
(original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/GramProvider.java
Mon Sep 10 13:46:25 2012
@@ -54,6 +54,7 @@ import org.apache.airavata.core.gfac.uti
 import org.apache.airavata.core.gfac.utils.OutputUtils;
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
 import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.schemas.gfac.StringArrayType;
 import org.apache.airavata.schemas.gfac.URIArrayType;
 import org.apache.airavata.schemas.gfac.URIParameterType;
 import org.apache.airavata.schemas.wec.WorkflowOutputDataHandlingDocument;
@@ -304,6 +305,13 @@ public class GramProvider extends Abstra
 							stringMap.put(paramName, actualParameter);
 							invocationContext.getExecutionContext().getNotifier().output(invocationContext, actualParameter.toString());
 						}
+                        if ("StringArray".equals(actualParameter.getType().getType().toString()))
{
+                            String[] valueList = OutputUtils.parseStdoutArray(stdout, paramName);
+                            ((StringArrayType) actualParameter.getType()).setValueArray(valueList);
+                            stringMap = new HashMap<String, ActualParameter>();
+                            stringMap.put(paramName, actualParameter);
+                            invocationContext.getExecutionContext().getNotifier().output(invocationContext,
actualParameter.toString());
+                        }
                     	else{
                     	// This is to handle exception during the output parsing.
                         stringMap = OutputUtils.fillOutputFromStdout(invocationContext.<ActualParameter>getOutput(),
stdout,stderr);

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java?rev=1382838&r1=1382837&r2=1382838&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java
(original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java
Mon Sep 10 13:46:25 2012
@@ -30,13 +30,14 @@ import java.util.regex.Pattern;
 import org.apache.airavata.commons.gfac.type.ActualParameter;
 import org.apache.airavata.commons.gfac.type.MappingFactory;
 import org.apache.airavata.core.gfac.context.message.MessageContext;
-import org.apache.airavata.schemas.gfac.DataType;
 import org.apache.airavata.schemas.gfac.StdErrParameterType;
 import org.apache.airavata.schemas.gfac.StdOutParameterType;
-import org.apache.xmlbeans.XmlException;
 
 public class OutputUtils {
 
+    private static String regexPattern = "\\s*=\\s*([^\\[\\s'\"][^\\s]*|\"[^\"]*\"|'[^']*'|\\[[^\\[]*\\])";
+
+
     private OutputUtils() {
     }
 
@@ -73,7 +74,7 @@ public class OutputUtils {
     }
 
     private static String parseStdout(String stdout, String outParam)throws Exception {
-        String regex = Pattern.quote(outParam) + "\\s*=\\s*([^\\[\\s'\"][^\\s]*|\"[^\"]*\"|'[^']*'|\\[[^\\[]*\\])";
+        String regex = Pattern.quote(outParam) + regexPattern;
         String match = null;
         Pattern pattern = Pattern.compile(regex);
         Matcher matcher = pattern.matcher(stdout);
@@ -87,4 +88,18 @@ public class OutputUtils {
             throw new Exception("Data for the output parameter '"+outParam+"' was not found");
         }
     }
+    public static String[] parseStdoutArray(String stdout, String outParam)throws NullPointerException
{
+        String regex = Pattern.quote(outParam) + regexPattern;
+        StringBuffer match = new StringBuffer();
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(stdout);
+        while (matcher.find()) {
+            match.append(matcher.group(1)+",");
+        }
+        if (match != null) {
+            return match.toString().split(",");
+        } else {
+            throw new NullPointerException();
+        }
+    }
 }



Mime
View raw message