Package org.apache.airavata.persistance.registry.jpa.utils

Examples of org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator


    public void remove(ResourceType type, Object name) {
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        QueryGenerator generator;
        switch (type){
            case WORKFLOW_DATA:
                generator = new QueryGenerator(WORKFLOW_DATA);
//                generator.setParameter(WorkflowDataConstants.EXPERIMENT_ID, experimentID);
                generator.setParameter(WorkflowDataConstants.WORKFLOW_INSTANCE_ID, name);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            case EXPERIMENT_METADATA:
                generator = new QueryGenerator(EXPERIMENT_METADATA);
                generator.setParameter(ExperimentDataConstants.EXPERIMENT_ID, name);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            default:
                break;
        }
View Full Code Here


     */
    public void remove(ResourceType type, Object name) {
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        QueryGenerator generator;
        switch (type){
            case USER:
                generator = new QueryGenerator(USERS);
                generator.setParameter(UserConstants.USERNAME, name);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            case PUBLISHED_WORKFLOW:
                generator = new QueryGenerator(PUBLISHED_WORKFLOW);
                generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME, name);
                generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            case HOST_DESCRIPTOR:
                generator = new QueryGenerator(HOST_DESCRIPTOR);
                generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, name);
                generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            case SERVICE_DESCRIPTOR:
                generator = new QueryGenerator(SERVICE_DESCRIPTOR);
                generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, name);
                generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            case EXPERIMENT:
                generator = new QueryGenerator(EXPERIMENT);
                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
                generator.setParameter(ExperimentConstants.GATEWAY_NAME, gatewayName);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            case APPLICATION_DESCRIPTOR:
                generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
                generator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, name);
                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            default:
                logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
                break;
View Full Code Here

     * @return specific child resource type
     */
    public Resource get(ResourceType type, Object name) {
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator generator;
        Query q;
        switch (type) {
            case USER:
                generator = new QueryGenerator(GATEWAY_WORKER);
                generator.setParameter(GatewayWorkerConstants.USERNAME, name);
                generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                Gateway_Worker worker = (Gateway_Worker) q.getSingleResult();
                WorkerResource workerResource =
                        (WorkerResource)Utils.getResource(ResourceType.GATEWAY_WORKER, worker);
                em.getTransaction().commit();
                em.close();
                return workerResource;
            case PUBLISHED_WORKFLOW:
                generator = new QueryGenerator(PUBLISHED_WORKFLOW);
                generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME, name);
                generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                Published_Workflow ePub_workflow = (Published_Workflow) q.getSingleResult();
                PublishWorkflowResource publishWorkflowResource =
                        (PublishWorkflowResource)Utils.getResource(ResourceType.PUBLISHED_WORKFLOW, ePub_workflow);
                em.getTransaction().commit();
                em.close();
                return publishWorkflowResource;
            case HOST_DESCRIPTOR:
                generator = new QueryGenerator(HOST_DESCRIPTOR);
                generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, name);
                generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                Host_Descriptor eHostDesc = (Host_Descriptor) q.getSingleResult();
                HostDescriptorResource hostDescriptorResource =
                        (HostDescriptorResource)Utils.getResource(ResourceType.HOST_DESCRIPTOR, eHostDesc);
                em.getTransaction().commit();
                em.close();
                return hostDescriptorResource;
            case EXPERIMENT:
                generator = new QueryGenerator(EXPERIMENT);
                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
                generator.setParameter(ExperimentConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                Experiment experiment = (Experiment)q.getSingleResult();
                ExperimentResource experimentResource =
                        (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
                em.getTransaction().commit();
                em.close();
                return experimentResource;
            case SERVICE_DESCRIPTOR:
                generator = new QueryGenerator(SERVICE_DESCRIPTOR);
                generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, name);
                generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                Service_Descriptor eServiceDesc = (Service_Descriptor) q.getSingleResult();
                ServiceDescriptorResource serviceDescriptorResource =
                        (ServiceDescriptorResource)Utils.getResource(ResourceType.SERVICE_DESCRIPTOR, eServiceDesc);
                em.getTransaction().commit();
                em.close();
                return serviceDescriptorResource;
            case APPLICATION_DESCRIPTOR:
                generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
                generator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, name);
                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                Application_Descriptor eAppDesc = (Application_Descriptor) q.getSingleResult();
                ApplicationDescriptorResource applicationDescriptorResource =
                        (ApplicationDescriptorResource)Utils.getResource(ResourceType.APPLICATION_DESCRIPTOR, eAppDesc);
                em.getTransaction().commit();
                em.close();
