airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject svn commit: r1476707 [1/2] - in /airavata/trunk: modules/gfac-core/ modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/ modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ modules/gfac-core/src/test/java/org/apa...
Date Sun, 28 Apr 2013 02:20:37 GMT
Author: smarru
Date: Sun Apr 28 02:20:36 2013
New Revision: 1476707

URL: http://svn.apache.org/r1476707
Log:
using the jsdl schemas bundled with gfac-schemas. Incrementally removing external dependencies.

Modified:
    airavata/trunk/modules/gfac-core/pom.xml
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTest.java
    airavata/trunk/tools/registry-tool/pom.xml

Modified: airavata/trunk/modules/gfac-core/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/pom.xml?rev=1476707&r1=1476706&r2=1476707&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/pom.xml (original)
+++ airavata/trunk/modules/gfac-core/pom.xml Sun Apr 28 02:20:36 2013
@@ -1,98 +1,96 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!--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. -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<parent>
-		<groupId>org.apache.airavata</groupId>
-		<artifactId>airavata</artifactId>
-		<version>0.8-SNAPSHOT</version>
-		<relativePath>../../pom.xml</relativePath>
-	</parent>
-
-	<modelVersion>4.0.0</modelVersion>
-	<artifactId>airavata-gfac-core</artifactId>
-	<name>Airavata GFac Core</name>
-	<description>The core GFAC functionality independent from any webservice implementation.</description>
-	<url>http://airavata.apache.org/</url>
-
-	<dependencies>
-		<dependency>
-			<groupId>cog-jglobus</groupId>
-			<artifactId>cog-jglobus</artifactId>
-			<version>1.8.0_bc</version>
-		</dependency>
-		<dependency>
-			<groupId>cog-globus</groupId>
-			<artifactId>puretls</artifactId>
-			<type>jar</type>
-			<version>1.0</version>
-		</dependency>
-		<dependency>
-			<groupId>cog-globus</groupId>
-			<artifactId>cryptix32</artifactId>
-			<version>1.0</version>
-		</dependency>
-		<!-- <dependency> <groupId>org.bouncycastle</groupId> <artifactId>bcprov-jdk16</artifactId> 
-			<version>1.46</version> </dependency> -->
-		<dependency>
-			<groupId>cog-globus</groupId>
-			<artifactId>cryptix-asn1</artifactId>
-			<version>1.0</version>
-		</dependency>
-		<dependency>
-			<groupId>commons-configuration</groupId>
-			<artifactId>commons-configuration</artifactId>
-			<version>1.6</version>
-		</dependency>
-
-		<!-- Logging -->
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-api</artifactId>
-		</dependency>
-
-		<!-- GFAC schemas -->
-		<dependency>
-			<groupId>org.apache.airavata</groupId>
-			<artifactId>airavata-client-api</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.airavata</groupId>
-			<artifactId>airavata-workflow-execution-context</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-
-		<!-- Workflow Tracking -->
-		<dependency>
-			<groupId>org.apache.airavata</groupId>
-			<artifactId>airavata-workflow-tracking</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-
-		<!-- SSH -->
-		<dependency>
-			<groupId>net.schmizz</groupId>
-			<artifactId>sshj</artifactId>
-			<version>0.8.0</version>
-		</dependency>
-
-		<!-- Amazon EC2 Provider  -->
-		<dependency>
-			<groupId>com.amazonaws</groupId>
-			<artifactId>aws-java-sdk</artifactId>
-			<version>1.3.20</version>
-		</dependency>
+<!--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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.airavata</groupId>
+        <artifactId>airavata</artifactId>
+        <version>0.8-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>airavata-gfac-core</artifactId>
+    <name>Airavata GFac Core</name>
+    <description>The core GFAC functionality independent from any webservice implementation.</description>
+    <url>http://airavata.apache.org/</url>
+
+    <dependencies>
+        <dependency>
+            <groupId>cog-jglobus</groupId>
+            <artifactId>cog-jglobus</artifactId>
+            <version>1.8.0_bc</version>
+        </dependency>
+        <dependency>
+            <groupId>cog-globus</groupId>
+            <artifactId>puretls</artifactId>
+            <type>jar</type>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>cog-globus</groupId>
+            <artifactId>cryptix32</artifactId>
+            <version>1.0</version>
+        </dependency>
+        <!-- <dependency> <groupId>org.bouncycastle</groupId> <artifactId>bcprov-jdk16</artifactId> <version>1.46</version> 
+            </dependency> -->
+        <dependency>
+            <groupId>cog-globus</groupId>
+            <artifactId>cryptix-asn1</artifactId>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-configuration</groupId>
+            <artifactId>commons-configuration</artifactId>
+            <version>1.6</version>
+        </dependency>
+
+        <!-- Logging -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <!-- GFAC schemas -->
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-client-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-workflow-execution-context</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- Workflow Tracking -->
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-workflow-tracking</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- SSH -->
+        <dependency>
+            <groupId>net.schmizz</groupId>
+            <artifactId>sshj</artifactId>
+            <version>0.8.0</version>
+        </dependency>
+
+        <!-- Amazon EC2 Provider -->
+        <dependency>
+            <groupId>com.amazonaws</groupId>
+            <artifactId>aws-java-sdk</artifactId>
+            <version>1.3.20</version>
+        </dependency>
         <dependency>
             <groupId>j2ssh</groupId>
             <artifactId>j2ssh-core</artifactId>
@@ -118,105 +116,105 @@
             <type>jar</type>
         </dependency>
 
-		<!-- Test -->
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>jcl-over-slf4j</artifactId>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-log4j12</artifactId>
-			<scope>test</scope>
-		</dependency>
-
-		<!-- Unicore dependencies -->
-		<dependency>
-			<groupId>eu.unicore</groupId>
-			<artifactId>ogsabes-client</artifactId>
-			<version>1.6.0</version>
-		</dependency>
-
-		<!-- Hadoop provider related dependencies -->
-		<dependency>
-			<groupId>org.apache.hadoop</groupId>
-			<artifactId>hadoop-core</artifactId>
-			<version>1.0.3</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.hadoop</groupId>
-			<artifactId>hadoop-client</artifactId>
-			<version>1.0.3</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.whirr</groupId>
-			<artifactId>whirr-core</artifactId>
-			<version>0.7.1</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.whirr</groupId>
-			<artifactId>whirr-hadoop</artifactId>
-			<version>0.7.1</version>
-		</dependency>
-		<dependency>
-			<groupId>org.hamcrest</groupId>
-			<artifactId>hamcrest-all</artifactId>
-			<version>1.1</version>
-		</dependency>
-		<dependency>
-			<groupId>org.mockito</groupId>
-			<artifactId>mockito-all</artifactId>
-			<version>1.8.5</version>
-		</dependency>
-		<dependency>
-			<groupId>com.jcraft</groupId>
-			<artifactId>jsch</artifactId>
-			<version>0.1.44-1</version>
-		</dependency>
-		<dependency>
-			<groupId>commons-configuration</groupId>
-			<artifactId>commons-configuration</artifactId>
-			<version>1.7</version>
-		</dependency>
-		<dependency>
-			<groupId>net.sf.jopt-simple</groupId>
-			<artifactId>jopt-simple</artifactId>
-			<version>3.2</version>
-		</dependency>
-		<dependency>
-			<groupId>net.sf.wsag4j.types</groupId>
-			<artifactId>wsag4j-jsdl-types</artifactId>
-			<version>2.0.0</version>
-		</dependency>
-		<!-- Guava -->
-		<dependency>
-			<groupId>com.google.guava</groupId>
-			<artifactId>guava</artifactId>
-			<version>12.0</version>
-		</dependency>
-	</dependencies>
-
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-surefire-plugin</artifactId>
-				<configuration>
-					<!--skip>true</skip -->
-					<excludes>
-						<exclude>**/services/**</exclude>
-					</excludes>
-					<forkMode>always</forkMode>
-					<useSystemClassloader>true</useSystemClassloader>
-					<failIfNoTests>false</failIfNoTests>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
+        <!-- Test -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- Unicore dependencies -->
+        <dependency>
+            <groupId>eu.unicore</groupId>
+            <artifactId>ogsabes-client</artifactId>
+            <version>1.6.0</version>
+        </dependency>
+
+        <!-- Hadoop provider related dependencies -->
+        <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-core</artifactId>
+            <version>1.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-client</artifactId>
+            <version>1.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.whirr</groupId>
+            <artifactId>whirr-core</artifactId>
+            <version>0.7.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.whirr</groupId>
+            <artifactId>whirr-hadoop</artifactId>
+            <version>0.7.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-all</artifactId>
+            <version>1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.8.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.jcraft</groupId>
+            <artifactId>jsch</artifactId>
+            <version>0.1.44-1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-configuration</groupId>
+            <artifactId>commons-configuration</artifactId>
+            <version>1.7</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.jopt-simple</groupId>
+            <artifactId>jopt-simple</artifactId>
+            <version>3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.wsag4j.types</groupId>
+            <artifactId>wsag4j-jsdl-types</artifactId>
+            <version>2.0.0</version>
+        </dependency>
+        <!-- Guava -->
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>12.0</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <!--skip>true</skip -->
+                    <excludes>
+                        <exclude>**/services/**</exclude>
+                    </excludes>
+                    <forkMode>always</forkMode>
+                    <useSystemClassloader>true</useSystemClassloader>
+                    <failIfNoTests>false</failIfNoTests>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>
\ No newline at end of file

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java?rev=1476707&r1=1476706&r2=1476707&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java Sun Apr 28 02:20:36 2013
@@ -88,8 +88,10 @@ public class BESProvider implements GFac
                 .newInstance();
         
         try {
-			cad.addNewCreateActivity().addNewActivityDocument()
-			        .setJobDefinition(JSDLGenerator.buildJSDLInstance(jobExecutionContext).getJobDefinition());
+            //FIXME: Replace by a native client
+//			cad.addNewCreateActivity().addNewActivityDocument()
+//			        .setJobDefinition(JSDLGenerator.buildJSDLInstance(jobExecutionContext).getJobDefinition());
+			System.out.println("REMOVE ME");
 		} catch (Exception e1) {
 			throw new GFacProviderException("Cannot generate JSDL instance from the JobExecutionContext.",e1);
 		}

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java?rev=1476707&r1=1476706&r2=1476707&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ApplicationProcessor.java Sun Apr 28 02:20:36 2013
@@ -17,7 +17,7 @@
  * specific language governing permissions and limitations
  * under the License.
  *
-*/
+ */
 package org.apache.airavata.gfac.provider.utils;
 
 import java.io.File;
