You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by he...@apache.org on 2012/10/30 20:06:52 UTC
svn commit: r1403814 -
/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/DescriptorUtil.java
Author: heshan
Date: Tue Oct 30 19:06:51 2012
New Revision: 1403814
URL: http://svn.apache.org/viewvc?rev=1403814&view=rev
Log:
Adding helper methods.
Modified:
airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/DescriptorUtil.java
Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/DescriptorUtil.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/DescriptorUtil.java?rev=1403814&r1=1403813&r2=1403814&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/DescriptorUtil.java (original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/DescriptorUtil.java Tue Oct 30 19:06:51 2012
@@ -1,7 +1,16 @@
package org.apache.airavata.services.registry.rest.utils;
+import org.apache.airavata.client.api.AiravataAPI;
+import org.apache.airavata.client.api.AiravataAPIInvocationException;
+import org.apache.airavata.client.api.ApplicationManager;
+import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.schemas.gfac.*;
+
+import javax.ws.rs.FormParam;
+import java.util.ArrayList;
+import java.util.List;
public class DescriptorUtil {
@@ -22,4 +31,53 @@ public class DescriptorUtil {
}
return host;
}
+
+ public static ApplicationDeploymentDescription registerApplication(String appName, String exeuctableLocation, String scratchWorkingDirectory, String hostName,
+ String projAccNumber, String queueName, String cpuCount, String nodeCount, String maxMemory) throws Exception {
+ // Create Application Description
+ ApplicationDeploymentDescription appDesc = new ApplicationDeploymentDescription(GramApplicationDeploymentType.type);
+ GramApplicationDeploymentType app = (GramApplicationDeploymentType) appDesc.getType();
+ app.setCpuCount(Integer.parseInt(cpuCount));
+ app.setNodeCount(Integer.parseInt(nodeCount));
+ ApplicationDeploymentDescriptionType.ApplicationName name = appDesc.getType().addNewApplicationName();
+ name.setStringValue(appName);
+ app.setExecutableLocation(exeuctableLocation);
+ app.setScratchWorkingDirectory(scratchWorkingDirectory);
+ ProjectAccountType projectAccountType = ((GramApplicationDeploymentType) appDesc.getType()).addNewProjectAccount();
+ projectAccountType.setProjectAccountNumber(projAccNumber);
+ QueueType queueType = app.addNewQueue();
+ queueType.setQueueName(queueName);
+ app.setMaxMemory(Integer.parseInt(maxMemory));
+ return appDesc;
+ }
+
+ public static ServiceDescription getServiceDescription(String serviceName, String inputName, String inputType,
+ String outputName, String outputType) {
+ // Create Service Description
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName(serviceName);
+
+ InputParameterType input = InputParameterType.Factory.newInstance();
+ input.setParameterName(inputName);
+ ParameterType parameterType = input.addNewParameterType();
+ parameterType.setType(DataType.Enum.forString(inputType));
+ parameterType.setName(inputName);
+ List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+ inputList.add(input);
+ InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+ .size()]);
+
+ OutputParameterType output = OutputParameterType.Factory.newInstance();
+ output.setParameterName(outputName);
+ ParameterType parameterType1 = output.addNewParameterType();
+ parameterType1.setType(DataType.Enum.forString(outputType));
+ parameterType1.setName(outputName);
+ List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+ outputList.add(output);
+ OutputParameterType[] outputParamList = outputList
+ .toArray(new OutputParameterType[outputList.size()]);
+ serv.getType().setInputParametersArray(inputParamList);
+ serv.getType().setOutputParametersArray(outputParamList);
+ return serv;
+ }
}