Author: bleny Date: 2011-04-28 13:31:00 +0000 (Thu, 28 Apr 2011) New Revision: 1242 Log: extract inner method in ServiceSynthesisImpl Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2011-04-28 10:29:33 UTC (rev 1241) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2011-04-28 13:31:00 UTC (rev 1242) @@ -1298,22 +1298,13 @@ return result; } - @Override - protected Map<String, Map<String, Integer>> executeGetDistinctBoatsCounts(TopiaContext transaction, SamplingFilter samplingFilter) throws Exception { - WaoQueryBuilder builder = context.newQueryBuilder(); - builder.initializeForContact(); - TopiaQuery query = builder.applySamplingFilter(samplingFilter); - ContactDAO contactDAO = WaoDAOHelper.getContactDAO(transaction); - List<Contact> contacts = contactDAO.findAllByQuery(query); - if (log.isDebugEnabled()) { - log.debug(contacts.size() + " found for distinct boats count synthesis"); - } + protected Map<String, Map<String, Integer>> computeBoatsCounts(List<Contact> contacts) { SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); SimpleDateFormat monthFormat = new SimpleDateFormat("M"); // For each year of the contact found, for each month of this year, the // boats observed this month of this year. We use a set, so we ensure - // that the boats are distincts + // that the boats are distinct Map<String, Map<String, Set<Boat>>> temp = new HashMap<String, Map<String, Set<Boat>>>(); for (Contact contact : contacts) { @@ -1352,8 +1343,25 @@ monthToCount.put(month, temp.get(year).get(month).size()); } } + return result; + } + + @Override + protected Map<String, Map<String, Integer>> executeGetDistinctBoatsCounts(TopiaContext transaction, SamplingFilter samplingFilter) throws Exception { + WaoQueryBuilder builder = context.newQueryBuilder(); + builder.initializeForContact(); + TopiaQuery query = builder.applySamplingFilter(samplingFilter); + ContactDAO contactDAO = WaoDAOHelper.getContactDAO(transaction); + List<Contact> contacts = contactDAO.findAllByQuery(query); + if (log.isDebugEnabled()) { + log.debug(contacts.size() + " found for distinct boats count synthesis"); + } + + Map<String, Map<String, Integer>> result = computeBoatsCounts(contacts); + + if (log.isDebugEnabled()) { log.debug("boat counts synthesis returns "); for (Map.Entry<String, Map<String, Integer>> entry : result.entrySet()) { String year = entry.getKey();