@@ -27,206 +27,197 @@ import org.apache.airavata.schemas.gfac.
 import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
 import org.apache.airavata.schemas.gfac.JobTypeType;
 import org.apache.airavata.schemas.gfac.NameValuePairType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.EnvironmentType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType;
-import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.NumberOfProcessesType;
-import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ProcessesPerHostType;
-import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ThreadsPerProcessType;
-
+import org.ogf.schemas.jsdl.ApplicationType;
+import org.ogf.schemas.jsdl.JobDefinitionType;
+import org.ogf.schemas.jsdl.posix.EnvironmentType;
+import org.ogf.schemas.jsdl.posix.FileNameType;
+import org.ogf.schemas.jsdl.spmd.NumberOfProcessesType;
+import org.ogf.schemas.jsdl.spmd.ProcessesPerHostType;
+import org.ogf.schemas.jsdl.spmd.ThreadsPerProcessType;
 
 public class ApplicationProcessor {
-	
-	public static void generateJobSpecificAppElements(JobDefinitionType value, JobExecutionContext context){
-		
-		HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context
-				.getApplicationContext().getApplicationDeploymentDescription()
-				.getType();
-		
-		createGenericApplication(value, appDepType);
-		
-		if (appDepType.getApplicationEnvironmentArray().length > 0) {
-			createApplicationEnvironment(value,
-					appDepType.getApplicationEnvironmentArray(), appDepType);
-		}
-
-		
-		if (appDepType.getExecutableLocation() != null) {
-			FileNameType fNameType = FileNameType.Factory.newInstance();
-			fNameType.setStringValue(appDepType.getExecutableLocation());
-			if(isParallelJob(appDepType)) {
-				JSDLUtils.getOrCreateSPMDApplication(value).setExecutable(fNameType);
-				JSDLUtils.getSPMDApplication(value).setSPMDVariation(getSPMDVariation(appDepType));
-				
-				if(getValueFromMap(appDepType, JSDLUtils.NUMBEROFPROCESSES)!=null){
-					NumberOfProcessesType num = NumberOfProcessesType.Factory.newInstance();
-					num.setStringValue(getValueFromMap(appDepType, JSDLUtils.NUMBEROFPROCESSES));
-					JSDLUtils.getSPMDApplication(value).setNumberOfProcesses(num);
-				}
-				
-				if(getValueFromMap(appDepType, JSDLUtils.PROCESSESPERHOST)!=null){
-					ProcessesPerHostType pph = ProcessesPerHostType.Factory.newInstance();
-					pph.setStringValue(getValueFromMap(appDepType, JSDLUtils.PROCESSESPERHOST));
-					JSDLUtils.getSPMDApplication(value).setProcessesPerHost(pph);
-				}
-				
-				if(getValueFromMap(appDepType, JSDLUtils.THREADSPERHOST)!=null){
-					ThreadsPerProcessType tpp = ThreadsPerProcessType.Factory.newInstance();
-					tpp.setStringValue(getValueFromMap(appDepType, JSDLUtils.THREADSPERHOST));
-					JSDLUtils.getSPMDApplication(value).setThreadsPerProcess(tpp);
-				}
-			}
-			else 
-				JSDLUtils.getOrCreatePOSIXApplication(value).setExecutable(fNameType);
-		}
-		
-		if(appDepType.getStandardOutput() != null) {
-			String stdout = new File(appDepType.getStandardOutput()).getName();
-			ApplicationProcessor.setApplicationStdOut(value, appDepType, stdout);
-		}
-		
-		if(appDepType.getStandardError() != null) {
-			String stderr = new File(appDepType.getStandardError()).getName();
-			ApplicationProcessor.setApplicationStdErr(value, appDepType, stderr);
-		}
-		
-		
-		
-		
-	}
-	
-	
-	public static boolean isParallelJob(HpcApplicationDeploymentType appDepType) {
-		
-		boolean isParallel = false;
-		
-		if (appDepType.getJobType() != null) {
-			// TODO set data output directory
-			int status = appDepType.getJobType().intValue();
-
-			switch (status) {
-			// TODO: this check should be done outside this class
-			case JobTypeType.INT_MPI:
-			case JobTypeType.INT_OPEN_MP:
-				isParallel = true;
-				break;
-				
-			case JobTypeType.INT_SERIAL:
-			case JobTypeType.INT_SINGLE:
-				isParallel = false;
-				break;
-
-			default:
-				isParallel = false;
-				break;
-			}
-		}
-		return isParallel;
-	}
-
-	
-	public static void createApplicationEnvironment(JobDefinitionType value, NameValuePairType[] nameValuePairs, HpcApplicationDeploymentType appDepType) {
-		
-		if(isParallelJob(appDepType)) {
-			for (NameValuePairType nv : nameValuePairs) {
-				EnvironmentType envType = JSDLUtils.getOrCreateSPMDApplication(value).addNewEnvironment();
-				envType.setName(nv.getName());
-				envType.setStringValue(nv.getValue());
-			}
-		}
-		else {
-			for (NameValuePairType nv : nameValuePairs) {
-				EnvironmentType envType = JSDLUtils.getOrCreatePOSIXApplication(value).addNewEnvironment();
-				envType.setName(nv.getName());
-				envType.setStringValue(nv.getValue());
-			}
-		}
-
-	}
-	
-	
-	public static String getSPMDVariation (HpcApplicationDeploymentType appDepType) {
-		
-		String variation = null;
-		
-		if (appDepType.getJobType() != null) {
-			// TODO set data output directory
-			int status = appDepType.getJobType().intValue();
-
-			switch (status) {
-			// TODO: this check should be done outside this class
-			case JobTypeType.INT_MPI:
-				variation = SPMDVariations.MPI.value();				
-				break;
-				
-			case JobTypeType.INT_OPEN_MP:
-				variation = SPMDVariations.OpenMPI.value();
-				break;
-				
-			}
-		}
-		return variation;
-	}
-	
-	
-	public static void addApplicationArgument(JobDefinitionType value, HpcApplicationDeploymentType appDepType, String stringPrm) {
-		if(isParallelJob(appDepType)) 		
-			JSDLUtils.getOrCreateSPMDApplication(value)
-			.addNewArgument().setStringValue(stringPrm);
-		else 
-		    JSDLUtils.getOrCreatePOSIXApplication(value)
-				.addNewArgument().setStringValue(stringPrm);
-
-	}
-	
-	public static void setApplicationStdErr(JobDefinitionType value, HpcApplicationDeploymentType appDepType, String stderr) {
-		FileNameType fName = FileNameType.Factory.newInstance();
-		fName.setStringValue(stderr);
-		if (isParallelJob(appDepType)) 
-			JSDLUtils.getOrCreateSPMDApplication(value).setError(fName);
-		else 
-			JSDLUtils.getOrCreatePOSIXApplication(value).setError(fName);
-	}
-	
-	public static void setApplicationStdOut(JobDefinitionType value, HpcApplicationDeploymentType appDepType, String stderr) {
-		FileNameType fName = FileNameType.Factory.newInstance();
-		fName.setStringValue(stderr);
-		if (isParallelJob(appDepType)) 
-			JSDLUtils.getOrCreateSPMDApplication(value).setOutput(fName);
-		else 
-			JSDLUtils.getOrCreatePOSIXApplication(value).setOutput(fName);
-	}
-	
-	public static String getApplicationStdOut(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
-		if (isParallelJob(appDepType)) return JSDLUtils.getOrCreateSPMDApplication(value).getOutput().getStringValue();
-		else return JSDLUtils.getOrCreatePOSIXApplication(value).getOutput().getStringValue();
-	}
-	
-	public static String getApplicationStdErr(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
-		if (isParallelJob(appDepType)) return JSDLUtils.getOrCreateSPMDApplication(value).getError().getStringValue();
-		else return JSDLUtils.getOrCreatePOSIXApplication(value).getError().getStringValue();
-	}
-	
-	public static void createGenericApplication(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
-		if (appDepType.getApplicationName() != null) {
-			ApplicationType appType = JSDLUtils.getOrCreateApplication(value);
-			String appName = appDepType.getApplicationName()
-					.getStringValue();
-			appType.setApplicationName(appName);
-			JSDLUtils.getOrCreateJobIdentification(value).setJobName(appName);
-		}
-	}
-	
-	
-	public static String getValueFromMap(HpcApplicationDeploymentType appDepType, String name) {
-		ExtendedKeyValueType[] extended = appDepType.getKeyValuePairsArray();
-		for(ExtendedKeyValueType e: extended) {
-			if(e.getName().equalsIgnoreCase(name)) {
-				return e.getStringValue();
-			}
-		}
-		return null;
-	}
-	
+
+    public static void generateJobSpecificAppElements(JobDefinitionType value, JobExecutionContext context) {
+
+        HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context.getApplicationContext()
+                .getApplicationDeploymentDescription().getType();
+
+        createGenericApplication(value, appDepType);
+
+        if (appDepType.getApplicationEnvironmentArray().length > 0) {
+            createApplicationEnvironment(value, appDepType.getApplicationEnvironmentArray(), appDepType);
+        }
+
+        if (appDepType.getExecutableLocation() != null) {
+            FileNameType fNameType = FileNameType.Factory.newInstance();
+            fNameType.setStringValue(appDepType.getExecutableLocation());
+            if (isParallelJob(appDepType)) {
+                JSDLUtils.getOrCreateSPMDApplication(value).setExecutable(fNameType);
+                JSDLUtils.getSPMDApplication(value).setSPMDVariation(getSPMDVariation(appDepType));
+
+                if (getValueFromMap(appDepType, JSDLUtils.NUMBEROFPROCESSES) != null) {
+                    NumberOfProcessesType num = NumberOfProcessesType.Factory.newInstance();
+                    num.setStringValue(getValueFromMap(appDepType, JSDLUtils.NUMBEROFPROCESSES));
+                    JSDLUtils.getSPMDApplication(value).setNumberOfProcesses(num);
+                }
+
+                if (getValueFromMap(appDepType, JSDLUtils.PROCESSESPERHOST) != null) {
+                    ProcessesPerHostType pph = ProcessesPerHostType.Factory.newInstance();
+                    pph.setStringValue(getValueFromMap(appDepType, JSDLUtils.PROCESSESPERHOST));
+                    JSDLUtils.getSPMDApplication(value).setProcessesPerHost(pph);
+                }
+
+                if (getValueFromMap(appDepType, JSDLUtils.THREADSPERHOST) != null) {
+                    ThreadsPerProcessType tpp = ThreadsPerProcessType.Factory.newInstance();
+                    tpp.setStringValue(getValueFromMap(appDepType, JSDLUtils.THREADSPERHOST));
+                    JSDLUtils.getSPMDApplication(value).setThreadsPerProcess(tpp);
+                }
+            } else
+                JSDLUtils.getOrCreatePOSIXApplication(value).setExecutable(fNameType);
+        }
+
+        if (appDepType.getStandardOutput() != null) {
+            String stdout = new File(appDepType.getStandardOutput()).getName();
+            ApplicationProcessor.setApplicationStdOut(value, appDepType, stdout);
+        }
+
+        if (appDepType.getStandardError() != null) {
+            String stderr = new File(appDepType.getStandardError()).getName();
+            ApplicationProcessor.setApplicationStdErr(value, appDepType, stderr);
+        }
+
+    }
+
+    public static boolean isParallelJob(HpcApplicationDeploymentType appDepType) {
+
+        boolean isParallel = false;
+
+        if (appDepType.getJobType() != null) {
+            // TODO set data output directory
+            int status = appDepType.getJobType().intValue();
+
+            switch (status) {
+            // TODO: this check should be done outside this class
+            case JobTypeType.INT_MPI:
+            case JobTypeType.INT_OPEN_MP:
+                isParallel = true;
+                break;
+
+            case JobTypeType.INT_SERIAL:
+            case JobTypeType.INT_SINGLE:
+                isParallel = false;
+                break;
+
+            default:
+                isParallel = false;
+                break;
+            }
+        }
+        return isParallel;
+    }
+
+    public static void createApplicationEnvironment(JobDefinitionType value, NameValuePairType[] nameValuePairs,
+            HpcApplicationDeploymentType appDepType) {
+
+        if (isParallelJob(appDepType)) {
+            for (NameValuePairType nv : nameValuePairs) {
+                EnvironmentType envType = JSDLUtils.getOrCreateSPMDApplication(value).addNewEnvironment();
+                envType.setName(nv.getName());
+                envType.setStringValue(nv.getValue());
+            }
+        } else {
+            for (NameValuePairType nv : nameValuePairs) {
+                EnvironmentType envType = JSDLUtils.getOrCreatePOSIXApplication(value).addNewEnvironment();
+                envType.setName(nv.getName());
+                envType.setStringValue(nv.getValue());
+            }
+        }
+
+    }
+
+    public static String getSPMDVariation(HpcApplicationDeploymentType appDepType) {
+
+        String variation = null;
+
+        if (appDepType.getJobType() != null) {
+            // TODO set data output directory
+            int status = appDepType.getJobType().intValue();
+
+            switch (status) {
+            // TODO: this check should be done outside this class
+            case JobTypeType.INT_MPI:
+                variation = SPMDVariations.MPI.value();
+                break;
+
+            case JobTypeType.INT_OPEN_MP:
+                variation = SPMDVariations.OpenMPI.value();
+                break;
+
+            }
+        }
+        return variation;
+    }
+
+    public static void addApplicationArgument(JobDefinitionType value, HpcApplicationDeploymentType appDepType,
+            String stringPrm) {
+        if (isParallelJob(appDepType))
+            JSDLUtils.getOrCreateSPMDApplication(value).addNewArgument().setStringValue(stringPrm);
+        else
+            JSDLUtils.getOrCreatePOSIXApplication(value).addNewArgument().setStringValue(stringPrm);
+
+    }
+
+    public static void setApplicationStdErr(JobDefinitionType value, HpcApplicationDeploymentType appDepType,
+            String stderr) {
+        FileNameType fName = FileNameType.Factory.newInstance();
+        fName.setStringValue(stderr);
+        if (isParallelJob(appDepType))
+            JSDLUtils.getOrCreateSPMDApplication(value).setError(fName);
+        else
+            JSDLUtils.getOrCreatePOSIXApplication(value).setError(fName);
+    }
+
+    public static void setApplicationStdOut(JobDefinitionType value, HpcApplicationDeploymentType appDepType,
+            String stderr) {
+        FileNameType fName = FileNameType.Factory.newInstance();
+        fName.setStringValue(stderr);
+        if (isParallelJob(appDepType))
+            JSDLUtils.getOrCreateSPMDApplication(value).setOutput(fName);
+        else
+            JSDLUtils.getOrCreatePOSIXApplication(value).setOutput(fName);
+    }
+
+    public static String getApplicationStdOut(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
+        if (isParallelJob(appDepType))
+            return JSDLUtils.getOrCreateSPMDApplication(value).getOutput().getStringValue();
+        else
+            return JSDLUtils.getOrCreatePOSIXApplication(value).getOutput().getStringValue();
+    }
+
+    public static String getApplicationStdErr(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
+        if (isParallelJob(appDepType))
+            return JSDLUtils.getOrCreateSPMDApplication(value).getError().getStringValue();
+        else
+            return JSDLUtils.getOrCreatePOSIXApplication(value).getError().getStringValue();
+    }
+
+    public static void createGenericApplication(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
+        if (appDepType.getApplicationName() != null) {
+            ApplicationType appType = JSDLUtils.getOrCreateApplication(value);
+            String appName = appDepType.getApplicationName().getStringValue();
+            appType.setApplicationName(appName);
+            JSDLUtils.getOrCreateJobIdentification(value).setJobName(appName);
+        }
+    }
+
+    public static String getValueFromMap(HpcApplicationDeploymentType appDepType, String name) {
+        ExtendedKeyValueType[] extended = appDepType.getKeyValuePairsArray();
+        for (ExtendedKeyValueType e : extended) {
+            if (e.getName().equalsIgnoreCase(name)) {
+                return e.getStringValue();
+            }
+        }
+        return null;
+    }
+
 }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java?rev=1476707&r1=1476706&r2=1476707&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/DataStagingProcessor.java Sun Apr 28 02:20:36 2013
