From bleny@users.labs.libre-entreprise.org Mon Jun 15 01:51:16 2026
From: bleny@users.labs.libre-entreprise.org
To: wao-commits@list.forge.codelutin.com
Subject: [Suiviobsmer-commits] r802 - in trunk:
	wao-business/src/main/java/fr/ifremer/wao/entity
	wao-business/src/main/java/fr/ifremer/wao/service	wao-business/src/main/xmi
	wao-ui/src/main/java/fr/ifremer/wao/ui/base wao-ui/src/main/webapp
Date: Fri, 26 Nov 2010 11:11:06 +0100
Message-ID: <20101126101106.2CE472F228@labs.libre-entreprise.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============9033228813354051161=="

--===============9033228813354051161==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Author: bleny
Date: 2010-11-26 10:11:05 +0000 (Fri, 26 Nov 2010)
New Revision: 802

Log:
update filters in sampling plan

Modified:
   trunk/wao-business/src/main/java/fr/ifremer/wao/entity/DCF5CodeImpl.java
   trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingGearDCFImpl.=
java
   trunk/wao-business/src/main/java/fr/ifremer/wao/entity/TargetSpeciesDCFImp=
l.java
   trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImp=
l.java
   trunk/wao-business/src/main/xmi/wao.zargo
   trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java
   trunk/wao-ui/src/main/webapp/SamplingPlan.tml

Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/DCF5CodeImpl=
.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/DCF5CodeImpl.java	=
2010-11-25 15:30:03 UTC (rev 801)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/DCF5CodeImpl.java	=
2010-11-26 10:11:05 UTC (rev 802)
@@ -40,12 +40,16 @@
=20
     @Override
     public String getFishingGearDescription() {
-        return _("DCF.gear." + getFishingGearDCF());
+        return getFishingGearDCF().getDescription();
     }
=20
     @Override
     public String getTargetSpeciesDescription() {
-        return _("DCF.species." + getTargetSpeciesDCF());
+        String description =3D null;
+        if (getTargetSpeciesDCF() !=3D null) {
+            description =3D getTargetSpeciesDCF().getDescription();
+        }
+        return description;
     }
=20
     @Override

Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingGearD=
CFImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingGearDCFImpl=
.java	2010-11-25 15:30:03 UTC (rev 801)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingGearDCFImpl=
.java	2010-11-26 10:11:05 UTC (rev 802)
@@ -1,5 +1,7 @@
 package fr.ifremer.wao.entity;
=20
+import static org.nuiton.i18n.I18n._;
+
 /**
  * @author bleny
  */
@@ -14,4 +16,8 @@
         setCode(code);
     }
=20
+    @Override
+    public String getDescription() {
+        return _(FishingGearDCF.class.getName() + "." + getCode());
+    }
 }

Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/TargetSpecie=
sDCFImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/TargetSpeciesDCFIm=
pl.java	2010-11-25 15:30:03 UTC (rev 801)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/TargetSpeciesDCFIm=
pl.java	2010-11-26 10:11:05 UTC (rev 802)
@@ -1,5 +1,7 @@
 package fr.ifremer.wao.entity;
=20
+import static org.nuiton.i18n.I18n._;
+
 /**
  * @author bleny
  */
@@ -13,4 +15,9 @@
         super();
         setCode(code);
     }
