@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
BatchQueue existingBatchQueue = em.find(BatchQueue.class, new BatchQueue_PK(computeResourceId, queueName));
em.close();
BatchQueue batchQueue;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingBatchQueue == null) {
batchQueue = new BatchQueue();
} else {
batchQueue = existingBatchQueue;
}
batchQueue.setComputeResourceId(getComputeResourceId());
ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
batchQueue.setComputeResource(computeResource);
batchQueue.setMaxRuntime(getMaxRuntime());
batchQueue.setMaxJobInQueue(getMaxJobInQueue());
batchQueue.setQueueDescription(getQueueDescription());
batchQueue.setQueueName(getQueueName());
batchQueue.setMaxProcessors(getMaxProcessors());
batchQueue.setMaxNodes(getMaxNodes());
if (existingBatchQueue == null) {
em.persist(batchQueue);
} else {
em.merge(batchQueue);
}