Search in sources :

Example 46 with InputDataObjectType

use of org.apache.airavata.model.application.io.InputDataObjectType 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 47 with InputDataObjectType

use of org.apache.airavata.model.application.io.InputDataObjectType 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 48 with InputDataObjectType

use of org.apache.airavata.model.application.io.InputDataObjectType in project airavata by apache.

the class SimpleOrchestratorImpl method createAndSaveInputDataStagingTasks.

public List<String> createAndSaveInputDataStagingTasks(ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
    List<String> dataStagingTaskIds = new ArrayList<>();
    List<InputDataObjectType> processInputs = processModel.getProcessInputs();
    sortByInputOrder(processInputs);
    if (processInputs != null) {
        for (InputDataObjectType processInput : processInputs) {
            DataType type = processInput.getType();
            switch(type) {
                case STDERR:
                    break;
                case STDOUT:
                    break;
                case URI:
                case URI_COLLECTION:
                    try {
                        TaskModel inputDataStagingTask = getInputDataStagingTask(processModel, processInput, gatewayId);
                        String taskId = (String) orchestratorContext.getRegistry().getExperimentCatalog().add(ExpCatChildDataType.TASK, inputDataStagingTask, processModel.getProcessId());
                        inputDataStagingTask.setTaskId(taskId);
                        dataStagingTaskIds.add(inputDataStagingTask.getTaskId());
                    } catch (TException | AppCatalogException | TaskException e) {
                        throw new RegistryException("Error while serializing data staging sub task model");
                    }
                    break;
                default:
                    // nothing to do
                    break;
            }
        }
    }
    return dataStagingTaskIds;
}
Also used : TException(org.apache.thrift.TException) TaskException(org.apache.airavata.gfac.core.task.TaskException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) DataType(org.apache.airavata.model.application.io.DataType)

Example 49 with InputDataObjectType

use of org.apache.airavata.model.application.io.InputDataObjectType in project airavata by apache.

the class ExperimentRegistry method updateExperiment.

// CPI Update Methods
public void updateExperiment(ExperimentModel experiment, String expId) throws RegistryException {
    try {
        if (!workerResource.isProjectExists(experiment.getProjectId())) {
            logger.error("Project does not exist in the system..");
            throw new Exception("Project does not exist in the system, Please create the project first...");
        }
        ExperimentResource existingExperiment = gatewayResource.getExperiment(expId);
        existingExperiment.setExperimentName(experiment.getExperimentName());
        existingExperiment.setUserName(experiment.getUserName());
        existingExperiment.setGatewayId(experiment.getGatewayId());
        existingExperiment.setGatewayExecutionId(experiment.getGatewayExecutionId());
        existingExperiment.setGatewayInstanceId(experiment.getGatewayInstanceId());
        existingExperiment.setProjectId(experiment.getProjectId());
        existingExperiment.setCreationTime(AiravataUtils.getTime(experiment.getCreationTime()));
        existingExperiment.setDescription(experiment.getDescription());
        existingExperiment.setExecutionId(experiment.getExecutionId());
        if (experiment.isEnableEmailNotification()) {
            existingExperiment.setEnableEmailNotification(true);
            if (experiment.getEmailAddresses() != null) {
                existingExperiment.setEmailAddresses(StringUtils.join(experiment.getEmailAddresses(), ","));
            }
        } else {
            existingExperiment.setEnableEmailNotification(false);
        }
        existingExperiment.save();
        UserConfigurationDataModel userConfigurationData = experiment.getUserConfigurationData();
        if (userConfigurationData != null) {
            updateUserConfigData(userConfigurationData, expId);
        }
        List<InputDataObjectType> experimentInputs = experiment.getExperimentInputs();
        if (experimentInputs != null && !experimentInputs.isEmpty()) {
            updateExpInputs(experimentInputs, expId);
        }
        List<OutputDataObjectType> experimentOutputs = experiment.getExperimentOutputs();
        if (experimentOutputs != null && !experimentOutputs.isEmpty()) {
            updateExpOutputs(experimentOutputs, expId);
        }
        List<ExperimentStatus> experimentStatuses = experiment.getExperimentStatus();
        if (experimentStatuses != null && experimentStatuses.size() > 0) {
            if (experimentStatuses.get(0) != null) {
                updateExperimentStatus(experimentStatuses.get(0), expId);
            }
        }
        List<ErrorModel> errors = experiment.getErrors();
        if (errors != null && !errors.isEmpty()) {
            for (ErrorModel errror : errors) {
                updateExperimentError(errror, expId);
            }
        }
    } catch (Exception e) {
        logger.error("Error while updating experiment...", e);
        throw new RegistryException(e);
    }
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ErrorModel(org.apache.airavata.model.commons.ErrorModel) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 50 with InputDataObjectType

use of org.apache.airavata.model.application.io.InputDataObjectType in project airavata by apache.

the class ExperimentRegistry method updateProcessInputs.

public void updateProcessInputs(List<InputDataObjectType> processInputs, String processID) throws RegistryException {
    try {
        ProcessResource processResource = new ProcessResource();
        processResource.setProcessId(processID);
        List<ProcessInputResource> existingProcessInputs = processResource.getProcessInputs();
        for (InputDataObjectType input : processInputs) {
            for (ProcessInputResource exinput : existingProcessInputs) {
                if (exinput.getInputName().equals(input.getName())) {
                    exinput.setProcessId(processID);
                    exinput.setInputValue(input.getValue());
                    if (input.getType() != null) {
                        exinput.setDataType(input.getType().toString());
                    }
                    exinput.setMetadata(input.getMetaData());
                    exinput.setApplicationArgument(input.getApplicationArgument());
                    exinput.setInputOrder(input.getInputOrder());
                    exinput.setIsRequired(input.isIsRequired());
                    exinput.setRequiredToAddedToCmd(input.isRequiredToAddedToCommandLine());
                    exinput.setStorageResourceId(input.getStorageResourceId());
                    exinput.setIsReadOnly(input.isIsReadOnly());
                    exinput.save();
                }
            }
        }
    } catch (Exception e) {
        logger.error("Unable to update experiment inputs", e);
        throw new RegistryException(e);
    }
}
Also used : InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Aggregations

InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)86 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)60 TException (org.apache.thrift.TException)49 AuthzToken (org.apache.airavata.model.security.AuthzToken)46 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)35 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)35 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)34 ArrayList (java.util.ArrayList)20 Project (org.apache.airavata.model.workspace.Project)17 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)7 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)7 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)7 RegistryException (org.apache.airavata.registry.cpi.RegistryException)6 HashMap (java.util.HashMap)3 DocumentCreatorNew (org.apache.airavata.integration.tools.DocumentCreatorNew)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 BeforeTest (org.testng.annotations.BeforeTest)3 Test (org.testng.annotations.Test)3 JSchException (com.jcraft.jsch.JSchException)2 Session (com.jcraft.jsch.Session)2