Search in sources :

Example 26 with RegistryException

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

the class ExperimentRegistry method addExpOutputs.

public String addExpOutputs(List<OutputDataObjectType> exOutput, String expId) throws RegistryException {
    try {
        for (OutputDataObjectType output : exOutput) {
            ExperimentOutputResource resource = new ExperimentOutputResource();
            resource.setExperimentId(expId);
            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();
        }
    } catch (Exception e) {
        logger.error("Error while adding experiment outputs...", e);
        throw new RegistryException(e);
    }
    return expId;
}
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 27 with RegistryException

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

the class ExperimentRegistry method isUserConfigDataExist.

public boolean isUserConfigDataExist(String expID) throws RegistryException {
    try {
        ExperimentResource experiment = gatewayResource.getExperiment(expID);
        experiment.isExists(ResourceType.USER_CONFIGURATION_DATA, expID);
        return true;
    } catch (Exception e) {
        logger.error("Error while retrieving experiment...", e);
        throw new RegistryException(e);
    }
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 28 with RegistryException

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

the class ExperimentRegistry method getTask.

public Object getTask(String taskId, String fieldName) throws RegistryException {
    try {
        ProcessResource processResource = new ProcessResource();
        TaskResource resource = processResource.getTask(taskId);
        if (fieldName == null) {
            return ThriftDataModelConversion.getTaskModel(resource);
        } else if (fieldName.equals(Constants.FieldConstants.TaskConstants.TASK_ERROR)) {
            return ThriftDataModelConversion.getErrorModel(resource.getTaskError());
        } else if (fieldName.equals(Constants.FieldConstants.TaskConstants.TASK_STATUS)) {
            return ThriftDataModelConversion.getTaskStatus(resource.getTaskStatus());
        } else {
            logger.error("Unsupported field name for task data..");
        }
    } catch (Exception e) {
        logger.error("Error while getting task 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 29 with RegistryException

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

the class ExperimentRegistry method addProcessError.

public String addProcessError(ErrorModel processError, String processID) throws RegistryException {
    try {
        ProcessErrorResource error = new ProcessErrorResource();
        error.setProcessId(processID);
        if (processError.getErrorId() == null) {
            error.setErrorId(AiravataUtils.getId("PROCESS_ERROR"));
        } else {
            error.setErrorId(processError.getErrorId());
        }
        error.setCreationTime(AiravataUtils.getTime(processError.getCreationTime()));
        error.setActualErrorMessage(processError.getActualErrorMessage());
        error.setUserFriendlyMessage(processError.getUserFriendlyMessage());
        error.setTransientOrPersistent(processError.isTransientOrPersistent());
        if (processError.getRootCauseErrorIdList() != null) {
            error.setRootCauseErrorIdList(StringUtils.join(processError.getRootCauseErrorIdList(), ","));
        }
        error.save();
    } catch (Exception e) {
        logger.error(processID, "Error while adding process status...", e);
        throw new RegistryException(e);
    }
    return processID;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 30 with RegistryException

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

the class ExperimentRegistry method getJobList.

public List<JobModel> getJobList(String fieldName, Object value) throws RegistryException {
    List<JobModel> jobs = new ArrayList<JobModel>();
    try {
        if (fieldName.equals(Constants.FieldConstants.JobConstants.PROCESS_ID)) {
            ProcessResource processResource = new ProcessResource();
            processResource.setProcessId((String) value);
            List<JobResource> resources = processResource.getJobList();
            for (JobResource jobResource : resources) {
                JobModel jobModel = ThriftDataModelConversion.getJobModel(jobResource);
                JobStatusResource latestSR = jobResource.getJobStatus();
                if (latestSR != null) {
                    JobStatus jobStatus = new JobStatus(JobState.valueOf(latestSR.getState()));
                    jobStatus.setReason(latestSR.getReason());
                    List<JobStatus> statuses = new ArrayList<>();
                    statuses.add(jobStatus);
                    jobModel.setJobStatuses(statuses);
                }
                jobs.add(jobModel);
            }
            return jobs;
        } else if (fieldName.equals(Constants.FieldConstants.JobConstants.TASK_ID)) {
            TaskResource taskResource = new TaskResource();
            taskResource.setTaskId((String) value);
            List<JobResource> resources = taskResource.getJobList();
            for (JobResource jobResource : resources) {
                JobModel jobModel = ThriftDataModelConversion.getJobModel(jobResource);
                JobStatusResource latestSR = jobResource.getJobStatus();
                if (latestSR != null) {
                    JobStatus jobStatus = new JobStatus(JobState.valueOf(latestSR.getState()));
                    jobStatus.setReason(latestSR.getReason());
                    List<JobStatus> statuses = new ArrayList<>();
                    statuses.add(jobStatus);
                    jobModel.setJobStatuses(statuses);
                }
                jobs.add(jobModel);
            }
            return jobs;
        } else {
            logger.error("Unsupported field name to retrieve job list...");
        }
    } catch (Exception e) {
        logger.error("Error while getting job list...", e);
        throw new RegistryException(e);
    }
    return jobs;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) JobModel(org.apache.airavata.model.job.JobModel)

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