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; case GFAC_JOB_DATA: generator = new QueryGenerator(GFAC_JOB_DATA); generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name); q = generator.deleteQuery(em); q.executeUpdate(); break; default: break; } em.getTransaction().commit(); em.close(); }
public Resource get(ResourceType type, Object name) { EntityManager em = ResourceUtils.getEntityManager(); em.getTransaction().begin(); QueryGenerator generator; Query q; 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.selectQuery(em); Workflow_Data eworkflowData = (Workflow_Data) q.getSingleResult(); WorkflowDataResource workflowDataResource = (WorkflowDataResource) Utils.getResource(ResourceType.WORKFLOW_DATA, eworkflowData); em.getTransaction().commit(); em.close(); return workflowDataResource; case EXPERIMENT_METADATA: generator = new QueryGenerator(EXPERIMENT_METADATA); generator.setParameter(ExperimentDataConstants.EXPERIMENT_ID, name); q = generator.selectQuery(em); Experiment_Metadata expMetadata = (Experiment_Metadata) q.getSingleResult(); ExperimentMetadataResource experimentMetadataResource = (ExperimentMetadataResource) Utils.getResource(ResourceType.EXPERIMENT_METADATA, expMetadata); em.getTransaction().commit(); em.close(); return experimentMetadataResource; case GFAC_JOB_DATA: generator = new QueryGenerator(GFAC_JOB_DATA); generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name); q = generator.selectQuery(em); GFac_Job_Data gFacJobData = (GFac_Job_Data) q.getSingleResult(); GFacJobDataResource gFacJobDataResource = (GFacJobDataResource) Utils.getResource(ResourceType.GFAC_JOB_DATA, gFacJobData); em.getTransaction().commit(); em.close(); return gFacJobDataResource; default: em.getTransaction().commit(); em.close(); logger.error( "Unsupported resource type for experiment data resource... ", new UnsupportedOperationException()); throw new IllegalArgumentException( "Unsupported resource type for experiment data resource."); } }
public List<ExecutionErrorResource> getExecutionErrors( String type, String experimentId, String workflowInstanceId, String nodeId, String gfacJobId) { List<ExecutionErrorResource> resourceList = new ArrayList<ExecutionErrorResource>(); EntityManager em = ResourceUtils.getEntityManager(); em.getTransaction().begin(); Query q; QueryGenerator generator; List<?> results; generator = new QueryGenerator(EXECUTION_ERROR); if (experimentId != null) { generator.setParameter(ExecutionErrorConstants.EXPERIMENT_ID, experimentId); } if (type != null) { generator.setParameter(ExecutionErrorConstants.SOURCE_TYPE, type); } if (workflowInstanceId != null) { generator.setParameter(ExecutionErrorConstants.WORKFLOW_ID, workflowInstanceId); } if (nodeId != null) { generator.setParameter(ExecutionErrorConstants.NODE_ID, nodeId); } if (gfacJobId != null) { generator.setParameter(ExecutionErrorConstants.GFAC_JOB_ID, gfacJobId); } q = generator.selectQuery(em); results = q.getResultList(); if (results.size() != 0) { for (Object result : results) { Execution_Error executionError = (Execution_Error) result; ExecutionErrorResource executionErrorResource = (ExecutionErrorResource) Utils.getResource(ResourceType.EXECUTION_ERROR, executionError); resourceList.add(executionErrorResource); } } em.getTransaction().commit(); em.close(); return resourceList; }
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 WORKFLOW_DATA: generator = new QueryGenerator(WORKFLOW_DATA); // generator.setParameter(WorkflowDataConstants.EXPERIMENT_ID, experimentID); Experiment_Data experiment_data = em.find(Experiment_Data.class, experimentID); generator.setParameter("experiment_data", experiment_data); q = generator.selectQuery(em); results = q.getResultList(); if (results.size() != 0) { for (Object result : results) { Workflow_Data workflowData = (Workflow_Data) result; WorkflowDataResource workflowDataResource = (WorkflowDataResource) Utils.getResource(ResourceType.WORKFLOW_DATA, workflowData); resourceList.add(workflowDataResource); } } break; case EXPERIMENT_METADATA: generator = new QueryGenerator(EXPERIMENT_METADATA); generator.setParameter(ExperimentDataConstants.EXPERIMENT_ID, experimentID); q = generator.selectQuery(em); results = q.getResultList(); if (results.size() != 0) { for (Object result : results) { Experiment_Metadata expMetadata = (Experiment_Metadata) result; ExperimentMetadataResource experimentMetadataResource = (ExperimentMetadataResource) Utils.getResource(ResourceType.EXPERIMENT_METADATA, expMetadata); resourceList.add(experimentMetadataResource); } } break; case EXECUTION_ERROR: generator = new QueryGenerator(EXECUTION_ERROR); generator.setParameter(ExecutionErrorConstants.EXPERIMENT_ID, experimentID); q = generator.selectQuery(em); results = q.getResultList(); if (results.size() != 0) { for (Object result : results) { Execution_Error executionError = (Execution_Error) result; ExecutionErrorResource executionErrorResource = (ExecutionErrorResource) Utils.getResource(ResourceType.EXECUTION_ERROR, executionError); resourceList.add(executionErrorResource); } } break; case GFAC_JOB_DATA: generator = new QueryGenerator(GFAC_JOB_DATA); generator.setParameter(GFacJobDataConstants.EXPERIMENT_ID, experimentID); q = generator.selectQuery(em); results = q.getResultList(); if (results.size() != 0) { for (Object result : results) { GFac_Job_Data gFacJobData = (GFac_Job_Data) result; GFacJobDataResource gFacJobDataResource = (GFacJobDataResource) Utils.getResource(ResourceType.GFAC_JOB_DATA, gFacJobData); resourceList.add(gFacJobDataResource); } } break; default: em.getTransaction().commit(); em.close(); logger.error( "Unsupported resource type for experiment data resource... ", new UnsupportedOperationException()); throw new IllegalArgumentException( "Unsupported resource type for experiment data resource."); } em.getTransaction().commit(); em.close(); return resourceList; }