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 TASK_DETAIL:
generator = new QueryGenerator(TASK_DETAIL);
generator.setParameter(TaskDetailConstants.TASK_ID, name);
q = generator.selectQuery(em);
TaskDetail taskDetail = (TaskDetail) q.getSingleResult();
TaskDetailResource taskDetailResource = (TaskDetailResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
em.getTransaction().commit();
em.close();
return taskDetailResource;
case ERROR_DETAIL:
generator = new QueryGenerator(ERROR_DETAIL);
generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_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 NODE_INPUT:
generator = new QueryGenerator(NODE_INPUT);
generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
q = generator.selectQuery(em);
NodeInput nodeInput = (NodeInput) q.getSingleResult();
NodeInputResource nodeInputResource = (NodeInputResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
em.getTransaction().commit();
em.close();
return nodeInputResource;
case NODE_OUTPUT:
generator = new QueryGenerator(NODE_OUTPUT);
generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
q = generator.selectQuery(em);
NodeOutput nodeOutput = (NodeOutput) q.getSingleResult();
NodeOutputResource nodeOutputResource = (NodeOutputResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
em.getTransaction().commit();
em.close();
return nodeOutputResource;
case STATUS:
generator = new QueryGenerator(STATUS);
generator.setParameter(StatusConstants.NODE_INSTANCE_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;