Wao-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- 2352 discussions
[Suiviobsmer-commits] r703 - in trunk: wao-business/src/main/java/fr/ifremer/wao wao-ui/src/main/java/fr/ifremer/wao/ui/pages
by bleny@users.labs.libre-entreprise.org 22 Oct '10
by bleny@users.labs.libre-entreprise.org 22 Oct '10
22 Oct '10
Author: bleny
Date: 2010-10-22 09:31:53 +0000 (Fri, 22 Oct 2010)
New Revision: 703
Log:
hack to bugfix unability to filter when a subquery is involved ; a bug in addSubQuery ?
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoQueryBuilder.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoQueryBuilder.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoQueryBuilder.java 2010-10-21 16:06:37 UTC (rev 702)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoQueryBuilder.java 2010-10-22 09:31:53 UTC (rev 703)
@@ -252,8 +252,28 @@
// Apply filter for fishingZone on subQuery
applySimpleFishingZoneFilter(filter, subquery);
+ if(logger.isDebugEnabled()) {
+ logger.debug("sampling filter subquery " + subquery);
+ logger.debug("sampling filter query " + query);
+ }
+
query.addSubQuery(WaoQueryHelper.format(
"$1 IN (?)", sampleRowProperty.$alias()), subquery);
+
+ // XXX 20101022 bleny it seems that last call don't
+ // keep params of the sub-query. Thus, the :facadeName is still
+ // in the query but misses in params of the request.
+ // the next line is a work-around that copy the params of the
+ // subquery is the main query. It works but it seems that
+ // there is a bug in addSubQuery, :facadeName should have been
+ // replaced in the query and removed from params OR not replaced
+ // in the query and kept in the params but NOT not replaced in
+ // the query and removed from params
+ query.getParams().addAll(subquery.getParams());
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("sampling filter query " + query);
+ }
}
}
@@ -289,6 +309,11 @@
calendar.add(Calendar.MONTH, nbMonthsFinishedFromToday);
query.addWhere(sampleRowProperty.periodEnd(), TopiaQuery.Op.GE, calendar.getTime());
}
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("sampling filter query " + query);
+ }
+
return query;
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-10-21 16:06:37 UTC (rev 702)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-10-22 09:31:53 UTC (rev 703)
@@ -163,7 +163,7 @@
logger.debug("Init contactFilter");
}
contactFilter = new ContactFilterImpl();
- // Initialized to 12 months before the current day
+ // Initialized to 3 months before the current day
Date fromDate = DateUtil.createDateAfterToday(0, -3, 0);
contactFilter.setFromDate(fromDate);
}
1
0
[Suiviobsmer-commits] r702 - in trunk: wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/xmi wao-ui/src/main/java/fr/ifremer/wao/ui/pages wao-ui/src/main/webapp
by bleny@users.labs.libre-entreprise.org 21 Oct '10
by bleny@users.labs.libre-entreprise.org 21 Oct '10
21 Oct '10
Author: bleny
Date: 2010-10-21 16:06:37 +0000 (Thu, 21 Oct 2010)
New Revision: 702
Log:
added filter on all synthesis ; refactoring done (break the build)
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
trunk/wao-ui/src/main/webapp/Synthesis.tml
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-10-21 14:51:31 UTC (rev 701)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-10-21 16:06:37 UTC (rev 702)
@@ -180,83 +180,7 @@
* value.
* @throws WaoException
*/
- @Deprecated
- public BoardingResult executeGetBoardingBoats(TopiaContext transaction,
- Company company,
- Date fromDate)
- throws TopiaException {
- Map<String, Integer> map = new LinkedHashMap<String, Integer>();
- BoardingResult result = new BoardingResultImpl();
- result.setData(map);
- // Initialize 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);
-
- 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;
-
- // Only for sampleRows with averageTideTime less or equals to 2 days
- query.addWhere(sampleRow + "." + SampleRow.AVERAGE_TIDE_TIME, Op.LE, 2.);
-
- // Add filter on sampleRow company if needed
- if (company != null) {
- query.addEquals(sampleRow + "." + SampleRow.COMPANY, company);
- }
-
- // 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(*)");
-
- if (log.isTraceEnabled()) {
- log.trace("Exec query : " + query);
- }
-
- List<Map<String, Object>> nbBoardingsByBoat = transaction.findByQuery(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);
- }
-
- // 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 BoardingResult executeGetBoardingBoats(TopiaContext transaction,
SamplingFilter filter)
@@ -332,101 +256,8 @@
return result;
}
-
- @Deprecated
+ // should be merged into getComplianceBoardingIndicator
public Map<String, Double> executeGetNonComplianceBoardingIndicator(
- TopiaContext transaction, Company company) throws TopiaException {
-
- // 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>();
-
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
-
- // Only for done contacts with no constraint
- TopiaQuery query =
- dao.createQueryDoneContactsFromDate(null, null);
-
- // Prepare properties for query
- String contactAlias = query.getMainAlias();
- String sampleRowProperty =
- TopiaQuery.getProperty(contactAlias, Contact.SAMPLE_ROW);
- String nbObservantsRealProperty =
- TopiaQuery.getProperty(contactAlias, Contact.NB_OBSERVANTS);
-
- String sampleRowEndProperty =
- TopiaQuery.getProperty(sampleRowProperty, SampleRow.PERIOD_END);
- String companyProperty =
- TopiaQuery.getProperty(sampleRowProperty, SampleRow.COMPANY);
- String nbObservantsExpectedProperty =
- TopiaQuery.getProperty(sampleRowProperty, SampleRow.NB_OBSERVANTS);
-
- String companyNameProperty =
- TopiaQuery.getProperty(companyProperty, Company.NAME);
-
- // Only for unfinished sampleRows
- query.addWhere(sampleRowEndProperty, Op.GE, context.getCurrentDate());
-
- if (company != null) {
- query.addEquals(companyProperty, company);
- }
-
- // Prepare results
- query.setSelect(companyNameProperty, "COUNT(*)").
- addGroup(companyNameProperty);
-
- if (log.isDebugEnabled()) {
- log.debug("Query for total : " + query);
- }
-
- List<Object[]> totalResults = transaction.findByQuery(query);
-
- // Use the same query and add the constraint of non compliance
- //i.e. nbObservantsReal (contact) < nbObservantsExpected (sampleRow)
-// query.addWhere(contact + "." + Contact.NB_OBSERVANTS + " < " +
-// sampleRow + "." + SampleRow.NB_OBSERVANTS);
- query.addWhere(new StringBuilder(nbObservantsRealProperty).
- append(" < ").
- append(nbObservantsExpectedProperty).
- toString()
- );
-
- if (log.isDebugEnabled()) {
- log.debug("Query for result : " + query);
- }
-
- List<Object[]> diffResults = transaction.findByQuery(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());
- }
-
- // 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;
- }
-
- public Map<String, Double> executeGetNonComplianceBoardingIndicator(
TopiaContext transaction, SamplingFilter filter) throws TopiaException {
// Carefull with results, the company may not be present in the map :
@@ -523,24 +354,6 @@
return results;
}
- @Deprecated
- protected Map<String, Double> executeGetComplianceBoardingIndicator(
- TopiaContext transaction, Company company) throws Exception {
- // here, we need compliance, so we get non-compliance values
- // and we make the operation to switch
-
- Map<String, Double> nonCompliances = executeGetNonComplianceBoardingIndicator(transaction, company);
- Map<String, Double> compliances = new HashMap<String, Double>();
-
- // make the switch, fill compliances with data from nonCompliances
- for (Map.Entry<String, Double> nonCompliance : nonCompliances.entrySet()) {
- Double compliance = 1.0 - nonCompliance.getValue();
- compliances.put(nonCompliance.getKey(), compliance);
- }
-
- return compliances;
- }
-
@Override
protected Map<String, Double> executeGetComplianceBoardingIndicator(
TopiaContext transaction, SamplingFilter filter) throws Exception {
@@ -559,136 +372,6 @@
return compliances;
}
- @Deprecated
- public Collection<ContactStateStatistics> executeGetContactStateStatistics(
- TopiaContext transaction, Company company, PeriodDates period)
- throws TopiaException {
-
-// ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
-
- // Only for contacts not refused by the program
-// String contactAlias = "C";
-// String validationProgramProperty =
-// TopiaQuery.getProperty(contactAlias, Contact.VALIDATION_PROGRAM);
-//
-// WaoQueryHelper.ContactProperty contactProperty =
-// WaoQueryHelper.newContactProperty();
-//
-// WaoQueryHelper.CompanyProperty companyProperty =
-// contactProperty.observerProperty().companyProperty();
-//
-// TopiaQuery query = dao.createQuery(contactProperty.$alias()).
-// addWhere(WaoQueryHelper.format(
-// "$1 IS NULL OR $1 = :booleanTrue", contactProperty.validationProgram())
-// ).addParam("booleanTrue", Boolean.TRUE);
-//// addWhere(new StringBuilder(validationProgramProperty).
-//// append(" IS NULL OR ").
-//// append(validationProgramProperty).
-//// append(" = :booleanTrue").
-//// toString()
-//// ).addParam("booleanTrue", Boolean.TRUE);
-//
-//// String companyProperty =
-//// TopiaQuery.getProperty(contactAlias, Contact.OBSERVER, WaoUser.COMPANY);
-//
-// if (company != null) {
-// query.addEquals(companyProperty.$alias(), company);
-// }
-//
-// if (period != null) {
-// // Contacts include in the period
-// period.initDayOfMonthExtremities();
-//
-//// String tideBeginDateProperty =
-//// TopiaQuery.getProperty(contactAlias, Contact.TIDE_BEGIN_DATE);
-//// String createDateProperty =
-//// TopiaQuery.getProperty(contactAlias, Contact.TOPIA_CREATE_DATE);
-// query.addWhere(WaoQueryHelper.format(
-// "($1 IS NOT NULL AND $1 BETWEEN :fromDate AND :thruDate)" +
-// " OR ($1 IS NULL AND $2 BETWEEN :fromData AND :thurDate)",
-// contactProperty.tideBeginDate(),
-// contactProperty.topiaCreateDate())
-//// query.addWhere(new StringBuilder("(").
-//// append(tideBeginDateProperty).
-//// append(" IS NOT NULL AND ").
-//// append(tideBeginDateProperty).
-//// append(" BETWEEN :fromDate AND :thruDate)").
-//// append(" OR (").
-//// append(tideBeginDateProperty).
-//// append(" IS NULL AND ").
-//// append(createDateProperty).
-//// append(" BETWEEN :fromDate AND :thruDate)").
-//// toString()
-// ).addParam("fromDate", period.getFromDate()).
-// addParam("thruDate", period.getThruDate());
-// }
-//
-//// String stateProperty =
-//// TopiaQuery.getProperty(contactAlias, Contact.STATE);
-//// String companyNameProperty =
-//// TopiaQuery.getProperty(companyProperty, Company.NAME);
-//
-// query.addGroup(companyProperty.name(), contactProperty.state()).
-// addOrder(companyProperty.name()).
-// setSelect(companyProperty.name(), contactProperty.state(), "COUNT(*)");
-
- WaoQueryHelper.ContactProperty contactProperty =
- WaoQueryHelper.newContactProperty();
-
- WaoQueryHelper.CompanyProperty companyProperty =
- contactProperty.observerProperty().companyProperty();
-
- TopiaQuery query = WaoQueryHelper.createQuery(contactProperty).
- addWhere(WaoQueryHelper.format(
- "$1 IS NULL OR $1 = :booleanTrue",
- contactProperty.validationProgram())
- ).addParam("booleanTrue", Boolean.TRUE);
-
- if (company != null) {
- query.addEquals(companyProperty.$alias(), company);
- }
-
- if (period != null) {
- // Contacts include in the period
- period.initDayOfMonthExtremities();
-
- query.addWhere(WaoQueryHelper.format(
- "($1 IS NOT NULL AND $1 BETWEEN :fromDate AND :thruDate)" +
- " OR ($1 IS NULL AND $2 BETWEEN :fromDate AND :thruDate)",
- contactProperty.tideBeginDate(),
- contactProperty.topiaCreateDate())
- ).addParam("fromDate", period.getFromDate()).
- addParam("thruDate", period.getThruDate());
- }
-
- query.addGroup(companyProperty.name(), contactProperty.state()).
- addOrder(companyProperty.name()).
- setSelect(companyProperty.name(), contactProperty.state(), "COUNT(*)");
-
- Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>();
-
- List<Object[]> queryResults = transaction.findByQuery(query);
-
- for (Object[] row : queryResults) {
- 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());
- }
-
- return results.values();
- }
-
@Override
public Collection<ContactStateStatistics> executeGetContactStateStatistics
(TopiaContext transaction, SamplingFilter filter)
@@ -749,72 +432,6 @@
return results.values();
}
- @Deprecated
- public Collection<ContactAverageReactivity>
- executeGetContactDataInputDateReactivity(TopiaContext transaction,
- Company company, PeriodDates period) throws TopiaException {
- // 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>();
-
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
-
- TopiaQuery query = dao.createQueryDoneContactsFromDate(null, period.getFromDate());
-
- String contactAlias = query.getMainAlias();
- String companyProperty =
- TopiaQuery.getProperty(contactAlias, Contact.OBSERVER, WaoUser.COMPANY);
- String companyNameProperty =
- TopiaQuery.getProperty(companyProperty, Company.NAME);
- String tideBeginDateProperty =
- TopiaQuery.getProperty(contactAlias, Contact.TIDE_BEGIN_DATE);
- String dataInputProperty =
- TopiaQuery.getProperty(contactAlias, Contact.DATA_INPUT_DATE);
-
- if (company != null) {
- query.addEquals(companyProperty, company);
- }
- //period.initDayOfMonthExtremities();
-
- if (period.getThruDate() != null) {
- query.addWhere(tideBeginDateProperty, Op.LE, period.getThruDate());
- }
-
- query.setSelect(companyNameProperty, dataInputProperty, tideBeginDateProperty);
-
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
-
- List<Object[]> res = transaction.findByQuery(query);
-
- for (Object[] row : res) {
- String rowCompanyName = (String)row[0];
- Date rowDataInputDate = (Date)row[1];
- Date rowTideBeginDate = (Date)row[2];
-
- int nbDays = DateUtil.getDifferenceInDays(rowTideBeginDate, rowDataInputDate);
-
- 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);
- }
- return results.values();
- }
-
@Override
public Collection<ContactAverageReactivity>
executeGetContactDataInputDateReactivity(TopiaContext transaction,
@@ -902,33 +519,6 @@
TopiaContext transaction, ContactFilter filter)
throws TopiaException {
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
-
-// WaoQueryHelper.ContactProperty contactProperty =
-// WaoQueryHelper.newContactProperty();
-//
-// WaoQueryHelper.BoatDistrictProperty boatDistrictProperty =
-// contactProperty.boatProperty().boatDistrictProperty();
-//
-// TopiaQuery query = dao.createQuery(contactProperty.$alias()).
-// // Only districts with no null coordinates
-// addNotNull(boatDistrictProperty.latitude()).
-// addNotNull(boatDistrictProperty.longitude()).
-// // Don't take contacts refused by company or program
-// addNullOr(contactProperty.validationCompany(), Op.NEQ, Boolean.FALSE).
-// addNullOr(contactProperty.validationProgram(), Op.NEQ, Boolean.FALSE);
-//
-// if (company != null) {
-// query.addEquals(contactProperty.observerProperty().company(), company);
-// }
-
-// WaoQueryBuilder builder = dao.createQueryWithBoatDistrictCoordinates(filter);
-//
-// ContactProperty contactProperty = builder.getContactProperty();
-//
-// BoatDistrictProperty boatDistrictProperty =
-// contactProperty.boatProperty().boatDistrictProperty();
-
WaoQueryBuilder builder = context.newQueryBuilder();
ContactProperty contactProperty = builder.initializeForContact();
@@ -1073,16 +663,15 @@
@Override
protected GlobalSynthesisResult executeGetGlobalSynthesisResult
- (TopiaContext transaction, Company company, PeriodDates period,
- SamplingFilter filter) throws Exception {
+ (TopiaContext transaction, SamplingFilter filter) throws Exception {
- Double value = 30.0;
+ Double value;
Map<SynthesisId, Double> indicatorValues = new HashMap<SynthesisId, Double>();
- // value = getIndicatorValueForDataSampling(transaction, samplingFilter);
+ value = getIndicatorValueForDataSampling(transaction, filter);
indicatorValues.put(SynthesisId.GRAPH_SAMPLING, value);
- // value = getIndicatorValueForBoarding(transaction, company, fromDate);
+ value = getIndicatorValueForBoarding(transaction, filter);
indicatorValues.put(SynthesisId.GRAPH_BOARDING, value);
value = getIndicatorValueForComplianceBoarding(transaction, filter);
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-21 14:51:31 UTC (rev 701)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-21 16:06:37 UTC (rev 702)
@@ -150,8 +150,7 @@
if (globalSynthesisResult == null) {
PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12);
Company company = !user.isAdmin() ? user.getCompany() : null;
- globalSynthesisResult = serviceSynthesis.getGlobalSynthesisResult(
- company, period, getFilter());
+ globalSynthesisResult = serviceSynthesis.getGlobalSynthesisResult(getFilter());
}
return globalSynthesisResult;
}
@@ -214,30 +213,18 @@
return this;
}
- /********************* DYNAMICAL GRAPH : DATA SAMPLING ********************/
+ /********************* FILTERS ********************************************/
@Persist
private SamplingFilter dataSamplingFilter;
-
- @InjectComponent
- private Zone filtersZone;
- @Persist
- private ChartType dataSamplingChartType;
-
- private boolean reset;
-
- private void initSamplingBlock() throws WaoException {
- initSelectFilters(true, false, true);
- }
-
@Override
public SamplingFilter getFilter() throws WaoException {
if (dataSamplingFilter == null) {
dataSamplingFilter = new SamplingFilterImpl();
if (!user.isAdmin()) {
dataSamplingFilter.setCompany(user.getCompany());
- }
+ }
}
return dataSamplingFilter;
}
@@ -258,6 +245,34 @@
return false;
}
+ void onSelectedFromReset() {
+ reset = true;
+ }
+
+ Object onSuccessFromFiltersForm() {
+ if (isEdited()) {
+ return filtersZone.getBody();
+ }
+ if (reset) {
+ dataSamplingFilter = null;
+ }
+ return this;
+ }
+
+ /********************* DYNAMICAL GRAPH : DATA SAMPLING ********************/
+
+ @InjectComponent
+ private Zone filtersZone;
+
+ @Persist
+ private ChartType dataSamplingChartType;
+
+ private boolean reset;
+
+ private void initSamplingBlock() throws WaoException {
+ initSelectFilters(true, false, true);
+ }
+
public JFreeChart getDataSamplingChart() throws WaoException {
List<SortedMap<Date, Integer>> res = serviceSynthesis.getDataSampling(getFilter());
Map<String, Map<?, Integer>> data = new HashMap<String, Map<?, Integer>>();
@@ -280,20 +295,6 @@
return dataSamplingChartType;
}
- void onSelectedFromReset() {
- reset = true;
- }
-
- Object onSuccessFromFiltersForm() {
- if (isEdited()) {
- return filtersZone.getBody();
- }
- if (reset) {
- dataSamplingFilter = null;
- }
- return this;
- }
-
/********************* STATIC GRAPH : BOARDING BOAT ***********************/
private BoardingResult boardingResult;
@@ -323,7 +324,7 @@
data.put("Navires", getBoardingResult().getData());
String title = "Sollicitations des navires depuis le " +
- getDateFormat().format(getFromDate());
+ getDateFormat().format(getFilter().getPeriod().getFromDate());
if (companyForBoarding != null) {
title += "\nSociété " + companyForBoarding.getName();
@@ -340,29 +341,8 @@
return boardingResult;
}
- public Company getCompanyForBoarding() {
- // Initialize only for an observer user. For admin, the company can
- // be null to search boardings for all companies.
- if (companyForBoarding == null && !user.isAdmin()) {
- companyForBoarding = user.getCompany();
- }
- if (log.isDebugEnabled()) {
- log.debug("company : " + companyForBoarding);
- }
- return companyForBoarding;
- }
+ /********************* INDICATOR : COMPLIANCE BOARDING ********************/
- public Date getFromDate() {
- return DateUtil.createDateAfterToday(0, -12, 0);
- }
-
- @Log
- void onSuccessFromFilterCompanyForBoarding() throws WaoException {
- companyForBoarding = getCompanySelectModel().findObject(companyIdForBoarding);
- }
-
- /********************* INDICATOR : NON COMPLIANCE BOARDING ****************/
-
private Map<String, Double> complianceBoarding;
@Property
@@ -382,7 +362,6 @@
complianceBoarding =
serviceSynthesis.getComplianceBoardingIndicator(getFilter());
}
-
return complianceBoarding;
}
@@ -401,9 +380,6 @@
private Collection<ContactStateStatistics> contactStateStatistics;
- @Persist
- private PeriodDates periodForContactStates;
-
@Property
private ContactStateStatistics contactStateStats;
@@ -436,13 +412,6 @@
return contactStateStatistics;
}
- public PeriodDates getPeriodForContactStates() {
- if (periodForContactStates == null) {
- periodForContactStates = PeriodDates.createMonthsPeriodFromToday(-12);
- }
- return periodForContactStates;
- }
-
/**
* Get the value for current contactStateStats in table row (by company)
* and current contactState in table column.
@@ -471,9 +440,6 @@
private Collection<ContactAverageReactivity> allegroReactivity;
- @Persist
- private PeriodDates periodForAllegroReactivity;
-
@Property
private ContactAverageReactivity allegroReactivityEntry;
@@ -487,14 +453,10 @@
return allegroReactivity;
}
- public PeriodDates getPeriodForAllegroReactivity() {
- if (periodForAllegroReactivity == null) {
- periodForAllegroReactivity = PeriodDates.createMonthsPeriodFromToday(-3);
- }
- return periodForAllegroReactivity;
- }
-
public Double getAllegroReactivityValue() throws WaoException {
+
+ // FIXME bleny 20101021 in this case, what occurs in indicator ?
+
if (!getAllegroReactivity().isEmpty()) {
ContactAverageReactivity entry = (ContactAverageReactivity)
CollectionUtils.get(getAllegroReactivity(), 0);
@@ -513,4 +475,4 @@
return "";
}
-}
+}
\ No newline at end of file
Modified: trunk/wao-ui/src/main/webapp/Synthesis.tml
===================================================================
--- trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-21 14:51:31 UTC (rev 701)
+++ trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-21 16:06:37 UTC (rev 702)
@@ -86,6 +86,8 @@
</div>
</fieldset>
+ <div class="mtop30" />
+
<!-- MENU : delegator -->
<div class="clearfix">
<div class="fleft" id="so-synthesis-menu">
@@ -158,14 +160,6 @@
<br />
<p>Ces résultats ne concernent que les lignes du plan d'échantillonnage<br /> ayant une durée moyenne de marées inférieure ou égale à 48h</p>
<br />
- <t:if t:test="user.admin">
- <form t:type="form" t:id="filterCompanyForBoarding">
- <t:label t:for="companyForBoarding" />:
- <input t:type="select" t:id="companyForBoarding" t:model="companySelectModel" value="companyIdForBoarding"/>
- <input t:type="submit" class="ico search-32px" t:id="searchForBoarding" value="Search"
- title="Création du graphique pour cette société"/>
- </form>
- </t:if>
<t:chart t:width="600" t:height="400" t:chart="boardingBoatsChart" />
<t:if t:test="boardingResult.maxBoardingBoat">
<p>
@@ -235,17 +229,6 @@
ceux qui ont été refusés par le programme.
</p>
<br />
- <p>
- <form t:type="form" t:id="filterPeriodForContactStates">
- <label>Période : </label>
- <t:label t:for="periodBeginForContactStates" />
- <input t:type="datefield" class="width70" t:id="periodBeginForContactStates" t:value="periodForContactStates.fromDate" t:format="MM/yyyy" t:validate="required"/>
- <t:label t:for="periodEndForContactStates" />
- <input t:type="datefield" class="width70" t:id="periodEndForContactStates" t:value="periodForContactStates.thruDate" t:format="MM/yyyy" t:validate="required" />
- <input t:type="submit" class="ico search-32px" t:id="searchForContactStates" value="Search"
- title="Rechercher les états des contacts sur cette période"/>
- </form>
- </p>
<table class="t-data-grid">
<thead>
<tr>
@@ -288,17 +271,6 @@
Ce résultat est une moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de la marée des contacts validés.
</p>
<br />
- <p>
- <form t:type="form" t:id="filterPeriodForAllegroReactivity">
- <label>Période : </label>
- <t:label t:for="periodBeginForAllegroReactivity" />
- <input t:type="datefield" class="width70" t:id="periodBeginForAllegroReactivity" t:value="periodForAllegroReactivity.fromDate" />
- <t:label t:for="periodEndForAllegroReactivity" />
- <input t:type="datefield" class="width70" t:id="periodEndForAllegroReactivity" t:value="periodForAllegroReactivity.thruDate" />
- <input t:type="submit" class="ico search-32px" t:id="searchForAllegroReactivity" value="Search"
- title="Calcul de la moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de marée sur la période sélectionnée"/>
- </form>
- </p>
<t:if t:test="user.admin">
<table class="t-data-grid">
<thead>
1
0
[Suiviobsmer-commits] r701 - in trunk: wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources/i18n wao-business/src/main/xmi wao-ui/src/main/java/fr/ifremer/wao/ui/pages wao-ui/src/main/webapp
by bleny@users.labs.libre-entreprise.org 21 Oct '10
by bleny@users.labs.libre-entreprise.org 21 Oct '10
21 Oct '10
Author: bleny
Date: 2010-10-21 14:51:31 +0000 (Thu, 21 Oct 2010)
New Revision: 701
Log:
added filter on all synthesis ; saving before refactor (break the build)
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
trunk/wao-ui/src/main/webapp/Synthesis.tml
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-10-21 10:21:30 UTC (rev 700)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-10-21 14:51:31 UTC (rev 701)
@@ -175,22 +175,21 @@
* results since this date. For observer view, only results for his
* company is needed.
*
- * @param company the company used to filter results
- * @param fromDate the since date used to filter contact results
* @return a BoardingResult which contains the number of boats for boardings
* from 1 to {@code MAX_BOARDINGS}, the boat with the max boarding and its
* value.
* @throws WaoException
*/
- @Override
+ @Deprecated
public BoardingResult executeGetBoardingBoats(TopiaContext transaction,
- Company company, Date fromDate)
- throws TopiaException {
+ Company company,
+ Date fromDate)
+ throws TopiaException {
Map<String, Integer> map = new LinkedHashMap<String, Integer>();
BoardingResult result = new BoardingResultImpl();
result.setData(map);
- // Initialiaze max boardings and its max key value
+ // Initialize max boardings and its max key value
final int maxBoardings = 12;
final String maxBoardingsKey = maxBoardings + " +";
@@ -201,13 +200,11 @@
}
map.put(maxBoardingsKey, 0);
- ContactDAO dao =
- WaoDAOHelper.getContactDAO(transaction);
+ 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);
+ TopiaQuery query = dao.createQueryDoneContactsFromDate(null, fromDate);
String contact = query.getMainAlias();
String sampleRow = contact + "." + Contact.SAMPLE_ROW;
@@ -260,7 +257,83 @@
return result;
}
+ @Override
+ public BoardingResult executeGetBoardingBoats(TopiaContext transaction,
+ SamplingFilter filter)
+ throws TopiaException {
+ Map<String, Integer> map = new LinkedHashMap<String, Integer>();
+ BoardingResult result = new BoardingResultImpl();
+ result.setData(map);
+ // Initialize 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);
+
+ // 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
+ WaoQueryBuilder builder = context.newQueryBuilder();
+ ContactProperty contactProperty = builder.initializeForContact();
+ TopiaQuery query = builder.applySamplingFilter(filter).
+ addEquals(contactProperty.state(), ContactState.BOARDING_DONE.ordinal()).
+ addEquals(contactProperty.validationCompany(), Boolean.TRUE).
+ addNullOr(contactProperty.validationProgram(), Op.EQ, Boolean.TRUE);
+
+ String contact = query.getMainAlias();
+ String sampleRow = contact + "." + Contact.SAMPLE_ROW;
+
+ // Only for sampleRows with averageTideTime less or equals to 2 days
+ query.addWhere(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(*)");
+
+ if (log.isTraceEnabled()) {
+ log.trace("Exec query : " + query);
+ }
+
+ List<Map<String, Object>> nbBoardingsByBoat = transaction.findByQuery(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);
+ }
+
+ // 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;
+ }
+
+
+ @Deprecated
public Map<String, Double> executeGetNonComplianceBoardingIndicator(
TopiaContext transaction, Company company) throws TopiaException {
@@ -353,7 +426,104 @@
return results;
}
- @Override
+ public Map<String, Double> executeGetNonComplianceBoardingIndicator(
+ TopiaContext transaction, SamplingFilter filter) throws TopiaException {
+
+ // 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>();
+
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
+
+
+ WaoQueryBuilder builder = context.newQueryBuilder();
+ ContactProperty contactProperty = builder.initializeForContact();
+ TopiaQuery query = builder.applySamplingFilter(filter).
+ addEquals(contactProperty.state(), ContactState.BOARDING_DONE.ordinal()).
+ addEquals(contactProperty.validationCompany(), Boolean.TRUE).
+ addNullOr(contactProperty.validationProgram(), Op.EQ, Boolean.TRUE);
+
+
+ // Only for done contacts with no constraint
+ // TopiaQuery query =
+ // dao.createQueryDoneContactsFromDate(null, null);
+
+ // Prepare properties for query
+ String contactAlias = query.getMainAlias();
+ String sampleRowProperty =
+ TopiaQuery.getProperty(contactAlias, Contact.SAMPLE_ROW);
+ String nbObservantsRealProperty =
+ TopiaQuery.getProperty(contactAlias, Contact.NB_OBSERVANTS);
+
+ String sampleRowEndProperty =
+ TopiaQuery.getProperty(sampleRowProperty, SampleRow.PERIOD_END);
+ String companyProperty =
+ TopiaQuery.getProperty(sampleRowProperty, SampleRow.COMPANY);
+ String nbObservantsExpectedProperty =
+ TopiaQuery.getProperty(sampleRowProperty, SampleRow.NB_OBSERVANTS);
+
+ String companyNameProperty =
+ TopiaQuery.getProperty(companyProperty, Company.NAME);
+
+ // Only for unfinished sampleRows
+ query.addWhere(sampleRowEndProperty, Op.GE, context.getCurrentDate());
+
+ // Prepare results
+ query.setSelect(companyNameProperty, "COUNT(*)").
+ addGroup(companyNameProperty);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query for total : " + query);
+ }
+
+ List<Object[]> totalResults = transaction.findByQuery(query);
+
+ // Use the same query and add the constraint of non compliance
+ //i.e. nbObservantsReal (contact) < nbObservantsExpected (sampleRow)
+// query.addWhere(contact + "." + Contact.NB_OBSERVANTS + " < " +
+// sampleRow + "." + SampleRow.NB_OBSERVANTS);
+ query.addWhere(new StringBuilder(nbObservantsRealProperty).
+ append(" < ").
+ append(nbObservantsExpectedProperty).
+ toString()
+ );
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query for result : " + query);
+ }
+
+ List<Object[]> diffResults = transaction.findByQuery(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());
+ }
+
+ // 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;
+ }
+
+ @Deprecated
protected Map<String, Double> executeGetComplianceBoardingIndicator(
TopiaContext transaction, Company company) throws Exception {
// here, we need compliance, so we get non-compliance values
@@ -372,6 +542,24 @@
}
@Override
+ protected Map<String, Double> executeGetComplianceBoardingIndicator(
+ TopiaContext transaction, SamplingFilter filter) throws Exception {
+ // here, we need compliance, so we get non-compliance values
+ // and we make the operation to switch
+
+ Map<String, Double> nonCompliances = executeGetNonComplianceBoardingIndicator(transaction, filter);
+ Map<String, Double> compliances = new HashMap<String, Double>();
+
+ // make the switch, fill compliances with data from nonCompliances
+ for (Map.Entry<String, Double> nonCompliance : nonCompliances.entrySet()) {
+ Double compliance = 1.0 - nonCompliance.getValue();
+ compliances.put(nonCompliance.getKey(), compliance);
+ }
+
+ return compliances;
+ }
+
+ @Deprecated
public Collection<ContactStateStatistics> executeGetContactStateStatistics(
TopiaContext transaction, Company company, PeriodDates period)
throws TopiaException {
@@ -502,7 +690,67 @@
}
@Override
- public Collection<ContactAverageReactivity>
+ public Collection<ContactStateStatistics> executeGetContactStateStatistics
+ (TopiaContext transaction, SamplingFilter filter)
+ throws TopiaException {
+
+ WaoQueryBuilder builder = context.newQueryBuilder();
+ ContactProperty contactProperty = builder.initializeForContact();
+ TopiaQuery query = builder.applySamplingFilter(filter).
+ addNullOr(contactProperty.validationProgram(), Op.EQ, Boolean.TRUE);
+
+ WaoQueryHelper.CompanyProperty companyProperty =
+ contactProperty.observerProperty().companyProperty();
+
+ Company company = filter.getCompany();
+ if (company != null) {
+ query.addEquals(companyProperty.$alias(), company);
+ }
+
+ PeriodDates period = filter.getPeriod();
+ if (period != null) {
+ // Contacts include in the period
+ period.initDayOfMonthExtremities();
+
+ query.addWhere(WaoQueryHelper.format(
+ "($1 IS NOT NULL AND $1 BETWEEN :fromDate AND :thruDate)" +
+ " OR ($1 IS NULL AND $2 BETWEEN :fromDate AND :thruDate)",
+ contactProperty.tideBeginDate(),
+ contactProperty.topiaCreateDate())
+ ).addParam("fromDate", period.getFromDate()).
+ addParam("thruDate", period.getThruDate());
+ }
+
+ query.addGroup(companyProperty.name(), contactProperty.state()).
+ addOrder(companyProperty.name()).
+ setSelect(companyProperty.name(), contactProperty.state(), "COUNT(*)");
+
+ Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>();
+
+ List<Object[]> queryResults = transaction.findByQuery(query);
+
+ for (Object[] row : queryResults) {
+ 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());
+ }
+
+ return results.values();
+ }
+
+ @Deprecated
+ public Collection<ContactAverageReactivity>
executeGetContactDataInputDateReactivity(TopiaContext transaction,
Company company, PeriodDates period) throws TopiaException {
// Carefull with results, the company may not be present in the map :
@@ -568,6 +816,88 @@
}
@Override
+ public Collection<ContactAverageReactivity>
+ executeGetContactDataInputDateReactivity(TopiaContext transaction,
+ SamplingFilter filter) throws TopiaException {
+
+ if (filter.getPeriod() == null) {
+ filter.setPeriod(PeriodDates.createMonthsPeriodFromToday(-3));
+ }
+
+
+ WaoQueryBuilder builder = context.newQueryBuilder();
+ ContactProperty contactProperty = builder.initializeForContact();
+ TopiaQuery query = builder.applySamplingFilter(filter).
+ addEquals(contactProperty.state(), ContactState.BOARDING_DONE.ordinal()).
+ addEquals(contactProperty.validationCompany(), Boolean.TRUE).
+ addNullOr(contactProperty.validationProgram(), Op.EQ, Boolean.TRUE);
+
+
+ // 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>();
+
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
+
+ //TopiaQuery query = dao.createQueryDoneContactsFromDate(null, period.getFromDate());
+
+ String contactAlias = query.getMainAlias();
+ String companyProperty =
+ TopiaQuery.getProperty(contactAlias, Contact.OBSERVER, WaoUser.COMPANY);
+ String companyNameProperty =
+ TopiaQuery.getProperty(companyProperty, Company.NAME);
+ String tideBeginDateProperty =
+ TopiaQuery.getProperty(contactAlias, Contact.TIDE_BEGIN_DATE);
+ String dataInputProperty =
+ TopiaQuery.getProperty(contactAlias, Contact.DATA_INPUT_DATE);
+
+ Company company = filter.getCompany();
+ if (company != null) {
+ query.addEquals(companyProperty, company);
+ }
+ //period.initDayOfMonthExtremities();
+
+ PeriodDates period = filter.getPeriod();
+ if (period.getThruDate() != null) {
+ query.addWhere(tideBeginDateProperty, Op.LE, period.getThruDate());
+ }
+
+ query.setSelect(companyNameProperty, dataInputProperty, tideBeginDateProperty);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
+
+ List<Object[]> res = transaction.findByQuery(query);
+
+ for (Object[] row : res) {
+ String rowCompanyName = (String)row[0];
+ Date rowDataInputDate = (Date)row[1];
+ Date rowTideBeginDate = (Date)row[2];
+
+ int nbDays = DateUtil.getDifferenceInDays(rowTideBeginDate, rowDataInputDate);
+
+ 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);
+ }
+ return results.values();
+ }
+
+ @Override
public Map<String, PieChartData> executeGetContactPieChartDataByBoatDistrict(
TopiaContext transaction, ContactFilter filter)
throws TopiaException {
@@ -652,6 +982,16 @@
return results;
}
+ @Override
+ protected Map<Company, Double> executeGetDataReliability
+ (TopiaContext transaction, SamplingFilter filter) throws Exception {
+
+ log.debug("period " + filter.getPeriod());
+
+ return null;
+
+ }
+
protected Double getIndicatorValueForDataSampling
(TopiaContext transaction, SamplingFilter filter) {
@@ -690,9 +1030,9 @@
}
protected Double getIndicatorValueForBoarding
- (TopiaContext transaction, Company company, Date fromDate) {
+ (TopiaContext transaction, SamplingFilter filter) {
- BoardingResult boardingResult = getBoardingBoats(company, fromDate);
+ BoardingResult boardingResult = getBoardingBoats(filter);
int numberOfBoatWithOneBoarding = boardingResult.getData().get("1");
int totalNumberOfBoarding = 0;
@@ -705,8 +1045,8 @@
}
protected Double getIndicatorValueForComplianceBoarding
- (TopiaContext transaction, Company company) {
- Map<String, Double> complianceBoarding = getComplianceBoardingIndicator(company);
+ (TopiaContext transaction, SamplingFilter filter) {
+ Map<String, Double> complianceBoarding = getComplianceBoardingIndicator(filter);
double total = 0.0;
int numberOfCompanies = complianceBoarding.size();
for (Double compliance : complianceBoarding.values()) {
@@ -717,8 +1057,9 @@
}
protected Double getIndicatorValueForAllegroReactivity
- (TopiaContext transaction, Company company, PeriodDates periodDates) {
- Collection<ContactAverageReactivity> allegroReactivity = getContactDataInputDateReactivity(company, periodDates);
+ (TopiaContext transaction, SamplingFilter filter) {
+ Collection<ContactAverageReactivity> allegroReactivity =
+ getContactDataInputDateReactivity(filter);
double sumAverages = 0.0;
for (ContactAverageReactivity reactivity : allegroReactivity) {
@@ -732,8 +1073,8 @@
@Override
protected GlobalSynthesisResult executeGetGlobalSynthesisResult
- (TopiaContext transaction, Company company, PeriodDates period)
- throws Exception {
+ (TopiaContext transaction, Company company, PeriodDates period,
+ SamplingFilter filter) throws Exception {
Double value = 30.0;
Map<SynthesisId, Double> indicatorValues = new HashMap<SynthesisId, Double>();
@@ -744,10 +1085,10 @@
// value = getIndicatorValueForBoarding(transaction, company, fromDate);
indicatorValues.put(SynthesisId.GRAPH_BOARDING, value);
- value = getIndicatorValueForComplianceBoarding(transaction, company);
+ value = getIndicatorValueForComplianceBoarding(transaction, filter);
indicatorValues.put(SynthesisId.IND_COMPLIANCE_BOARDING, value);
- value = getIndicatorValueForAllegroReactivity(transaction, company, period);
+ value = getIndicatorValueForAllegroReactivity(transaction, filter);
indicatorValues.put(SynthesisId.IND_ALLEGRO_REACTIVITY, value);
// add data reliability indicator here
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-10-21 10:21:30 UTC (rev 700)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-10-21 14:51:31 UTC (rev 701)
@@ -79,6 +79,7 @@
wao.error.serviceSynthesis.getContactPieChartData=
wao.error.serviceSynthesis.getContactPieChartDataByBoatDistrict=
wao.error.serviceSynthesis.getContactStateStatistics=
+wao.error.serviceSynthesis.getDataReliability=
wao.error.serviceSynthesis.getDataSampling=
wao.error.serviceSynthesis.getGlobalSynthesisParameters=Unable to get data about global synthesis parameters
wao.error.serviceSynthesis.getGlobalSynthesisResult=
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-10-21 10:21:30 UTC (rev 700)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-10-21 14:51:31 UTC (rev 701)
@@ -78,6 +78,7 @@
wao.error.serviceSynthesis.getContactPieChartData=
wao.error.serviceSynthesis.getContactPieChartDataByBoatDistrict=
wao.error.serviceSynthesis.getContactStateStatistics=Impossible de r\u00E9cup\u00E9rer les statistiques sur les \u00E9tats des contacts
+wao.error.serviceSynthesis.getDataReliability=
wao.error.serviceSynthesis.getDataSampling=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es pour le graphique dynamique des efforts de mar\u00E9es
wao.error.serviceSynthesis.getGlobalSynthesisParameters=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es concernant les indicateurs pour la synth\u00E8se globale
wao.error.serviceSynthesis.getGlobalSynthesisResult=
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-21 10:21:30 UTC (rev 700)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-21 14:51:31 UTC (rev 701)
@@ -151,7 +151,7 @@
PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12);
Company company = !user.isAdmin() ? user.getCompany() : null;
globalSynthesisResult = serviceSynthesis.getGlobalSynthesisResult(
- company, period);
+ company, period, getFilter());
}
return globalSynthesisResult;
}
@@ -294,7 +294,7 @@
return this;
}
- /********************* STATIC GRAPH : BOARDINGBOAT ************************/
+ /********************* STATIC GRAPH : BOARDING BOAT ***********************/
private BoardingResult boardingResult;
@@ -335,8 +335,7 @@
public BoardingResult getBoardingResult() throws WaoException {
if (boardingResult == null) {
- boardingResult = serviceSynthesis.getBoardingBoats(
- getCompanyForBoarding(), getFromDate());
+ boardingResult = serviceSynthesis.getBoardingBoats(getFilter());
}
return boardingResult;
}
@@ -381,7 +380,7 @@
if (complianceBoarding == null) {
Company company = !user.isAdmin() ? user.getCompany() : null;
complianceBoarding =
- serviceSynthesis.getComplianceBoardingIndicator(company);
+ serviceSynthesis.getComplianceBoardingIndicator(getFilter());
}
return complianceBoarding;
@@ -432,7 +431,7 @@
if (contactStateStatistics == null) {
Company company = !user.isAdmin() ? user.getCompany() : null;
contactStateStatistics =
- serviceSynthesis.getContactStateStatistics(company, getPeriodForContactStates());
+ serviceSynthesis.getContactStateStatistics(getFilter());
}
return contactStateStatistics;
}
@@ -483,8 +482,7 @@
if (allegroReactivity == null) {
Company company = !user.isAdmin() ? user.getCompany() : null;
allegroReactivity =
- serviceSynthesis.getContactDataInputDateReactivity(company,
- getPeriodForAllegroReactivity());
+ serviceSynthesis.getContactDataInputDateReactivity(getFilter());
}
return allegroReactivity;
}
Modified: trunk/wao-ui/src/main/webapp/Synthesis.tml
===================================================================
--- trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-21 10:21:30 UTC (rev 700)
+++ trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-21 14:51:31 UTC (rev 701)
@@ -30,6 +30,62 @@
<t:layout t:pageTitle="Synthèse et indicateurs" t:contentId="so-synthesis"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+ <fieldset>
+ <legend>Filtres</legend>
+ <div t:type="zone" t:id="filtersZone" class="so-filters-form" id="so-datasampling-filters">
+ <!--<div t:type="zone" t:id="dataSamplingFiltersZone" t:update="show" id="so-datasampling-filters">-->
+ <form t:type="form" t:id="filtersForm" t:zone="so-datasampling-filters">
+ <t:errors />
+ <div class="t-beaneditor">
+ <div class="filterRow">
+ <label>Période: </label>
+ <t:label t:for="periodBegin" />:
+ <input t:type="datefield" class="width70" t:id="periodBegin" t:value="period.fromDate" t:format="MM/yyyy" t:validate="required"/>
+ <t:label t:for="periodEnd" />:
+ <input t:type="datefield" class="width70" t:id="periodEnd" t:value="period.thruDate" t:format="MM/yyyy" t:validate="required"/>
+ </div>
+ <div>
+ <t:if t:test="user.admin">
+ <t:label t:for="company" />:
+ <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId"/>
+ <input t:type="submit" class="ico22px refresh" t:id="refreshByCompany" value="Refresh"
+ title="Rafraîchir les filtres en fonction de la société sélectionnée"/>
+ </t:if>
+ <t:label t:for="programName" />:
+ <select t:type="select" t:id="programName" t:model="programSelectModel" value="filter.programName" />
+ <input t:type="submit" class="ico22px refresh" t:id="refreshByProgram" value="Refresh"
+ title="Rafraîchir les secteurs de pêche et les métiers en fonction du programme sélectionné"/>
+ </div>
+ <div class="filterRow" t:type="zone" t:id="sampleRowZone" t:update="show">
+ <t:label t:for="facadeName" />:
+ <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="filter.facadeName" />
+ <input t:type="submit" class="ico22px refresh" t:id="refreshByFacade" value="Refresh"
+ title="Rafraîchir les zones et les métiers en fonction de la façade sélectionnée"/>
+ <t:label t:for="sectorName" />:
+ <select t:type="select" t:id="sectorName" t:model="sectorSelectModel" value="filter.sectorName" />
+ <input t:type="submit" class="ico22px refresh" t:id="refreshBySector" value="Refresh"
+ title="Rafraîchir les métiers en fonction de la zone sélectionnée"/>
+ <t:label t:for="sampleRow" />:
+ <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" />
+
+ <!--<t:label t:for="program" />:
+ <input t:type="select" t:id="program" t:model="programSelectModel" value="programId" />-->
+ </div>
+ <div class="filterRow">
+ <input t:type="checkbox" t:id="estimatedTides" value="filter.estimatedTides" />
+ <t:label t:for="estimatedTides" title="L'effort d'observations estimé équivaut au nombre de contacts validés ou non par la société. Les contacts refusés par le programme ne sont pas pris en compte" />
+ </div>
+ <div class="t-beaneditor-row aright">
+ <input t:type="submit" class="ico search-32px" t:id="search" value="Search" title="Création du graphique en fonction des filtres saisies"/>
+ <input t:type="submit" class="ico undo" t:id="reset" value="Reset" title="Remettre les filtres par défaut" />
+ </div>
+ </div>
+ </form>
+ <!--</div>-->
+ </div>
+ </fieldset>
+
<!-- MENU : delegator -->
<div class="clearfix">
<div class="fleft" id="so-synthesis-menu">
@@ -75,60 +131,6 @@
<t:block t:id="ind0">
<div class="acenter" id="so-datasampling">
<h2>Données des marées (réalisé / planifié)</h2>
- <fieldset>
- <legend>Filtres</legend>
- <div t:type="zone" t:id="filtersZone" class="so-filters-form" id="so-datasampling-filters">
- <!--<div t:type="zone" t:id="dataSamplingFiltersZone" t:update="show" id="so-datasampling-filters">-->
- <form t:type="form" t:id="filtersForm" t:zone="so-datasampling-filters">
- <t:errors />
- <div class="t-beaneditor">
- <div class="filterRow">
- <label>Période: </label>
- <t:label t:for="periodBegin" />:
- <input t:type="datefield" class="width70" t:id="periodBegin" t:value="period.fromDate" t:format="MM/yyyy" t:validate="required"/>
- <t:label t:for="periodEnd" />:
- <input t:type="datefield" class="width70" t:id="periodEnd" t:value="period.thruDate" t:format="MM/yyyy" t:validate="required"/>
- </div>
- <div>
- <t:if t:test="user.admin">
- <t:label t:for="company" />:
- <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId"/>
- <input t:type="submit" class="ico22px refresh" t:id="refreshByCompany" value="Refresh"
- title="Rafraîchir les filtres en fonction de la société sélectionnée"/>
- </t:if>
- <t:label t:for="programName" />:
- <select t:type="select" t:id="programName" t:model="programSelectModel" value="filter.programName" />
- <input t:type="submit" class="ico22px refresh" t:id="refreshByProgram" value="Refresh"
- title="Rafraîchir les secteurs de pêche et les métiers en fonction du programme sélectionné"/>
- </div>
- <div class="filterRow" t:type="zone" t:id="sampleRowZone" t:update="show">
- <t:label t:for="facadeName" />:
- <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="filter.facadeName" />
- <input t:type="submit" class="ico22px refresh" t:id="refreshByFacade" value="Refresh"
- title="Rafraîchir les zones et les métiers en fonction de la façade sélectionnée"/>
- <t:label t:for="sectorName" />:
- <select t:type="select" t:id="sectorName" t:model="sectorSelectModel" value="filter.sectorName" />
- <input t:type="submit" class="ico22px refresh" t:id="refreshBySector" value="Refresh"
- title="Rafraîchir les métiers en fonction de la zone sélectionnée"/>
- <t:label t:for="sampleRow" />:
- <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" />
-
- <!--<t:label t:for="program" />:
- <input t:type="select" t:id="program" t:model="programSelectModel" value="programId" />-->
- </div>
- <div class="filterRow">
- <input t:type="checkbox" t:id="estimatedTides" value="filter.estimatedTides" />
- <t:label t:for="estimatedTides" title="L'effort d'observations estimé équivaut au nombre de contacts validés ou non par la société. Les contacts refusés par le programme ne sont pas pris en compte" />
- </div>
- <div class="t-beaneditor-row aright">
- <input t:type="submit" class="ico search-32px" t:id="search" value="Search" title="Création du graphique en fonction des filtres saisies"/>
- <input t:type="submit" class="ico undo" t:id="reset" value="Reset" title="Remettre les filtres par défaut" />
- </div>
- </div>
- </form>
- <!--</div>-->
- </div>
- </fieldset>
<p class="so-chart-types">
<a t:type="actionlink" t:context="[actionChartType,'BAR']">
<img src="${asset:context:}/img/chart-bar.png" alt="Diagramme en bâtons" title="Diagramme en bâtons" />
@@ -180,7 +182,7 @@
<!-- IND1 : COMPLIANCE_BOARDING -->
<t:block t:id="ind2">
<div class="ind-table acenter" id="so-noncomplianceboarding">
- <h2>Non respect du nombre d'observateurs embarqués</h2>
+ <h2>Respect du nombre d'observateurs embarqués</h2>
<br />
<t:if t:test="user.admin">
<p>
1
0
[Suiviobsmer-commits] r700 - trunk/wao-business/src/main/java/fr/ifremer/wao
by bleny@users.labs.libre-entreprise.org 21 Oct '10
by bleny@users.labs.libre-entreprise.org 21 Oct '10
21 Oct '10
Author: bleny
Date: 2010-10-21 10:21:30 +0000 (Thu, 21 Oct 2010)
New Revision: 700
Log:
include default values for the coefficient in migration
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/PostgresMigrationCallback.java
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/PostgresMigrationCallback.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/PostgresMigrationCallback.java 2010-10-20 15:04:23 UTC (rev 699)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/PostgresMigrationCallback.java 2010-10-21 10:21:30 UTC (rev 700)
@@ -330,19 +330,24 @@
String insertIntoIndicator = "INSERT INTO Indicator (topiaId, topiaVersion, topiaCreateDate, indicatorId, coefficient) "
+ "VALUES ('%s', %s, %s, %s, %s);";
- SynthesisId[] synthesisIds = { SynthesisId.GRAPH_SAMPLING,
- SynthesisId.IND_COMPLIANCE_BOARDING,
- SynthesisId.GRAPH_BOARDING,
- SynthesisId.IND_ALLEGRO_REACTIVITY,
- SynthesisId.IND_DATA_RELIABILITY };
+ // all the criterias for global synthesis + default coefficient values
+ Map<SynthesisId, Double> synthesisIds = new HashMap<SynthesisId, Double>();
+ synthesisIds.put(SynthesisId.GRAPH_SAMPLING, 0.35);
+ synthesisIds.put(SynthesisId.IND_COMPLIANCE_BOARDING, 0.1);
+ synthesisIds.put(SynthesisId.GRAPH_BOARDING, 0.2);
+ synthesisIds.put(SynthesisId.IND_ALLEGRO_REACTIVITY, 0.15);
+ synthesisIds.put(SynthesisId.IND_DATA_RELIABILITY, 0.2);
- double coefficientValue = 1.0;
-
Map <SynthesisId, String> indicatorsTopiaIds = new HashMap<SynthesisId, String>();
- for (SynthesisId synthesisId : synthesisIds) {
- String topiaId = topiaIndicatorIdPrefix + synthesisId.ordinal();
+ for (Map.Entry<SynthesisId, Double> indicatorAndCoeff : synthesisIds.entrySet()) {
+
+ SynthesisId synthesisId = indicatorAndCoeff.getKey();
+ Double coefficientValue = indicatorAndCoeff.getValue();
+
+ String topiaId = topiaIndicatorIdPrefix + indicatorAndCoeff.getKey().ordinal();
indicatorsTopiaIds.put(synthesisId, topiaId);
+
queries.add(String.format(insertIntoIndicator, topiaId,
topiaVersion,
topiaCreateDateValue,
1
0
[Suiviobsmer-commits] r699 - in trunk: wao-business/src/main/java/fr/ifremer/wao/bean wao-business/src/main/java/fr/ifremer/wao/service wao-ui/src/main/java/fr/ifremer/wao/ui/pages
by bleny@users.labs.libre-entreprise.org 20 Oct '10
by bleny@users.labs.libre-entreprise.org 20 Oct '10
20 Oct '10
Author: bleny
Date: 2010-10-20 15:04:23 +0000 (Wed, 20 Oct 2010)
New Revision: 699
Log:
removing business code from UI
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java 2010-10-20 13:01:31 UTC (rev 698)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java 2010-10-20 15:04:23 UTC (rev 699)
@@ -2,12 +2,17 @@
import fr.ifremer.wao.entity.Indicator;
import fr.ifremer.wao.entity.IndicatorLevel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
public class GlobalSynthesisResultImpl extends GlobalSynthesisResult {
+ private static final Logger log =
+ LoggerFactory.getLogger(GlobalSynthesisResultImpl.class);
+
protected Map<SynthesisId, Double> values;
protected List<Indicator> indicators;
@@ -32,8 +37,15 @@
@Override
public IndicatorLevel getLevelForIndicator(SynthesisId synthesisId) {
+ if (log.isDebugEnabled()) {
+ log.debug("looking for value of " + synthesisId);
+ for (Map.Entry<SynthesisId, Double> value : values.entrySet()) {
+ log.debug("in values : " + value.getKey() + " -> " + value.getValue());
+ }
+ }
+ Double value = values.get(synthesisId);
+
Indicator indicator = findIndicator(synthesisId);
- Double value = values.get(indicator);
IndicatorLevel result = indicator.getLevelForValue(value);
return result;
}
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-10-20 13:01:31 UTC (rev 698)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-10-20 15:04:23 UTC (rev 699)
@@ -735,8 +735,6 @@
(TopiaContext transaction, Company company, PeriodDates period)
throws Exception {
- GlobalSynthesisResultImpl result = new GlobalSynthesisResultImpl();
-
Double value = 30.0;
Map<SynthesisId, Double> indicatorValues = new HashMap<SynthesisId, Double>();
@@ -755,9 +753,10 @@
// add data reliability indicator here
+ List<Indicator> indicators = executeGetGlobalSynthesisParameters(transaction);
+ GlobalSynthesisResultImpl result = new GlobalSynthesisResultImpl();
result.setIndicatorValues(indicatorValues);
- List<Indicator> indicators = executeGetGlobalSynthesisParameters(transaction);
result.setIndicators(indicators);
return result;
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-20 13:01:31 UTC (rev 698)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-20 15:04:23 UTC (rev 699)
@@ -24,6 +24,7 @@
package fr.ifremer.wao.ui.pages;
+import fr.ifremer.wao.bean.GlobalSynthesisResult;
import fr.ifremer.wao.bean.SynthesisId;
import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.BoardingResult;
@@ -143,6 +144,18 @@
return globalSynthesisParameters;
}
+ private GlobalSynthesisResult globalSynthesisResult;
+
+ public GlobalSynthesisResult getGlobalSynthesisResult() {
+ if (globalSynthesisResult == null) {
+ PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12);
+ Company company = !user.isAdmin() ? user.getCompany() : null;
+ globalSynthesisResult = serviceSynthesis.getGlobalSynthesisResult(
+ company, period);
+ }
+ return globalSynthesisResult;
+ }
+
/** update activeIndicator to the indicator corresponding to activeSynthesis.
* @return the value of activeIndicator field, after modification
*/
@@ -154,6 +167,7 @@
}
public IndicatorLevel getActiveIndicatorLevel() {
+ activeIndicatorLevel = getGlobalSynthesisResult().getLevelForIndicator(getActiveSynthesis());
return activeIndicatorLevel;
}
@@ -252,45 +266,6 @@
getFilter().getEstimatedTides() ? "Estimé" : "Réalisé";
data.put(realText, res.get(1));
String title = manager.getDataSamplingTitle(getFilter());
-
-
-
- // FIXME 20101015 bleny business code, should be moved in business
- // computing level for indicator
- int totalNumberOfRealized = 0;
- int totalNumberOfPlanned = 0;
- for (Map.Entry<Date, Integer> entry : res.get(1).entrySet()) {
- // res.get(1) contains number of realized
- // while res.get(0) contains planned
-
- Date date = entry.getKey();
- // both variables will contains planned and realized at the same date
- int numberOfRealized = entry.getValue();
- int numberOfPlanned = res.get(0).get(date);
-
- totalNumberOfPlanned += numberOfPlanned;
- totalNumberOfRealized += numberOfRealized;
-
- if (log.isDebugEnabled()) {
- log.debug(String.format(
- "number of planed %s (%s), number of realized %s (%s)",
- numberOfPlanned, totalNumberOfPlanned,
- numberOfRealized, totalNumberOfRealized));
- }
- }
-
- double percentRealized = ((double) totalNumberOfRealized /
- (double) totalNumberOfPlanned) * 100.0;
-
- if (log.isDebugEnabled()) {
- log.debug(String.format("percent realized %f %%", percentRealized));
- }
-
- activeIndicatorLevel = getActiveIndicator().getLevelForValue(percentRealized);
- if (log.isDebugEnabled()) {
- log.debug("activeIndicatorLevel = " + activeIndicatorLevel.getLevel());
- }
-
return ChartUtils.createCategoryChart(title, "Nb marées", "Mois", getDataSamplingChartType(), data);
}
@@ -362,18 +337,6 @@
if (boardingResult == null) {
boardingResult = serviceSynthesis.getBoardingBoats(
getCompanyForBoarding(), getFromDate());
-
- // FIXME 20101015 bleny business code, should be moved in business
- // computing level for indicator
- int numberOfBoatWithOneBoarding = boardingResult.getData().get("1");
- int totalNumberOfBoarding = 0;
- for (Integer numberOfBoarding : boardingResult.getData().values()) {
- totalNumberOfBoarding += numberOfBoarding;
- }
- double rate = ((double) numberOfBoatWithOneBoarding /
- (double) totalNumberOfBoarding) * 100.0;
- activeIndicator = getActiveIndicator();
- activeIndicatorLevel = activeIndicator.getLevelForValue(rate);
}
return boardingResult;
}
@@ -419,19 +382,6 @@
Company company = !user.isAdmin() ? user.getCompany() : null;
complianceBoarding =
serviceSynthesis.getComplianceBoardingIndicator(company);
-
- // FIXME 20101015 bleny business code, should be moved in business
- // computing level for indicator
- double total = 0.0;
- int numberOfCompanies = complianceBoarding.size();
- for (Double compliance : complianceBoarding.values()) {
- total += compliance;
- }
- double indicatorValue = 100 * (total / numberOfCompanies);
-
- activeSynthesis = SynthesisId.IND_COMPLIANCE_BOARDING;
- activeIndicator = getActiveIndicator();
- activeIndicatorLevel = activeIndicator.getLevelForValue(indicatorValue);
}
return complianceBoarding;
@@ -535,19 +485,6 @@
allegroReactivity =
serviceSynthesis.getContactDataInputDateReactivity(company,
getPeriodForAllegroReactivity());
-
- // FIXME 20101015 bleny business code, should be moved in business
- // computing level for indicator
- double sumAverages = 0.0;
- for (ContactAverageReactivity reactivity : allegroReactivity) {
- sumAverages += reactivity.getResult();
- }
-
- double numberOfCompanies = (double) allegroReactivity.size();
- double totalAverages = sumAverages / numberOfCompanies;
-
- activeIndicator = getActiveIndicator();
- activeIndicatorLevel = activeIndicator.getLevelForValue(totalAverages);
}
return allegroReactivity;
}
1
0
[Suiviobsmer-commits] r698 - in trunk: wao-business/src/main/java/fr/ifremer/wao/bean wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources/i18n wao-business/src/main/xmi wao-ui/src/main/java/fr/ifremer/wao/ui/components wao-ui/src/main/webapp
by bleny@users.labs.libre-entreprise.org 20 Oct '10
by bleny@users.labs.libre-entreprise.org 20 Oct '10
20 Oct '10
Author: bleny
Date: 2010-10-20 13:01:31 +0000 (Wed, 20 Oct 2010)
New Revision: 698
Log:
WIP ; moved to business global synthesis in business
Added:
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalIndicatorValue.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java
trunk/wao-ui/src/main/webapp/Contacts.tml
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java 2010-10-19 15:58:34 UTC (rev 697)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java 2010-10-20 13:01:31 UTC (rev 698)
@@ -49,18 +49,29 @@
BOAT_DEFINITIVE_REFUSED("Refus définitif", true, true);
+ /** @deprecated I18N should be done properly by tapestry */
+ @Deprecated
private String libelle;
private boolean finalState;
private boolean unfinishedState;
+ /** @deprecated I18N should be done properly by tapestry */
+ @Deprecated
ContactState(String value, boolean finalState, boolean unfinishedState) {
this.libelle = value;
this.finalState = finalState;
this.unfinishedState = unfinishedState;
}
+ ContactState(boolean finalState, boolean unfinishedState) {
+ this.finalState = finalState;
+ this.unfinishedState = unfinishedState;
+ }
+
+ /** @deprecated I18N should be done properly by tapestry */
+ @Deprecated
public String libelle() {
return this.libelle;
}
Added: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalIndicatorValue.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalIndicatorValue.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalIndicatorValue.java 2010-10-20 13:01:31 UTC (rev 698)
@@ -0,0 +1,16 @@
+package fr.ifremer.wao.bean;
+
+public enum GlobalIndicatorValue {
+
+ VERY_BAD,
+
+ BAD,
+
+ NEUTRAL,
+
+ GOOD,
+
+ VERY_GOOD;
+
+
+}
Added: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java 2010-10-20 13:01:31 UTC (rev 698)
@@ -0,0 +1,72 @@
+package fr.ifremer.wao.bean;
+
+import fr.ifremer.wao.entity.Indicator;
+import fr.ifremer.wao.entity.IndicatorLevel;
+
+import java.util.List;
+import java.util.Map;
+
+public class GlobalSynthesisResultImpl extends GlobalSynthesisResult {
+
+ protected Map<SynthesisId, Double> values;
+
+ protected List<Indicator> indicators;
+
+ public void setIndicatorValues(Map<SynthesisId, Double> indicatorValues) {
+ this.values = indicatorValues;
+ }
+
+ public void setIndicators(List<Indicator> indicators) {
+ this.indicators = indicators;
+ }
+
+ /** in the list of indicators, find the one with given synthesisId. */
+ protected Indicator findIndicator(SynthesisId id) {
+ for (Indicator indicator : indicators) {
+ if (indicator.getSynthesisId().equals(id)) {
+ return indicator;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public IndicatorLevel getLevelForIndicator(SynthesisId synthesisId) {
+ Indicator indicator = findIndicator(synthesisId);
+ Double value = values.get(indicator);
+ IndicatorLevel result = indicator.getLevelForValue(value);
+ return result;
+ }
+
+ /** return a value between 1 and 6 */
+ @Override
+ public GlobalIndicatorValue getGlobalLevel() {
+ // compute an average with coefficients
+ double totalValues = 0.0;
+ double totalCoefficients = 0.0;
+
+ for (Indicator indicator : indicators) {
+ Double value = values.get(indicator.getSynthesisId());
+ Double coefficient = indicator.getCoefficient();
+
+ totalValues += value * coefficient;
+ totalCoefficients += coefficient;
+ }
+
+ double value = totalValues / totalCoefficients;
+
+ GlobalIndicatorValue result = null;
+ if (value >= 1.0 && value < 2.0) {
+ result = GlobalIndicatorValue.VERY_BAD;
+ } else if (value >= 2.0 && value < 3.0) {
+ result = GlobalIndicatorValue.BAD;
+ } else if (value >= 3.0 && value < 5.0) {
+ result = GlobalIndicatorValue.NEUTRAL;
+ } else if (value >= 5.0 && value < 5.5) {
+ result = GlobalIndicatorValue.GOOD;
+ } else if (value >= 5.5 && value <= 6.0) {
+ result = GlobalIndicatorValue.VERY_GOOD;
+ }
+ return result;
+ }
+}
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-10-19 15:58:34 UTC (rev 697)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-10-20 13:01:31 UTC (rev 698)
@@ -64,7 +64,7 @@
*/
public class ServiceSynthesisImpl extends ServiceSynthesisAbstract {
- private static final Logger logger =
+ private static final Logger log =
LoggerFactory.getLogger(ServiceSynthesisImpl.class);
private WaoContext context;
@@ -146,8 +146,8 @@
// builder.setSampleRowProperty("M." + SampleMonth.SAMPLE_ROW);
// builder.applySamplingFilter(filter);
- if (logger.isTraceEnabled()) {
- logger.trace("Exec query : " + query);
+ if (log.isTraceEnabled()) {
+ log.trace("Exec query : " + query);
}
List<Object[]> res = transaction.findByQuery(query);
@@ -158,10 +158,10 @@
int sumExpected = ((Long)tab[2]).intValue();
serie1.put(date, sumExpected);
serie2.put(date, sumReal);
- if (logger.isTraceEnabled()) {
+ if (log.isTraceEnabled()) {
DateFormat dateFormat =
new SimpleDateFormat(period.getPattern());
- logger.trace("Res : " + dateFormat.format(date) + " : "
+ log.trace("Res : " + dateFormat.format(date) + " : "
+ sumReal + " / " + sumExpected);
}
}
@@ -231,8 +231,8 @@
addGroup(contact + "." + Contact.BOAT).
addOrderDesc("COUNT(*)");
- if (logger.isTraceEnabled()) {
- logger.trace("Exec query : " + query);
+ if (log.isTraceEnabled()) {
+ log.trace("Exec query : " + query);
}
List<Map<String, Object>> nbBoardingsByBoat = transaction.findByQuery(query);
@@ -302,8 +302,8 @@
query.setSelect(companyNameProperty, "COUNT(*)").
addGroup(companyNameProperty);
- if (logger.isDebugEnabled()) {
- logger.debug("Query for total : " + query);
+ if (log.isDebugEnabled()) {
+ log.debug("Query for total : " + query);
}
List<Object[]> totalResults = transaction.findByQuery(query);
@@ -318,8 +318,8 @@
toString()
);
- if (logger.isDebugEnabled()) {
- logger.debug("Query for result : " + query);
+ if (log.isDebugEnabled()) {
+ log.debug("Query for result : " + query);
}
List<Object[]> diffResults = transaction.findByQuery(query);
@@ -328,8 +328,8 @@
for (Object[] row : diffResults) {
String rowCompanyName = (String)row[0];
Long rowCount = (Long)row[1];
- if (logger.isDebugEnabled()) {
- logger.debug("result row : " + rowCompanyName + " = " + rowCount);
+ if (log.isDebugEnabled()) {
+ log.debug("result row : " + rowCompanyName + " = " + rowCount);
}
results.put(rowCompanyName, rowCount.doubleValue());
}
@@ -340,8 +340,8 @@
for (Object[] row : totalResults) {
String rowCompanyName = (String)row[0];
Long rowCount = (Long)row[1];
- if (logger.isDebugEnabled()) {
- logger.debug("total row : " + rowCompanyName + " = " + rowCount);
+ if (log.isDebugEnabled()) {
+ log.debug("total row : " + rowCompanyName + " = " + rowCount);
}
Double value = results.get(rowCompanyName);
if (value == null) {
@@ -486,8 +486,8 @@
int rowState = (Integer)row[1];
ContactState state = ContactState.valueOf(rowState);
Long rowCount = (Long)row[2];
- if (logger.isDebugEnabled()) {
- logger.debug("res : " + rowCompanyName + " _ " + state + " _ " + rowCount);
+ if (log.isDebugEnabled()) {
+ log.debug("res : " + rowCompanyName + " _ " + state + " _ " + rowCount);
}
ContactStateStatistics stats = results.get(rowCompanyName);
if (stats == null) {
@@ -535,8 +535,8 @@
query.setSelect(companyNameProperty, dataInputProperty, tideBeginDateProperty);
- if (logger.isDebugEnabled()) {
- logger.debug("Query : " + query);
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
}
List<Object[]> res = transaction.findByQuery(query);
@@ -548,11 +548,11 @@
int nbDays = DateUtil.getDifferenceInDays(rowTideBeginDate, rowDataInputDate);
- if (logger.isDebugEnabled()) {
- logger.debug("Company : " + rowCompanyName);
- logger.debug("tideBegin : " + rowTideBeginDate);
- logger.debug("dataInput : " + rowDataInputDate);
- logger.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);
@@ -652,7 +652,117 @@
return results;
}
+ protected Double getIndicatorValueForDataSampling
+ (TopiaContext transaction, SamplingFilter filter) {
+
+ List<SortedMap<Date, Integer>> res = getDataSampling(filter);
+
+ int totalNumberOfRealized = 0;
+ int totalNumberOfPlanned = 0;
+ for (Map.Entry<Date, Integer> entry : res.get(1).entrySet()) {
+ // res.get(1) contains number of realized
+ // while res.get(0) contains planned
+
+ Date date = entry.getKey();
+ // both variables will contains planned and realized at the same date
+ int numberOfRealized = entry.getValue();
+ int numberOfPlanned = res.get(0).get(date);
+
+ totalNumberOfPlanned += numberOfPlanned;
+ totalNumberOfRealized += numberOfRealized;
+
+ if (log.isDebugEnabled()) {
+ log.debug(String.format(
+ "number of planed %s (%s), number of realized %s (%s)",
+ numberOfPlanned, totalNumberOfPlanned,
+ numberOfRealized, totalNumberOfRealized));
+ }
+ }
+
+ double percentRealized = ((double) totalNumberOfRealized /
+ (double) totalNumberOfPlanned) * 100.0;
+
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("percent realized %f %%", percentRealized));
+ }
+
+ return percentRealized;
+ }
+
+ protected Double getIndicatorValueForBoarding
+ (TopiaContext transaction, Company company, Date fromDate) {
+
+ BoardingResult boardingResult = getBoardingBoats(company, fromDate);
+
+ int numberOfBoatWithOneBoarding = boardingResult.getData().get("1");
+ int totalNumberOfBoarding = 0;
+ for (Integer numberOfBoarding : boardingResult.getData().values()) {
+ totalNumberOfBoarding += numberOfBoarding;
+ }
+ double rate = ((double) numberOfBoatWithOneBoarding /
+ (double) totalNumberOfBoarding) * 100.0;
+ return rate;
+ }
+
+ protected Double getIndicatorValueForComplianceBoarding
+ (TopiaContext transaction, Company company) {
+ Map<String, Double> complianceBoarding = getComplianceBoardingIndicator(company);
+ double total = 0.0;
+ int numberOfCompanies = complianceBoarding.size();
+ for (Double compliance : complianceBoarding.values()) {
+ total += compliance;
+ }
+ double indicatorValue = 100 * (total / numberOfCompanies);
+ return indicatorValue;
+ }
+
+ protected Double getIndicatorValueForAllegroReactivity
+ (TopiaContext transaction, Company company, PeriodDates periodDates) {
+ Collection<ContactAverageReactivity> allegroReactivity = getContactDataInputDateReactivity(company, periodDates);
+
+ double sumAverages = 0.0;
+ for (ContactAverageReactivity reactivity : allegroReactivity) {
+ sumAverages += reactivity.getResult();
+ }
+
+ double numberOfCompanies = (double) allegroReactivity.size();
+ double totalAverages = sumAverages / numberOfCompanies;
+ return totalAverages;
+ }
+
@Override
+ protected GlobalSynthesisResult executeGetGlobalSynthesisResult
+ (TopiaContext transaction, Company company, PeriodDates period)
+ throws Exception {
+
+ GlobalSynthesisResultImpl result = new GlobalSynthesisResultImpl();
+
+ Double value = 30.0;
+ Map<SynthesisId, Double> indicatorValues = new HashMap<SynthesisId, Double>();
+
+ // value = getIndicatorValueForDataSampling(transaction, samplingFilter);
+ indicatorValues.put(SynthesisId.GRAPH_SAMPLING, value);
+
+ // value = getIndicatorValueForBoarding(transaction, company, fromDate);
+ indicatorValues.put(SynthesisId.GRAPH_BOARDING, value);
+
+ value = getIndicatorValueForComplianceBoarding(transaction, company);
+ indicatorValues.put(SynthesisId.IND_COMPLIANCE_BOARDING, value);
+
+ value = getIndicatorValueForAllegroReactivity(transaction, company, period);
+ indicatorValues.put(SynthesisId.IND_ALLEGRO_REACTIVITY, value);
+
+ // add data reliability indicator here
+
+
+
+ result.setIndicatorValues(indicatorValues);
+ List<Indicator> indicators = executeGetGlobalSynthesisParameters(transaction);
+ result.setIndicators(indicators);
+ return result;
+ }
+
+ @Override
protected List<Indicator> executeGetGlobalSynthesisParameters(TopiaContext transaction) throws Exception {
IndicatorDAO indicatorDAO = WaoDAOHelper.getIndicatorDAO(transaction);
List<Indicator> indicators = indicatorDAO.findAll();
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-10-19 15:58:34 UTC (rev 697)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-10-20 13:01:31 UTC (rev 698)
@@ -81,6 +81,7 @@
wao.error.serviceSynthesis.getContactStateStatistics=
wao.error.serviceSynthesis.getDataSampling=
wao.error.serviceSynthesis.getGlobalSynthesisParameters=Unable to get data about global synthesis parameters
+wao.error.serviceSynthesis.getGlobalSynthesisResult=
wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=
wao.error.serviceUser.connect=
wao.error.serviceUser.createDefaultAdmin=
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-10-19 15:58:34 UTC (rev 697)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-10-20 13:01:31 UTC (rev 698)
@@ -80,6 +80,7 @@
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.getGlobalSynthesisParameters=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es concernant les indicateurs pour la synth\u00E8se globale
+wao.error.serviceSynthesis.getGlobalSynthesisResult=
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.createDefaultAdmin=Impossible de cr\u00E9er l'administrateur par d\u00E9faut
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java 2010-10-19 15:58:34 UTC (rev 697)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java 2010-10-20 13:01:31 UTC (rev 698)
@@ -46,7 +46,7 @@
}
public Boolean isWithLegend() {
- if (withLegend = null) {
+ if (withLegend == null) {
withLegend = false;
}
return withLegend;
Modified: trunk/wao-ui/src/main/webapp/Contacts.tml
===================================================================
--- trunk/wao-ui/src/main/webapp/Contacts.tml 2010-10-19 15:58:34 UTC (rev 697)
+++ trunk/wao-ui/src/main/webapp/Contacts.tml 2010-10-20 13:01:31 UTC (rev 698)
@@ -295,9 +295,7 @@
<t:if t:test="contact.validationProgram">
${contact.dataReliability.label}
<p:else>
- <t:if t:test="canValidate()">
- <input t:type="select" t:id="dataReliability" t:value="contact.dataReliability" validate="required" /> -->
- </t:if>
+ <input t:type="select" t:id="dataReliability" t:value="contact.dataReliability" validate="required" />
</p:else>
</t:if>
</t:if>
1
0
[Suiviobsmer-commits] r697 - in trunk/wao-ui/src/main: java/fr/ifremer/wao/ui/pages webapp
by bleny@users.labs.libre-entreprise.org 19 Oct '10
by bleny@users.labs.libre-entreprise.org 19 Oct '10
19 Oct '10
Author: bleny
Date: 2010-10-19 15:58:34 +0000 (Tue, 19 Oct 2010)
New Revision: 697
Log:
bugfix ano2540 (from branch) ; data reliability form in contact lists + validation
Modified:
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
trunk/wao-ui/src/main/webapp/Contacts.tml
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-10-19 13:42:47 UTC (rev 696)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-10-19 15:58:34 UTC (rev 697)
@@ -30,6 +30,7 @@
import fr.ifremer.wao.bean.ContactFilter;
import fr.ifremer.wao.bean.ContactFilterImpl;
import fr.ifremer.wao.bean.ContactState;
+import fr.ifremer.wao.bean.DataReliability;
import fr.ifremer.wao.bean.SamplingFilter;
import fr.ifremer.wao.bean.UserRole;
import fr.ifremer.wao.entity.Boat;
@@ -414,6 +415,10 @@
return validation == null;
}
+ public boolean isBoardingDone() {
+ return contact.getContactState() == ContactState.BOARDING_DONE;
+ }
+
/**************************** CONTACT ROW ACTION **************************/
/**
@@ -684,29 +689,21 @@
" du jour");
}
- if (logger.isDebugEnabled()) {
- logger.debug("IsUnfinished : " + contactState.isUnfinishedState());
- logger.debug("OldUnfinished : " + oldState.isUnfinishedState());
-
- String newComment = contactEdited.getComment();
- boolean commentDefined = StringUtils.isNotEmpty(newComment);
- boolean commentChanged = commentDefined && !newComment.equals(oldComment);
-
- logger.debug("commentDefined : " + commentDefined);
- logger.debug("commentChanged : " + commentChanged);
- }
-
// Non abouti, Refus ou Refus Définitif
if (contactState.isUnfinishedState()) {
String newComment = contactEdited.getComment();
- boolean commentChanged =
- StringUtils.isNotEmpty(newComment) &&
+ boolean commentDefined = StringUtils.isNotEmpty(newComment);
+ boolean commentChanged = commentDefined &&
!newComment.equals(oldComment);
+ // Ano #2540 : NPE on oldState, extract boolean for
+ // previous unfinishedState case
+ boolean previousUnfinishedState = commentDefined &&
+ oldState != null && oldState.isUnfinishedState();
+
// Ano #2440 : no restriction if previous state is unfinished
- if (oldState.isUnfinishedState() &&
- StringUtils.isNotEmpty(newComment) || commentChanged) {
+ if (previousUnfinishedState || commentChanged) {
// RAZ des champs
contactEdited.setTideBeginDate(null);
@@ -715,6 +712,7 @@
contactEdited.setMammalsCapture(false);
contactEdited.setMammalsObservation(false);
contactEdited.setDataInputDate(null);
+
} else {
contactsForm.recordError(comment, "Vous devez ajouter" +
" un commentaire pour l'état" +
@@ -737,6 +735,19 @@
" avoir aucun observateur pour l'état" +
" '" + contactState.libelle() + "'");
}
+
+ if (contactEdited.isValidationProgram()) {
+
+ // it's an admin validation, data-reliability field must be filled
+ if (logger.isDebugEnabled()) {
+ logger.debug("field data reliability is " + contactEdited.getDataReliability());
+ }
+
+ if (contactEdited.getDataReliability() == null ||
+ contactEdited.getDataReliability() == DataReliability.UNKNOWN) {
+ contactsForm.recordError("Il faut préciser la qualité des données avant de valider");
+ }
+ }
}
}
}
Modified: trunk/wao-ui/src/main/webapp/Contacts.tml
===================================================================
--- trunk/wao-ui/src/main/webapp/Contacts.tml 2010-10-19 13:42:47 UTC (rev 696)
+++ trunk/wao-ui/src/main/webapp/Contacts.tml 2010-10-19 15:58:34 UTC (rev 697)
@@ -290,12 +290,18 @@
</t:if>
</p:commentCell>
<p:dataReliabilityCell>
- <t:if t:test="editionMode">
- <input t:type="select" t:id="dataReliability" t:value="contactEdited.dataReliability" /><!-- validate="required"/> -->
- <p:else>
- ${contact.dataReliability.label}
- </p:else>
- </t:if>
+ <t:if t:test="boardingDone">
+ <t:if t:test="contact.validationCompany">
+ <t:if t:test="contact.validationProgram">
+ ${contact.dataReliability.label}
+ <p:else>
+ <t:if t:test="canValidate()">
+ <input t:type="select" t:id="dataReliability" t:value="contact.dataReliability" validate="required" /> -->
+ </t:if>
+ </p:else>
+ </t:if>
+ </t:if>
+ </t:if>
</p:dataReliabilityCell>
<p:commentCoordinatorCell>
<span t:type="ck/Tooltip" title="Commentaire société" t:value="${getCommentTooltip(contact.commentCoordinator)}" t:effect="appear">
1
0
[Suiviobsmer-commits] r696 - trunk/wao-business/src/test/java/fr/ifremer/wao/service
by bleny@users.labs.libre-entreprise.org 19 Oct '10
by bleny@users.labs.libre-entreprise.org 19 Oct '10
19 Oct '10
Author: bleny
Date: 2010-10-19 13:42:47 +0000 (Tue, 19 Oct 2010)
New Revision: 696
Log:
fix broken build, test was not up to date
Modified:
trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java 2010-10-19 12:13:06 UTC (rev 695)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java 2010-10-19 13:42:47 UTC (rev 696)
@@ -194,8 +194,8 @@
* Test of getBoardingBoats method, of class ServiceSynthesisImpl.
*/
@Test
- public void testGetNonComplianceBoardingIndicator() throws Exception {
- log.info("getNonComplianceBoardingIndicator");
+ public void testGetComplianceBoardingIndicator() throws Exception {
+ log.info("getComplianceBoardingIndicator");
/** PREPARE DATA **/
InputStream input = getClass().getResourceAsStream("/import/navires.csv");
ServiceBoat serviceBoat = manager.getServiceBoat();
@@ -279,22 +279,22 @@
// result for company TARTANPION
Map<String, Double> results =
- service.getNonComplianceBoardingIndicator(company);
+ service.getComplianceBoardingIndicator(company);
assertEquals(1, results.size());
// 0% of non compliance
Double value = results.get(company.getName());
- assertEquals(0., value, 0);
+ assertEquals(1., value, 0);
// result for company BIS using admin mode (no company filtered)
- results = service.getNonComplianceBoardingIndicator(null);
+ results = service.getComplianceBoardingIndicator(null);
assertEquals(2, results.size());
// 100% of non compliance
value = results.get(company2.getName());
- assertEquals(1., value, 0);
+ assertEquals(0., value, 0);
}
/**
1
0
[Suiviobsmer-commits] r695 - in tags/wao-1.5.4: wao-business/src/main/resources/i18n wao-ui/src/license
by bleny@users.labs.libre-entreprise.org 19 Oct '10
by bleny@users.labs.libre-entreprise.org 19 Oct '10
19 Oct '10
Author: bleny
Date: 2010-10-19 12:13:06 +0000 (Tue, 19 Oct 2010)
New Revision: 695
Log:
add missing third-party licence
Modified:
tags/wao-1.5.4/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
tags/wao-1.5.4/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
tags/wao-1.5.4/wao-ui/src/license/THIRD-PARTY.properties
Modified: tags/wao-1.5.4/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
===================================================================
--- tags/wao-1.5.4/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-10-19 09:01:38 UTC (rev 694)
+++ tags/wao-1.5.4/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-10-19 12:13:06 UTC (rev 695)
@@ -1,3 +1,26 @@
+###
+# #%L
+# Wao :: Business
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2010 Ifremer
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# #L%
+###
wao.error.boat.canCreateContact=
wao.error.boat.getNbBoarding=
wao.error.boatInfos.getNbBoardingForCompany=
Modified: tags/wao-1.5.4/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- tags/wao-1.5.4/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-10-19 09:01:38 UTC (rev 694)
+++ tags/wao-1.5.4/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-10-19 12:13:06 UTC (rev 695)
@@ -1,3 +1,26 @@
+###
+# #%L
+# Wao :: Business
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2010 Ifremer
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# #L%
+###
wao.error.boat.canCreateContact=Impossible de cr\u00E9er un nouveau contact pour la soci\u00E9t\u00E9 %1$s et le navire %2$s (%3$d)
wao.error.boat.getNbBoarding=Impossible de r\u00E9cup\u00E9rer le nombre d'embarquements r\u00E9els depuis le %1$s
wao.error.boatInfos.getNbBoardingForCompany=Impossible de r\u00E9cup\u00E9rer le nombre d'embarquements r\u00E9els depuis le %1$s pour la soci\u00E9t\u00E9 %2$s
Modified: tags/wao-1.5.4/wao-ui/src/license/THIRD-PARTY.properties
===================================================================
--- tags/wao-1.5.4/wao-ui/src/license/THIRD-PARTY.properties 2010-10-19 09:01:38 UTC (rev 694)
+++ tags/wao-1.5.4/wao-ui/src/license/THIRD-PARTY.properties 2010-10-19 12:13:06 UTC (rev 695)
@@ -1,8 +1,8 @@
# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
+# - Affero General Public License (AGPL)
# - Apache Software License 2.0
-# - BSD
# - BSD License
# - BSD license
# - BSD style
@@ -17,8 +17,6 @@
# - GNU Lesser General Public License version 2.1
# - GNU Library or Lesser General Public License
# - GPL, LGPL, MPL
-# - General Public License (GPL) v 3.0
-# - Lesser General Public License (LGPL) v 2.1
# - Lesser General Public License (LGPL) v 3.0
# - MIT License
# - Public Domain
@@ -32,7 +30,7 @@
# Please fill the missing licenses for dependencies :
#
#
-#Sun Jul 11 22:47:24 CEST 2010
+#Tue Oct 19 12:44:22 CEST 2010
antlr--antlr--2.7.6=BSD
com.formos.tapestry--tapestry-testify--1.0.2=The Apache Software License, Version 2.0
com.sun.xml.bind--jaxb-impl--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 & GNU General Public License (GPL) Version 2
@@ -40,6 +38,7 @@
commons-beanutils--commons-beanutils-core--1.7.0=The Apache Software License, Version 2.0
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD
+javassist--javassist--3.8.0.GA=Lesser General Public Licence (LGPL) v 2.1
javassist--javassist--3.9.0.GA=Lesser General Public License (LGPL) v 2.1
javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
javax.xml.bind--jaxb-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 & GNU General Public License (GPL) Version 2
1
0
[Suiviobsmer-commits] r694 - in branches/wao-1.5.x: . wao-business wao-ui
by bleny@users.labs.libre-entreprise.org 19 Oct '10
by bleny@users.labs.libre-entreprise.org 19 Oct '10
19 Oct '10
Author: bleny
Date: 2010-10-19 09:01:38 +0000 (Tue, 19 Oct 2010)
New Revision: 694
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
branches/wao-1.5.x/pom.xml
branches/wao-1.5.x/wao-business/pom.xml
branches/wao-1.5.x/wao-ui/pom.xml
Modified: branches/wao-1.5.x/pom.xml
===================================================================
--- branches/wao-1.5.x/pom.xml 2010-10-19 09:01:35 UTC (rev 693)
+++ branches/wao-1.5.x/pom.xml 2010-10-19 09:01:38 UTC (rev 694)
@@ -15,7 +15,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
<modules>
<module>wao-ui</module>
@@ -308,9 +308,9 @@
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/tags/wao-1.5.4</connection>
- <developerConnection>scm:svn:svn+ssh://${username}@labs.libre-entreprise.org/svnroot/suiviobsmer/tags/wao-1.5.4</developerConnection>
- <url>http://labs.libre-entreprise.org/scm/viewvc.php/tags/wao-1.5.4?root=suiviob…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/branches/wao-1.5.x</connection>
+ <developerConnection>scm:svn:svn+ssh://bleny at labs.libre-entreprise.org/svnroot/suiviobsmer/branches/wao-1.5.x</developerConnection>
+ <url>http://labs.libre-entreprise.org/scm/viewvc.php/branches/wao-1.5.x?root=sui…</url>
</scm>
<build>
Modified: branches/wao-1.5.x/wao-business/pom.xml
===================================================================
--- branches/wao-1.5.x/wao-business/pom.xml 2010-10-19 09:01:35 UTC (rev 693)
+++ branches/wao-1.5.x/wao-business/pom.xml 2010-10-19 09:01:38 UTC (rev 694)
@@ -10,7 +10,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.wao</groupId>
@@ -204,9 +204,9 @@
</build>
<scm>
- <url>http://labs.libre-entreprise.org/scm/viewvc.php/tags/wao-1.5.4/?root=suivio…</url>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/tags/wao-1.5.4/wao-business</connection>
- <developerConnection>scm:svn:svn+ssh://${username}@labs.libre-entreprise.org/svnroot/suiviobsmer/tags/wao-1.5.4/wao-business</developerConnection>
+ <url>http://labs.libre-entreprise.org/scm/viewvc.php/branches/wao-1.5.x/?root=su…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/branches/wao-1.5.x/wao-busine…</connection>
+ <developerConnection>scm:svn:svn+ssh://bleny at labs.libre-entreprise.org/svnroot/suiviobsmer/branches/wao-1.5.x/wao-busine…</developerConnection>
</scm>
<!--<repositories>-->
Modified: branches/wao-1.5.x/wao-ui/pom.xml
===================================================================
--- branches/wao-1.5.x/wao-ui/pom.xml 2010-10-19 09:01:35 UTC (rev 693)
+++ branches/wao-1.5.x/wao-ui/pom.xml 2010-10-19 09:01:38 UTC (rev 694)
@@ -10,7 +10,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.wao</groupId>
@@ -227,9 +227,9 @@
</repositories>
<scm>
- <url>http://labs.libre-entreprise.org/scm/viewvc.php/tags/wao-1.5.4/?root=suivio…</url>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/tags/wao-1.5.4/wao-ui</connection>
- <developerConnection>scm:svn:svn+ssh://${username}@labs.libre-entreprise.org/svnroot/suiviobsmer/tags/wao-1.5.4/wao-ui</developerConnection>
+ <url>http://labs.libre-entreprise.org/scm/viewvc.php/branches/wao-1.5.x/?root=su…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/branches/wao-1.5.x/wao-ui</connection>
+ <developerConnection>scm:svn:svn+ssh://bleny at labs.libre-entreprise.org/svnroot/suiviobsmer/branches/wao-1.5.x/wao-ui</developerConnection>
</scm>
</project>
1
0