use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class UnicoreDataMovementResource method get.
public AppCatalogResource get(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
generator.setParameter(UnicoreDataMovementConstants.DATAMOVEMENT_ID, identifier);
Query q = generator.selectQuery(em);
UnicoreDataMovement unicoreDataMovement = (UnicoreDataMovement) q.getSingleResult();
UnicoreDataMovementResource dataMovementResource = (UnicoreDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_DATA_MOVEMENT, unicoreDataMovement);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return dataMovementResource;
} 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 UnicoreJobSubmissionResource 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;
}
use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator 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.util.AppCatalogQueryGenerator in project airavata by apache.
the class UserComputeHostPreferenceResource method remove.
@Override
public void remove(Object identifier) throws AppCatalogException {
CompositeIdentifier ids;
if (identifier instanceof CompositeIdentifier) {
ids = (CompositeIdentifier) identifier;
} else {
logger.error("Identifier should be a instance of CompositeIdentifier class");
throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_COMPUTE_RESOURCE_PREFERENCE);
generator.setParameter(UserComputeResourcePreferenceConstants.RESOURCE_ID, ids.getTopLevelIdentifier().toString());
generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, ids.getSecondLevelIdentifier().toString());
generator.setParameter(UserComputeResourcePreferenceConstants.GATEWAY_ID, ids.getThirdLevelIdentifier().toString());
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} 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 UserResourceProfileResource method get.
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> userResourceProfileResources = new ArrayList<AppCatalogResource>();
EntityManager em = null;
CompositeIdentifier ids;
if (value instanceof CompositeIdentifier) {
ids = (CompositeIdentifier) value;
} else {
logger.error("Identifier should be a instance of CompositeIdentifier class");
throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
List results;
if (fieldName.equals(UserResourceProfileConstants.USER_ID)) {
generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.getTopLevelIdentifier().toString());
generator.setParameter(UserStoragePreferenceConstants.GATEWAY_ID, ids.getSecondLevelIdentifier().toString());
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
UserResourceProfile userResourceProfile = (UserResourceProfile) result;
UserResourceProfileResource userResourceProfileResource = (UserResourceProfileResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.USER_RESOURCE_PROFILE, userResourceProfile);
userResourceProfileResources.add(userResourceProfileResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for User Resource Profile resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for User Resource Profile 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 userResourceProfileResources;
}
Aggregations