You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by pa...@apache.org on 2011/10/25 21:01:28 UTC

svn commit: r1188854 - in /incubator/airavata/trunk/modules: commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/ gfac-core/src/test/java/org/apache/airavata/...

Author: patanachai
Date: Tue Oct 25 19:01:28 2011
New Revision: 1188854

URL: http://svn.apache.org/viewvc?rev=1188854&view=rev
Log:
AIRAVATA-170 fixed save Parameter problem

Modified:
    incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Parameter.java
    incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java
    incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java
    incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java

Modified: incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Parameter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Parameter.java?rev=1188854&r1=1188853&r2=1188854&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Parameter.java (original)
+++ incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Parameter.java Tue Oct 25 19:01:28 2011
@@ -49,6 +49,10 @@ public class Parameter implements Type {
     public void setDescription(String description) {
         this.parameterType.setDescription(description);
     }
+    
+    public org.apache.airavata.schemas.gfac.Parameter getParameterType(){
+    	return this.parameterType;
+    }
 
     // TODO
     public DataType getType() {
@@ -58,18 +62,4 @@ public class Parameter implements Type {
     public void setType(DataType type) {
         this.type = type;
     }
-
-	public String toXml() {
-		return parameterType.xmlText();
-	}
-
-	public Parameter fromXml(String xml) {
-		try {
-			this.parameterType = org.apache.airavata.schemas.gfac.Parameter.Factory
-					.parse(xml);
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		}
-		return this;
-	}
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java?rev=1188854&r1=1188853&r2=1188854&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java (original)
+++ incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java Tue Oct 25 19:01:28 2011
@@ -47,19 +47,41 @@ public class ServiceDescription implemen
         return serviceDescriptionType;
     }
 
-    public org.apache.airavata.schemas.gfac.Parameter[] getInputParameters() {
-        return this.serviceDescriptionType.getInputParametersArray();
+    public Parameter[] getInputParameters() {    	
+    	int length = this.serviceDescriptionType.getInputParametersArray().length;
+    	Parameter[] result = new Parameter[length];
+    	for (int i = 0; i < length; i++) {
+    		result[i] = new Parameter(this.serviceDescriptionType.getInputParametersArray(i));			
+		}
+        return result; 
     }
 
-    public void setInputParameters(org.apache.airavata.schemas.gfac.Parameter[] inputParameters) {
-        this.serviceDescriptionType.setInputParametersArray(inputParameters);
+    public void setInputParameters(Parameter[] inputParameters) {
+    	int length = inputParameters.length;
+    	org.apache.airavata.schemas.gfac.Parameter[] result = new org.apache.airavata.schemas.gfac.Parameter[length];
+    	for (int i = 0; i < length; i++) {
+    		result[i] = inputParameters[i].getParameterType();			
+		}
+    	
+        this.serviceDescriptionType.setInputParametersArray(result);
     }
 
-    public org.apache.airavata.schemas.gfac.Parameter[] getOutputParameters() {
-        return this.serviceDescriptionType.getOutputParametersArray();
+    public Parameter[] getOutputParameters() {
+    	int length = this.serviceDescriptionType.getOutputParametersArray().length;
+    	Parameter[] result = new Parameter[length];
+    	for (int i = 0; i < length; i++) {
+    		result[i] = new Parameter(this.serviceDescriptionType.getOutputParametersArray(i));			
+		}    	
+        return result;
     }
 
-    public void setOutputParameters(org.apache.airavata.schemas.gfac.Parameter[] outputParameters) {
-        this.serviceDescriptionType.setOutputParametersArray(outputParameters);
+    public void setOutputParameters(Parameter[] outputParameters) {
+    	int length = outputParameters.length;
+    	org.apache.airavata.schemas.gfac.Parameter[] result = new org.apache.airavata.schemas.gfac.Parameter[length];
+    	for (int i = 0; i < length; i++) {
+    		result[i] = outputParameters[i].getParameterType();			
+		}
+    	
+        this.serviceDescriptionType.setInputParametersArray(result);
     }
 }

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java?rev=1188854&r1=1188853&r2=1188854&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java Tue Oct 25 19:01:28 2011
@@ -26,11 +26,11 @@ import static org.junit.Assert.fail;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.airavata.commons.gfac.type.DataType;
 import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.Parameter;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.commons.gfac.type.host.GlobusHost;
-import org.apache.airavata.schemas.gfac.DataType;
-import org.apache.airavata.schemas.gfac.Parameter;
 import org.junit.Test;
 
 public class JCRRegistryTest {
@@ -100,23 +100,23 @@ public class JCRRegistryTest {
             ServiceDescription serv = new ServiceDescription();
             serv.setId(serviceId);
 
-            Parameter input = Parameter.Factory.newInstance();
-            input.setName("echo_input");
-            input.addNewType().setType(DataType.STRING);
-            List<Parameter> inputList = new ArrayList<Parameter>();
-            inputList.add(input);
-            org.apache.airavata.schemas.gfac.Parameter[] inputParamList = inputList
-                    .toArray(new org.apache.airavata.schemas.gfac.Parameter[inputList.size()]);
-
-            Parameter output = Parameter.Factory.newInstance();
-            output.setName("echo_output");
-            output.addNewType().setType(DataType.STRING);
-            List<Parameter> outputList = new ArrayList<Parameter>();
-            outputList.add(output);
-            org.apache.airavata.schemas.gfac.Parameter[] outputParamList = outputList
-                    .toArray(new org.apache.airavata.schemas.gfac.Parameter[outputList.size()]);
-            serv.setInputParameters(inputParamList);
-            serv.setOutputParameters(outputParamList);
+            Parameter input = new Parameter();
+    		input.setName("echo_input");
+    		input.setType(new DataType());
+    		List<Parameter> inputList = new ArrayList<Parameter>();
+    		inputList.add(input);
+    		Parameter[] inputParamList = inputList.toArray(new Parameter[inputList
+    				.size()]);
+
+    		Parameter output = new Parameter();
+    		output.setName("echo_output");
+    		input.setType(new DataType());
+    		List<Parameter> outputList = new ArrayList<Parameter>();
+    		outputList.add(output);
+    		Parameter[] outputParamList = outputList
+    				.toArray(new Parameter[outputList.size()]);
+    		serv.setInputParameters(inputParamList);
+    		serv.setOutputParameters(outputParamList);
 
             /*
              * Save to registry

Modified: incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java?rev=1188854&r1=1188853&r2=1188854&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java Tue Oct 25 19:01:28 2011
@@ -21,7 +21,9 @@
 
 package org.apache.airavata.core.gfac.services.impl;
 
+import org.apache.airavata.commons.gfac.type.DataType;
 import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.Parameter;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.commons.gfac.type.app.ShellApplicationDeployment;
 import org.apache.airavata.commons.gfac.type.parameter.AbstractParameter;
@@ -31,8 +33,6 @@ import org.apache.airavata.core.gfac.con
 import org.apache.airavata.core.gfac.context.message.impl.ParameterContextImpl;
 import org.apache.airavata.core.gfac.notification.impl.LoggingNotification;
 import org.apache.airavata.registry.api.impl.JCRRegistry;
-import org.apache.airavata.schemas.gfac.DataType;
-import org.apache.airavata.schemas.gfac.Parameter;
 import org.apache.airavata.schemas.gfac.ShellApplicationDeploymentType;
 import org.junit.Assert;
 import org.junit.Before;
@@ -44,109 +44,114 @@ import java.util.List;
 import static org.junit.Assert.fail;
 
 public class PropertiesBasedServiceImplTest {
-    @Before
-    public void setUp() throws Exception {
-        /*
-         * Create database
-         */
-        JCRRegistry jcrRegistry = new JCRRegistry(null, "org.apache.jackrabbit.core.RepositoryFactoryImpl", "admin",
-                "admin", null);
-
-        /*
-         * Host
-         */
-        HostDescription host = new HostDescription();
-        host.setId("localhost");
-        host.setAddress("localhost");
-
-        /*
-         * App
-         */
-        ShellApplicationDeployment app = new ShellApplicationDeployment();
-        app.setId("EchoLocal");
-        app.setExecutable("/bin/echo");
-        app.setTmpDir("/tmp");
-        app.setWorkingDir("/tmp");
-        app.setInputDir("/tmp/input");
-        app.setOutputDir("/tmp/output");
-        app.setStdOut("/tmp/echo.stdout");
-        app.setStdErr("/tmp/echo.stdout");
-        app.setEnv(ShellApplicationDeploymentType.Factory.newInstance().getEnv());
-
-        /*
-         * Service
-         */
-        ServiceDescription serv = new ServiceDescription();
-        serv.setId("SimpleEcho");
-
-        Parameter input = Parameter.Factory.newInstance();
-        input.setName("echo_input");
-        input.addNewType().setType(DataType.STRING);
-        List<Parameter> inputList = new ArrayList<Parameter>();
-        inputList.add(input);
-        org.apache.airavata.schemas.gfac.Parameter[] inputParamList = inputList
-                .toArray(new org.apache.airavata.schemas.gfac.Parameter[inputList.size()]);
-
-        Parameter output = Parameter.Factory.newInstance();
-        output.setName("echo_output");
-        output.addNewType().setType(DataType.STRING);
-        List<Parameter> outputList = new ArrayList<Parameter>();
-        outputList.add(output);
-        org.apache.airavata.schemas.gfac.Parameter[] outputParamList = outputList
-                .toArray(new org.apache.airavata.schemas.gfac.Parameter[outputList.size()]);
-        serv.setInputParameters(inputParamList);
-        serv.setOutputParameters(outputParamList);
-
-        /*
-         * Save to registry
-         */
-        jcrRegistry.saveHostDescription(host);
-        jcrRegistry.saveDeploymentDescription(serv.getId(), host.getId(), app);
-        jcrRegistry.saveServiceDescription(serv);
-        jcrRegistry.deployServiceOnHost(serv.getId(), host.getId());
-    }
-
-    @Test
-    public void testExecute() {
-        try {
-
-            DefaultInvocationContext ct = new DefaultInvocationContext();
-            DefaultExecutionContext ec = new DefaultExecutionContext();
-            ec.addNotifiable(new LoggingNotification());
-            ct.setExecutionContext(ec);
-
-            ct.setServiceName("SimpleEcho");
-
-            /*
-             * Input
-             */
-            ParameterContextImpl input = new ParameterContextImpl();
-            AbstractParameter echo_input = ParameterFactory.getInstance().createActualParameter("String");
-            echo_input.parseStringVal("echo_output=hello");
-            input.add("echo_input", echo_input);
-
-            /*
-             * Output
-             */
-            ParameterContextImpl output = new ParameterContextImpl();
-            AbstractParameter echo_output = ParameterFactory.getInstance().createActualParameter("String");
-            output.add("echo_output", echo_output);
-
-            // parameter
-            ct.setInput(input);
-            ct.setOutput(output);
-
-            PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
-            service.init();
-            service.execute(ct);
-
-            Assert.assertNotNull(ct.getOutput());
-            Assert.assertNotNull(ct.getOutput().getValue("echo_output"));
-            Assert.assertEquals("hello", ((AbstractParameter) ct.getOutput().getValue("echo_output")).toStringVal());
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("ERROR");
-        }
-    }
+	@Before
+	public void setUp() throws Exception {
+		/*
+		 * Create database
+		 */
+		JCRRegistry jcrRegistry = new JCRRegistry(null,
+				"org.apache.jackrabbit.core.RepositoryFactoryImpl", "admin",
+				"admin", null);
+
+		/*
+		 * Host
+		 */
+		HostDescription host = new HostDescription();
+		host.setId("localhost");
+		host.setAddress("localhost");
+
+		/*
+		 * App
+		 */
+		ShellApplicationDeployment app = new ShellApplicationDeployment();
+		app.setId("EchoLocal");
+		app.setExecutable("/bin/echo");
+		app.setTmpDir("/tmp");
+		app.setWorkingDir("/tmp");
+		app.setInputDir("/tmp/input");
+		app.setOutputDir("/tmp/output");
+		app.setStdOut("/tmp/echo.stdout");
+		app.setStdErr("/tmp/echo.stdout");
+		app.setEnv(ShellApplicationDeploymentType.Factory.newInstance()
+				.getEnv());
+
+		/*
+		 * Service
+		 */
+		ServiceDescription serv = new ServiceDescription();
+		serv.setId("SimpleEcho");
+
+		Parameter input = new Parameter();
+		input.setName("echo_input");
+		input.setType(new DataType());
+		List<Parameter> inputList = new ArrayList<Parameter>();
+		inputList.add(input);
+		Parameter[] inputParamList = inputList.toArray(new Parameter[inputList
+				.size()]);
+
+		Parameter output = new Parameter();
+		output.setName("echo_output");
+		input.setType(new DataType());
+		List<Parameter> outputList = new ArrayList<Parameter>();
+		outputList.add(output);
+		Parameter[] outputParamList = outputList
+				.toArray(new Parameter[outputList.size()]);
+		serv.setInputParameters(inputParamList);
+		serv.setOutputParameters(outputParamList);
+
+		/*
+		 * Save to registry
+		 */
+		jcrRegistry.saveHostDescription(host);
+		jcrRegistry.saveDeploymentDescription(serv.getId(), host.getId(), app);
+		jcrRegistry.saveServiceDescription(serv);
+		jcrRegistry.deployServiceOnHost(serv.getId(), host.getId());
+	}
+
+	@Test
+	public void testExecute() {
+		try {
+
+			DefaultInvocationContext ct = new DefaultInvocationContext();
+			DefaultExecutionContext ec = new DefaultExecutionContext();
+			ec.addNotifiable(new LoggingNotification());
+			ct.setExecutionContext(ec);
+
+			ct.setServiceName("SimpleEcho");
+
+			/*
+			 * Input
+			 */
+			ParameterContextImpl input = new ParameterContextImpl();
+			AbstractParameter echo_input = ParameterFactory.getInstance()
+					.createActualParameter("String");
+			echo_input.parseStringVal("echo_output=hello");
+			input.add("echo_input", echo_input);
+
+			/*
+			 * Output
+			 */
+			ParameterContextImpl output = new ParameterContextImpl();
+			AbstractParameter echo_output = ParameterFactory.getInstance()
+					.createActualParameter("String");
+			output.add("echo_output", echo_output);
+
+			// parameter
+			ct.setInput(input);
+			ct.setOutput(output);
+
+			PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
+			service.init();
+			service.execute(ct);
+
+			Assert.assertNotNull(ct.getOutput());
+			Assert.assertNotNull(ct.getOutput().getValue("echo_output"));
+			Assert.assertEquals("hello", ((AbstractParameter) ct.getOutput()
+					.getValue("echo_output")).toStringVal());
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			fail("ERROR");
+		}
+	}
 }