public Resource get(ResourceType type, Object name) throws RegistryException{
EntityManager em = null;
try {
em = ResourceUtils.getEntityManager();
em.getTransaction().begin();
QueryGenerator generator;
Query q;
switch (type) {
case ERROR_DETAIL:
generator = new QueryGenerator(ERROR_DETAIL);
generator.setParameter(ErrorDetailConstants.TASK_ID, name);
q = generator.selectQuery(em);
ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
em.getTransaction().commit();
em.close();
return errorDetailResource;
case APPLICATION_INPUT:
generator = new QueryGenerator(APPLICATION_INPUT);
generator.setParameter(ApplicationInputConstants.TASK_ID, name);
q = generator.selectQuery(em);
ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
ApplicationInputResource inputResource = (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
em.getTransaction().commit();
em.close();
return inputResource;
case APPLICATION_OUTPUT:
generator = new QueryGenerator(APPLICATION_OUTPUT);
generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
q = generator.selectQuery(em);
ApplicationOutput applicationOutput = (ApplicationOutput) q.getSingleResult();
ApplicationOutputResource outputResource = (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
em.getTransaction().commit();
em.close();
return outputResource;
case JOB_DETAIL:
generator = new QueryGenerator(JOB_DETAIL);
generator.setParameter(JobDetailConstants.JOB_ID, name);
generator.setParameter(JobDetailConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
JobDetail jobDetail = (JobDetail) q.getSingleResult();
JobDetailResource jobDetailResource = (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
em.getTransaction().commit();
em.close();
return jobDetailResource;
case DATA_TRANSFER_DETAIL:
generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
q = generator.selectQuery(em);
DataTransferDetail transferDetail = (DataTransferDetail) q.getSingleResult();
DataTransferDetailResource transferDetailResource = (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
em.getTransaction().commit();
em.close();
return transferDetailResource;
case STATUS:
generator = new QueryGenerator(STATUS);
generator.setParameter(StatusConstants.TASK_ID, name);
q = generator.selectQuery(em);
Status status = (Status) q.getSingleResult();
StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
em.getTransaction().commit();
em.close();
return statusResource;
case COMPUTATIONAL_RESOURCE_SCHEDULING:
generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
q = generator.selectQuery(em);
Computational_Resource_Scheduling resourceScheduling = (Computational_Resource_Scheduling) q.getSingleResult();
ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling);
em.getTransaction().commit();
em.close();
return schedulingResource;
case ADVANCE_INPUT_DATA_HANDLING:
generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
q = generator.selectQuery(em);
AdvancedInputDataHandling dataHandling = (AdvancedInputDataHandling) q.getSingleResult();
AdvanceInputDataHandlingResource inputDataHandlingResource = (AdvanceInputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, dataHandling);
em.getTransaction().commit();
em.close();
return inputDataHandlingResource;
case ADVANCE_OUTPUT_DATA_HANDLING:
generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
q = generator.selectQuery(em);
AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
em.getTransaction().commit();
em.close();
return outputDataHandlingResource;
case QOS_PARAM:
generator = new QueryGenerator(QOS_PARAMS);
generator.setParameter(QosParamsConstants.TASK_ID, name);
q = generator.selectQuery(em);
QosParam qosParam = (QosParam) q.getSingleResult();
QosParamResource qosParamResource = (QosParamResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
em.getTransaction().commit();
em.close();
return qosParamResource;