HashMap<String,String> environmentVariables = applicationDescriptor.getEnvironmentVariables();
if (environmentVariables != null && !environmentVariables.isEmpty()){
NameValuePairType[] appEnviVariablesArray = new NameValuePairType[environmentVariables.size()];
for(String key : environmentVariables.keySet()) {
int i = 0;
NameValuePairType nameValuePairType = applicationDescription.getType().addNewApplicationEnvironment();
nameValuePairType.setName(key);
nameValuePairType.setValue(environmentVariables.get(key));
appEnviVariablesArray[i] = nameValuePairType;
i++;
}
applicationDescription.getType().setApplicationEnvironmentArray(appEnviVariablesArray);
}
//set advanced options according app desc type
if(applicationDescriptor.getApplicationDescType() != null && !applicationDescriptor.getApplicationDescType().isEmpty()){
if (applicationDescriptor.getApplicationDescType().equals(ApplicationDescriptorTypes.HPC_APP_DEP_DESC_TYPE)){
ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
appDesc.getType().setApplicationName(name);
appDesc.getType().setExecutableLocation(applicationDescriptor.getExecutablePath());
appDesc.getType().setScratchWorkingDirectory(applicationDescriptor.getWorkingDir());
if (applicationDescriptor.getInputDir() != null){
appDesc.getType().setInputDataDirectory(applicationDescriptor.getInputDir());
}
if (applicationDescriptor.getOutputDir() != null){
appDesc.getType().setOutputDataDirectory(applicationDescriptor.getOutputDir());
}
if (applicationDescriptor.getStdIn() != null){
appDesc.getType().setStandardInput(applicationDescriptor.getStdIn());
}
if (applicationDescriptor.getStdOut() != null){
appDesc.getType().setStandardOutput(applicationDescriptor.getStdOut());
}
if (applicationDescriptor.getStdError() != null){
appDesc.getType().setStandardError(applicationDescriptor.getStdError());
}
if (applicationDescriptor.getStaticWorkigDir() != null){
appDesc.getType().setStaticWorkingDirectory(applicationDescriptor.getStaticWorkigDir());
}
HashMap<String,String> envVariables = applicationDescriptor.getEnvironmentVariables();
if (envVariables != null && !envVariables.isEmpty()){
NameValuePairType[] appEnviVariablesArray = new NameValuePairType[envVariables.size()];
for(String key : envVariables.keySet()) {
int i = 0;
NameValuePairType nameValuePairType = applicationDescription.getType().addNewApplicationEnvironment();
nameValuePairType.setName(key);
nameValuePairType.setValue(envVariables.get(key));
appEnviVariablesArray[i] = nameValuePairType;
i++;
}
appDesc.getType().setApplicationEnvironmentArray(appEnviVariablesArray);
}