use of org.apache.airavata.registry.core.app.catalog.model.GSISSHSubmission in project airavata by apache.
the class GSISSHSubmissionResource method get.
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> gsiSSHSubmissionResourceList = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
List results;
if (fieldName.equals(GSISSHSubmissionConstants.MONITOR_MODE)) {
generator.setParameter(GSISSHSubmissionConstants.MONITOR_MODE, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
GSISSHSubmissionResource gsisshSubmissionResource = (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
}
}
} else if (fieldName.equals(GSISSHSubmissionConstants.INSTALLED_PATH)) {
generator.setParameter(GSISSHSubmissionConstants.INSTALLED_PATH, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
GSISSHSubmissionResource gsisshSubmissionResource = (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
}
}
} else if (fieldName.equals(GSISSHSubmissionConstants.SSH_PORT)) {
generator.setParameter(GSISSHSubmissionConstants.SSH_PORT, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
GSISSHSubmissionResource gsisshSubmissionResource = (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
}
}
} else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
generator.setParameter(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
GSISSHSubmissionResource gsisshSubmissionResource = (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for GSISSH submission resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Submission 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 gsiSSHSubmissionResourceList;
}
Aggregations