@@ -34,7 +34,7 @@ import org.apache.airavata.schemas.gfac.
 import org.apache.airavata.schemas.gfac.URIArrayType;
 import org.apache.airavata.schemas.gfac.URIParameterType;
 import org.apache.airavata.schemas.gfac.UnicoreHostType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
+import org.ogf.schemas.jsdl.JobDefinitionType;
 
 public class DataStagingProcessor {
 	
@@ -217,7 +217,7 @@ public class DataStagingProcessor {
 			else if ("String".equals(paramDataType)) {
 				String stringPrm = ((StringParameterType) inParam.getType())
 						.getValue();
-				ApplicationProcessor.addApplicationArgument(value, appDepType, stringPrm);
+                ApplicationProcessor.addApplicationArgument(value, appDepType, stringPrm);
 			}
 		}
 		

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java?rev=1476707&r1=1476706&r2=1476707&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLGenerator.java Sun Apr 28 02:20:36 2013
@@ -20,11 +20,10 @@
  */
 package org.apache.airavata.gfac.provider.utils;
 
-
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
+import org.ogf.schemas.jsdl.JobDefinitionDocument;
+import org.ogf.schemas.jsdl.JobDefinitionType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,45 +34,39 @@ import org.slf4j.LoggerFactory;
  * */
 
 public class JSDLGenerator {
-	
-	protected final Logger log = LoggerFactory.getLogger(this.getClass());
-	
-	
-	public synchronized static JobDefinitionDocument buildJSDLInstance(JobExecutionContext context) throws Exception {
-
-		JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory
-				.newInstance();
-		JobDefinitionType value = jobDefDoc.addNewJobDefinition();
-
-		HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context
-				.getApplicationContext().getApplicationDeploymentDescription()
-				.getType();
-
-		// build Identification
-		createJobIdentification(value, appDepType);
-		
-		ResourceProcessor.generateResourceElements(value, context);
-		
-		ApplicationProcessor.generateJobSpecificAppElements(value, context);
-		
-		DataStagingProcessor.generateDataStagingElements(value, context);
-		
-		return jobDefDoc;
-	}
-
-		
-	private static void createJobIdentification(JobDefinitionType value, HpcApplicationDeploymentType appDepType){
-		if( appDepType.getProjectAccount() != null ){
-			
-			if (appDepType.getProjectAccount().getProjectAccountNumber() != null)
-				JSDLUtils.addProjectName(value, appDepType.getProjectAccount()
-						.getProjectAccountNumber());
-
-			if (appDepType.getProjectAccount().getProjectAccountDescription() != null)
-				JSDLUtils.getOrCreateJobIdentification(value).setDescription(
-						appDepType.getProjectAccount()
-								.getProjectAccountDescription());
-		}
-	}
-	
+
+    protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    public synchronized static JobDefinitionDocument buildJSDLInstance(JobExecutionContext context) throws Exception {
+
+        JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory.newInstance();
+        JobDefinitionType value = jobDefDoc.addNewJobDefinition();
+
+        HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context.getApplicationContext()
+                .getApplicationDeploymentDescription().getType();
+
+        // build Identification
+        createJobIdentification(value, appDepType);
+
+        ResourceProcessor.generateResourceElements(value, context);
+
+        ApplicationProcessor.generateJobSpecificAppElements(value, context);
+
+        DataStagingProcessor.generateDataStagingElements(value, context);
+
+        return jobDefDoc;
+    }
+
+    private static void createJobIdentification(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
+        if (appDepType.getProjectAccount() != null) {
+
+            if (appDepType.getProjectAccount().getProjectAccountNumber() != null)
+                JSDLUtils.addProjectName(value, appDepType.getProjectAccount().getProjectAccountNumber());
+
+            if (appDepType.getProjectAccount().getProjectAccountDescription() != null)
+                JSDLUtils.getOrCreateJobIdentification(value).setDescription(
+                        appDepType.getProjectAccount().getProjectAccountDescription());
+        }
+    }
+
 }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java?rev=1476707&r1=1476706&r2=1476707&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/JSDLUtils.java Sun Apr 28 02:20:36 2013
@@ -17,7 +17,7 @@
  * specific language governing permissions and limitations
  * under the License.
  *
-*/
+ */
 
 package org.apache.airavata.gfac.provider.utils;
 
@@ -26,508 +26,488 @@ import javax.xml.namespace.QName;
 import org.apache.commons.httpclient.URIException;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.BoundaryType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.CPUArchitectureType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.CandidateHostsType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.CreationFlagEnumeration;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.DataStagingType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ExactType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDescriptionType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobIdentificationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.OperatingSystemType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.OperatingSystemTypeEnumeration;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.OperatingSystemTypeType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ProcessorArchitectureEnumeration;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.SourceTargetType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.EnvironmentType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationType;
-import org.ggf.schemas.jsdl.x2006.x07.jsdlHpcpa.HPCProfileApplicationDocument;
-import org.ggf.schemas.jsdl.x2006.x07.jsdlHpcpa.HPCProfileApplicationType;
-import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.SPMDApplicationDocument;
-import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.SPMDApplicationType;
-
-public class JSDLUtils
-{
-
-	public static final int FLAG_OVERWRITE = 1;
-	public static final int FLAG_APPEND = 2;
-	public static final int FLAG_DELETE_ON_TERMINATE = 32;
-
-	public static final QName POSIX_APPLICATION=POSIXApplicationDocument.type.getDocumentElementName();
-	
-	public static final QName HPC_PROFILE_APPLICATION=HPCProfileApplicationDocument.type.getDocumentElementName();
-	
-	public static final QName SPMD_APPLICATION=SPMDApplicationDocument.type.getDocumentElementName();
-	
-	public static final String PROCESSESPERHOST = "ProcessesPerHost"; 
-	public static final String NUMBEROFPROCESSES = "NumberOfProcesses";
-	public static final String THREADSPERHOST = "ThreadsPerHost";
-
-	
-	
-	public static EnvironmentType addEnvVariable(JobDefinitionType def,String name, String value) {
-		POSIXApplicationType posixApp = getOrCreatePOSIXApplication(def);
-		EnvironmentType newEnv = posixApp.addNewEnvironment();
-		newEnv.setName(name);
-		newEnv.setStringValue(value);
-		return newEnv;
-	}
-
-	public static void setApplicationName(JobDefinitionType value, String applicationName) {
-		getOrCreateApplication(value).setApplicationName(applicationName);
-	}
-
-	public static void setApplicationVersion(JobDefinitionType value, String applicationVersion) {
-		getOrCreateApplication(value).setApplicationVersion(applicationVersion);
-	}
-
-	public static void addProjectName(JobDefinitionType value, String projectName) {
-		getOrCreateJobIdentification(value).addNewJobProject().setStringValue(projectName);
-	}
-	
-	public static void addMultipleProjectNames(JobDefinitionType value, String[] projectNames) {
-		for (String name : projectNames) {
-			getOrCreateJobIdentification(value).addNewJobProject().setStringValue(name);
-		}
-	}
-
-	public static void addCandidateHost(JobDefinitionType value, String host) {
-		getOrCreateCandidateHosts(value).addHostName(host);
-
-	}
-	public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri) {
-		addDataStagingTargetElement(value,fileSystem, file, uri, 0);
-	}
-
-	public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri, int flags) {
-		JobDescriptionType jobDescr = getOrCreateJobDescription(value);
-		DataStagingType newDS = jobDescr.addNewDataStaging();
-		CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
-		if((flags & FLAG_OVERWRITE) != 0) creationFlag = CreationFlagEnumeration.OVERWRITE;
-		if((flags & FLAG_APPEND) != 0) creationFlag = CreationFlagEnumeration.APPEND;
-		boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
-		newDS.setCreationFlag(creationFlag);
-		newDS.setDeleteOnTermination(deleteOnTerminate);
-		SourceTargetType target = newDS.addNewTarget();
-
-		try {
-			uri = (uri == null) ? null : URIUtils.encodeAll(uri);
-		} catch (URIException e) {
-		}
-		target.setURI(uri);
-		newDS.setFileName(file);
-		if (fileSystem != null && !fileSystem.equals("Work")) {  //$NON-NLS-1$
-			newDS.setFilesystemName(fileSystem);
-		}
-	}
-
-	public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file) {
-		addDataStagingSourceElement(value, uri, fileSystem, file, 0);
-	}
-
-	public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file, int flags) {
-		JobDescriptionType jobDescr = getOrCreateJobDescription(value);
-
-		try {
-			uri = (uri == null) ? null : URIUtils.encodeAll(uri);
-		} catch (URIException e) {
-		}
-		DataStagingType newDS = jobDescr.addNewDataStaging();
-		CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
-		if((flags & FLAG_OVERWRITE) != 0) creationFlag = CreationFlagEnumeration.OVERWRITE;
-		if((flags & FLAG_APPEND) != 0) creationFlag = CreationFlagEnumeration.APPEND;
-		boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
-		newDS.setCreationFlag(creationFlag);
-		newDS.setDeleteOnTermination(deleteOnTerminate);
-		SourceTargetType source = newDS.addNewSource();
-		source.setURI(uri);
-		newDS.setFileName(file);
-		if (fileSystem != null && !fileSystem.equals("Work")) {  //$NON-NLS-1$
-			newDS.setFilesystemName(fileSystem);
-		}
-	}
-
-
-	public static ApplicationType getOrCreateApplication(JobDefinitionType value) {
-		JobDescriptionType jobDescr = getOrCreateJobDescription(value);
-		if (!jobDescr.isSetApplication()) {
-			jobDescr.addNewApplication();
-		}
-		return jobDescr.getApplication();
-	}
-
-	public static CandidateHostsType getOrCreateCandidateHosts(JobDefinitionType value) {
-		ResourcesType resources = getOrCreateResources(value);
-		if (!resources.isSetCandidateHosts()) {
-			resources.addNewCandidateHosts();
-		}
-		return resources.getCandidateHosts();
-	}
-
-	public static CPUArchitectureType getOrCreateCPUArchitecture(JobDefinitionType value) {
-
-		ResourcesType jobResources = getOrCreateResources(value);
-		if (!jobResources.isSetCPUArchitecture()) {
-			jobResources.addNewCPUArchitecture();
-		}
-		return jobResources.getCPUArchitecture();
-	}
-
-	public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualCPUCount(JobDefinitionType value) {        
-		ResourcesType jobResources = getOrCreateResources(value);
-		if (!jobResources.isSetIndividualCPUCount()) {
-			jobResources.addNewIndividualCPUCount();
-		}
-		return jobResources.getIndividualCPUCount();
-	}
-
-
-	public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualCPUSpeed(JobDefinitionType value) {
-
-		ResourcesType jobResources = getOrCreateResources(value);
-		if (!jobResources.isSetIndividualCPUSpeed()) {
-			jobResources.addNewIndividualCPUSpeed();
-		}
-		return jobResources.getIndividualCPUSpeed();
-	}
-
-	public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualCPUTime(JobDefinitionType value) {
-
-		ResourcesType jobResources = getOrCreateResources(value);
-		if ( !jobResources.isSetIndividualCPUTime() ) {
-			jobResources.addNewIndividualCPUTime();
-		}
-		return jobResources.getIndividualCPUTime();
-	}
-
-	public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualDiskSpace(JobDefinitionType value) {
-
-		ResourcesType jobResources = getOrCreateResources(value);
-		if (!jobResources.isSetIndividualDiskSpace()) {
-			jobResources.addNewIndividualDiskSpace();
-		}
-		return jobResources.getIndividualDiskSpace();
-	}
-
-	public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateIndividualPhysicalMemory(JobDefinitionType value) {
-
-		ResourcesType jobResources = getOrCreateResources(value);
-		if (!jobResources.isSetIndividualPhysicalMemory()) {
-			jobResources.addNewIndividualPhysicalMemory();
-		}
-		return jobResources.getIndividualPhysicalMemory();
-	}
-
-	public static JobDescriptionType getOrCreateJobDescription(JobDefinitionType value) {
-		if (value.getJobDescription() == null) {
-			return value.addNewJobDescription();
-		}
-		return value.getJobDescription();
-	}
-
-	public static JobIdentificationType getOrCreateJobIdentification(JobDefinitionType value) {
-		JobDescriptionType descr = getOrCreateJobDescription(value);
-		if (descr.getJobIdentification() == null) {
-			return descr.addNewJobIdentification();
-		}
-		return descr.getJobIdentification();
-	}
-
-	public static OperatingSystemType getOrCreateOperatingSystem(JobDefinitionType value)
-	{
-		ResourcesType jobResources = getOrCreateResources(value);        
-		if(!jobResources.isSetOperatingSystem()) {
-			jobResources.addNewOperatingSystem();
-		}
-		return jobResources.getOperatingSystem();
-	}
-
-	public static ResourcesType getOrCreateResources(JobDefinitionType value) {
-		JobDescriptionType jobDescr = getOrCreateJobDescription(value);
-		if (!jobDescr.isSetResources()) {
-			jobDescr.addNewResources();
-		}
-		return jobDescr.getResources();
-	}
-
-
-	public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateTotalCPUCount(JobDefinitionType value) {
-
-		ResourcesType jobResources = getOrCreateResources(value);
-		if ( !jobResources.isSetTotalCPUCount() ) {
-			jobResources.addNewTotalCPUCount();
-		}
-		return jobResources.getTotalCPUCount();
-	}
-
-
-	public static org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType getOrCreateTotalResourceCount(JobDefinitionType value) {
-
-		ResourcesType jobResources = getOrCreateResources(value);
-		if ( !jobResources.isSetTotalResourceCount())
-		{
-			jobResources.addNewTotalResourceCount();
-		}
-		return jobResources.getTotalResourceCount();
-	}
-
-	public static POSIXApplicationType getOrCreatePOSIXApplication(JobDefinitionType value) {
-		
-		ApplicationType application = getOrCreateApplication(value);
-		
-		if(getHPCProfileApplication(value) != null){
-			//TODO handle: not creating POSIX element if HPCProfile already exists
-			return getPOSIXApplication(value);
-		}
-		
-		if (getPOSIXApplication(value) == null) {
-			XmlCursor acursor = application.newCursor();
-			acursor.toEndToken();
-			acursor.insertElement(POSIX_APPLICATION);
-			acursor.dispose();
-		}
-		return getPOSIXApplication(value);
-	}
-
-	
-	public static SPMDApplicationType getOrCreateSPMDApplication(JobDefinitionType value) {
-		
-		ApplicationType application = getOrCreateApplication(value);
-		
-		if (getSPMDApplication(value) == null) {
-			XmlCursor acursor = application.newCursor();
-			acursor.toEndToken();
-			acursor.insertElement(SPMD_APPLICATION);
-			acursor.dispose();
-		}
-		return getSPMDApplication(value);
-	}
-
-	public static SPMDApplicationType getSPMDApplication(JobDefinitionType value) {
-		if (value != null &&
-				value.getJobDescription() != null && 
-				value.getJobDescription().isSetApplication() ) {
-			XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
-			if (acursor.toFirstChild()) {
-				do {
-					if(acursor.getName().equals(SPMD_APPLICATION)) {
-						XmlObject result = acursor.getObject();
-						acursor.dispose();
-						return (SPMDApplicationType) result;
-					}
-				} while (acursor.toNextSibling());
-				acursor.dispose();
-				return null;
-			} else {
-				acursor.dispose();                               
-				return null;
-			}
-		} else {
-			return null;
-		}
-	}
-
-	
-	
-	public static POSIXApplicationType getPOSIXApplication(JobDefinitionType value) {
-		if (value != null &&
-				value.getJobDescription() != null && 
-				value.getJobDescription().isSetApplication() ) {
-			XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
-			if (acursor.toFirstChild()) {
-				do {
-					if(acursor.getName().equals(POSIX_APPLICATION)) {
-						XmlObject result = acursor.getObject();
-						acursor.dispose();
-						return (POSIXApplicationType) result;
-					}
-				} while (acursor.toNextSibling());
-				acursor.dispose();
-				return null;
-			} else {
-				acursor.dispose();                               
-				return null;
-			}
-		} else {
-			return null;
-		}
-	}
-	
-	
-	
-	public static HPCProfileApplicationType getOrCreateHPCProfileApplication(JobDefinitionType value) {
-
-		ApplicationType application = getOrCreateApplication(value);
-		
-		if(getPOSIXApplication(value) != null){
-			//TODO handle: creating HPC element if POSIX already exists
-			return getHPCProfileApplication(value);
-		}
-		
-		if (getHPCProfileApplication(value) == null) {
-			XmlCursor acursor = application.newCursor();
-			acursor.toEndToken();
-			acursor.insertElement(HPC_PROFILE_APPLICATION);
-			acursor.dispose();
-		}
-		return getHPCProfileApplication(value);
-	}
-
-	
-	public static HPCProfileApplicationType getHPCProfileApplication(JobDefinitionType value) {
-		if (value != null &&
-				value.getJobDescription() != null && 
-				value.getJobDescription().isSetApplication() ) {
-			XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
-			if (acursor.toFirstChild()) {
-				do {
-					if(acursor.getName().equals(HPC_PROFILE_APPLICATION)) {
-						XmlObject result = acursor.getObject();
-						acursor.dispose();
-						return (HPCProfileApplicationType) result;
-					}
-				} while (acursor.toNextSibling());
-				acursor.dispose();
-				return null;
-			} else {
-				acursor.dispose();                               
-				return null;
-			}
-		} else {
-			return null;
-		}
-	}
-
-	
-	
-
-	public static RangeValueType getTotalCPUCountRequirements(JobDefinitionType value) {
-		if(value != null && value.getJobDescription() != null && value.getJobDescription().isSetResources() && 
-				value.getJobDescription().getResources().isSetTotalCPUCount()){
-			return toU6RangeValue(value.getJobDescription().getResources().getTotalCPUCount());
-		}
-		else
-			return null;
-	}
-
-	public static RangeValueType getTotalResourceCountRequirements(JobDefinitionType value) {
-		if(value != null && value.getJobDescription() != null && value.getJobDescription().isSetResources() && 
-				value.getJobDescription().getResources().isSetTotalResourceCount()){
-			return toU6RangeValue(value.getJobDescription().getResources().getTotalResourceCount());
-		}
-		else
-			return null;
-	}
-
-
-	public static RangeValueType toU6RangeValue(org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType jsdlType) {
-		RangeValueType result = new RangeValueType();
-		if(jsdlType.getExactArray().length > 0){
-			result.setExact(jsdlType.getExactArray(0).getDoubleValue());                
-		}
-		if(jsdlType.isSetLowerBoundedRange()){
-			result.setLowerBound(jsdlType.getLowerBoundedRange().getDoubleValue());                
-		}
-		if(jsdlType.isSetUpperBoundedRange()){
-			result.setUpperBound(jsdlType.getUpperBoundedRange().getDoubleValue());                
-		}
-		return result;
-	}
-
-
-
-	public static void setCPUArchitectureRequirements(JobDefinitionType value, ProcessorRequirement cpuArchitecture) { 
-		if(cpuArchitecture == null || cpuArchitecture.getValue() == null) return;
-		CPUArchitectureType cpuArch = getOrCreateCPUArchitecture(value);
-		cpuArch.setCPUArchitectureName(ProcessorArchitectureEnumeration.Enum.forString(cpuArchitecture.getValue()));        
-	}
-
-	public static void setIndividualCPUCountRequirements(JobDefinitionType value, RangeValueType cpuCount) {
-		org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType individualCPUCount = getOrCreateIndividualCPUCount(value);
-		setRangeValue(cpuCount, individualCPUCount);
-	}
-
-	public static void setIndividualCPUSpeedRequirements(JobDefinitionType value, RangeValueType cpuSpeed) {
-		org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType individualCPUSpeed = getOrCreateIndividualCPUSpeed(value);
-		setRangeValue(cpuSpeed, individualCPUSpeed);
-	}
-
-	public static void setIndividualCPUTimeRequirements(JobDefinitionType value, RangeValueType cpuTime) {
-		org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType cpuIndividualTime = getOrCreateIndividualCPUTime(value);       
-		setRangeValue(cpuTime, cpuIndividualTime);
-	}
-
-	public static void setIndividualDiskSpaceRequirements(JobDefinitionType value, RangeValueType diskSpace) {
-		org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType individualDiskSpace = getOrCreateIndividualDiskSpace(value);
-		setRangeValue(diskSpace, individualDiskSpace);
-	}
-
-	public static void setIndividualPhysicalMemoryRequirements(JobDefinitionType value, RangeValueType physicalMemory) {
-		org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType individualPhysicalMemory = getOrCreateIndividualPhysicalMemory(value);
-		setRangeValue(physicalMemory, individualPhysicalMemory);
-	}
-
-
-	public static void setName(JobDefinitionType value, String name) {
-		getOrCreateJobIdentification(value).setJobName(name);
-	}
-
-	public static void setOperatingSystemRequirements(JobDefinitionType value, OSRequirement osType) {
-		if(osType == null || osType.getOSType() == null) return;
-		OperatingSystemType os_Type = getOrCreateOperatingSystem(value);
-		OperatingSystemTypeType ostt = os_Type.addNewOperatingSystemType();
-		ostt.setOperatingSystemName(OperatingSystemTypeEnumeration.Enum.forString(osType.getOSType().getValue()));
-		if(osType.getOSVersion() != null) 
-		{
-			os_Type.setOperatingSystemVersion(osType.getOSVersion());
-		}
-	}
-
-	public static void setRangeValue(RangeValueType u6Type, org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType jsdlType) {
-		Double exact = u6Type.getExact();
-		Double epsilon = u6Type.getEpsilon();
-		Double lower = u6Type.getLowerBound();
-		Double upper = u6Type.getUpperBound();
-
-
-		if(lower.isNaN() && upper.isNaN())
-		{
-			ExactType exactType = jsdlType.getExactArray().length > 0 ? jsdlType.getExactArray(0) : jsdlType.addNewExact();
-			exactType.setDoubleValue(exact);
-			if(!epsilon.isNaN() && epsilon != 0)
-			{
-				exactType.setEpsilon(epsilon);
-			}
-		}
-		else
-		{
-			if(!lower.isNaN())
-			{
-				BoundaryType lowerBound = jsdlType.isSetLowerBoundedRange() ? jsdlType.getLowerBoundedRange() : jsdlType.addNewLowerBoundedRange(); 
-				lowerBound.setDoubleValue(lower);
-				lowerBound.setExclusiveBound(!u6Type.isIncludeLowerBound());
-			}
-
-			if(!upper.isNaN())
-			{
-				BoundaryType upperBound = jsdlType.isSetUpperBoundedRange() ? jsdlType.getUpperBoundedRange() : jsdlType.addNewUpperBoundedRange();
-				upperBound.setDoubleValue(upper);
-				upperBound.setExclusiveBound(!u6Type.isIncludeUpperBound());
-			}
-		}
-	}
-
-	public static void setTotalCPUCountRequirements(JobDefinitionType value, RangeValueType cpuCount) {
-		org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType cpuTotalCount = getOrCreateTotalCPUCount(value);        
-		setRangeValue(cpuCount, cpuTotalCount);
-	}
-
-	public static void setTotalResourceCountRequirements(JobDefinitionType value, RangeValueType resourceCount) {
-		org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType totalCount = getOrCreateTotalResourceCount(value);   
-		setRangeValue(resourceCount, totalCount);
-	}
+import org.ogf.schemas.jsdl.ApplicationType;
+import org.ogf.schemas.jsdl.BoundaryType;
+import org.ogf.schemas.jsdl.CPUArchitectureType;
+import org.ogf.schemas.jsdl.CandidateHostsType;
+import org.ogf.schemas.jsdl.CreationFlagEnumeration;
+import org.ogf.schemas.jsdl.DataStagingType;
+import org.ogf.schemas.jsdl.ExactType;
+import org.ogf.schemas.jsdl.JobDefinitionType;
+import org.ogf.schemas.jsdl.JobDescriptionType;
+import org.ogf.schemas.jsdl.JobIdentificationType;
+import org.ogf.schemas.jsdl.OperatingSystemType;
+import org.ogf.schemas.jsdl.OperatingSystemTypeEnumeration;
+import org.ogf.schemas.jsdl.OperatingSystemTypeType;
+import org.ogf.schemas.jsdl.ProcessorArchitectureEnumeration;
+import org.ogf.schemas.jsdl.ResourcesType;
+import org.ogf.schemas.jsdl.SourceTargetType;
+import org.ogf.schemas.jsdl.hpcpa.HPCProfileApplicationDocument;
+import org.ogf.schemas.jsdl.hpcpa.HPCProfileApplicationType;
+import org.ogf.schemas.jsdl.posix.EnvironmentType;
+import org.ogf.schemas.jsdl.posix.POSIXApplicationDocument;
+import org.ogf.schemas.jsdl.posix.POSIXApplicationType;
+import org.ogf.schemas.jsdl.spmd.SPMDApplicationDocument;
+import org.ogf.schemas.jsdl.spmd.SPMDApplicationType;
+
+public class JSDLUtils {
+
+    public static final int FLAG_OVERWRITE = 1;
+    public static final int FLAG_APPEND = 2;
+    public static final int FLAG_DELETE_ON_TERMINATE = 32;
+
+    public static final QName POSIX_APPLICATION = POSIXApplicationDocument.type.getDocumentElementName();
+
+    public static final QName HPC_PROFILE_APPLICATION = HPCProfileApplicationDocument.type.getDocumentElementName();
+
+    public static final QName SPMD_APPLICATION = SPMDApplicationDocument.type.getDocumentElementName();
+
+    public static final String PROCESSESPERHOST = "ProcessesPerHost";
+    public static final String NUMBEROFPROCESSES = "NumberOfProcesses";
+    public static final String THREADSPERHOST = "ThreadsPerHost";
+
+    public static EnvironmentType addEnvVariable(JobDefinitionType def, String name, String value) {
+        POSIXApplicationType posixApp = getOrCreatePOSIXApplication(def);
+        EnvironmentType newEnv = posixApp.addNewEnvironment();
+        newEnv.setName(name);
+        newEnv.setStringValue(value);
+        return newEnv;
+    }
+
+    public static void setApplicationName(JobDefinitionType value, String applicationName) {
+        getOrCreateApplication(value).setApplicationName(applicationName);
+    }
+
+    public static void setApplicationVersion(JobDefinitionType value, String applicationVersion) {
+        getOrCreateApplication(value).setApplicationVersion(applicationVersion);
+    }
+
+    public static void addProjectName(JobDefinitionType value, String projectName) {
+        getOrCreateJobIdentification(value).addNewJobProject().setStringValue(projectName);
+    }
+
+    public static void addMultipleProjectNames(JobDefinitionType value, String[] projectNames) {
+        for (String name : projectNames) {
+            getOrCreateJobIdentification(value).addNewJobProject().setStringValue(name);
+        }
+    }
+
+    public static void addCandidateHost(JobDefinitionType value, String host) {
+        getOrCreateCandidateHosts(value).addHostName(host);
+
+    }
+
+    public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri) {
+        addDataStagingTargetElement(value, fileSystem, file, uri, 0);
+    }
+
+    public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri,
+            int flags) {
+        JobDescriptionType jobDescr = getOrCreateJobDescription(value);
+        DataStagingType newDS = jobDescr.addNewDataStaging();
+        CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
+        if ((flags & FLAG_OVERWRITE) != 0)
+            creationFlag = CreationFlagEnumeration.OVERWRITE;
+        if ((flags & FLAG_APPEND) != 0)
+            creationFlag = CreationFlagEnumeration.APPEND;
+        boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
+        newDS.setCreationFlag(creationFlag);
+        newDS.setDeleteOnTermination(deleteOnTerminate);
+        SourceTargetType target = newDS.addNewTarget();
+
+        try {
+            uri = (uri == null) ? null : URIUtils.encodeAll(uri);
+        } catch (URIException e) {
+        }
+        target.setURI(uri);
+        newDS.setFileName(file);
+        if (fileSystem != null && !fileSystem.equals("Work")) { //$NON-NLS-1$
+            newDS.setFilesystemName(fileSystem);
+        }
+    }
+
+    public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file) {
+        addDataStagingSourceElement(value, uri, fileSystem, file, 0);
+    }
+
+    public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file,
+            int flags) {
+        JobDescriptionType jobDescr = getOrCreateJobDescription(value);
+
+        try {
+            uri = (uri == null) ? null : URIUtils.encodeAll(uri);
+        } catch (URIException e) {
+        }
+        DataStagingType newDS = jobDescr.addNewDataStaging();
+        CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
+        if ((flags & FLAG_OVERWRITE) != 0)
+            creationFlag = CreationFlagEnumeration.OVERWRITE;
+        if ((flags & FLAG_APPEND) != 0)
+            creationFlag = CreationFlagEnumeration.APPEND;
+        boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
+        newDS.setCreationFlag(creationFlag);
+        newDS.setDeleteOnTermination(deleteOnTerminate);
+        SourceTargetType source = newDS.addNewSource();
+        source.setURI(uri);
+        newDS.setFileName(file);
+        if (fileSystem != null && !fileSystem.equals("Work")) { //$NON-NLS-1$
+            newDS.setFilesystemName(fileSystem);
+        }
+    }
+
+    public static ApplicationType getOrCreateApplication(JobDefinitionType value) {
+        JobDescriptionType jobDescr = getOrCreateJobDescription(value);
+        if (!jobDescr.isSetApplication()) {
+            jobDescr.addNewApplication();
+        }
+        return jobDescr.getApplication();
+    }
+
+    public static CandidateHostsType getOrCreateCandidateHosts(JobDefinitionType value) {
+        ResourcesType resources = getOrCreateResources(value);
+        if (!resources.isSetCandidateHosts()) {
+            resources.addNewCandidateHosts();
+        }
+        return resources.getCandidateHosts();
+    }
+
+    public static CPUArchitectureType getOrCreateCPUArchitecture(JobDefinitionType value) {
+
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetCPUArchitecture()) {
+            jobResources.addNewCPUArchitecture();
+        }
+        return jobResources.getCPUArchitecture();
+    }
+
+    public static org.ogf.schemas.jsdl.RangeValueType getOrCreateIndividualCPUCount(
+            JobDefinitionType value) {
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetIndividualCPUCount()) {
+            jobResources.addNewIndividualCPUCount();
+        }
+        return jobResources.getIndividualCPUCount();
+    }
+
+    public static org.ogf.schemas.jsdl.RangeValueType getOrCreateIndividualCPUSpeed(
+            JobDefinitionType value) {
+
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetIndividualCPUSpeed()) {
+            jobResources.addNewIndividualCPUSpeed();
+        }
+        return jobResources.getIndividualCPUSpeed();
+    }
+
+    public static org.ogf.schemas.jsdl.RangeValueType getOrCreateIndividualCPUTime(
+            JobDefinitionType value) {
+
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetIndividualCPUTime()) {
+            jobResources.addNewIndividualCPUTime();
+        }
+        return jobResources.getIndividualCPUTime();
+    }
+
+    public static org.ogf.schemas.jsdl.RangeValueType getOrCreateIndividualDiskSpace(
+            JobDefinitionType value) {
+
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetIndividualDiskSpace()) {
+            jobResources.addNewIndividualDiskSpace();
+        }
+        return jobResources.getIndividualDiskSpace();
+    }
+
+    public static org.ogf.schemas.jsdl.RangeValueType getOrCreateIndividualPhysicalMemory(
+            JobDefinitionType value) {
+
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetIndividualPhysicalMemory()) {
+            jobResources.addNewIndividualPhysicalMemory();
+        }
+        return jobResources.getIndividualPhysicalMemory();
+    }
+
+    public static JobDescriptionType getOrCreateJobDescription(JobDefinitionType value) {
+        if (value.getJobDescription() == null) {
+            return value.addNewJobDescription();
+        }
+        return value.getJobDescription();
+    }
+
+    public static JobIdentificationType getOrCreateJobIdentification(JobDefinitionType value) {
+        JobDescriptionType descr = getOrCreateJobDescription(value);
+        if (descr.getJobIdentification() == null) {
+            return descr.addNewJobIdentification();
+        }
+        return descr.getJobIdentification();
+    }
+
+    public static OperatingSystemType getOrCreateOperatingSystem(JobDefinitionType value) {
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetOperatingSystem()) {
+            jobResources.addNewOperatingSystem();
+        }
+        return jobResources.getOperatingSystem();
+    }
+
+    public static ResourcesType getOrCreateResources(JobDefinitionType value) {
+        JobDescriptionType jobDescr = getOrCreateJobDescription(value);
+        if (!jobDescr.isSetResources()) {
+            jobDescr.addNewResources();
+        }
+        return jobDescr.getResources();
+    }
+
+    public static org.ogf.schemas.jsdl.RangeValueType getOrCreateTotalCPUCount(JobDefinitionType value) {
+
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetTotalCPUCount()) {
+            jobResources.addNewTotalCPUCount();
+        }
+        return jobResources.getTotalCPUCount();
+    }
+
+    public static org.ogf.schemas.jsdl.RangeValueType getOrCreateTotalResourceCount(
+            JobDefinitionType value) {
+
+        ResourcesType jobResources = getOrCreateResources(value);
+        if (!jobResources.isSetTotalResourceCount()) {
+            jobResources.addNewTotalResourceCount();
+        }
+        return jobResources.getTotalResourceCount();
+    }
+
+    public static POSIXApplicationType getOrCreatePOSIXApplication(JobDefinitionType value) {
+
+        ApplicationType application = getOrCreateApplication(value);
+
+        if (getHPCProfileApplication(value) != null) {
+            // TODO handle: not creating POSIX element if HPCProfile already exists
+            return getPOSIXApplication(value);
+        }
+
+        if (getPOSIXApplication(value) == null) {
+            XmlCursor acursor = application.newCursor();
+            acursor.toEndToken();
+            acursor.insertElement(POSIX_APPLICATION);
+            acursor.dispose();
+        }
+        return getPOSIXApplication(value);
+    }
+
+    public static SPMDApplicationType getOrCreateSPMDApplication(JobDefinitionType value) {
+
+        ApplicationType application = getOrCreateApplication(value);
+
+        if (getSPMDApplication(value) == null) {
+            XmlCursor acursor = application.newCursor();
+            acursor.toEndToken();
+            acursor.insertElement(SPMD_APPLICATION);
+            acursor.dispose();
+        }
+        return getSPMDApplication(value);
+    }
+
+    public static SPMDApplicationType getSPMDApplication(JobDefinitionType value) {
+        if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetApplication()) {
+            XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
+            if (acursor.toFirstChild()) {
+                do {
+                    if (acursor.getName().equals(SPMD_APPLICATION)) {
+                        XmlObject result = acursor.getObject();
+                        acursor.dispose();
+                        return (SPMDApplicationType) result;
+                    }
+                } while (acursor.toNextSibling());
+                acursor.dispose();
+                return null;
+            } else {
+                acursor.dispose();
+                return null;
+            }
+        } else {
+            return null;
+        }
+    }
+
+    public static POSIXApplicationType getPOSIXApplication(JobDefinitionType value) {
+        if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetApplication()) {
+            XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
+            if (acursor.toFirstChild()) {
+                do {
+                    if (acursor.getName().equals(POSIX_APPLICATION)) {
+                        XmlObject result = acursor.getObject();
+                        acursor.dispose();
+                        return (POSIXApplicationType) result;
+                    }
+                } while (acursor.toNextSibling());
+                acursor.dispose();
+                return null;
+            } else {
+                acursor.dispose();
+                return null;
+            }
+        } else {
+            return null;
+        }
+    }
+
+    public static HPCProfileApplicationType getOrCreateHPCProfileApplication(JobDefinitionType value) {
+
+        ApplicationType application = getOrCreateApplication(value);
+
+        if (getPOSIXApplication(value) != null) {
+            // TODO handle: creating HPC element if POSIX already exists
+            return getHPCProfileApplication(value);
+        }
+
+        if (getHPCProfileApplication(value) == null) {
+            XmlCursor acursor = application.newCursor();
+            acursor.toEndToken();
+            acursor.insertElement(HPC_PROFILE_APPLICATION);
+            acursor.dispose();
+        }
+        return getHPCProfileApplication(value);
+    }
+
+    public static HPCProfileApplicationType getHPCProfileApplication(JobDefinitionType value) {
+        if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetApplication()) {
+            XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
+            if (acursor.toFirstChild()) {
+                do {
+                    if (acursor.getName().equals(HPC_PROFILE_APPLICATION)) {
+                        XmlObject result = acursor.getObject();
+                        acursor.dispose();
+                        return (HPCProfileApplicationType) result;
+                    }
+                } while (acursor.toNextSibling());
+                acursor.dispose();
+                return null;
+            } else {
+                acursor.dispose();
+                return null;
+            }
+        } else {
+            return null;
+        }
+    }
+
+    public static RangeValueType getTotalCPUCountRequirements(JobDefinitionType value) {
+        if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetResources()
+                && value.getJobDescription().getResources().isSetTotalCPUCount()) {
+            return toU6RangeValue(value.getJobDescription().getResources().getTotalCPUCount());
+        } else
+            return null;
+    }
+
+    public static RangeValueType getTotalResourceCountRequirements(JobDefinitionType value) {
+        if (value != null && value.getJobDescription() != null && value.getJobDescription().isSetResources()
+                && value.getJobDescription().getResources().isSetTotalResourceCount()) {
+            return toU6RangeValue(value.getJobDescription().getResources().getTotalResourceCount());
+        } else
+            return null;
+    }
+
+    public static RangeValueType toU6RangeValue(org.ogf.schemas.jsdl.RangeValueType jsdlType) {
+        RangeValueType result = new RangeValueType();
+        if (jsdlType.getExactArray().length > 0) {
+            result.setExact(jsdlType.getExactArray(0).getDoubleValue());
+        }
+        if (jsdlType.isSetLowerBoundedRange()) {
+            result.setLowerBound(jsdlType.getLowerBoundedRange().getDoubleValue());
+        }
+        if (jsdlType.isSetUpperBoundedRange()) {
+            result.setUpperBound(jsdlType.getUpperBoundedRange().getDoubleValue());
+        }
+        return result;
+    }
+
+    public static void setCPUArchitectureRequirements(JobDefinitionType value, ProcessorRequirement cpuArchitecture) {
+        if (cpuArchitecture == null || cpuArchitecture.getValue() == null)
+            return;
+        CPUArchitectureType cpuArch = getOrCreateCPUArchitecture(value);
+        cpuArch.setCPUArchitectureName(ProcessorArchitectureEnumeration.Enum.forString(cpuArchitecture.getValue()));
+    }
+
+    public static void setIndividualCPUCountRequirements(JobDefinitionType value, RangeValueType cpuCount) {
+        org.ogf.schemas.jsdl.RangeValueType individualCPUCount = getOrCreateIndividualCPUCount(value);
+        setRangeValue(cpuCount, individualCPUCount);
+    }
+
+    public static void setIndividualCPUSpeedRequirements(JobDefinitionType value, RangeValueType cpuSpeed) {
+        org.ogf.schemas.jsdl.RangeValueType individualCPUSpeed = getOrCreateIndividualCPUSpeed(value);
+        setRangeValue(cpuSpeed, individualCPUSpeed);
+    }
+
+    public static void setIndividualCPUTimeRequirements(JobDefinitionType value, RangeValueType cpuTime) {
+        org.ogf.schemas.jsdl.RangeValueType cpuIndividualTime = getOrCreateIndividualCPUTime(value);
+        setRangeValue(cpuTime, cpuIndividualTime);
+    }
+
+    public static void setIndividualDiskSpaceRequirements(JobDefinitionType value, RangeValueType diskSpace) {
+        org.ogf.schemas.jsdl.RangeValueType individualDiskSpace = getOrCreateIndividualDiskSpace(value);
+        setRangeValue(diskSpace, individualDiskSpace);
+    }
+
+    public static void setIndividualPhysicalMemoryRequirements(JobDefinitionType value, RangeValueType physicalMemory) {
+        org.ogf.schemas.jsdl.RangeValueType individualPhysicalMemory = getOrCreateIndividualPhysicalMemory(value);
+        setRangeValue(physicalMemory, individualPhysicalMemory);
+    }
+
+    public static void setName(JobDefinitionType value, String name) {
+        getOrCreateJobIdentification(value).setJobName(name);
+    }
+
+    public static void setOperatingSystemRequirements(JobDefinitionType value, OSRequirement osType) {
+        if (osType == null || osType.getOSType() == null)
+            return;
+        OperatingSystemType os_Type = getOrCreateOperatingSystem(value);
+        OperatingSystemTypeType ostt = os_Type.addNewOperatingSystemType();
+        ostt.setOperatingSystemName(OperatingSystemTypeEnumeration.Enum.forString(osType.getOSType().getValue()));
+        if (osType.getOSVersion() != null) {
+            os_Type.setOperatingSystemVersion(osType.getOSVersion());
+        }
+    }
+
+    public static void setRangeValue(RangeValueType u6Type, org.ogf.schemas.jsdl.RangeValueType jsdlType) {
+        Double exact = u6Type.getExact();
+        Double epsilon = u6Type.getEpsilon();
+        Double lower = u6Type.getLowerBound();
+        Double upper = u6Type.getUpperBound();
+
+        if (lower.isNaN() && upper.isNaN()) {
+            ExactType exactType = jsdlType.getExactArray().length > 0 ? jsdlType.getExactArray(0) : jsdlType
+                    .addNewExact();
+            exactType.setDoubleValue(exact);
+            if (!epsilon.isNaN() && epsilon != 0) {
+                exactType.setEpsilon(epsilon);
+            }
+        } else {
+            if (!lower.isNaN()) {
+                BoundaryType lowerBound = jsdlType.isSetLowerBoundedRange() ? jsdlType.getLowerBoundedRange()
+                        : jsdlType.addNewLowerBoundedRange();
+                lowerBound.setDoubleValue(lower);
+                lowerBound.setExclusiveBound(!u6Type.isIncludeLowerBound());
+            }
+
+            if (!upper.isNaN()) {
+                BoundaryType upperBound = jsdlType.isSetUpperBoundedRange() ? jsdlType.getUpperBoundedRange()
+                        : jsdlType.addNewUpperBoundedRange();
+                upperBound.setDoubleValue(upper);
+                upperBound.setExclusiveBound(!u6Type.isIncludeUpperBound());
+            }
+        }
+    }
+
+    public static void setTotalCPUCountRequirements(JobDefinitionType value, RangeValueType cpuCount) {
+        org.ogf.schemas.jsdl.RangeValueType cpuTotalCount = getOrCreateTotalCPUCount(value);
+        setRangeValue(cpuCount, cpuTotalCount);
+    }
+
+    public static void setTotalResourceCountRequirements(JobDefinitionType value, RangeValueType resourceCount) {
+        org.ogf.schemas.jsdl.RangeValueType totalCount = getOrCreateTotalResourceCount(value);
+        setRangeValue(resourceCount, totalCount);
+    }
 }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java?rev=1476707&r1=1476706&r2=1476707&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ResourceProcessor.java Sun Apr 28 02:20:36 2013
