use of org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager in project airavata by apache.
the class ResourceJobManagerResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
ResourceJobManager existingResourceJobManager = em.find(ResourceJobManager.class, resourceJobManagerId);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
ResourceJobManager resourceJobManager;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingResourceJobManager == null) {
resourceJobManager = new ResourceJobManager();
resourceJobManager.setCreationTime(AiravataUtils.getCurrentTimestamp());
} else {
resourceJobManager = existingResourceJobManager;
resourceJobManager.setUpdateTime(AiravataUtils.getCurrentTimestamp());
}
resourceJobManager.setResourceJobManagerId(getResourceJobManagerId());
resourceJobManager.setPushMonitoringEndpoint(getPushMonitoringEndpoint());
resourceJobManager.setJobManagerBinPath(getJobManagerBinPath());
resourceJobManager.setResourceJobManagerType(getResourceJobManagerType());
if (existingResourceJobManager == null) {
em.persist(resourceJobManager);
} else {
em.merge(resourceJobManager);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager in project airavata by apache.
the class ResourceJobManagerResource method isExists.
@Override
public boolean isExists(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, identifier);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return resourceJobManager != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager in project airavata by apache.
the class SshJobSubmissionResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
SshJobSubmission existingSshJobSubmission = em.find(SshJobSubmission.class, jobSubmissionInterfaceId);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
SshJobSubmission sshJobSubmission;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingSshJobSubmission == null) {
sshJobSubmission = new SshJobSubmission();
sshJobSubmission.setCreationTime(AiravataUtils.getCurrentTimestamp());
} else {
sshJobSubmission = existingSshJobSubmission;
sshJobSubmission.setUpdateTime(AiravataUtils.getCurrentTimestamp());
}
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());
sshJobSubmission.setMonitorMode(getMonitorMode());
if (existingSshJobSubmission == null) {
em.persist(sshJobSubmission);
} else {
em.merge(sshJobSubmission);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
Aggregations