@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
SshJobSubmission existingSshJobSubmission = em.find(SshJobSubmission.class, jobSubmissionInterfaceId);
em.close();
SshJobSubmission sshJobSubmission;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingSshJobSubmission == null) {
sshJobSubmission = new SshJobSubmission();
} else {
sshJobSubmission = existingSshJobSubmission;
}
sshJobSubmission.setResourceJobManagerId(getResourceJobManagerId());
ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
sshJobSubmission.setResourceJobManager(resourceJobManager);
sshJobSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
sshJobSubmission.setAlternativeSshHostname(getAlternativeSshHostname());
sshJobSubmission.setSecurityProtocol(getSecurityProtocol());
sshJobSubmission.setSshPort(getSshPort());
if (existingSshJobSubmission == null) {
em.persist(sshJobSubmission);
} else {
em.merge(sshJobSubmission);
}