Author: bleny Date: 2010-10-14 10:51:37 +0000 (Thu, 14 Oct 2010) New Revision: 674 Log: add indicators in services, render all levels in administration pages Added: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/SynthesisId.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java trunk/wao-business/src/main/xmi/wao.properties trunk/wao-business/src/main/xmi/wao.zargo trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java trunk/wao-ui/src/main/webapp/Administration.tml trunk/wao-ui/src/main/webapp/css/common.css Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/SynthesisId.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/SynthesisId.java 2010-10-14 10:51:10 UTC (rev 673) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/SynthesisId.java 2010-10-14 10:51:37 UTC (rev 674) @@ -71,4 +71,13 @@ } return null; } + + public static SynthesisId valueOf(int ordinal) { + for (SynthesisId synthesisId : SynthesisId.values()) { + if (synthesisId.ordinal() == ordinal) { + return synthesisId; + } + } + return null; + } } Added: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorImpl.java (rev 0) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorImpl.java 2010-10-14 10:51:37 UTC (rev 674) @@ -0,0 +1,19 @@ +package fr.ifremer.wao.entity; + +import fr.ifremer.wao.SynthesisId; + +/** + * + */ +public class IndicatorImpl extends IndicatorAbstract { + + @Override + public SynthesisId getSynthesisId() { + return SynthesisId.valueOf(getIndicatorId()); + } + + @Override + public void setSynthesisId(SynthesisId synthesisId) { + setIndicatorId(synthesisId.ordinal()); + } +} Added: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java (rev 0) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java 2010-10-14 10:51:37 UTC (rev 674) @@ -0,0 +1,27 @@ +package fr.ifremer.wao.entity; + +public class IndicatorLevelImpl extends IndicatorLevelAbstract { + + protected double lowerBound; + + @Override + public double getLowerBound() { + return lowerBound; + } + + @Override + public void setLowerBound(double lowerBound) { + this.lowerBound = lowerBound; + } + + @Override + public boolean isLowerBoundPositiveInfinity() { + return lowerBound == Double.MAX_VALUE; + } + + @Override + public void setLowerBoundToPositiveInfinity() { + lowerBound = Double.MAX_VALUE; + } + +} 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-14 10:51:10 UTC (rev 673) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-10-14 10:51:37 UTC (rev 674) @@ -24,6 +24,7 @@ package fr.ifremer.wao.service; +import fr.ifremer.wao.SynthesisId; import fr.ifremer.wao.WaoContext; import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.WaoException; @@ -31,26 +32,8 @@ import fr.ifremer.wao.WaoQueryHelper; import fr.ifremer.wao.WaoQueryHelper.BoatDistrictProperty; import fr.ifremer.wao.WaoQueryHelper.ContactProperty; -import fr.ifremer.wao.bean.BoardingResult; -import fr.ifremer.wao.bean.BoardingResultImpl; -import fr.ifremer.wao.bean.ContactAverageReactivity; -import fr.ifremer.wao.bean.ContactAverageReactivityImpl; -import fr.ifremer.wao.bean.ContactFilter; -import fr.ifremer.wao.bean.ContactPieChartConstant; -import fr.ifremer.wao.bean.ContactState; -import fr.ifremer.wao.bean.ContactStateStatistics; -import fr.ifremer.wao.bean.ContactStateStatisticsImpl; -import fr.ifremer.wao.bean.PieChartData; -import fr.ifremer.wao.bean.PieChartDataImpl; -import fr.ifremer.wao.bean.PieChartSeries; -import fr.ifremer.wao.bean.PieChartSeriesImpl; -import fr.ifremer.wao.bean.SamplingFilter; -import fr.ifremer.wao.entity.Boat; -import fr.ifremer.wao.entity.Company; -import fr.ifremer.wao.entity.Contact; -import fr.ifremer.wao.entity.ContactDAO; -import fr.ifremer.wao.entity.SampleRow; -import fr.ifremer.wao.entity.WaoUser; +import fr.ifremer.wao.bean.*; +import fr.ifremer.wao.entity.*; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; @@ -651,6 +634,42 @@ return results; } + @Override + protected List<Indicator> executeGetGlobalSynthesisParameters(TopiaContext transaction) throws Exception { + IndicatorDAO indicatorDAO = WaoDAOHelper.getIndicatorDAO(transaction); + List<Indicator> indicators = indicatorDAO.findAll(); + + // now, setting the lowerBound + + for (Indicator indicator : indicators) { + Collection<IndicatorLevel> levels = indicator.getIndicatorLevel(); + + double lowerBound; + double lastUpperBound; + if (indicator.getSynthesisId() == SynthesisId.IND_ALLEGRO_REACTIVITY) { + lowerBound = Double.MAX_VALUE; + lastUpperBound = 0.0; + } else { + lowerBound = 0.0; + lastUpperBound = 100.0; + } + + for (IndicatorLevel level : levels) { + level.setLowerBound(lowerBound); + lowerBound = level.getUpperBound(); + } + + IndicatorLevel lastIndicatorLevel = new IndicatorLevelImpl(); + int nextLevelNumber = levels.size() + 1; + lastIndicatorLevel.setLevel(nextLevelNumber); + lastIndicatorLevel.setLowerBound(lowerBound); + lastIndicatorLevel.setUpperBound(lastUpperBound); + indicator.getIndicatorLevel().add(lastIndicatorLevel); + } + + return indicators; + } + protected PieChartData createContactPieChartData() { PieChartData data = new PieChartDataImpl(); for (ContactPieChartConstant constant : ContactPieChartConstant.values()) { Modified: trunk/wao-business/src/main/xmi/wao.properties =================================================================== --- trunk/wao-business/src/main/xmi/wao.properties 2010-10-14 10:51:10 UTC (rev 673) +++ trunk/wao-business/src/main/xmi/wao.properties 2010-10-14 10:51:37 UTC (rev 674) @@ -30,4 +30,6 @@ fr.ifremer.wao.entity.ElligibleBoat.attribute.boat.tagvalue.lazy=false fr.ifremer.wao.entity.Contact.attribute.sampleRow.tagvalue.lazy=false -fr.ifremer.wao.entity.Contact.attribute.boat.tagvalue.lazy=false \ No newline at end of file +fr.ifremer.wao.entity.Contact.attribute.boat.tagvalue.lazy=false + +fr.ifremer.wao.entity.Indicator.attribute.indicatorLevel.tagvalue.lazy=false Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-10-14 10:51:10 UTC (rev 673) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-10-14 10:51:37 UTC (rev 674) @@ -32,6 +32,8 @@ import fr.ifremer.wao.bean.UserRole; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyImpl; +import fr.ifremer.wao.entity.Indicator; +import fr.ifremer.wao.entity.IndicatorLevel; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.io.ImportResults; import fr.ifremer.wao.io.ImportResultsImpl; @@ -39,6 +41,7 @@ import fr.ifremer.wao.service.ServiceCartography; import fr.ifremer.wao.service.ServiceReferential; import fr.ifremer.wao.service.ServiceSampling; +import fr.ifremer.wao.service.ServiceSynthesis; import fr.ifremer.wao.service.ServiceUser; import fr.ifremer.wao.ui.components.Layout; import fr.ifremer.wao.ui.data.ErrorReport; @@ -74,6 +77,7 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Collection; import java.util.List; /** @@ -96,7 +100,7 @@ private ConnectedUser currentUser; @Inject - private Logger logger; + private Logger log; @Inject private WaoManager manager; @@ -253,8 +257,8 @@ result = serviceBoat.getActivityCalendarLogFile(); } } catch (FileNotFoundException eee) { - if (logger.isInfoEnabled()) { - logger.info("Not existing log file for " + property); + if (log.isInfoEnabled()) { + log.info("Not existing log file for " + property); } } return result; @@ -285,7 +289,7 @@ } } - /**************************** FORMS ****************************************/ + /**************************** EDITING COMPANIES ***************************/ public List<Company> getCompanies() throws WaoException { if (companies == null) { @@ -353,8 +357,8 @@ // public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoException { // if (usersSelectModel == null) { // List<WaoUser> users = serviceUser.getUsersByCompany(getCompany()); -// if (logger.isDebugEnabled()) { -// logger.debug("Nb users : " + users.size()); +// if (log.isDebugEnabled()) { +// log.debug("Nb users : " + users.size()); // } // usersSelectModel = new GenericSelectModel<WaoUser>(users, WaoUser.class, // "fullName", "id", propertyAccess); @@ -405,12 +409,12 @@ layout.addError(eee.getMessage()); } } - if (logger.isDebugEnabled()) { - logger.debug("'User id : " + userId); + if (log.isDebugEnabled()) { + log.debug("'User id : " + userId); } } - /******************** USER FORM ******************************************/ + /******************** USER PROFILE FORM ***********************************/ @InjectComponent private Zone userFormZone; @@ -436,8 +440,8 @@ public WaoUser getUserEdited() throws WaoException { if (userEdited == null) { if (userId != null) { - if (logger.isDebugEnabled()) { - logger.debug("User exist in selectModel : " + userId); + if (log.isDebugEnabled()) { + log.debug("User exist in selectModel : " + userId); } userEdited = findUser(userId); } else { @@ -480,8 +484,8 @@ @Log Object onSuccessFromUserForm() throws WaoException { - if (logger.isDebugEnabled()) { - logger.debug("User : " + userEdited); + if (log.isDebugEnabled()) { + log.debug("User : " + userEdited); } if (!StringUtils.isEmpty(password)) { @@ -574,8 +578,8 @@ @Log Object onActionFromAddRole() { - if (logger.isDebugEnabled()) { - logger.debug("Add userRole : " + userRole + + if (log.isDebugEnabled()) { + log.debug("Add userRole : " + userRole + " (readOnly=" + readOnly + ")"); } if (userRole != null) { @@ -597,5 +601,48 @@ refreshUserRoleZone = true; return userRoleZone; } + + /*********************** INDICATORS AND LEVELS ****************************/ + + @Inject + private ServiceSynthesis serviceSynthesis; + + /* variable used in view */ + @Property + private Indicator indicator; + + /* variable used in view */ + private List<Indicator> indicators; + + /* variable used in view */ + @Property + private IndicatorLevel indicatorLevel; + + /* variable used in view */ + private List<IndicatorLevel> indicatorLevels; + + /* variable used in view */ + private boolean lowerUpperBoundAreEquals; + + public List<Indicator> getIndicators() { + List<Indicator> indicators = serviceSynthesis.getGlobalSynthesisParameters(); + return indicators; + } + + public List<IndicatorLevel> getIndicatorLevels() { + Collection<IndicatorLevel> indicatorLevels = indicator.getIndicatorLevel(); + List<IndicatorLevel> result = new ArrayList<IndicatorLevel>(indicatorLevels); + + if (log.isDebugEnabled()) { + log.debug(String.format("levels for indicator %s are %s", + indicator, indicatorLevels)); + } + + return result; + } + + public boolean getLowerUpperBoundAreEquals() { + return indicatorLevel.getLowerBound() == indicatorLevel.getUpperBound(); + } } Modified: trunk/wao-ui/src/main/webapp/Administration.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Administration.tml 2010-10-14 10:51:10 UTC (rev 673) +++ trunk/wao-ui/src/main/webapp/Administration.tml 2010-10-14 10:51:37 UTC (rev 674) @@ -30,9 +30,9 @@ <t:layout t:pageTitle="Administration" t:contentId="so-admin" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> + <t:if t:test="currentUser.admin"> + <h2>Sociétés</h2> - - <t:if t:test="currentUser.admin"> <form class="actions clearfix" t:type="form" t:id="actionsForm"> <div class="fields fleft"> <t:label t:for="companies" /> : @@ -144,6 +144,8 @@ <div class="mtop30" /> <t:if t:test="currentUser.admin"> + <h2>Imports</h2> + <t:importFieldSet t:label="des zones de pêche" t:engine="fishingZoneImportEngine" /> <t:importFieldSet t:label="du plan d'échantillonnage" t:engine="samplingPlanImportEngine" /> @@ -170,4 +172,48 @@ <div class="mtop10" /> + <t:if t:test="currentUser.admin"> + + <h2>Synthèse globale</h2> + + <!-- ALL ACTUAL VALUES FOR INDICATORS OF GLOBAL SYNTHESIS --> + + <t:loop t:source="indicators" t:value="indicator"> + <table class="indicator"> + <caption>Indicateur : ${indicator.synthesisId} (coefficient = ${indicator.coefficient})</caption> + <tbody> + <tr> + <th>Niveaux</th> + <t:loop t:source="indicatorLevels" t:value="indicatorLevel"> + <td>${indicatorLevel.level}</td> + </t:loop> + </tr> + <tr> + <th>Bornes</th> + <t:loop t:source="indicatorLevels" t:value="indicatorLevel"> + <td> + <t:if test="lowerUpperBoundAreEquals"> + ${indicatorLevel.upperBound} + <p:else> + <t:if test="indicatorLevel.lowerBoundPositiveInfinity"> + ${indicatorLevel.upperBound} et plus + <p:else> + ${indicatorLevel.lowerBound} à ${indicatorLevel.upperBound} + </p:else> + </t:if> + </p:else> + </t:if> + </td> + </t:loop> + </tr> + </tbody> + </table> + </t:loop> + + <!-- FORM TO MODIFY INDICATOR --> + + + + </t:if> + </t:layout> Modified: trunk/wao-ui/src/main/webapp/css/common.css =================================================================== --- trunk/wao-ui/src/main/webapp/css/common.css 2010-10-14 10:51:10 UTC (rev 673) +++ trunk/wao-ui/src/main/webapp/css/common.css 2010-10-14 10:51:37 UTC (rev 674) @@ -372,3 +372,25 @@ height: 22px; background: url(../img/file-import-22px.png) no-repeat center center; } + +/* INDICATOR TABLES */ +table.indicator { + border: solid 1px black; + margin-left: auto; + margin-right: auto; + margin-bottom: 10px; + border-collapse: collapse; +} + +table.indicator th, table.indicator td { + border: solid 1px black; + padding: 5px; +} + +table.indicator th { + text-align: left; +} + +table.indicator td { + text-align: center; +} \ No newline at end of file