use of org.apache.airavata.registry.core.app.catalog.model.GatewayProfile in project airavata by apache.
the class GatewayProfileResource method get.
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> gatewayProfileResources = new ArrayList<AppCatalogResource>();
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;
GatewayProfileResource gatewayProfileResource = (GatewayProfileResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
gatewayProfileResources.add(gatewayProfileResource);
}
}
} 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 gatewayProfileResources;
}
Aggregations