use of org.apache.airavata.registry.core.app.catalog.model.UnicoreJobSubmission in project airavata by apache.
the class UnicoreJobSubmissionResource method get.
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> unicoreSubmissionResourceList = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
List results;
if (fieldName.equals(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL)) {
generator.setParameter(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) result;
UnicoreJobSubmissionResource unicoreJobSubmissionResource = (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
}
}
} else if (fieldName.equals(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL)) {
generator.setParameter(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) result;
UnicoreJobSubmissionResource unicoreJobSubmissionResource = (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for Unicore submission resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Unicore 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 unicoreSubmissionResourceList;
}
use of org.apache.airavata.registry.core.app.catalog.model.UnicoreJobSubmission in project airavata by apache.
the class UnicoreJobSubmissionResource method isExists.
public boolean isExists(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
UnicoreJobSubmission unicoreJobSubmission = em.find(UnicoreJobSubmission.class, identifier);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return unicoreJobSubmission != 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();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.UnicoreJobSubmission in project airavata by apache.
the class UnicoreJobSubmissionResource method save.
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
UnicoreJobSubmission existingUnicoreSubmission = em.find(UnicoreJobSubmission.class, jobSubmissionInterfaceId);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingUnicoreSubmission != null) {
existingUnicoreSubmission.setSubmissionID(jobSubmissionInterfaceId);
;
existingUnicoreSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
existingUnicoreSubmission.setSecurityProtocol(securityProtocol);
em.merge(existingUnicoreSubmission);
} else {
UnicoreJobSubmission unicoreJobSubmission = new UnicoreJobSubmission();
unicoreJobSubmission.setSubmissionID(jobSubmissionInterfaceId);
unicoreJobSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
unicoreJobSubmission.setSecurityProtocol(securityProtocol);
em.persist(unicoreJobSubmission);
}
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.UnicoreJobSubmission in project airavata by apache.
the class UnicoreJobSubmissionResource method get.
public AppCatalogResource get(Object identifier) throws AppCatalogException {
HashMap<String, String> ids;
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
generator.setParameter(UnicoreJobSubmissionConstants.SUBMISSION_ID, identifier);
Query q = generator.selectQuery(em);
UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) q.getSingleResult();
UnicoreJobSubmissionResource unicoreSubmissionResource = (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return unicoreSubmissionResource;
} 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