View Full Code Here

    public List<Resource> get(ResourceType type) {
        List<Resource> resourceList = new ArrayList<Resource>();
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        QueryGenerator generator;
        List results;
        switch (type){
            case PROJECT:
                generator = new QueryGenerator(PROJECT);
                Gateway gatewayModel = em.find(Gateway.class, gatewayName);
                generator.setParameter("gateway", gatewayModel);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Project project = (Project) result;
                        ProjectResource projectResource =
                                (ProjectResource)Utils.getResource(ResourceType.PROJECT, project);
                        resourceList.add(projectResource);
                    }
                }
                break;
            case GATEWAY_WORKER:
                generator = new QueryGenerator(GATEWAY_WORKER);
                generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Gateway_Worker gatewayWorker = (Gateway_Worker) result;
                        WorkerResource workerResource =
                                (WorkerResource)Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
                        resourceList.add(workerResource);
                    }
                }
                break;
            case  PUBLISHED_WORKFLOW :
                generator = new QueryGenerator(PUBLISHED_WORKFLOW);
                generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Published_Workflow publishedWorkflow = (Published_Workflow) result;
                        PublishWorkflowResource publishWorkflowResource =
                                (PublishWorkflowResource)Utils.getResource(ResourceType.PUBLISHED_WORKFLOW, publishedWorkflow);
                        resourceList.add(publishWorkflowResource);
                    }
                }
                break;
            case HOST_DESCRIPTOR:
                generator = new QueryGenerator(HOST_DESCRIPTOR);
                generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Host_Descriptor hostDescriptor = (Host_Descriptor) result;
                        HostDescriptorResource hostDescriptorResource =
                                (HostDescriptorResource)Utils.getResource(ResourceType.HOST_DESCRIPTOR, hostDescriptor);
                        resourceList.add(hostDescriptorResource);
                    }
                }
                break;
            case SERVICE_DESCRIPTOR:
                generator = new QueryGenerator(SERVICE_DESCRIPTOR);
                generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Service_Descriptor serviceDescriptor = (Service_Descriptor) result;
                        ServiceDescriptorResource serviceDescriptorResource =
                                (ServiceDescriptorResource)Utils.getResource(ResourceType.SERVICE_DESCRIPTOR, serviceDescriptor);
                        resourceList.add(serviceDescriptorResource);
                    }
                }
                break;
            case APPLICATION_DESCRIPTOR:
                generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
                        ApplicationDescriptorResource applicationDescriptorResource =
                                (ApplicationDescriptorResource)Utils.getResource(ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
                        resourceList.add(applicationDescriptorResource);
                    }
                }
                break;
            case EXPERIMENT:
                generator = new QueryGenerator(EXPERIMENT);
                generator.setParameter(ExperimentConstants.GATEWAY_NAME, gatewayName);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Experiment experiment = (Experiment) result;
                        ExperimentResource experimentResource =
