}
return applicationDescription;
}
public static ApplicationDescriptor createApplicationDescriptor (ApplicationDescription applicationDescription){
ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor();
applicationDescriptor.setName(applicationDescription.getType().getApplicationName().getStringValue());
applicationDescriptor.setExecutablePath(applicationDescription.getType().getExecutableLocation());
applicationDescriptor.setWorkingDir(applicationDescription.getType().getScratchWorkingDirectory());
if (applicationDescription.getType().getInputDataDirectory() != null && !applicationDescription.getType().getInputDataDirectory().equals("") ){
applicationDescriptor.setInputDir(applicationDescription.getType().getInputDataDirectory());
}
if (applicationDescription.getType().getOutputDataDirectory() != null && !applicationDescription.getType().getOutputDataDirectory().equals("")){
applicationDescriptor.setOutputDir(applicationDescription.getType().getOutputDataDirectory());
}
if (applicationDescription.getType().getStaticWorkingDirectory() != null && !applicationDescription.getType().getStaticWorkingDirectory().equals("")){
applicationDescriptor.setStaticWorkigDir(applicationDescription.getType().getStaticWorkingDirectory());
}
if (applicationDescription.getType().getStandardInput() != null && !applicationDescription.getType().getStandardInput().equals("")){
applicationDescriptor.setStdIn(applicationDescription.getType().getStandardInput());
}
if (applicationDescription.getType().getStandardOutput() != null && !applicationDescription.getType().getStandardOutput().equals("")){
applicationDescriptor.setStdOut(applicationDescription.getType().getStandardOutput());
}
if (applicationDescription.getType().getStandardError() != null && !applicationDescription.getType().getStandardError().equals("")){
applicationDescriptor.setStdError(applicationDescription.getType().getStandardError());
}
NameValuePairType[] environmentArray = applicationDescription.getType().getApplicationEnvironmentArray();
HashMap<String, String> environmentVariableMap = new HashMap<String, String>();
if (environmentArray != null && environmentArray.length != 0){
for (NameValuePairType nameValuePairType : environmentArray){
environmentVariableMap.put(nameValuePairType.getName(), nameValuePairType.getValue());
}
applicationDescriptor.setEnvironmentVariables(environmentVariableMap);
}
if(applicationDescription.getType() != null){
if(applicationDescription.getType() instanceof HpcApplicationDeploymentType){
applicationDescriptor.setApplicationDescType(ApplicationDescriptorTypes.HPC_APP_DEP_DESC_TYPE);
HpcApplicationDeploymentType gramApplicationDeploymentType = (HpcApplicationDeploymentType) applicationDescription.getType();
if(gramApplicationDeploymentType != null){
applicationDescriptor.setCpuCount(gramApplicationDeploymentType.getCpuCount());
applicationDescriptor.setNodeCount(gramApplicationDeploymentType.getNodeCount());
applicationDescriptor.setMaxMemory(gramApplicationDeploymentType.getMaxMemory());
applicationDescriptor.setMinMemory(gramApplicationDeploymentType.getMinMemory());
applicationDescriptor.setMaxWallTime(gramApplicationDeploymentType.getMaxWallTime());
applicationDescriptor.setJobSubmitterCommand(gramApplicationDeploymentType.getJobSubmitterCommand());
applicationDescriptor.setInstalledPath(gramApplicationDeploymentType.getInstalledParentPath());
if (gramApplicationDeploymentType.getJobType() != null) {
applicationDescriptor.setJobType(gramApplicationDeploymentType.getJobType().toString());
}
if (gramApplicationDeploymentType.getProjectAccount() != null){
if (gramApplicationDeploymentType.getProjectAccount().getProjectAccountNumber() != null){
applicationDescriptor.setProjectNumber(gramApplicationDeploymentType.getProjectAccount().getProjectAccountNumber());
}
}
if (gramApplicationDeploymentType.getProjectAccount() != null){
if (gramApplicationDeploymentType.getProjectAccount().getProjectAccountDescription() != null){
applicationDescriptor.setProjectDescription(gramApplicationDeploymentType.getProjectAccount().getProjectAccountDescription());
}
}
if(gramApplicationDeploymentType.getQueue() != null){
applicationDescriptor.setQueueName(gramApplicationDeploymentType.getQueue().getQueueName());
}
applicationDescriptor.setProcessorsPerNode(gramApplicationDeploymentType.getProcessorsPerNode());
}
} else if (applicationDescription.getType() instanceof Ec2ApplicationDeploymentType) {
applicationDescriptor.setApplicationDescType(ApplicationDescriptorTypes.EC2_APP_DEP_DESC_TYPE);
}
}
return applicationDescriptor;
}