use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class DataRetrievalIT method runExperiment.
public String runExperiment(String user, String project) throws ApplicationSettingsException, AiravataClientException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException, ExperimentNotFoundException {
List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
InputDataObjectType input = new InputDataObjectType();
input.setName("echo_input");
input.setType(DataType.STRING);
input.setValue("echo_output=Hello World");
exInputs.add(input);
List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
OutputDataObjectType output = new OutputDataObjectType();
output.setName("echo_output");
output.setType(DataType.STRING);
output.setValue("");
exOut.add(output);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment("default", project, user, "echoExperiment", "SimpleEcho0", "SimpleEcho0", exInputs);
simpleExperiment.setExperimentOutputs(exOut);
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("localhost", 1, 1, 1, "normal", 0, 0);
scheduling.setResourceHostId("localhost");
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
simpleExperiment.setUserConfigurationData(userConfigurationData);
Client client = getClient();
final String expId = client.createExperiment(authzToken, "default", simpleExperiment);
client.launchExperiment(authzToken, expId, "testToken");
return expId;
}
use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class ApplicationInterfaceImpl method addApplicationInterface.
@Override
public String addApplicationInterface(ApplicationInterfaceDescription applicationInterfaceDescription, String gatewayId) throws AppCatalogException {
try {
AppInterfaceResource resource = new AppInterfaceResource();
resource.setAppName(applicationInterfaceDescription.getApplicationName());
if (!applicationInterfaceDescription.getApplicationInterfaceId().equals("") && !applicationInterfaceDescription.getApplicationInterfaceId().equals(application_interface_modelConstants.DEFAULT_ID)) {
resource.setInterfaceId(applicationInterfaceDescription.getApplicationInterfaceId());
} else {
resource.setInterfaceId(AppCatalogUtils.getID(applicationInterfaceDescription.getApplicationName()));
}
resource.setAppDescription(applicationInterfaceDescription.getApplicationDescription());
resource.setGatewayId(gatewayId);
resource.setArchiveWorkingDirectory(applicationInterfaceDescription.isArchiveWorkingDirectory());
resource.setHasOptionalFileInputs(applicationInterfaceDescription.isHasOptionalFileInputs());
resource.save();
applicationInterfaceDescription.setApplicationInterfaceId(resource.getInterfaceId());
List<String> applicationModules = applicationInterfaceDescription.getApplicationModules();
if (applicationModules != null && !applicationModules.isEmpty()) {
for (String moduleId : applicationModules) {
AppModuleResource appModuleResource = new AppModuleResource();
AppModuleMappingAppCatalogResourceAppCat moduleMappingResource = new AppModuleMappingAppCatalogResourceAppCat();
moduleMappingResource.setInterfaceId(resource.getInterfaceId());
moduleMappingResource.setModuleId(moduleId);
moduleMappingResource.setModuleResource((AppModuleResource) appModuleResource.get(moduleId));
moduleMappingResource.setAppInterfaceResource(resource);
moduleMappingResource.save();
}
}
List<InputDataObjectType> applicationInputs = applicationInterfaceDescription.getApplicationInputs();
if (applicationInputs != null && !applicationInputs.isEmpty()) {
for (InputDataObjectType input : applicationInputs) {
ApplicationInputResource inputResource = new ApplicationInputResource();
inputResource.setAppInterfaceResource(resource);
inputResource.setInterfaceID(resource.getInterfaceId());
inputResource.setUserFriendlyDesc(input.getUserFriendlyDescription());
inputResource.setInputKey(input.getName());
inputResource.setInputVal(input.getValue());
inputResource.setDataType(input.getType().toString());
inputResource.setMetadata(input.getMetaData());
inputResource.setStandardInput(input.isStandardInput());
inputResource.setAppArgument(input.getApplicationArgument());
inputResource.setInputOrder(input.getInputOrder());
inputResource.setRequired(input.isIsRequired());
inputResource.setRequiredToCMD(input.isRequiredToAddedToCommandLine());
inputResource.save();
}
}
List<OutputDataObjectType> applicationOutputs = applicationInterfaceDescription.getApplicationOutputs();
if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
for (OutputDataObjectType output : applicationOutputs) {
ApplicationOutputResource outputResource = new ApplicationOutputResource();
outputResource.setInterfaceID(resource.getInterfaceId());
outputResource.setAppInterfaceResource(resource);
outputResource.setOutputKey(output.getName());
outputResource.setOutputVal(output.getValue());
outputResource.setDataType(output.getType().toString());
outputResource.setRequired(output.isIsRequired());
outputResource.setRequiredToCMD(output.isRequiredToAddedToCommandLine());
outputResource.setDataMovement(output.isDataMovement());
outputResource.setDataNameLocation(output.getLocation());
outputResource.setAppArgument(output.getApplicationArgument());
outputResource.setSearchQuery(output.getSearchQuery());
outputResource.setOutputStreaming(output.isOutputStreaming());
outputResource.save();
}
}
return resource.getInterfaceId();
} catch (Exception e) {
logger.error("Error while adding application interface " + applicationInterfaceDescription.getApplicationName(), e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class ApplicationInterfaceImpl method updateApplicationInterface.
@Override
public void updateApplicationInterface(String interfaceId, ApplicationInterfaceDescription updatedInterface) throws AppCatalogException {
try {
AppInterfaceResource resource = new AppInterfaceResource();
AppInterfaceResource existingInterface = (AppInterfaceResource) resource.get(interfaceId);
existingInterface.setAppName(updatedInterface.getApplicationName());
existingInterface.setAppDescription(updatedInterface.getApplicationDescription());
existingInterface.setHasOptionalFileInputs(updatedInterface.isHasOptionalFileInputs());
existingInterface.setArchiveWorkingDirectory(updatedInterface.isArchiveWorkingDirectory());
existingInterface.save();
// remove existing modules before adding
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppModuleMappingConstants.INTERFACE_ID, interfaceId);
AppModuleMappingAppCatalogResourceAppCat moduleMappingResource = new AppModuleMappingAppCatalogResourceAppCat();
moduleMappingResource.remove(ids);
List<String> applicationModules = updatedInterface.getApplicationModules();
if (applicationModules != null && !applicationModules.isEmpty()) {
for (String moduleId : applicationModules) {
AppModuleResource appModuleResource = new AppModuleResource();
moduleMappingResource = new AppModuleMappingAppCatalogResourceAppCat();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppModuleMappingConstants.MODULE_ID, moduleId);
ids.put(AppCatAbstractResource.AppModuleMappingConstants.INTERFACE_ID, interfaceId);
AppModuleMappingAppCatalogResourceAppCat existingMapping;
if (!moduleMappingResource.isExists(ids)) {
existingMapping = new AppModuleMappingAppCatalogResourceAppCat();
} else {
existingMapping = (AppModuleMappingAppCatalogResourceAppCat) moduleMappingResource.get(ids);
}
existingMapping.setInterfaceId(interfaceId);
existingMapping.setModuleId(moduleId);
existingMapping.setModuleResource((AppModuleResource) appModuleResource.get(moduleId));
existingMapping.setAppInterfaceResource(existingInterface);
existingMapping.save();
}
}
// remove existing application inputs
ApplicationInputResource inputResource = new ApplicationInputResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppInputConstants.INTERFACE_ID, interfaceId);
inputResource.remove(ids);
List<InputDataObjectType> applicationInputs = updatedInterface.getApplicationInputs();
if (applicationInputs != null && !applicationInputs.isEmpty()) {
for (InputDataObjectType input : applicationInputs) {
inputResource = new ApplicationInputResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppInputConstants.INTERFACE_ID, interfaceId);
ids.put(AppCatAbstractResource.AppInputConstants.INPUT_KEY, input.getName());
if (inputResource.isExists(ids)) {
inputResource = (ApplicationInputResource) inputResource.get(ids);
}
inputResource.setAppInterfaceResource(existingInterface);
inputResource.setInterfaceID(interfaceId);
inputResource.setUserFriendlyDesc(input.getUserFriendlyDescription());
inputResource.setInputKey(input.getName());
inputResource.setInputVal(input.getValue());
inputResource.setDataType(input.getType().toString());
inputResource.setMetadata(input.getMetaData());
inputResource.setStandardInput(input.isStandardInput());
inputResource.setAppArgument(input.getApplicationArgument());
inputResource.setInputOrder(input.getInputOrder());
inputResource.setRequired(input.isIsRequired());
inputResource.setRequiredToCMD(input.isRequiredToAddedToCommandLine());
inputResource.setDataStaged(input.isDataStaged());
inputResource.setIsReadOnly(input.isIsReadOnly());
inputResource.save();
}
}
// remove existing app outputs before adding
ApplicationOutputResource outputResource = new ApplicationOutputResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppOutputConstants.INTERFACE_ID, interfaceId);
outputResource.remove(ids);
List<OutputDataObjectType> applicationOutputs = updatedInterface.getApplicationOutputs();
if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
for (OutputDataObjectType output : applicationOutputs) {
outputResource = new ApplicationOutputResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppOutputConstants.INTERFACE_ID, interfaceId);
ids.put(AppCatAbstractResource.AppOutputConstants.OUTPUT_KEY, output.getName());
if (outputResource.isExists(ids)) {
outputResource = (ApplicationOutputResource) outputResource.get(ids);
}
outputResource.setInterfaceID(interfaceId);
outputResource.setAppInterfaceResource(existingInterface);
outputResource.setOutputKey(output.getName());
outputResource.setOutputVal(output.getValue());
outputResource.setDataType(output.getType().toString());
outputResource.setRequired(output.isIsRequired());
outputResource.setRequiredToCMD(output.isRequiredToAddedToCommandLine());
outputResource.setDataMovement(output.isDataMovement());
outputResource.setDataNameLocation(output.getLocation());
outputResource.setAppArgument(output.getApplicationArgument());
outputResource.setSearchQuery(output.getSearchQuery());
outputResource.setOutputStreaming(output.isOutputStreaming());
outputResource.save();
}
}
} catch (Exception e) {
logger.error("Error while updating application interface " + interfaceId, e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class ExperimentRegistry method addProcessOutputs.
public String addProcessOutputs(List<OutputDataObjectType> processOutput, String processID) throws RegistryException {
try {
for (OutputDataObjectType output : processOutput) {
ProcessOutputResource resource = new ProcessOutputResource();
resource.setProcessId(processID);
resource.setOutputName(output.getName());
resource.setOutputValue(output.getValue());
if (output.getType() != null) {
resource.setDataType(output.getType().toString());
}
resource.setApplicationArgument(output.getApplicationArgument());
resource.setIsRequired(output.isIsRequired());
resource.setRequiredToAddedToCmd(output.isRequiredToAddedToCommandLine());
resource.setDataMovement(output.isDataMovement());
resource.setLocation(output.getLocation());
resource.setSearchQuery(output.getSearchQuery());
resource.setOutputStreaming(output.isOutputStreaming());
resource.setStorageResourceId(output.getStorageResourceId());
resource.save();
}
return processID;
} catch (Exception e) {
logger.error("Error while adding process outputs...", e);
throw new RegistryException(e);
}
}
use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class ExperimentRegistry method updateExpOutputs.
public void updateExpOutputs(List<OutputDataObjectType> exOutput, String expId) throws RegistryException {
try {
ExperimentResource experiment = gatewayResource.getExperiment(expId);
List<ExperimentOutputResource> existingExpOutputs = experiment.getExperimentOutputs();
for (OutputDataObjectType output : exOutput) {
for (ExperimentOutputResource resource : existingExpOutputs) {
if (resource.getOutputName().equals(output.getName())) {
resource.setExperimentId(expId);
resource.setOutputName(output.getName());
resource.setOutputValue(output.getValue());
if (output.getType() != null) {
resource.setDataType(output.getType().toString());
}
resource.setIsRequired(output.isIsRequired());
resource.setRequiredToAddedToCmd(output.isRequiredToAddedToCommandLine());
resource.setDataMovement(output.isDataMovement());
resource.setLocation(output.getLocation());
resource.setApplicationArgument(output.getApplicationArgument());
resource.setSearchQuery(output.getSearchQuery());
resource.setOutputStreaming(output.isOutputStreaming());
resource.setStorageResourceId(output.getStorageResourceId());
resource.save();
}
}
}
} catch (Exception e) {
logger.error("Error while updating experiment outputs", e);
throw new RegistryException(e);
}
}
Aggregations