EntityManager em = null;
try {
em = ResourceUtils.getEntityManager();
em.getTransaction().begin();
Query q;
QueryGenerator generator;
List results;
switch (type) {
case ERROR_DETAIL:
generator = new QueryGenerator(ERROR_DETAIL);
generator.setParameter(ErrorDetailConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
ErrorDetail errorDetail = (ErrorDetail) result;
ErrorDetailResource errorDetailResource =
(ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
resourceList.add(errorDetailResource);
}
}
break;
case APPLICATION_INPUT:
generator = new QueryGenerator(APPLICATION_INPUT);
generator.setParameter(ApplicationInputConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
ApplicationInput applicationInput = (ApplicationInput) result;
ApplicationInputResource inputResource =
(ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
resourceList.add(inputResource);
}
}
break;
case APPLICATION_OUTPUT:
generator = new QueryGenerator(APPLICATION_OUTPUT);
generator.setParameter(ApplicationOutputConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
ApplicationOutput applicationOutput = (ApplicationOutput) result;
ApplicationOutputResource outputResource =
(ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
resourceList.add(outputResource);
}
}
break;
case JOB_DETAIL:
generator = new QueryGenerator(JOB_DETAIL);
generator.setParameter(JobDetailConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
JobDetail jobDetail = (JobDetail) result;
JobDetailResource jobDetailResource =
(JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
resourceList.add(jobDetailResource);
}
}
break;
case DATA_TRANSFER_DETAIL:
generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
generator.setParameter(DataTransferDetailConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
DataTransferDetail transferDetail = (DataTransferDetail) result;
DataTransferDetailResource transferDetailResource =
(DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
resourceList.add(transferDetailResource);
}
}
break;
case STATUS:
generator = new QueryGenerator(STATUS);
generator.setParameter(StatusConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
Status status = (Status) result;
StatusResource statusResource =