@@ -17,85 +17,78 @@
  * specific language governing permissions and limitations
  * under the License.
  *
-*/
+ */
 package org.apache.airavata.gfac.provider.utils;
 
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
+import org.ogf.schemas.jsdl.JobDefinitionType;
 
 public class ResourceProcessor {
 
-	
-	public static void generateResourceElements(JobDefinitionType value, JobExecutionContext context) throws Exception{
-		
-		HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context
-				.getApplicationContext().getApplicationDeploymentDescription()
-				.getType();
-		
-		createMemory(value, appDepType);
-		
-		if (appDepType.getCpuCount() > 0) {
-			RangeValueType rangeType = new RangeValueType();
-			rangeType.setLowerBound(Double.NaN);
-			rangeType.setUpperBound(Double.NaN);
-			rangeType.setExact(appDepType.getCpuCount());
-			JSDLUtils.setTotalCPUCountRequirements(value, rangeType);
-		}
-
-		if (appDepType.getProcessorsPerNode() > 0) {
-			RangeValueType rangeType = new RangeValueType();
-			rangeType.setLowerBound(Double.NaN);
-			rangeType.setUpperBound(Double.NaN);
-			rangeType.setExact(appDepType.getProcessorsPerNode());
-			JSDLUtils.setIndividualCPUCountRequirements(value, rangeType);
-		}
-		
-		if (appDepType.getNodeCount() > 0) {
-			RangeValueType rangeType = new RangeValueType();
-			rangeType.setLowerBound(Double.NaN);
-			rangeType.setUpperBound(Double.NaN);
-			rangeType.setExact(appDepType.getNodeCount());
-			JSDLUtils.setTotalResourceCountRequirements(value, rangeType);
-		}
-		
-		if(appDepType.getMaxWallTime() > 0) {
-			RangeValueType cpuTime = new RangeValueType();
-			cpuTime.setLowerBound(Double.NaN);
-			cpuTime.setUpperBound(Double.NaN);
-			long wallTime = appDepType.getMaxWallTime() * 60;
-			cpuTime.setExact(wallTime);
-			JSDLUtils.setIndividualCPUTimeRequirements(value, cpuTime);
-		}
-	}
-	
-	
-	private static void createMemory(JobDefinitionType value, HpcApplicationDeploymentType appDepType){
-		if (appDepType.getMinMemory() > 0 && appDepType.getMaxMemory() > 0) {
-			RangeValueType rangeType = new RangeValueType();
-			rangeType.setLowerBound(appDepType.getMinMemory());
-			rangeType.setUpperBound(appDepType.getMaxMemory());
-			JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
-		}
-
-		else if (appDepType.getMinMemory() > 0 && appDepType.getMaxMemory() <= 0) {
-			// TODO set Wall time
-			RangeValueType rangeType = new RangeValueType();
-			rangeType.setLowerBound(appDepType.getMinMemory());
-			JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
-		}
-		
-		else if (appDepType.getMinMemory() <= 0 && appDepType.getMaxMemory() > 0) {
-			// TODO set Wall time
-			RangeValueType rangeType = new RangeValueType();
-			rangeType.setUpperBound(appDepType.getMinMemory());
-			JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
-		}
-		
-	}
+    public static void generateResourceElements(JobDefinitionType value, JobExecutionContext context) throws Exception {
 
-	
-	
+        HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context.getApplicationContext()
+                .getApplicationDeploymentDescription().getType();
+
+        createMemory(value, appDepType);
+
+        if (appDepType.getCpuCount() > 0) {
+            RangeValueType rangeType = new RangeValueType();
+            rangeType.setLowerBound(Double.NaN);
+            rangeType.setUpperBound(Double.NaN);
+            rangeType.setExact(appDepType.getCpuCount());
+            JSDLUtils.setTotalCPUCountRequirements(value, rangeType);
+        }
+
+        if (appDepType.getProcessorsPerNode() > 0) {
+            RangeValueType rangeType = new RangeValueType();
+            rangeType.setLowerBound(Double.NaN);
+            rangeType.setUpperBound(Double.NaN);
+            rangeType.setExact(appDepType.getProcessorsPerNode());
+            JSDLUtils.setIndividualCPUCountRequirements(value, rangeType);
+        }
+
+        if (appDepType.getNodeCount() > 0) {
+            RangeValueType rangeType = new RangeValueType();
+            rangeType.setLowerBound(Double.NaN);
+            rangeType.setUpperBound(Double.NaN);
+            rangeType.setExact(appDepType.getNodeCount());
+            JSDLUtils.setTotalResourceCountRequirements(value, rangeType);
+        }
+
+        if (appDepType.getMaxWallTime() > 0) {
+            RangeValueType cpuTime = new RangeValueType();
+            cpuTime.setLowerBound(Double.NaN);
+            cpuTime.setUpperBound(Double.NaN);
+            long wallTime = appDepType.getMaxWallTime() * 60;
+            cpuTime.setExact(wallTime);
+            JSDLUtils.setIndividualCPUTimeRequirements(value, cpuTime);
+        }
+    }
+
+    private static void createMemory(JobDefinitionType value, HpcApplicationDeploymentType appDepType) {
+        if (appDepType.getMinMemory() > 0 && appDepType.getMaxMemory() > 0) {
+            RangeValueType rangeType = new RangeValueType();
+            rangeType.setLowerBound(appDepType.getMinMemory());
+            rangeType.setUpperBound(appDepType.getMaxMemory());
+            JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
+        }
+
+        else if (appDepType.getMinMemory() > 0 && appDepType.getMaxMemory() <= 0) {
+            // TODO set Wall time
+            RangeValueType rangeType = new RangeValueType();
+            rangeType.setLowerBound(appDepType.getMinMemory());
+            JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
+        }
+
+        else if (appDepType.getMinMemory() <= 0 && appDepType.getMaxMemory() > 0) {
+            // TODO set Wall time
+            RangeValueType rangeType = new RangeValueType();
+            rangeType.setUpperBound(appDepType.getMinMemory());
+            JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
+        }
+
+    }
 
-	
 }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java?rev=1476707&r1=1476706&r2=1476707&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/SPMDProcessor.java Sun Apr 28 02:20:36 2013
@@ -22,12 +22,12 @@
 package org.apache.airavata.gfac.provider.utils;
 
 import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
+import org.ogf.schemas.jsdl.JobDefinitionType;
 
 public class SPMDProcessor {
 
-	public static void generateSPMDElements(JobDefinitionType value, JobExecutionContext context) {
-		
-	}
-	
+    public static void generateSPMDElements(JobDefinitionType value, JobExecutionContext context) {
+
+    }
+
 }



Mime
View raw message