use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class GSISSHSubmissionResource method getIds.
public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
List<String> gsiSSHSubmissionResourceIDs = new ArrayList<String>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
List results;
if (fieldName.equals(GSISSHSubmissionConstants.SUBMISSION_ID)) {
generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
}
}
} 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;
gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
}
}
} else 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;
gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
}
}
} 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;
gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
}
}
} 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;
gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
}
}
} 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 gsiSSHSubmissionResourceIDs;
}
use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class GSISSHSubmissionResource method get.
public AppCatalogResource get(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, identifier);
Query q = generator.selectQuery(em);
GSISSHSubmission gsisshSubmission = (GSISSHSubmission) q.getSingleResult();
GSISSHSubmissionResource gsisshSubmissionResource = (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return gsisshSubmissionResource;
} 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.util.AppCatalogQueryGenerator in project airavata by apache.
the class GlobusGKEndpointResource method get.
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> resources = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
List results;
if (fieldName.equals(GlobusEPConstants.ENDPOINT)) {
generator.setParameter(GlobusEPConstants.ENDPOINT, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusGKEndpoint gkEndpoint = (GlobusGKEndpoint) result;
GlobusGKEndpointResource gkEndpointResource = (GlobusGKEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, gkEndpoint);
resources.add(gkEndpointResource);
}
}
} else if (fieldName.equals(GlobusEPConstants.SUBMISSION_ID)) {
generator.setParameter(GlobusEPConstants.SUBMISSION_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusGKEndpoint globusGKEndpoint = (GlobusGKEndpoint) result;
GlobusGKEndpointResource gkEndpointResource = (GlobusGKEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, globusGKEndpoint);
resources.add(gkEndpointResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for Globus Endpoint Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Globus Endpoint 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 resources;
}
use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class GlobusJobSubmissionResource method get.
public AppCatalogResource get(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, identifier);
Query q = generator.selectQuery(em);
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) q.getSingleResult();
GlobusJobSubmissionResource globusJobSubmissionResource = (GlobusJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return globusJobSubmissionResource;
} 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.util.AppCatalogQueryGenerator in project airavata by apache.
the class GlobusJobSubmissionResource method getIds.
public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
List<String> globusSubmissionResourceIDs = new ArrayList<String>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
List results;
if (fieldName.equals(GlobusJobSubmissionConstants.SUBMISSION_ID)) {
generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
}
}
} else if (fieldName.equals(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP)) {
generator.setParameter(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
}
}
} else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
}
}
} else if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for Globus Submission resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Globus 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 globusSubmissionResourceIDs;
}
Aggregations