@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
LocalSubmission existingLocalSubmission = em.find(LocalSubmission.class, jobSubmissionInterfaceId);
em.close();
LocalSubmission localSubmission;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingLocalSubmission == null) {
localSubmission = new LocalSubmission();
} else {
localSubmission = existingLocalSubmission;
}
localSubmission.setResourceJobManagerId(getResourceJobManagerId());
ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
localSubmission.setResourceJobManager(resourceJobManager);
localSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
if (existingLocalSubmission == null) {
em.persist(localSubmission);
} else {
em.merge(localSubmission);
}