@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
JobManagerCommand existingJobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(resourceJobManagerId, commandType));
em.close();
JobManagerCommand jobManagerCommand;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingJobManagerCommand == null) {
jobManagerCommand = new JobManagerCommand();
} else {
jobManagerCommand = existingJobManagerCommand;
}
jobManagerCommand.setResourceJobManagerId(getResourceJobManagerId());
ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
jobManagerCommand.setResourceJobManager(resourceJobManager);
jobManagerCommand.setCommandType(getCommandType());
jobManagerCommand.setCommand(getCommand());
if (existingJobManagerCommand == null) {
em.persist(jobManagerCommand);
} else {
em.merge(jobManagerCommand);
}