Search in sources :

Example 81 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method searchExperiments.

// CPI Search Methods
public List<ExperimentSummaryModel> searchExperiments(Map<String, String> filters, int limit, int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
    Map<String, String> fil = new HashMap<String, String>();
    if (filters != null && filters.size() != 0) {
        List<ExperimentSummaryModel> experimentSummaries = new ArrayList<>();
        long fromTime = 0;
        long toTime = 0;
        try {
            for (String field : filters.keySet()) {
                if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.EXPERIMENT_NAME, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.USER_NAME, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.PROJECT_ID)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.PROJECT_ID, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.GATEWAY_ID, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.DESCRIPTION)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.DESCRIPTION, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.EXECUTION_ID, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS)) {
                    fil.put(AbstractExpCatResource.ExperimentStatusConstants.STATE, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.FROM_DATE)) {
                    fromTime = Long.parseLong(filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.TO_DATE)) {
                    toTime = Long.parseLong(filters.get(field));
                }
            }
            List<ExperimentSummaryResource> experimentSummaryResources;
            if (fromTime != 0 && toTime != 0) {
                experimentSummaryResources = workerResource.searchExperiments(null, new Timestamp(fromTime), new Timestamp(toTime), fil, limit, offset, orderByIdentifier, resultOrderType);
            } else {
                experimentSummaryResources = workerResource.searchExperiments(null, null, null, fil, limit, offset, orderByIdentifier, resultOrderType);
            }
            if (experimentSummaryResources != null && !experimentSummaryResources.isEmpty()) {
                for (ExperimentSummaryResource ex : experimentSummaryResources) {
                    experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
                }
            }
            return experimentSummaries;
        } catch (Exception e) {
            logger.error("Error while retrieving experiment summary from registry", e);
            throw new RegistryException(e);
        }
    }
    return null;
}
Also used : ExperimentSummaryModel(org.apache.airavata.model.experiment.ExperimentSummaryModel) Timestamp(java.sql.Timestamp) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 82 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method getUserConfigData.

public Object getUserConfigData(String expId, String fieldName) throws RegistryException {
    try {
        ExperimentResource resource = gatewayResource.getExperiment(expId);
        UserConfigurationDataResource userConfigData = resource.getUserConfigurationDataResource();
        if (fieldName == null) {
            return ThriftDataModelConversion.getUserConfigData(userConfigData);
        } else if (fieldName.equals(Constants.FieldConstants.UserConfigurationDataConstants.COMPUTATIONAL_RESOURCE_SCHEDULING)) {
            return ThriftDataModelConversion.getComputationalResourceScheduling(userConfigData);
        } else {
            logger.error("Unsupported field name for experiment configuration data..");
        }
    } catch (Exception e) {
        logger.error("Error while getting config data..", e);
        throw new RegistryException(e);
    }
    return null;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 83 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method getProcessList.

public List<ProcessModel> getProcessList(String fieldName, Object value) throws RegistryException {
    List<ProcessModel> processes = new ArrayList<ProcessModel>();
    try {
        if (fieldName.equals(Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID)) {
            ExperimentResource experimentResource = new ExperimentResource();
            experimentResource.setExperimentId((String) value);
            List<ProcessResource> resources = experimentResource.getProcessList();
            for (ProcessResource processResource : resources) {
                ProcessModel processModel = ThriftDataModelConversion.getProcessModel(processResource);
                processes.add(processModel);
            }
            return processes;
        } else {
            logger.error("Unsupported field name to retrieve process list...");
        }
    } catch (Exception e) {
        logger.error("Error while getting process list...", e);
        throw new RegistryException(e);
    }
    return processes;
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 84 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method addExperimentError.

public String addExperimentError(ErrorModel experimentError, String expId) throws RegistryException {
    try {
        ExperimentErrorResource error = new ExperimentErrorResource();
        if (experimentError.getErrorId() == null) {
            error.setErrorId(AiravataUtils.getId("EXP_ERROR"));
        } else {
            error.setErrorId(experimentError.getErrorId());
        }
        error.setExperimentId(expId);
        error.setCreationTime(AiravataUtils.getTime(experimentError.getCreationTime()));
        error.setActualErrorMessage(experimentError.getActualErrorMessage());
        error.setUserFriendlyMessage(experimentError.getUserFriendlyMessage());
        error.setTransientOrPersistent(experimentError.isTransientOrPersistent());
        if (experimentError.getRootCauseErrorIdList() != null) {
            error.setRootCauseErrorIdList(StringUtils.join(experimentError.getRootCauseErrorIdList(), ","));
        }
        error.save();
    } catch (Exception e) {
        logger.error(expId, "Error while updating experiment status...", e);
        throw new RegistryException(e);
    }
    return expId;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 85 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException 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

RegistryException (org.apache.airavata.registry.cpi.RegistryException)134 EntityManager (javax.persistence.EntityManager)54 Query (javax.persistence.Query)29 QueryGenerator (org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator)29 ArrayList (java.util.ArrayList)15 List (java.util.List)12 ExperimentCatResource (org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)12 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)11 ExperimentCatalogException (org.apache.airavata.registry.cpi.ExperimentCatalogException)8 AiravataException (org.apache.airavata.common.exception.AiravataException)6 GFacException (org.apache.airavata.gfac.core.GFacException)6 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)6 Node (org.apache.airavata.workflow.model.graph.Node)6 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)6 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)6 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)6 Timestamp (java.sql.Timestamp)5 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 DataPort (org.apache.airavata.workflow.model.graph.DataPort)4 HashMap (java.util.HashMap)3