use of org.apache.airavata.registry.core.app.catalog.model.GSISSHExport 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.GSISSHExport in project airavata by apache.
the class GSISSHExportResource method get.
public AppCatalogResource get(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();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, ids.get(GSISSHExportConstants.SUBMISSION_ID));
generator.setParameter(GSISSHExportConstants.EXPORT, ids.get(GSISSHExportConstants.EXPORT));
Query q = generator.selectQuery(em);
GSISSHExport gsisshExport = (GSISSHExport) q.getSingleResult();
GSISSHExportResource gsisshExportResource = (GSISSHExportResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT, gsisshExport);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return gsisshExportResource;
} 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.GSISSHExport in project airavata by apache.
the class GSISSHExportResource method get.
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> gsiSSHExportResources = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
List results;
if (fieldName.equals(GSISSHExportConstants.EXPORT)) {
generator.setParameter(GSISSHExportConstants.EXPORT, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHExport gsisshExport = (GSISSHExport) result;
GSISSHExportResource gsisshExportResource = (GSISSHExportResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT, gsisshExport);
gsiSSHExportResources.add(gsisshExportResource);
}
}
} else if (fieldName.equals(GSISSHExportConstants.SUBMISSION_ID)) {
generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHExport gsisshExport = (GSISSHExport) result;
GSISSHExportResource gsisshExportResource = (GSISSHExportResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT, gsisshExport);
gsiSSHExportResources.add(gsisshExportResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for GSISSH Export Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Export Resource.");
}
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();
}
}
return gsiSSHExportResources;
}
use of org.apache.airavata.registry.core.app.catalog.model.GSISSHExport in project airavata by apache.
the class GSISSHExportResource method getIds.
public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
List<String> gsiSSHExportIDs = new ArrayList<String>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
List results;
if (fieldName.equals(GSISSHExportConstants.SUBMISSION_ID)) {
generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHExport gsisshExport = (GSISSHExport) result;
gsiSSHExportIDs.add(gsisshExport.getSubmissionID());
}
}
} else if (fieldName.equals(GSISSHExportConstants.EXPORT)) {
generator.setParameter(GSISSHExportConstants.EXPORT, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHExport gsisshExport = (GSISSHExport) result;
gsiSSHExportIDs.add(gsisshExport.getSubmissionID());
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for GSISSH Export resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Export Resource.");
}
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();
}
}
return gsiSSHExportIDs;
}
use of org.apache.airavata.registry.core.app.catalog.model.GSISSHExport 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