+
+    @Override
+    public String getDescription() {
+        return _(TargetSpeciesDCF.class.getName() + "." + getCode());
+    }
 }

Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamp=
lingImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingIm=
pl.java	2010-11-25 15:30:03 UTC (rev 801)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingIm=
pl.java	2010-11-26 10:11:05 UTC (rev 802)
@@ -103,7 +103,6 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
=20
 /**
  * ServiceSamplingImpl
@@ -441,30 +440,6 @@
=20
         SampleRowDAO dao =3D WaoDAOHelper.getSampleRowDAO(transaction);
=20
-//        // FishingZone properties
-//        String fishingZoneAlias =3D "Z";
-//        String fishingZoneFacadeProperty =3D
-//                TopiaQuery.getProperty(fishingZoneAlias, FishingZone.FACAD=
E_NAME);
-//        String fishingZoneSectorProperty =3D
-//                TopiaQuery.getProperty(fishingZoneAlias, FishingZone.SECTO=
R_NAME);
-//        String fishingZoneDistrictProperty =3D
-//                TopiaQuery.getProperty(fishingZoneAlias, FishingZone.DISTR=
ICT_CODE);
-//        String fishingZoneSampleRowProperty =3D
-//                TopiaQuery.getProperty(fishingZoneAlias, FishingZone.SAMPL=
E_ROW);
-//
-//        // SampleRow properties
-//        String sampleRowAlias =3D "S";
-//        String sampleRowCodeProperty =3D
-//                TopiaQuery.getProperty(sampleRowAlias, SampleRow.CODE);
-//
-//        // Query
-//        TopiaQuery query =3D dao.createQuery(sampleRowAlias).addDistinct().
-//                               addFrom(FishingZone.class, fishingZoneAlias=
).
-//                               // TODO-fdesbois-2010-06-07 for ToPIA 2.4 :=
 replace this statement by addInElements
-//                               add(sampleRowAlias + " IN elements(" + fish=
ingZoneSampleRowProperty + ")");
-//
-//        filter.prepareQueryForSampling(query, sampleRowAlias, fishingZoneA=
lias);
-
         WaoQueryBuilder builder =3D context.newQueryBuilder();
=20
         WaoQueryHelper.SampleRowProperty sampleRowProperty =3D
@@ -1165,12 +1140,61 @@
     }
=20
     @Override
-    protected Set<String> executeGetDCFGears(TopiaContext transaction, Sampl=
ingFilter filter) throws Exception {
-        throw new UnsupportedOperationException();
+    protected List<FishingGearDCF> executeGetDCFGears(TopiaContext transacti=
on, SamplingFilter filter) throws Exception {
+
+        // return all distinct fishing gear DCF codes used in sample-rows fi=
ltered by filter
+
+        WaoQueryBuilder builder =3D context.newQueryBuilder();
+
+        WaoQueryHelper.SampleRowProperty sampleRowProperty =3D
+                builder.initializeForSampleRow(true);
+
+        WaoQueryHelper.FishingZoneProperty fishingZoneProperty =3D WaoQueryH=
elper.newFishingZoneProperty();
+        WaoQueryHelper.DCF5CodeProperty dcf5CodeProperty =3D WaoQueryHelper.=
newDCF5CodeProperty();
+        WaoQueryHelper.FishingGearDCFProperty fishingGearDCFProperty =3D Wao=
QueryHelper.newFishingGearDCFProperty();
+
+        TopiaQuery query =3D builder.applySamplingFilter(filter).
+                addDistinct().
+                setSelect(fishingGearDCFProperty.$alias()).
+                addJoin(sampleRowProperty.fishingZone(), fishingZoneProperty=
.$alias(), false).
+                addJoin(sampleRowProperty.dCF5Code(), dcf5CodeProperty.$alia=
s(), false).
+                addJoin(dcf5CodeProperty.fishingGearDCF(), fishingGearDCFPro=
perty.$alias(), false).
+                addOrder(fishingGearDCFProperty.code());
+
+        if (log.isDebugEnabled()) {
+            log.debug("query to get distinct DCF fishing gears : " + query);
+        }
+
+        List<FishingGearDCF> dcfGears =3D transaction.findByQuery(query);
+        return dcfGears;
     }
=20
     @Override
-    protected Set<String> executeGetDCFSpecies(TopiaContext transaction, Sam=
plingFilter filter) throws Exception {
-        throw new UnsupportedOperationException();
+    protected List<TargetSpeciesDCF> executeGetDCFSpecies(TopiaContext trans=
action, SamplingFilter filter) throws Exception {
+
+        // return all distinct target species DCF codes used in sample-rows =
filtered by filter
+
+        WaoQueryBuilder builder =3D context.newQueryBuilder();
+
+        WaoQueryHelper.SampleRowProperty sampleRowProperty =3D builder.initi=
alizeForSampleRow(true);
+
+        WaoQueryHelper.FishingZoneProperty fishingZoneProperty =3D WaoQueryH=
elper.newFishingZoneProperty();
+        WaoQueryHelper.DCF5CodeProperty dcf5CodeProperty =3D WaoQueryHelper.=
newDCF5CodeProperty();
+        WaoQueryHelper.TargetSpeciesDCFProperty targetSpeciesDCFProperty =3D=
 WaoQueryHelper.newTargetSpeciesDCFProperty();
+
+        TopiaQuery query =3D builder.applySamplingFilter(filter).
+                addDistinct().
+                setSelect(targetSpeciesDCFProperty.$alias()).
+                addJoin(sampleRowProperty.fishingZone(), fishingZoneProperty=
.$alias(), false).
+                addJoin(sampleRowProperty.dCF5Code(), dcf5CodeProperty.$alia=
s(), false).
+                addJoin(dcf5CodeProperty.targetSpeciesDCF(), targetSpeciesDC=
FProperty.$alias(), false).
+                addOrder(targetSpeciesDCFProperty.code());
+
+        if (log.isDebugEnabled()) {
+            log.debug("query to get distinct DCF target species : " + query);
+        }
+
+        List<TargetSpeciesDCF> dcfSpecies =3D transaction.findByQuery(query);
+        return dcfSpecies;
     }
 }

Modified: trunk/wao-business/src/main/xmi/wao.zargo
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
(Binary files differ)

Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredP=
age.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.ja=
va	2010-11-25 15:30:03 UTC (rev 801)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.ja=
va	2010-11-26 10:11:05 UTC (rev 802)
@@ -28,7 +28,9 @@
 import fr.ifremer.wao.bean.ConnectedUser;
 import fr.ifremer.wao.bean.SamplingFilter;
 import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.FishingGearDCF;
 import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.TargetSpeciesDCF;
 import fr.ifremer.wao.entity.WaoUser;
 import fr.ifremer.wao.service.ServiceBoat;
 import fr.ifremer.wao.service.ServiceReferential;
@@ -50,8 +52,6 @@
 import java.util.ArrayList;
 import java.util.List;
=20
-import static org.nuiton.i18n.I18n._;
-
 /**
  * AbstractFilteredPage
  *
@@ -312,7 +312,7 @@
             getFilter().setSampleRows(rowsFiltered);
=20
             sampleRowSelectModel =3D new GenericSelectModel<SampleRow>(sampl=
eRows, SampleRow.class,
-                "code", "topiaId", propertyAccess);
+                SampleRow.CODE, SampleRow.TOPIA_ID, propertyAccess);
         }
         return sampleRowSelectModel;
     }
@@ -329,7 +329,7 @@
         if (companySelectModel =3D=3D null) {
             List<Company> companies =3D serviceUser.getCompanies(isAvailable=
DataForFiltersOnly());
             companySelectModel =3D new GenericSelectModel<Company>(companies=
,Company.class,
-                    "name","topiaId",propertyAccess);
+                    Company.NAME, Company.TOPIA_ID, propertyAccess);
         }
         return companySelectModel;
     }
@@ -348,7 +348,7 @@
                     serviceUser.getObservers(getFilter().getCompany(),
                         isAvailableDataForFiltersOnly());
             observerSelectModel =3D new GenericSelectModel<WaoUser>(observer=
s,WaoUser.class,
-                    "fullName","topiaId",propertyAccess);
+                    "fullName", "topiaId", propertyAccess);
         }
         return observerSelectModel;
     }
@@ -371,30 +371,42 @@
         return programSelectModel;
     }
=20
-    private SelectModel dcfGearSelectModel;
+    @Property
+    @Persist
+    private String fishingGearDCFId;
=20
-    public SelectModel getDcfGearSelectModel() throws WaoException {
+    private GenericSelectModel<FishingGearDCF> dcfGearSelectModel;
+
+    public GenericSelectModel<FishingGearDCF> getDcfGearSelectModel() throws=
 WaoException {
         if (dcfGearSelectModel =3D=3D null) {
-            List<OptionModel> options =3D new ArrayList<OptionModel>();
-            for (String dcfGear : serviceSampling.getDCFGears(getFilter())) {
-                options.add(new OptionModelImpl(dcfGear + " - " +
-                                      _("DCF.gear." + dcfGear), dcfGear));
-            }
-            dcfGearSelectModel =3D new SelectModelImpl(null, options);
+            // don't filter with already defined DCFs
+            FishingGearDCF keptFishingGearDCF =3D getFilter().getFishingGear=
DCF();
+            getFilter().setFishingGearDCF(null);
+            List<FishingGearDCF> fishingGearDCFs =3D serviceSampling.getDCFG=
ears(getFilter());
+            getFilter().setFishingGearDCF(keptFishingGearDCF);
+
+            dcfGearSelectModel =3D new GenericSelectModel<FishingGearDCF>(fi=
shingGearDCFs, FishingGearDCF.class,
+                    FishingGearDCF.CODE, FishingGearDCF.TOPIA_ID, propertyAc=
cess);
         }
         return dcfGearSelectModel;
     }
=20
-    private SelectModel dcfSpeciesSelectModel;
+    @Property
+    @Persist
+    private String targetSpeciesDCFId;
=20
-    public SelectModel getDcfSpeciesSelectModel() throws WaoException {
+    private GenericSelectModel<TargetSpeciesDCF> dcfSpeciesSelectModel;
+
+    public GenericSelectModel<TargetSpeciesDCF> getDcfSpeciesSelectModel() t=
hrows WaoException {
         if (dcfSpeciesSelectModel =3D=3D null) {
-            List<OptionModel> options =3D new ArrayList<OptionModel>();
-            for (String dcfSpecies : serviceSampling.getDCFSpecies(getFilter=
())) {
-                options.add(new OptionModelImpl(dcfSpecies + " - " +
-                                      _("DCF.species." + dcfSpecies), dcfSpe=
cies));
-            }
-            dcfSpeciesSelectModel =3D new SelectModelImpl(null, options);
+            // don't filter with already defined DCFs
+            TargetSpeciesDCF keptTargetSpeciesDCF =3D getFilter().getTargetS=
peciesDCF();
+            getFilter().setTargetSpeciesDCF(null);
+            List<TargetSpeciesDCF> targetSpeciesDCFs =3D serviceSampling.get=
DCFSpecies(getFilter());
+            getFilter().setTargetSpeciesDCF(keptTargetSpeciesDCF);
+
+            dcfSpeciesSelectModel =3D new GenericSelectModel<TargetSpeciesDC=
F>(targetSpeciesDCFs, TargetSpeciesDCF.class,
+                    TargetSpeciesDCF.CODE, TargetSpeciesDCF.TOPIA_ID, proper=
tyAccess);
         }
         return dcfSpeciesSelectModel;
     }
@@ -441,6 +453,15 @@
             }
             getFilter().setObserver(observer);
         }
+
+        if (fishingGearDCFId !=3D null) {
+            FishingGearDCF fishingGearDCF =3D getDcfGearSelectModel().findOb=
ject(fishingGearDCFId);
+            getFilter().setFishingGearDCF(fishingGearDCF);
+        }
+        if (targetSpeciesDCFId !=3D null) {
+            TargetSpeciesDCF targetSpeciesDCF =3D getDcfSpeciesSelectModel()=
.findObject(targetSpeciesDCFId);
+            getFilter().setTargetSpeciesDCF(targetSpeciesDCF);
+        }
     }
=20
     private boolean edited;

Modified: trunk/wao-ui/src/main/webapp/SamplingPlan.tml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/wao-ui/src/main/webapp/SamplingPlan.tml	2010-11-25 15:30:03 UTC (re=
v 801)
+++ trunk/wao-ui/src/main/webapp/SamplingPlan.tml	2010-11-26 10:11:05 UTC (re=
v 802)
@@ -124,9 +124,9 @@
                                 </div>
                                 <div>
                                     <t:label t:for=3D"fishingGearDCF" />&nbs=
p;:
-                                    <input t:type=3D"select" t:id=3D"fishing=
GearDCF" t:model=3D"dcfGearSelectModel" value=3D"filter.fishingGearDCF"/>&nbs=
p;
+                                    <input t:type=3D"select" t:id=3D"fishing=
GearDCF" t:model=3D"dcfGearSelectModel" value=3D"fishingGearDCFId"/>&nbsp;
                                     <t:label t:for=3D"targetSpeciesDCF" />&n=
bsp;:
-                                    <input t:type=3D"select" t:id=3D"targetS=
peciesDCF" t:model=3D"dcfSpeciesSelectModel" value=3D"filter.targetSpeciesDCF=
"/>&nbsp;
+                                    <input t:type=3D"select" t:id=3D"targetS=
peciesDCF" t:model=3D"dcfSpeciesSelectModel" value=3D"targetSpeciesDCFId"/>&n=
bsp;
                                 </div>
                                 <div class=3D"t-beaneditor-row aright">
                                     <input t:type=3D"submit" class=3D"ico se=
arch-32px" t:id=3D"search" value=3D"Search" title=3D"Rechercher les lignes du=
 plan correspondants aux filtres saisies" />&nbsp;


--===============9033228813354051161==--


