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/26 23:02:44 UTC
svn commit: r1189457 - in /incubator/airavata/trunk/modules:
commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/
gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/
gfac-core/src/main/java/org/apache/airavat...
Author: patanachai
Date: Wed Oct 26 21:02:44 2011
New Revision: 1189457
URL: http://svn.apache.org/viewvc?rev=1189457&view=rev
Log:
AIRAVATA-171 Add mapping from application to Gfac
Added:
incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java
Modified:
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java
incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java
Added: incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java?rev=1189457&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java (added)
+++ incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java Wed Oct 26 21:02:44 2011
@@ -0,0 +1,69 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.commons.gfac.type;
+
+import org.apache.airavata.schemas.gfac.BooleanParameter;
+import org.apache.airavata.schemas.gfac.DataType;
+import org.apache.airavata.schemas.gfac.DoubleParameter;
+import org.apache.airavata.schemas.gfac.FileParameter;
+import org.apache.airavata.schemas.gfac.FloatParameter;
+import org.apache.airavata.schemas.gfac.IntegerParameter;
+import org.apache.airavata.schemas.gfac.StringParameter;
+
+/*
+ * TODO use XML meta data instead of static coding
+ *
+ */
+public class MappingFactory {
+ public static String toString(ActualParameter param){
+ if(param.hasType(DataType.STRING)){
+ return ((StringParameter)param.getType()).getValue();
+ }else if (param.hasType(DataType.INTEGER)){
+ return String.valueOf(((IntegerParameter)param.getType()).getValue());
+ }else if (param.hasType(DataType.DOUBLE)){
+ return String.valueOf(((DoubleParameter)param.getType()).getValue());
+ }else if (param.hasType(DataType.BOOLEAN)){
+ return String.valueOf(((BooleanParameter)param.getType()).getValue());
+ }else if (param.hasType(DataType.FILE)){
+ return ((FileParameter)param.getType()).getValue();
+ }else if (param.hasType(DataType.FLOAT)){
+ return String.valueOf(((FloatParameter)param.getType()).getValue());
+ }
+ return null;
+ }
+
+ public static void fromString(ActualParameter param, String val){
+ if(param.hasType(DataType.STRING)){
+ ((StringParameter)param.getType()).setValue(val);
+ }else if (param.hasType(DataType.INTEGER)){
+ ((IntegerParameter)param.getType()).setValue(Integer.parseInt(val));
+ }else if (param.hasType(DataType.DOUBLE)){
+ ((DoubleParameter)param.getType()).setValue(Double.parseDouble(val));
+ }else if (param.hasType(DataType.BOOLEAN)){
+ ((BooleanParameter)param.getType()).setValue(Boolean.parseBoolean(val));
+ }else if (param.hasType(DataType.FILE)){
+ ((FileParameter)param.getType()).setValue(val);
+ }else if (param.hasType(DataType.FLOAT)){
+ ((FloatParameter)param.getType()).setValue(Float.parseFloat(val));
+ }
+ }
+}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java?rev=1189457&r1=1189456&r2=1189457&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java Wed Oct 26 21:02:44 2011
@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.Map;
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;
/**
@@ -49,7 +50,7 @@ public class ParameterContextImpl implem
public String getStringValue(String name) {
if (this.value.containsKey(name))
- return this.value.get(name).toXML();
+ return MappingFactory.toString(this.value.get(name));
else
return null;
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java?rev=1189457&r1=1189456&r2=1189457&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java Wed Oct 26 21:02:44 2011
@@ -81,7 +81,7 @@ public class RegistryDataService extends
/*
* Stdout and Stderr for Shell
*/
- if (appDesc.getClass().isAssignableFrom(ShellApplicationDeploymentType.class)) {
+ if (ShellApplicationDeploymentType.class.isAssignableFrom(appDesc.getClass())) {
ShellApplicationDeploymentType shell = (ShellApplicationDeploymentType) appDesc;
if (shell.getStdOut() == null) {
shell.setStdOut(appDesc.getWorkingDir() + File.separator + appDesc.getName() + ".stdout");
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=1189457&r1=1189456&r2=1189457&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 Wed Oct 26 21:02:44 2011
@@ -28,6 +28,7 @@ import java.util.regex.Matcher;
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.xmlbeans.XmlException;
@@ -48,7 +49,9 @@ public class OutputUtils {
continue;
}
- result.put(parameterName, ActualParameter.fromXML(parseStdout(stdout, parameterName)));
+ ActualParameter actual = outMessage.getValue(parameterName);
+ MappingFactory.fromString(actual, parseStdout(stdout, parameterName));
+ result.put(parameterName, actual);
}
return result;
}
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=1189457&r1=1189456&r2=1189457&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 Wed Oct 26 21:02:44 2011
@@ -62,8 +62,10 @@ public class PropertiesBasedServiceImplT
/*
* App
*/
- ApplicationDeploymentDescription appDesc = new ApplicationDeploymentDescription(ShellApplicationDeploymentType.type);
- ShellApplicationDeploymentType app = (ShellApplicationDeploymentType) appDesc.getType();
+ ApplicationDeploymentDescription appDesc = new ApplicationDeploymentDescription(
+ ShellApplicationDeploymentType.type);
+ ShellApplicationDeploymentType app = (ShellApplicationDeploymentType) appDesc
+ .getType();
app.setName("EchoLocal");
app.setExecutable("/bin/echo");
app.setTmpDir("/tmp");
@@ -80,7 +82,7 @@ public class PropertiesBasedServiceImplT
ServiceDescription serv = new ServiceDescription();
serv.getType().setName("SimpleEcho");
- Parameter input = Parameter.Factory.newInstance();
+ Parameter input = Parameter.Factory.newInstance();
input.setName("echo_input");
input.addNewType();
List<Parameter> inputList = new ArrayList<Parameter>();
@@ -102,9 +104,11 @@ public class PropertiesBasedServiceImplT
* Save to registry
*/
jcrRegistry.saveHostDescription(host);
- jcrRegistry.saveDeploymentDescription(serv.getType().getName(), host.getType().getName(), appDesc);
+ jcrRegistry.saveDeploymentDescription(serv.getType().getName(), host
+ .getType().getName(), appDesc);
jcrRegistry.saveServiceDescription(serv);
- jcrRegistry.deployServiceOnHost(serv.getType().getName(), host.getType().getName());
+ jcrRegistry.deployServiceOnHost(serv.getType().getName(), host
+ .getType().getName());
}
@Test
@@ -122,15 +126,15 @@ public class PropertiesBasedServiceImplT
* Input
*/
ParameterContextImpl input = new ParameterContextImpl();
- ActualParameter echo_input = new ActualParameter();
- ((StringParameter)echo_input.getType()).setValue("echo_output=<value>hello</value>");
+ ActualParameter echo_input = new ActualParameter(StringParameter.type);
+ ((StringParameter)echo_input.getType()).setValue("echo_output=hello");
input.add("echo_input", echo_input);
/*
* Output
*/
ParameterContextImpl output = new ParameterContextImpl();
- ActualParameter echo_output = new ActualParameter();
+ ActualParameter echo_output = new ActualParameter(StringParameter.type);
output.add("echo_output", echo_output);
// parameter
@@ -143,8 +147,7 @@ public class PropertiesBasedServiceImplT
Assert.assertNotNull(ct.getOutput());
Assert.assertNotNull(ct.getOutput().getValue("echo_output"));
- Assert.assertEquals("hello", ((StringParameter) ct.getOutput()
- .getValue("echo_output")).getValue());
+ Assert.assertEquals("hello", ((StringParameter)((ActualParameter)ct.getOutput().getValue("echo_output")).getType()).getValue());
} catch (Exception e) {
e.printStackTrace();