Search in sources :

Example 41 with OutputDataObjectType

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;
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList) Client(org.apache.airavata.api.Airavata.Client) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 42 with OutputDataObjectType

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);
    }
}
Also used : InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType)

Example 43 with OutputDataObjectType

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);
    }
}
Also used : HashMap(java.util.HashMap) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType)

Example 44 with OutputDataObjectType

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);
    }
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 45 with OutputDataObjectType

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);
    }
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Aggregations

OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)93 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)60 TException (org.apache.thrift.TException)51 AuthzToken (org.apache.airavata.model.security.AuthzToken)44 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)34 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)33 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)33 ArrayList (java.util.ArrayList)18 Project (org.apache.airavata.model.workspace.Project)16 RegistryException (org.apache.airavata.registry.cpi.RegistryException)14 GFacException (org.apache.airavata.gfac.core.GFacException)7 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)7 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)7 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)7 URISyntaxException (java.net.URISyntaxException)6 AiravataException (org.apache.airavata.common.exception.AiravataException)5 HashMap (java.util.HashMap)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)4 JobStatus (org.apache.airavata.model.status.JobStatus)4