View Full Code Here

    public void remove(ResourceType type, Object name) {
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        QueryGenerator generator;
        switch (type){
            case NODE_DATA:
                generator = new QueryGenerator(NODE_DATA);
                generator.setParameter(NodeDataConstants.WORKFLOW_INSTANCE_ID, workflowInstanceID);
                generator.setParameter(NodeDataConstants.NODE_ID, name);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            case GRAM_DATA:
                generator = new QueryGenerator(GRAM_DATA);
                generator.setParameter(GramDataConstants.WORKFLOW_INSTANCE_ID, workflowInstanceID);
                generator.setParameter(GramDataConstants.NODE_ID, name);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
            default:
                logger.error("Unsupported resource type for workflow data resource.", new IllegalArgumentException());
                break;
View Full Code Here

    }

    public Resource get(ResourceType type, Object name) {
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator generator;
        Query q;
        switch (type) {
            case NODE_DATA:
                generator = new QueryGenerator(NODE_DATA);
                generator.setParameter(NodeDataConstants.WORKFLOW_INSTANCE_ID, workflowInstanceID);
                generator.setParameter(NodeDataConstants.NODE_ID, name);
                q = generator.selectQuery(em);
                Node_Data enodeDeata = (Node_Data)q.getSingleResult();
                NodeDataResource nodeDataResource = (NodeDataResource)Utils.getResource(ResourceType.NODE_DATA, enodeDeata);
                em.getTransaction().commit();
                em.close();
                return nodeDataResource;
            case GRAM_DATA:
                generator = new QueryGenerator(GRAM_DATA);
                generator.setParameter(GramDataConstants.WORKFLOW_INSTANCE_ID, workflowInstanceID);
                generator.setParameter(GramDataConstants.NODE_ID, name);
                q = generator.selectQuery(em);
                Gram_Data egramData = (Gram_Data)q.getSingleResult();
                GramDataResource gramDataResource = (GramDataResource)Utils.getResource(ResourceType.GRAM_DATA, egramData);
                em.getTransaction().commit();
                em.close();
                return gramDataResource;
View Full Code Here

    public List<Resource> get(ResourceType type) {
        List<Resource> resourceList = new ArrayList<Resource>();
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        QueryGenerator generator;
        List<?> results;
        switch (type){
            case NODE_DATA:
                generator = new QueryGenerator(NODE_DATA);
                generator.setParameter(NodeDataConstants.WORKFLOW_INSTANCE_ID, workflowInstanceID);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Node_Data nodeData = (Node_Data)result;
                        NodeDataResource nodeDataResource = (NodeDataResource)Utils.getResource(ResourceType.NODE_DATA,nodeData);
                        resourceList.add(nodeDataResource);

                    }
                }
                break;
            case GRAM_DATA:
                generator = new QueryGenerator(GRAM_DATA);
                generator.setParameter(GramDataConstants.WORKFLOW_INSTANCE_ID, workflowInstanceID);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        Gram_Data gramData = (Gram_Data)result;
                        GramDataResource gramDataResource = (GramDataResource)Utils.getResource(ResourceType.GRAM_DATA, gramData);
View Full Code Here

     */
    public void remove(ResourceType type, Object name) {
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        QueryGenerator generator;
        switch (type){
            case EXPERIMENT_DATA:
                generator = new QueryGenerator(EXPERIMENT_DATA);
                generator.setParameter(ExperimentDataConstants.EXPERIMENT_ID, name);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
        }
        em.getTransaction().commit();
        em.close();
View Full Code Here

     * @return UnsupportedOperationException
     */
    public Resource get(ResourceType type, Object name) {
      EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator generator;
        Query q;
        switch (type) {
            case EXPERIMENT_DATA:
                generator = new QueryGenerator(EXPERIMENT_DATA);
                generator.setParameter(ExperimentDataConstants.EXPERIMENT_ID, name);
                q = generator.selectQuery(em);
                Experiment_Data experimentData = (Experiment_Data)q.getSingleResult();
                ExperimentDataResource experimentDataResource = (ExperimentDataResource)Utils.getResource(ResourceType.EXPERIMENT_DATA, experimentData);
                em.getTransaction().commit();
                em.close();
                return experimentDataResource;
View Full Code Here

     */
    public List<Resource> populate(Object[] keys) {
        List<Resource> list = new ArrayList<Resource>();
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator queryGenerator = new QueryGenerator(EXPERIMENT);
        queryGenerator.setParameter(ExperimentConstants.EXPERIMENT_ID, keys[0]);
        Query q = queryGenerator.selectQuery(em);
        Experiment experiment = (Experiment)q.getSingleResult();
        ExperimentResource experimentResource =
                (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
        em.getTransaction().commit();
        em.close();
View Full Code Here

TOP

Related Classes of org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.