Search in sources :

Example 11 with ExperimentCatResource

use of org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource in project airavata by apache.

the class ProcessResource method getProcessInputs.

public List<ProcessInputResource> getProcessInputs() throws RegistryException {
    List<ProcessInputResource> processInputResources = new ArrayList();
    List<ExperimentCatResource> resources = get(ResourceType.PROCESS_INPUT);
    for (ExperimentCatResource resource : resources) {
        ProcessInputResource inputResource = (ProcessInputResource) resource;
        processInputResources.add(inputResource);
    }
    return processInputResources;
}
Also used : ArrayList(java.util.ArrayList) ExperimentCatResource(org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)

Example 12 with ExperimentCatResource

use of org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource in project airavata by apache.

the class ProcessResource method getJobList.

public List<JobResource> getJobList() throws RegistryException {
    List<JobResource> jobResources = new ArrayList();
    List<ExperimentCatResource> resources = get(ResourceType.JOB);
    for (ExperimentCatResource resource : resources) {
        JobResource jobResource = (JobResource) resource;
        jobResources.add(jobResource);
    }
    return jobResources;
}
Also used : ArrayList(java.util.ArrayList) ExperimentCatResource(org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)

Example 13 with ExperimentCatResource

use of org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource in project airavata by apache.

the class ProcessResource method get.

public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
    List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
    EntityManager em = null;
    try {
        em = ExpCatResourceUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        QueryGenerator generator;
        List results;
        switch(type) {
            case PROCESS_INPUT:
                generator = new QueryGenerator(PROCESS_INPUT);
                generator.setParameter(ProcessInputConstants.PROCESS_ID, processId);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        ProcessInput processInput = (ProcessInput) result;
                        ProcessInputResource processInputResource = (ProcessInputResource) Utils.getResource(ResourceType.PROCESS_INPUT, processInput);
                        resourceList.add(processInputResource);
                    }
                }
                break;
            case PROCESS_OUTPUT:
                generator = new QueryGenerator(PROCESS_OUTPUT);
                generator.setParameter(ProcessOutputConstants.PROCESS_ID, processId);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        ProcessOutput processOutput = (ProcessOutput) result;
                        ProcessOutputResource processOutputResource = (ProcessOutputResource) Utils.getResource(ResourceType.PROCESS_OUTPUT, processOutput);
                        resourceList.add(processOutputResource);
                    }
                }
                break;
            case TASK:
                generator = new QueryGenerator(TASK);
                generator.setParameter(TaskConstants.PROCESS_ID, processId);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Task task = (Task) result;
                        TaskResource taskResource = (TaskResource) Utils.getResource(ResourceType.TASK, task);
                        resourceList.add(taskResource);
                    }
                }
                break;
            case PROCESS_ERROR:
                generator = new QueryGenerator(PROCESS_ERROR);
                generator.setParameter(ProcessErrorConstants.PROCESS_ID, processId);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        ProcessError processError = (ProcessError) result;
                        ProcessErrorResource processErrorResource = (ProcessErrorResource) Utils.getResource(ResourceType.PROCESS_ERROR, processError);
                        resourceList.add(processErrorResource);
                    }
                }
                break;
            case PROCESS_STATUS:
                generator = new QueryGenerator(PROCESS_STATUS);
                generator.setParameter(ProcessStatusConstants.PROCESS_ID, processId);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        ProcessStatus processStatus = (ProcessStatus) result;
                        ProcessStatusResource processStatusResource = (ProcessStatusResource) Utils.getResource(ResourceType.PROCESS_STATUS, processStatus);
                        resourceList.add(processStatusResource);
                    }
                }
                break;
            case JOB:
                generator = new QueryGenerator(JOB);
                generator.setParameter(JobConstants.PROCESS_ID, processId);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Job job = (Job) result;
                        JobResource jobResource = (JobResource) Utils.getResource(ResourceType.JOB, job);
                        resourceList.add(jobResource);
                    }
                }
                break;
            default:
                logger.error("Unsupported resource type for task resource.", new UnsupportedOperationException());
                throw new UnsupportedOperationException();
        }
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new RegistryException(e);
    } finally {
        if (em != null && em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    }
    return resourceList;
}
Also used : Query(javax.persistence.Query) ArrayList(java.util.ArrayList) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) EntityManager(javax.persistence.EntityManager) QueryGenerator(org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator) ArrayList(java.util.ArrayList) List(java.util.List) ExperimentCatResource(org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)

Example 14 with ExperimentCatResource

use of org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource in project airavata by apache.

the class ProcessResource method getProcessOutputs.

public List<ProcessOutputResource> getProcessOutputs() throws RegistryException {
    List<ProcessOutputResource> outputResources = new ArrayList();
    List<ExperimentCatResource> resources = get(ResourceType.PROCESS_OUTPUT);
    for (ExperimentCatResource resource : resources) {
        ProcessOutputResource outputResource = (ProcessOutputResource) resource;
        outputResources.add(outputResource);
    }
    return outputResources;
}
Also used : ArrayList(java.util.ArrayList) ExperimentCatResource(org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)

Example 15 with ExperimentCatResource

use of org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource in project airavata by apache.

the class ExperimentResource method getExperimentOutputs.

public List<ExperimentOutputResource> getExperimentOutputs() throws RegistryException {
    List<ExperimentOutputResource> outputResources = new ArrayList();
    List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_OUTPUT);
    for (ExperimentCatResource resource : resources) {
        ExperimentOutputResource outputResource = (ExperimentOutputResource) resource;
        outputResources.add(outputResource);
    }
    return outputResources;
}
Also used : ArrayList(java.util.ArrayList) ExperimentCatResource(org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)

Aggregations

ExperimentCatResource (org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)36 ArrayList (java.util.ArrayList)31 RegistryException (org.apache.airavata.registry.cpi.RegistryException)12 EntityManager (javax.persistence.EntityManager)11 Query (javax.persistence.Query)11 QueryGenerator (org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator)10 List (java.util.List)8 Notification (org.apache.airavata.model.workspace.Notification)1 Job (org.apache.airavata.registry.core.experiment.catalog.model.Job)1 JobStatus (org.apache.airavata.registry.core.experiment.catalog.model.JobStatus)1 Notification (org.apache.airavata.registry.core.experiment.catalog.model.Notification)1 Process (org.apache.airavata.registry.core.experiment.catalog.model.Process)1 QueueStatus (org.apache.airavata.registry.core.experiment.catalog.model.QueueStatus)1 TaskError (org.apache.airavata.registry.core.experiment.catalog.model.TaskError)1 TaskStatus (org.apache.airavata.registry.core.experiment.catalog.model.TaskStatus)1 NotificationResource (org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource)1 QueueStatusResource (org.apache.airavata.registry.core.experiment.catalog.resources.QueueStatusResource)1 Test (org.junit.Test)1