use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator 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.util.AppCatalogQueryGenerator 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.util.AppCatalogQueryGenerator in project airavata by apache.
the class GatewayProfileResource method getIds.
public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
List<String> gatewayProfileResourceIDs = new ArrayList<String>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
List results;
if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GatewayProfile gatewayProfile = (GatewayProfile) result;
gatewayProfileResourceIDs.add(gatewayProfile.getGatewayID());
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for Gateway Profile resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gateway 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 gatewayProfileResourceIDs;
}
use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class GatewayProfileResource method remove.
public void remove(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
generator.setParameter(GatewayProfileConstants.GATEWAY_ID, identifier);
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 GatewayProfileResource method getAll.
@Override
public List<AppCatalogResource> getAll() throws AppCatalogException {
List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
Query q = generator.selectQuery(em);
List results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GatewayProfile gatewayProfile = (GatewayProfile) result;
GatewayProfileResource gatewayProfileResource = (GatewayProfileResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
resourceList.add(gatewayProfileResource);
}
}
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 resourceList;
}
Aggregations