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

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


    public List<Resource> get(ResourceType type) {
        List<Resource> resourceList = new ArrayList<Resource>();
        if (type == ResourceType.APPLICATION_DESCRIPTOR) {
            EntityManager em = ResourceUtils.getEntityManager();
            em.getTransaction().begin();
            QueryGenerator queryGenerator = new QueryGenerator(APPLICATION_DESCRIPTOR);
            queryGenerator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
            queryGenerator.setParameter(ApplicationDescriptorConstants.SERVICE_DESC_ID, serviceDescName);
            Query q = queryGenerator.selectQuery(em);
            List 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);
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(CONFIGURATION);
        queryGenerator.setParameter(ConfigurationConstants.CONFIG_KEY, keys[0]);
        Query q = queryGenerator.selectQuery(em);
        List resultList = q.getResultList();
        if (resultList.size() != 0) {
            for (Object result : resultList) {
                Configuration configuration = (Configuration) result;
                ConfigurationResource configurationResource =
View Full Code Here

     */
    public void remove(ResourceType type, Object name) {
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        if (type == ResourceType.EXPERIMENT) {
          QueryGenerator generator = new QueryGenerator(EXPERIMENT);
          generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
          Query q = generator.deleteQuery(em);
          q.executeUpdate();
        }else {
            logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
            throw new IllegalArgumentException("Unsupported resource type for project resource.");
        }
View Full Code Here

     */
    public Resource get(ResourceType type, Object name) {
        if (type == ResourceType.EXPERIMENT) {
            EntityManager em = ResourceUtils.getEntityManager();
            em.getTransaction().begin();
          QueryGenerator generator = new QueryGenerator(EXPERIMENT);
          generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
          Query q = generator.selectQuery(em);
            Experiment experiment = (Experiment) q.getSingleResult();
            ExperimentResource experimentResource = (ExperimentResource)
                    Utils.getResource(ResourceType.EXPERIMENT, experiment);
            em.getTransaction().commit();
            em.close();
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(PROJECT);
        queryGenerator.setParameter(ProjectConstants.PROJECT_NAME, keys[0]);
        Query q = queryGenerator.selectQuery(em);
        List<?> resultList = q.getResultList();
        if (resultList.size() != 0) {
            for (Object result : resultList) {
                Project project = (Project) result;
                ProjectResource projectResource = (ProjectResource)
View Full Code Here

        List<Resource> resourceList = new ArrayList<Resource>();

        if (type == ResourceType.EXPERIMENT) {
            EntityManager em = ResourceUtils.getEntityManager();
            em.getTransaction().begin();
          QueryGenerator generator = new QueryGenerator(EXPERIMENT);
          generator.setParameter(ExperimentConstants.PROJECT_NAME, name);
          Query q = generator.selectQuery(em);
            List<?> results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    Experiment experiment = (Experiment) result;
                    ExperimentResource experimentResource = (ExperimentResource)
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(USER_WORKFLOW);
        queryGenerator.setParameter(UserWorkflowConstants.GATEWAY_NAME, keys[0]);
        queryGenerator.setParameter(UserWorkflowConstants.OWNER, keys[1]);
        queryGenerator.setParameter(UserWorkflowConstants.TEMPLATE_NAME, keys[2]);
        Query q = queryGenerator.selectQuery(em);
        User_Workflow userWorkflow = (User_Workflow)q.getSingleResult();
        UserWorkflowResource userWorkflowResource = (UserWorkflowResource)Utils.getResource(
                ResourceType.USER_WORKFLOW, userWorkflow);
        em.getTransaction().commit();
        em.close();
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 PROJECT:
                generator = new QueryGenerator(PROJECT);
                generator.setParameter(ProjectConstants.PROJECT_NAME, name);
                q = generator.deleteQuery(em);
              q.executeUpdate();
        break;
      case USER_WORKFLOW:
                generator = new QueryGenerator(USER_WORKFLOW);
                generator.setParameter(UserWorkflowConstants.OWNER, getUser());
                generator.setParameter(UserWorkflowConstants.TEMPLATE_NAME, name);
                generator.setParameter(UserWorkflowConstants.GATEWAY_NAME, gateway.getGatewayName());
                q = generator.deleteQuery(em);
              q.executeUpdate();
              break;
      case EXPERIMENT:
                generator = new QueryGenerator(EXPERIMENT);
                generator.setParameter(ExperimentConstants.USERNAME, getUser());
                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
                q = generator.deleteQuery(em);
              q.executeUpdate();
              break;
            case WORKFLOW_DATA:
                generator = new QueryGenerator(WORKFLOW_DATA);
                generator.setParameter(WorkflowDataConstants.WORKFLOW_INSTANCE_ID, name);
                q = generator.deleteQuery(em);
                q.executeUpdate();
                break;
      default:
                logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
                break;
View Full Code Here

     */
  public Resource get(ResourceType type, Object name) {
    Resource result = null;
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator generator;
        Query q;
    switch (type) {
      case PROJECT:
                generator = new QueryGenerator(PROJECT);
                generator.setParameter(ProjectConstants.PROJECT_NAME, name);
                q = generator.selectQuery(em);
              Project project = (Project) q.getSingleResult();
                result= Utils.getResource(ResourceType.PROJECT, project);
        break;
      case USER_WORKFLOW:
                generator = new QueryGenerator(USER_WORKFLOW);
                generator.setParameter(UserWorkflowConstants.OWNER, getUser());
                generator.setParameter(UserWorkflowConstants.TEMPLATE_NAME, name);
                generator.setParameter(UserWorkflowConstants.GATEWAY_NAME, gateway.getGatewayName());
                q = generator.selectQuery(em);
              User_Workflow userWorkflow = (User_Workflow) q.getSingleResult();
                result= Utils.getResource(ResourceType.USER_WORKFLOW, userWorkflow);
              break;
      case EXPERIMENT:
                generator = new QueryGenerator(EXPERIMENT);
                generator.setParameter(ExperimentConstants.USERNAME, getUser());
                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
                q = generator.selectQuery(em);
              Experiment experiment = (Experiment) q.getSingleResult();
                result= Utils.getResource(ResourceType.EXPERIMENT, experiment);
        break;
      case WORKFLOW_DATA:
                generator = new QueryGenerator(WORKFLOW_DATA);
                generator.setParameter(WorkflowDataConstants.WORKFLOW_INSTANCE_ID, name);
                q = generator.selectQuery(em);
                Workflow_Data eworkflowData = (Workflow_Data)q.getSingleResult();
                WorkflowDataResource workflowDataResource = (WorkflowDataResource)Utils.getResource(ResourceType.WORKFLOW_DATA, eworkflowData);
                result= workflowDataResource;
                break;
      default:
View Full Code Here

     */
    public List<Resource> get(ResourceType type) {
    List<Resource> result = new ArrayList<Resource>();
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator generator;
        Query q;
    switch (type) {
      case PROJECT:
                generator = new QueryGenerator(PROJECT);
                Users users = em.find(Users.class, getUser());
                Gateway gatewayModel = em.find(Gateway.class, gateway.getGatewayName());
                generator.setParameter("users", users);
                generator.setParameter("gateway", gatewayModel);
//                generator.setParameter(ProjectConstants.USERNAME, getUser());
//                generator.setParameter(ProjectConstants.GATEWAY_NAME, gateway.getGatewayName());
                q = generator.selectQuery(em);
              for (Object o : q.getResultList()) {
                Project project = (Project) o;
                ProjectResource projectResource = (ProjectResource)Utils.getResource(ResourceType.PROJECT, project);
                result.add(projectResource);
        }
        break;
      case USER_WORKFLOW:
                generator = new QueryGenerator(USER_WORKFLOW);
                generator.setParameter(UserWorkflowConstants.OWNER, getUser());
                q = generator.selectQuery(em);
//              q.setParameter("usr_name", getUser());
              for (Object o : q.getResultList()) {
                User_Workflow userWorkflow = (User_Workflow) o;
                UserWorkflowResource userWorkflowResource = (UserWorkflowResource)Utils.getResource(ResourceType.USER_WORKFLOW, userWorkflow);
                result.add(userWorkflowResource);
              }
              break;
      case EXPERIMENT:
                generator = new QueryGenerator(EXPERIMENT);
                generator.setParameter(ExperimentConstants.USERNAME, getUser());
                generator.setParameter(ExperimentConstants.GATEWAY_NAME, gateway.getGatewayName());
                q = generator.selectQuery(em);
              for (Object o : q.getResultList()) {
                Experiment experiment = (Experiment) o;
                ExperimentResource experimentResource = (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
                result.add(experimentResource);
              }
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.