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 PROJECT:
generator = new QueryGenerator(PROJECT);
Gateway gatewayModel = em.find(Gateway.class, gatewayName);
generator.setParameter("gateway", gatewayModel);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
Project project = (Project) result;
ProjectResource projectResource =
(ProjectResource)Utils.getResource(ResourceType.PROJECT, project);
resourceList.add(projectResource);
}
}
break;
case GATEWAY_WORKER:
generator = new QueryGenerator(GATEWAY_WORKER);
generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
Gateway_Worker gatewayWorker = (Gateway_Worker) result;
WorkerResource workerResource =
(WorkerResource)Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
resourceList.add(workerResource);
}
}
break;
case PUBLISHED_WORKFLOW :
generator = new QueryGenerator(PUBLISHED_WORKFLOW);
generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
Published_Workflow publishedWorkflow = (Published_Workflow) result;
PublishWorkflowResource publishWorkflowResource =
(PublishWorkflowResource)Utils.getResource(ResourceType.PUBLISHED_WORKFLOW, publishedWorkflow);
resourceList.add(publishWorkflowResource);
}
}
break;
case HOST_DESCRIPTOR:
generator = new QueryGenerator(HOST_DESCRIPTOR);
generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
Host_Descriptor hostDescriptor = (Host_Descriptor) result;
HostDescriptorResource hostDescriptorResource =
(HostDescriptorResource)Utils.getResource(ResourceType.HOST_DESCRIPTOR, hostDescriptor);
resourceList.add(hostDescriptorResource);
}
}
break;
case SERVICE_DESCRIPTOR:
generator = new QueryGenerator(SERVICE_DESCRIPTOR);
generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
Service_Descriptor serviceDescriptor = (Service_Descriptor) result;
ServiceDescriptorResource serviceDescriptorResource =
(ServiceDescriptorResource)Utils.getResource(ResourceType.SERVICE_DESCRIPTOR, serviceDescriptor);
resourceList.add(serviceDescriptorResource);
}
}
break;
case APPLICATION_DESCRIPTOR:
generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
q = generator.selectQuery(em);
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);
resourceList.add(applicationDescriptorResource);
}
}
break;
case EXPERIMENT:
generator = new QueryGenerator(EXPERIMENT);
generator.setParameter(ExperimentConstants.GATEWAY_NAME, gatewayName);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
Experiment experiment = (Experiment) result;
ExperimentResource experimentResource =