use of org.apache.airavata.registry.core.app.catalog.model.GSISSHExportPK in project airavata by apache.
the class GSISSHExportResource method save.
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
GSISSHExport existingGSIExport = em.find(GSISSHExport.class, new GSISSHExportPK(submissionID, export));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
GSISSHSubmission gsisshSubmission = em.find(GSISSHSubmission.class, submissionID);
if (existingGSIExport != null) {
existingGSIExport.setSubmissionID(submissionID);
existingGSIExport.setExport(export);
existingGSIExport.setGsisshJobSubmission(gsisshSubmission);
em.merge(existingGSIExport);
} else {
GSISSHExport gsisshExport = new GSISSHExport();
gsisshExport.setSubmissionID(submissionID);
gsisshExport.setExport(export);
gsisshExport.setGsisshJobSubmission(gsisshSubmission);
em.persist(gsisshExport);
}
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.GSISSHExportPK in project airavata by apache.
the class GSISSHExportResource method isExists.
public boolean isExists(Object identifier) throws AppCatalogException {
HashMap<String, String> ids;
if (identifier instanceof Map) {
ids = (HashMap) identifier;
} else {
logger.error("Identifier should be a map with the field name and it's value");
throw new AppCatalogException("Identifier should be a map with the field name and it's value");
}
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
GSISSHExport gsisshExport = em.find(GSISSHExport.class, new GSISSHExportPK(ids.get(GSISSHExportConstants.SUBMISSION_ID), ids.get(GSISSHExportConstants.EXPORT)));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return gsisshExport != 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();
}
}
}
Aggregations