@Test public void testGetTaggersByCodes() { List<String> codeList = new ArrayList<String>(); codeList.add(crisisDTO.getCode()); List<TaggersForCodes> taggersForCodes = null; if(!codeList.isEmpty()){ taggersForCodes = modelFamilyResourceFacadeImp.getTaggersByCodes(codeList); } assertNotNull(taggersForCodes); }
@Override public List<TaggersForCodes> getTaggersByCodes(final List<String> codes) { List<qa.qcri.aidr.dbmanager.dto.taggerapi.TaggersForCodes> result = new ArrayList<TaggersForCodes>(); String sql = "select c.code as code, " + " count(mf.modelFamilyID) as modelsCount " + " from model_family mf " + " right outer join collection c on c.id = mf.crisisID and classifier_enabled = 1" + " where c.code in :codes " + " group by mf.crisisID "; Query query = em.createNativeQuery(sql); query.setParameter("codes", codes); List<Object[]> rows = null; try { rows = query.getResultList(); } catch (NoResultException e) { logger.warn("No result for codes : " + codes); return null; } for (Object[] row : rows) { TaggersForCodes taggersForCodes = new TaggersForCodes(); taggersForCodes.setCode((String) row[0]); taggersForCodes.setCount((BigInteger) row[1]); result.add(taggersForCodes); } return result; }
ModelFamilyResourceFacadeImp extends CoreDBServiceFacadeImp<ModelFamily, Long> implements ModelFamilyResourceFacade { @Override public List<TaggersForCodes> getTaggersByCodes(final List<String> codes) { List<qa.qcri.aidr.dbmanager.dto.taggerapi.TaggersForCodes> result = new ArrayList<TaggersForCodes>(); String sql = "select c.code as code, " + " count(mf.modelFamilyID) as modelsCount " + " from model_family mf " + " right outer join collection c on c.id = mf.crisisID and classifier_enabled = 1" + " where c.code in :codes " + " group by mf.crisisID "; Query query = em.createNativeQuery(sql); query.setParameter("codes", codes); List<Object[]> rows = null; try { rows = query.getResultList(); } catch (NoResultException e) { logger.warn("No result for codes : " + codes); return null; } for (Object[] row : rows) { TaggersForCodes taggersForCodes = new TaggersForCodes(); taggersForCodes.setCode((String) row[0]); taggersForCodes.setCount((BigInteger) row[1]); result.add(taggersForCodes); } return result; } }
ModelFamilyResourceFacadeImp extends CoreDBServiceFacadeImp<ModelFamily, Long> implements ModelFamilyResourceFacade { @Override public List<TaggersForCodes> getTaggersByCodes(final List<String> codes) { List<qa.qcri.aidr.dbmanager.dto.taggerapi.TaggersForCodes> result = new ArrayList<TaggersForCodes>(); String sql = "select c.code as code, " + " count(mf.modelFamilyID) as modelsCount " + " from model_family mf " + " right outer join collection c on c.id = mf.crisisID and classifier_enabled = 1" + " where c.code in :codes " + " group by mf.crisisID "; Query query = em.createNativeQuery(sql); query.setParameter("codes", codes); List<Object[]> rows = null; try { rows = query.getResultList(); } catch (NoResultException e) { logger.warn("No result for codes : " + codes); return null; } for (Object[] row : rows) { TaggersForCodes taggersForCodes = new TaggersForCodes(); taggersForCodes.setCode((String) row[0]); taggersForCodes.setCount((BigInteger) row[1]); result.add(taggersForCodes); } return result; } ModelFamilyResourceFacadeImp(); }
ModelFamilyResourceFacadeImp extends CoreDBServiceFacadeImp<ModelFamily, Long> implements ModelFamilyResourceFacade { @Override public List<TaggersForCodes> getTaggersByCodes(final List<String> codes) { List<qa.qcri.aidr.dbmanager.dto.taggerapi.TaggersForCodes> result = new ArrayList<TaggersForCodes>(); String sql = "select c.code as code, " + " count(mf.modelFamilyID) as modelsCount " + " from model_family mf " + " right outer join collection c on c.id = mf.crisisID and classifier_enabled = 1" + " where c.code in :codes " + " group by mf.crisisID "; Query query = em.createNativeQuery(sql); query.setParameter("codes", codes); List<Object[]> rows = null; try { rows = query.getResultList(); } catch (NoResultException e) { logger.warn("No result for codes : " + codes); return null; } for (Object[] row : rows) { TaggersForCodes taggersForCodes = new TaggersForCodes(); taggersForCodes.setCode((String) row[0]); taggersForCodes.setCount((BigInteger) row[1]); result.add(taggersForCodes); } return result; } ModelFamilyResourceFacadeImp(); @Override List<ModelFamilyDTO> getAllModelFamilies(); @Override List<ModelFamilyDTO> getAllModelFamiliesByCrisis(Long crisisID); @Override ModelFamilyDTO getModelFamilyByID(Long id); @Override boolean addCrisisAttribute(ModelFamilyDTO modelFamily); @Override boolean deleteModelFamily(Long modelFamilyID); @Override List<TaggersForCodes> getTaggersByCodes(final List<String> codes); @Override List<ModelWrapper> getModelFamilyAggregateDataForCollection(Long collectionId); }
ModelFamilyResourceFacadeImp extends CoreDBServiceFacadeImp<ModelFamily, Long> implements ModelFamilyResourceFacade { @Override public List<TaggersForCodes> getTaggersByCodes(final List<String> codes) { List<qa.qcri.aidr.dbmanager.dto.taggerapi.TaggersForCodes> result = new ArrayList<TaggersForCodes>(); String sql = "select c.code as code, " + " count(mf.modelFamilyID) as modelsCount " + " from model_family mf " + " right outer join collection c on c.id = mf.crisisID and classifier_enabled = 1" + " where c.code in :codes " + " group by mf.crisisID "; Query query = em.createNativeQuery(sql); query.setParameter("codes", codes); List<Object[]> rows = null; try { rows = query.getResultList(); } catch (NoResultException e) { logger.warn("No result for codes : " + codes); return null; } for (Object[] row : rows) { TaggersForCodes taggersForCodes = new TaggersForCodes(); taggersForCodes.setCode((String) row[0]); taggersForCodes.setCount((BigInteger) row[1]); result.add(taggersForCodes); } return result; } ModelFamilyResourceFacadeImp(); @Override List<ModelFamilyDTO> getAllModelFamilies(); @Override List<ModelFamilyDTO> getAllModelFamiliesByCrisis(Long crisisID); @Override ModelFamilyDTO getModelFamilyByID(Long id); @Override boolean addCrisisAttribute(ModelFamilyDTO modelFamily); @Override boolean deleteModelFamily(Long modelFamilyID); @Override List<TaggersForCodes> getTaggersByCodes(final List<String> codes); @Override List<ModelWrapper> getModelFamilyAggregateDataForCollection(Long collectionId);  }