use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.
the class ModuleLoadCmdResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
ModuleLoadCmd existingModuleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(cmd, appDeploymentId));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
ModuleLoadCmd moduleLoadCmd;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingModuleLoadCmd == null) {
moduleLoadCmd = new ModuleLoadCmd();
} else {
moduleLoadCmd = existingModuleLoadCmd;
}
moduleLoadCmd.setCmd(getCmd());
moduleLoadCmd.setAppDeploymentId(getAppDeploymentId());
moduleLoadCmd.setOrder(order);
ApplicationDeployment applicationDeployment = em.find(ApplicationDeployment.class, getAppDeploymentId());
moduleLoadCmd.setApplicationDeployment(applicationDeployment);
if (existingModuleLoadCmd == null) {
em.persist(moduleLoadCmd);
} else {
em.merge(moduleLoadCmd);
}
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.ApplicationDeployment in project airavata by apache.
the class PostJobCommandResource method save.
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
PostJobCommand existingPostJobCommand = em.find(PostJobCommand.class, new PostJobCommandPK(appDeploymentId, command));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
if (existingPostJobCommand != null) {
existingPostJobCommand.setDeploymentId(appDeploymentId);
existingPostJobCommand.setCommand(command);
existingPostJobCommand.setOrder(order);
existingPostJobCommand.setDeployment(deployment);
em.merge(existingPostJobCommand);
} else {
PostJobCommand postJobCommand = new PostJobCommand();
postJobCommand.setDeploymentId(appDeploymentId);
postJobCommand.setCommand(command);
postJobCommand.setOrder(order);
postJobCommand.setDeployment(deployment);
em.persist(postJobCommand);
}
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.ApplicationDeployment in project airavata by apache.
the class PreJobCommandResource method save.
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
PreJobCommand existingPreJobCommand = em.find(PreJobCommand.class, new PreJobCommandPK(appDeploymentId, command));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
if (existingPreJobCommand != null) {
existingPreJobCommand.setDeploymentId(appDeploymentId);
existingPreJobCommand.setCommand(command);
existingPreJobCommand.setApplicationDeployment(deployment);
existingPreJobCommand.setOrder(order);
em.merge(existingPreJobCommand);
} else {
PreJobCommand preJobCommand = new PreJobCommand();
preJobCommand.setDeploymentId(appDeploymentId);
preJobCommand.setCommand(command);
preJobCommand.setOrder(order);
preJobCommand.setApplicationDeployment(deployment);
em.persist(preJobCommand);
}
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