Author: fdesbois Date: 2010-04-01 18:28:32 +0000 (Thu, 01 Apr 2010) New Revision: 410 Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties Log: Clean ServiceSynthesisImpl Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 18:21:22 UTC (rev 409) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 18:28:32 UTC (rev 410) @@ -38,7 +38,6 @@ import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.BoatDAO; import fr.ifremer.wao.entity.Company; -import fr.ifremer.wao.entity.CompanyDAO; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactDAO; import fr.ifremer.wao.entity.ContactImpl; 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 2010-04-01 18:21:22 UTC (rev 409) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-01 18:28:32 UTC (rev 410) @@ -75,89 +75,66 @@ private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImpl.class); -// protected TopiaContext rootContext; -// -// public ServiceSynthesisImpl() throws WaoExceptionO { -// rootContext = context.getTopiaRootContext(); -// } - @Override public List<SortedMap<Date, Integer>> executeGetDataSampling( TopiaContext transaction, SamplingFilter filter) throws TopiaException { -// TopiaContext transaction = null; List<SortedMap<Date, Integer>> results = new ArrayList<SortedMap<Date, Integer>>(); -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - PeriodDates period = filter.getPeriod(); - if (period == null || period.getFromDate() == null || period.getThruDate() == null) { - return results; - } - period.initDayOfMonthExtremities(); + PeriodDates period = filter.getPeriod(); + if (period == null || period.getFromDate() == null || + period.getThruDate() == null) { + return results; + } + period.initDayOfMonthExtremities(); - // Expected - SortedMap<Date, Integer> serie1 = new TreeMap<Date,Integer>(); - // Real - SortedMap<Date, Integer> serie2 = new TreeMap<Date,Integer>(); - results.add(serie1); - results.add(serie2); + // Expected + SortedMap<Date, Integer> serie1 = new TreeMap<Date,Integer>(); + // Real + SortedMap<Date, Integer> serie2 = new TreeMap<Date,Integer>(); + results.add(serie1); + results.add(serie2); - // Prepare results - for (Date month : period.getMonths()) { - serie1.put(month, 0); - serie2.put(month, 0); - } + // Prepare results + for (Date month : period.getMonths()) { + serie1.put(month, 0); + serie2.put(month, 0); + } - SampleMonthDAO dao = WaoDAOHelper.getSampleMonthDAO(transaction); - String periodDate = "M." + SampleMonth.PERIOD_DATE; - TopiaQuery query = dao.createQuery("M"). - setSelect(periodDate). - addSelect("SUM(M." + SampleMonth.REAL_TIDES_VALUE + ")"). - addSelect("SUM(M." + SampleMonth.EXPECTED_TIDES_VALUE + ")"). - add(periodDate + " BETWEEN :fromDate AND :thruDate"). - addParam("fromDate", period.getFromDate()).addParam("thruDate", period.getThruDate()). - addGroup(periodDate).addOrder(periodDate); + SampleMonthDAO dao = WaoDAOHelper.getSampleMonthDAO(transaction); + String periodDate = "M." + SampleMonth.PERIOD_DATE; + TopiaQuery query = dao.createQuery("M"). + setSelect(periodDate). + addSelect("SUM(M." + SampleMonth.REAL_TIDES_VALUE + ")"). + addSelect("SUM(M." + SampleMonth.EXPECTED_TIDES_VALUE + ")"). + add(periodDate + " BETWEEN :fromDate AND :thruDate"). + addParam("fromDate", period.getFromDate()). + addParam("thruDate", period.getThruDate()). + addGroup(periodDate).addOrder(periodDate); - query = filter.prepareQueryForSampling(query, "M." + SampleMonth.SAMPLE_ROW); + query = filter.prepareQueryForSampling(query, + "M." + SampleMonth.SAMPLE_ROW); - if (log.isTraceEnabled()) { - log.trace("Exec query : " + query); - } + if (log.isTraceEnabled()) { + log.trace("Exec query : " + query); + } - List<Object[]> res = (List<Object[]>)query.execute(); + List<Object[]> res = (List<Object[]>)query.execute(); - for (Object[] tab : res) { - Date date = (Date)tab[0]; - int sumReal = ((Long)tab[1]).intValue(); - int sumExpected = ((Long)tab[2]).intValue(); - serie1.put(date, sumExpected); - serie2.put(date, sumReal); - if (log.isTraceEnabled()) { - DateFormat dateFormat = new SimpleDateFormat(period.getPattern()); - log.trace("Res : " + dateFormat.format(date) + " : " + sumReal + " / " + sumExpected); - } + for (Object[] tab : res) { + Date date = (Date)tab[0]; + int sumReal = ((Long)tab[1]).intValue(); + int sumExpected = ((Long)tab[2]).intValue(); + serie1.put(date, sumExpected); + serie2.put(date, sumReal); + if (log.isTraceEnabled()) { + DateFormat dateFormat = + new SimpleDateFormat(period.getPattern()); + log.trace("Res : " + dateFormat.format(date) + " : " + + sumReal + " / " + sumExpected); } - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getDataSampling ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee); -// } finally { -// context.closeTransaction(transaction); -// } + } return results; } @@ -179,202 +156,153 @@ public BoardingResult executeGetBoardingBoats(TopiaContext transaction, Company company, Date fromDate) throws TopiaException { -// TopiaContext transaction = null; Map<String, Integer> map = new LinkedHashMap<String, Integer>(); BoardingResult result = new BoardingResultImpl(); result.setData(map); -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - // Initialiaze max boardings and its max key value - final int maxBoardings = 12; - final String maxBoardingsKey = maxBoardings + " +"; + // Initialiaze max boardings and its max key value + final int maxBoardings = 12; + final String maxBoardingsKey = maxBoardings + " +"; - // Prepare map which contains for each entry the number of boardings - // for the key and the number of boats for the value. - for (int i = 1; i < maxBoardings; i++) { - map.put(String.valueOf(i), 0); - } - map.put(maxBoardingsKey, 0); + // Prepare map which contains for each entry the number of boardings + // for the key and the number of boats for the value. + for (int i = 1; i < maxBoardings; i++) { + map.put(String.valueOf(i), 0); + } + map.put(maxBoardingsKey, 0); - ContactDAO dao = - WaoDAOHelper.getContactDAO(transaction); - // The number of boardings is the number of finished contacts - // Use fromDate to filter contacts finished from this date - // No need to use boat filter for this method - TopiaQuery query = - dao.createQueryDoneContactsFromDate(null, fromDate); - - String contact = query.getMainAlias(); - String sampleRow = contact + "." + Contact.SAMPLE_ROW; + ContactDAO dao = + WaoDAOHelper.getContactDAO(transaction); + // The number of boardings is the number of finished contacts + // Use fromDate to filter contacts finished from this date + // No need to use boat filter for this method + TopiaQuery query = + dao.createQueryDoneContactsFromDate(null, fromDate); - // Only for sampleRows with averageTideTime less or equals to 2 days - query.add(sampleRow + "." + SampleRow.AVERAGE_TIDE_TIME, Op.LE, 2.); + String contact = query.getMainAlias(); + String sampleRow = contact + "." + Contact.SAMPLE_ROW; - // Add filter on sampleRow company if needed - if (company != null) { - query.add(sampleRow + "." + SampleRow.COMPANY, company); - } + // Only for sampleRows with averageTideTime less or equals to 2 days + query.add(sampleRow + "." + SampleRow.AVERAGE_TIDE_TIME, Op.LE, 2.); - // Prepare aliases for mapping results in select part - String countAlias = "nbBoardings"; - String boatAlias = "boat"; - // Use a map for each result with boat and its number of boardings - // Order by number of boardings to easily find the max value (the - // first result) - query.setSelect("new map(" + contact + "." + Contact.BOAT + " as " + - boatAlias + ", COUNT(*) as " + countAlias + ")"). - addGroup(contact + "." + Contact.BOAT). - addOrderDesc("COUNT(*)"); + // Add filter on sampleRow company if needed + if (company != null) { + query.add(sampleRow + "." + SampleRow.COMPANY, company); + } - if (log.isTraceEnabled()) { - log.trace("Exec query : " + query); - } + // Prepare aliases for mapping results in select part + String countAlias = "nbBoardings"; + String boatAlias = "boat"; + // Use a map for each result with boat and its number of boardings + // Order by number of boardings to easily find the max value (the + // first result) + query.setSelect("new map(" + contact + "." + Contact.BOAT + " as " + + boatAlias + ", COUNT(*) as " + countAlias + ")"). + addGroup(contact + "." + Contact.BOAT). + addOrderDesc("COUNT(*)"); - List<Map<String, Object>> nbBoardingsByBoat = query.execute(); + if (log.isTraceEnabled()) { + log.trace("Exec query : " + query); + } - if (!nbBoardingsByBoat.isEmpty()) { - for (Map<String, Object> row : nbBoardingsByBoat) { - Long count = (Long)row.get(countAlias); - int intValue = count.intValue(); - String value = count.toString(); - if (intValue >= maxBoardings) { - value = maxBoardingsKey; - } - // Increment the number of boats for the current number of - // boardings - Integer nbBoats = map.get(value); - map.put(value, nbBoats + 1); - } + List<Map<String, Object>> nbBoardingsByBoat = query.execute(); - // Set the max boat and its number of boardings value - Map<String, Object> max = nbBoardingsByBoat.get(0); - result.setMaxBoardingBoat((Boat)max.get(boatAlias)); - Long maxValue = (Long)max.get(countAlias); - result.setMaxBoardingValue(maxValue.intValue()); + if (!nbBoardingsByBoat.isEmpty()) { + for (Map<String, Object> row : nbBoardingsByBoat) { + Long count = (Long)row.get(countAlias); + int intValue = count.intValue(); + String value = count.toString(); + if (intValue >= maxBoardings) { + value = maxBoardingsKey; + } + // Increment the number of boats for the current number of + // boardings + Integer nbBoats = map.get(value); + map.put(value, nbBoats + 1); } -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getBoardingBoats ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de récupérer les données pour le graphique " + -// "dynamique des efforts de marées", eee); -// } finally { -// context.closeTransaction(transaction); -// } + // Set the max boat and its number of boardings value + Map<String, Object> max = nbBoardingsByBoat.get(0); + result.setMaxBoardingBoat((Boat)max.get(boatAlias)); + Long maxValue = (Long)max.get(countAlias); + result.setMaxBoardingValue(maxValue.intValue()); + } return result; } @Override public Map<String, Double> executeGetNonComplianceBoardingIndicator( TopiaContext transaction, Company company) throws TopiaException { -// TopiaContext transaction = null; + // Carefull with results, the company may not be present in the map : // only if there is no unfinished sampleRow or no contact done Map<String, Double> results = new HashMap<String, Double>(); -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - - // Only for done contacts with no constraint - TopiaQuery query = - dao.createQueryDoneContactsFromDate(null, null); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - String contact = query.getMainAlias(); - String sampleRow = contact + "." + Contact.SAMPLE_ROW; - String companyProp = sampleRow + "." + SampleRow.COMPANY; - String companyName = companyProp + "." + Company.NAME; + // Only for done contacts with no constraint + TopiaQuery query = + dao.createQueryDoneContactsFromDate(null, null); - // Only for unfinished sampleRows - Date current = context.getCurrentDate(); - query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current); + String contact = query.getMainAlias(); + String sampleRow = contact + "." + Contact.SAMPLE_ROW; + String companyProp = sampleRow + "." + SampleRow.COMPANY; + String companyName = companyProp + "." + Company.NAME; - if (company != null) { - query.add(companyProp, company); - } + // Only for unfinished sampleRows + Date current = context.getCurrentDate(); + query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current); - // Prepare results - query.setSelect(companyName, "COUNT(*)").addGroup(companyName); + if (company != null) { + query.add(companyProp, company); + } - if (log.isDebugEnabled()) { - log.debug("Exec query for total : " + query); - } + // Prepare results + query.setSelect(companyName, "COUNT(*)").addGroup(companyName); - List<Object[]> totalResults = query.execute(); + if (log.isDebugEnabled()) { + log.debug("Exec query for total : " + query); + } - // Use the same query and add the constraint of non compliance - //i.e. nbObservantsReal (contact) < nbObservantsExpected (sampleRow) - query.add(contact + "." + Contact.NB_OBSERVANTS + " < " + - sampleRow + "." + SampleRow.NB_OBSERVANTS); + List<Object[]> totalResults = query.execute(); - if (log.isDebugEnabled()) { - log.debug("Exec query for result : " + query); - } + // Use the same query and add the constraint of non compliance + //i.e. nbObservantsReal (contact) < nbObservantsExpected (sampleRow) + query.add(contact + "." + Contact.NB_OBSERVANTS + " < " + + sampleRow + "." + SampleRow.NB_OBSERVANTS); - List<Object[]> diffResults = query.execute(); + if (log.isDebugEnabled()) { + log.debug("Exec query for result : " + query); + } - // Use the map to set the number of non compliance results - for (Object[] row : diffResults) { - String rowCompanyName = (String)row[0]; - Long rowCount = (Long)row[1]; - if (log.isDebugEnabled()) { - log.debug("result row : " + rowCompanyName + " = " + rowCount); - } - results.put(rowCompanyName, rowCount.doubleValue()); - } + List<Object[]> diffResults = query.execute(); - // Get the previous value from the map and make the division to have - // the result percent of non compliance. Put 0 in the map if no - // previous result is set - for (Object[] row : totalResults) { - String rowCompanyName = (String)row[0]; - Long rowCount = (Long)row[1]; - if (log.isDebugEnabled()) { - log.debug("total row : " + rowCompanyName + " = " + rowCount); - } - Double value = results.get(rowCompanyName); - if (value == null) { - results.put(rowCompanyName, 0.); - } else { - results.put(rowCompanyName, value / rowCount); - } + // Use the map to set the number of non compliance results + for (Object[] row : diffResults) { + String rowCompanyName = (String)row[0]; + Long rowCount = (Long)row[1]; + if (log.isDebugEnabled()) { + log.debug("result row : " + rowCompanyName + " = " + rowCount); } + results.put(rowCompanyName, rowCount.doubleValue()); + } -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getNonComplianceBoardingIndicator ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// String msgEnd = ""; -// if (company != null) { -// msgEnd = " pour la société " + company.getName(); -// } -// context.serviceException(transaction, -// "Impossible de récupérer l'indicateur de non respect du " + -// "nombre d'observateurs embarqués" + msgEnd, eee); -// } finally { -// context.closeTransaction(transaction); -// } + // Get the previous value from the map and make the division to have + // the result percent of non compliance. Put 0 in the map if no + // previous result is set + for (Object[] row : totalResults) { + String rowCompanyName = (String)row[0]; + Long rowCount = (Long)row[1]; + if (log.isDebugEnabled()) { + log.debug("total row : " + rowCompanyName + " = " + rowCount); + } + Double value = results.get(rowCompanyName); + if (value == null) { + results.put(rowCompanyName, 0.); + } else { + results.put(rowCompanyName, value / rowCount); + } + } return results; } @@ -382,93 +310,68 @@ public Collection<ContactStateStatistics> executeGetContactStateStatistics( TopiaContext transaction, Company company, PeriodDates period) throws TopiaException { -// TopiaContext transaction = null; + Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>(); -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - // Only for contacts not refused by the program - String contact = "C"; - String validationProgram = contact + "." + Contact.VALIDATION_PROGRAM; - TopiaQuery query = dao.createQuery(contact). - add(validationProgram + " IS NULL " + - "OR " + validationProgram + " = :booleanTrue"). - addParam("booleanTrue", Boolean.TRUE); + // Only for contacts not refused by the program + String contact = "C"; + String validationProgram = contact + "." + Contact.VALIDATION_PROGRAM; + TopiaQuery query = dao.createQuery(contact). + add(validationProgram + " IS NULL " + + "OR " + validationProgram + " = :booleanTrue"). + addParam("booleanTrue", Boolean.TRUE); - String companyProp = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY; + String companyProp = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY; - if (company != null) { - query.add(companyProp, company); - } + if (company != null) { + query.add(companyProp, company); + } - if (period != null) { - // Contacts include in the period - String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE; - String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE; - query.add("(" + tideBeginDate + " IS NOT NULL " + - "AND " + tideBeginDate + " BETWEEN :fromDate AND :thruDate)" + - " OR (" + tideBeginDate + " IS NULL " + - "AND " + createDate + " BETWEEN :fromDate AND :thruDate)"); + if (period != null) { + // Contacts include in the period + String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE; + String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE; + query.add("(" + tideBeginDate + " IS NOT NULL " + + "AND " + tideBeginDate + " BETWEEN :fromDate AND :thruDate)" + + " OR (" + tideBeginDate + " IS NULL " + + "AND " + createDate + " BETWEEN :fromDate AND :thruDate)"); - period.initDayOfMonthExtremities(); - query.addParam("fromDate", period.getFromDate()). - addParam("thruDate", period.getThruDate()); - } + period.initDayOfMonthExtremities(); + query.addParam("fromDate", period.getFromDate()). + addParam("thruDate", period.getThruDate()); + } - String stateProp = contact + "." + Contact.STATE; - String companyName = companyProp + "." + Company.NAME; - query.addGroup(companyName, stateProp). - addOrder(companyName). - setSelect(companyName, stateProp, "COUNT(*)"); + String stateProp = contact + "." + Contact.STATE; + String companyName = companyProp + "." + Company.NAME; + query.addGroup(companyName, stateProp). + addOrder(companyName). + setSelect(companyName, stateProp, "COUNT(*)"); - if (log.isDebugEnabled()) { - log.debug("Exec query : " + query); - } + if (log.isDebugEnabled()) { + log.debug("Exec query : " + query); + } - List<Object[]> res = query.execute(); + List<Object[]> res = query.execute(); - for (Object[] row : res) { - String rowCompanyName = (String)row[0]; - int rowState = (Integer)row[1]; - ContactState state = ContactState.valueOf(rowState); - Long rowCount = (Long)row[2]; - if (log.isDebugEnabled()) { - log.debug("res : " + rowCompanyName + " _ " + state + " _ " + rowCount); - } - ContactStateStatistics stats = results.get(rowCompanyName); - if (stats == null) { - stats = new ContactStateStatisticsImpl(); - stats.setCompanyName(rowCompanyName); - results.put(rowCompanyName, stats); - } - stats.addResult(state, rowCount.intValue()); + for (Object[] row : res) { + String rowCompanyName = (String)row[0]; + int rowState = (Integer)row[1]; + ContactState state = ContactState.valueOf(rowState); + Long rowCount = (Long)row[2]; + if (log.isDebugEnabled()) { + log.debug("res : " + rowCompanyName + " _ " + state + " _ " + rowCount); } - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getContactStateStatistics ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// } catch (Exception eee) { -// String msgEnd = ""; -// if (company != null) { -// msgEnd = " pour la société " + company.getName(); -// } -// context.serviceException(transaction, -// "Impossible de récupérer les statistiques sur les états des " + -// "contacts " + msgEnd, eee); -// } finally { -// context.closeTransaction(transaction); -// } + ContactStateStatistics stats = results.get(rowCompanyName); + if (stats == null) { + stats = new ContactStateStatisticsImpl(); + stats.setCompanyName(rowCompanyName); + results.put(rowCompanyName, stats); + } + stats.addResult(state, rowCount.intValue()); + } return results.values(); } @@ -476,91 +379,62 @@ public Collection<ContactAverageReactivity> executeGetContactDataInputDateReactivity(TopiaContext transaction, Company company, PeriodDates period) throws TopiaException { -// TopiaContext transaction = null; // Carefull with results, the company may not be present in the map : // only if there is no unfinished sampleRow or no contact done Map<String, ContactAverageReactivity> results = new HashMap<String, ContactAverageReactivity>(); -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); -// String contact = "C"; -// TopiaQuery query = dao.createQuery(contact); + TopiaQuery query = dao.createQueryDoneContactsFromDate(null, period.getFromDate()); - TopiaQuery query = dao.createQueryDoneContactsFromDate(null, period.getFromDate()); - - String contact = query.getMainAlias(); - String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY; - String companyName = companyKey + "." + Company.NAME; + String contact = query.getMainAlias(); + String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY; + String companyName = companyKey + "." + Company.NAME; - if (company != null) { - query.add(companyKey, company); - } + if (company != null) { + query.add(companyKey, company); + } - String tideBegin = contact + "." + Contact.TIDE_BEGIN_DATE; - //period.initDayOfMonthExtremities(); + String tideBegin = contact + "." + Contact.TIDE_BEGIN_DATE; + //period.initDayOfMonthExtremities(); - if (period.getThruDate() != null) { - query.add(tideBegin, Op.LE, period.getThruDate()); - } + if (period.getThruDate() != null) { + query.add(tideBegin, Op.LE, period.getThruDate()); + } - String dataInput = contact + "." + Contact.DATA_INPUT_DATE; - query.setSelect(companyName, dataInput, tideBegin); + String dataInput = contact + "." + Contact.DATA_INPUT_DATE; + query.setSelect(companyName, dataInput, tideBegin); - if (log.isDebugEnabled()) { - log.debug("Exec query : " + query); - } + if (log.isDebugEnabled()) { + log.debug("Exec query : " + query); + } - List<Object[]> res = query.execute(); + List<Object[]> res = query.execute(); - for (Object[] row : res) { - String rowCompanyName = (String)row[0]; - Date rowDataInputDate = (Date)row[1]; - Date rowTideBeginDate = (Date)row[2]; + for (Object[] row : res) { + String rowCompanyName = (String)row[0]; + Date rowDataInputDate = (Date)row[1]; + Date rowTideBeginDate = (Date)row[2]; - int nbDays = DateUtils.getDifferenceInDays(rowTideBeginDate, rowDataInputDate); + int nbDays = DateUtils.getDifferenceInDays(rowTideBeginDate, rowDataInputDate); - if (log.isDebugEnabled()) { - log.debug("Company : " + rowCompanyName); - log.debug("tideBegin : " + rowTideBeginDate); - log.debug("dataInput : " + rowDataInputDate); - log.debug("nbDays : " + nbDays); - } + if (log.isDebugEnabled()) { + log.debug("Company : " + rowCompanyName); + log.debug("tideBegin : " + rowTideBeginDate); + log.debug("dataInput : " + rowDataInputDate); + log.debug("nbDays : " + nbDays); + } - ContactAverageReactivity avg = results.get(rowCompanyName); - if (avg == null) { - avg = new ContactAverageReactivityImpl(); - avg.setCompanyName(rowCompanyName); - results.put(rowCompanyName, avg); - } - - avg.addValue(nbDays); + ContactAverageReactivity avg = results.get(rowCompanyName); + if (avg == null) { + avg = new ContactAverageReactivityImpl(); + avg.setCompanyName(rowCompanyName); + results.put(rowCompanyName, avg); } -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getContactDataInputDateReactivity ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// } catch (Exception eee) { -// String msgEnd = ""; -// if (company != null) { -// msgEnd = " pour la société " + company.getName(); -// } -// context.serviceException(transaction, -// "Impossible de récupérer l'indicateur de réactivité sur " + -// "les dates de saisies dans Allegro" + msgEnd, eee); -// } finally { -// context.closeTransaction(transaction); -// } + avg.addValue(nbDays); + } return results.values(); } Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 18:21:22 UTC (rev 409) +++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 18:28:32 UTC (rev 410) @@ -49,11 +49,11 @@ wao.error.serviceSampling.getSampleRowsByFilter=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage wao.error.serviceSampling.importSamplingPlanCsv=Erreur \u00E0 la ligne %1$d [CODE \= %2$s] -wao.error.serviceSynthesis.getBoardingBoats= -wao.error.serviceSynthesis.getContactDataInputDateReactivity= -wao.error.serviceSynthesis.getContactStateStatistics= -wao.error.serviceSynthesis.getDataSampling= -wao.error.serviceSynthesis.getNonComplianceBoardingIndicator= +wao.error.serviceSynthesis.getBoardingBoats=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es du graphique concernant les embarquements sur les navires +wao.error.serviceSynthesis.getContactDataInputDateReactivity=Impossible de r\u00E9cup\u00E9rer l'indicateur de r\u00E9activit\u00E9 sur les dates de saisies dans Allegro +wao.error.serviceSynthesis.getContactStateStatistics=Impossible de r\u00E9cup\u00E9rer les statistiques sur les \u00E9tats des contacts +wao.error.serviceSynthesis.getDataSampling=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es pour le graphique dynamique des efforts de mar\u00E9es +wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=Impossible de r\u00E9cup\u00E9rer l'indicateur de non respect du nombre d'observateurs embarqu\u00E9s wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9 wao.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er ou de mettre \u00E0 jour l'utilisateur