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] r131 - in trunk/suiviobsmer-ui/src/main/webapp: . css
by fdesbois@users.labs.libre-entreprise.org 17 Dec '09
by fdesbois@users.labs.libre-entreprise.org 17 Dec '09
17 Dec '09
Author: fdesbois
Date: 2009-12-17 18:57:17 +0000 (Thu, 17 Dec 2009)
New Revision: 131
Modified:
trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml
trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css
Log:
Minor corrections of style/template
Modified: trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml 2009-12-17 18:55:43 UTC (rev 130)
+++ trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml 2009-12-17 18:57:17 UTC (rev 131)
@@ -163,16 +163,6 @@
</tbody>
</table>
</t:zone>
- <t:if t:test="user.admin">
- <div class="actions aright">
- <span>
- <img src="${asset:context:}/img/undo.png" alt="Annuler" title="Annuler les modifications"/>
- </span>
- <span>
- <img src="${asset:context:}/img/save.png" alt="Enregistrer" title="Enregistrer les modifications"/>
- </span>
- </div>
- </t:if>
</div>
Modified: trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css 2009-12-17 18:55:43 UTC (rev 130)
+++ trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css 2009-12-17 18:57:17 UTC (rev 131)
@@ -63,6 +63,7 @@
div#so-contacts table.t-data-grid thead tr th.mammals {
white-space: normal;
+ width: 100px;
}
div#so-contacts table.t-data-grid thead tr th.actions {
1
0
[Suiviobsmer-commits] r130 - in trunk/suiviobsmer-business/src/main: java/fr/ifremer/suiviobsmer/entity java/fr/ifremer/suiviobsmer/impl xmi
by fdesbois@users.labs.libre-entreprise.org 17 Dec '09
by fdesbois@users.labs.libre-entreprise.org 17 Dec '09
17 Dec '09
Author: fdesbois
Date: 2009-12-17 18:55:43 +0000 (Thu, 17 Dec 2009)
New Revision: 130
Modified:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ActivityCalendarImport.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
Log:
- Add index on immatriculation attribute in Boat entity
- All data from ActivityCalendar is always updated (even they already exist)
- Change default return value for canCreateContact method : waiting for business validation on create contact conditions.
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2009-12-17 09:35:21 UTC (rev 129)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2009-12-17 18:55:43 UTC (rev 130)
@@ -142,10 +142,13 @@
@Override
public boolean canCreateContact(Company company, SampleRow row) throws SuiviObsmerException {
TopiaContext transaction = null;
- boolean result = true;
+ // FIXME depends on condition over double creation on the same sampleRow for the same company.
+ // Normally, the default value is true (if no contact exist for this boat, it's possible to create one)
+ boolean result = false;
try {
transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ // Return the last contact for this boat, sampleRow and company
List results = transaction.find(
"FROM ContactImpl C1" +
" WHERE C1.user.company = :company" +
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ActivityCalendarImport.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ActivityCalendarImport.java 2009-12-17 09:35:21 UTC (rev 129)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ActivityCalendarImport.java 2009-12-17 18:55:43 UTC (rev 130)
@@ -96,8 +96,6 @@
Boat boat = boatDAO.findByImmatriculation(boatImmatriculation);
-
-
if (boat != null) {
ActivityCalendarDAO dao = SuiviObsmerModelDAOHelper.getActivityCalendarDAO(transaction);
@@ -118,123 +116,130 @@
calendar.setActivityMonth(new ArrayList<ActivityMonth>());
- info("Création d'un calendrier " + year +
+ if (log.isDebugEnabled()) {
+ info("Création d'un calendrier " + year +
" pour le navire immatriculé " + boatImmatriculation, currRow);
-
- //transaction.commitTransaction();
+ }
}
String calendarCode = "[ calendrier " + year + ", navire " + boatImmatriculation + " ]";
int monthNum = Integer.parseInt(reader.get("SYNA_MOI").trim());
String harbourCode = reader.get("SYNA_POR_COD").trim();
+ boolean active = !harbourCode.equals("INA");
ActivityMonth month = calendar.getActivityMonth(monthNum);
if (month == null) {
- boolean active = !harbourCode.equals("INA");
-
ActivityMonthDAO monthDAO = SuiviObsmerModelDAOHelper.getActivityMonthDAO(transaction);
month = monthDAO.create(
ActivityMonth.ACTIVITY_CALENDAR, calendar,
- ActivityMonth.MONTH, monthNum,
- ActivityMonth.ACTIVE, active);
+ ActivityMonth.MONTH, monthNum);
month.setActivityProfession(new ArrayList<ActivityProfession>());
- info("Création du mois " + monthNum + " actif(" + active + ") " + calendarCode, currRow);
+ if (log.isDebugEnabled()) {
+ info("Création du mois " + monthNum + " actif(" + active + ") " + calendarCode, currRow);
+ }
- if (active) {
- String nbSeaDaysString = reader.get("SYNA_NOMJDM").trim();
- Integer nbSeaDays = !nbSeaDaysString.equals("NA") ?
- Integer.valueOf(nbSeaDaysString) : null;
+ calendar.addActivityMonth(month);
+ }
- String nbFishingDaysString = reader.get("SYNA_NOMJDP").trim();
- Integer nbFishingDays = !nbFishingDaysString.equals("NA") ?
- Integer.valueOf(nbFishingDaysString) : null;
+ month.setActive(active);
- String nbBoardingPersonsString = reader.get("SYNA_NOMHE").trim();
- Integer nbBoardingPersons = !nbBoardingPersonsString.equals("NA") ?
- Integer.valueOf(nbBoardingPersonsString) : null;
+ if (active) {
+ String nbSeaDaysString = reader.get("SYNA_NOMJDM").trim();
+ Integer nbSeaDays = !nbSeaDaysString.equals("NA") ?
+ Integer.valueOf(nbSeaDaysString) : null;
- int harbourId = Integer.parseInt(reader.get("SYNA_TPOR_COD").trim());
- String harbourLibelle = reader.get("SYNA_POR_LIB").trim();
- //String harbourCode = reader.get("SYNA_POR_COD").trim();
+ String nbFishingDaysString = reader.get("SYNA_NOMJDP").trim();
+ Integer nbFishingDays = !nbFishingDaysString.equals("NA") ?
+ Integer.valueOf(nbFishingDaysString) : null;
- month.setHarbourId(harbourId);
- month.setHarbourCode(harbourCode);
- month.setHarbourLibelle(harbourLibelle);
- month.setNbBoardingPersons(nbBoardingPersons);
- month.setNbFishingDays(nbFishingDays);
- month.setNbSeaDays(nbSeaDays);
- } else {
- result++;
- }
+ String nbBoardingPersonsString = reader.get("SYNA_NOMHE").trim();
+ Integer nbBoardingPersons = !nbBoardingPersonsString.equals("NA") ?
+ Integer.valueOf(nbBoardingPersonsString) : null;
- calendar.addActivityMonth(month);
+ int harbourId = Integer.parseInt(reader.get("SYNA_TPOR_COD").trim());
+ String harbourLibelle = reader.get("SYNA_POR_LIB").trim();
+ //String harbourCode = reader.get("SYNA_POR_COD").trim();
- //transaction.commitTransaction();
- }
+ month.setHarbourId(harbourId);
+ month.setHarbourCode(harbourCode);
+ month.setHarbourLibelle(harbourLibelle);
+ month.setNbBoardingPersons(nbBoardingPersons);
+ month.setNbFishingDays(nbFishingDays);
+ month.setNbSeaDays(nbSeaDays);
- if (month.getActive()) {
+ int professionOrder = Integer.parseInt(reader.get("META_ORDRE").trim());
+ String professionCode = reader.get("MET_COD").trim();
+ int professionId = Integer.parseInt(reader.get("MET_ID").trim());
+ String professionLibelle = reader.get("MET_LIB").trim();
- int professionOrder = Integer.parseInt(reader.get("META_ORDRE").trim());
ActivityProfession profession = month.getActivityProfession(professionOrder);
if (profession == null) {
- String professionCode = reader.get("MET_COD").trim();
- int professionId = Integer.parseInt(reader.get("MET_ID").trim());
- String professionLibelle = reader.get("MET_LIB").trim();
ActivityProfessionDAO professionDAO =
SuiviObsmerModelDAOHelper.getActivityProfessionDAO(transaction);
profession = professionDAO.create(
ActivityProfession.ACTIVITY_MONTH, month,
- ActivityProfession.PROFESSION_ORDER, professionOrder,
- ActivityProfession.ID, professionId,
- ActivityProfession.CODE, professionCode,
- ActivityProfession.LIBELLE, professionLibelle);
+ ActivityProfession.PROFESSION_ORDER, professionOrder);
profession.setActivityZone(new ArrayList<ActivityZone>());
- info("Création du métier " + professionOrder + " code(" + professionCode + ") " +
+ if (log.isDebugEnabled()) {
+ info("Création du métier " + professionOrder + " code(" + professionCode + ") " +
"[ mois " + monthNum + " ] " +
calendarCode, currRow);
+ }
month.addActivityProfession(profession);
}
+ profession.setId(professionId);
+ profession.setCode(professionCode);
+ profession.setLibelle(professionLibelle);
+
String zoneCode = reader.get("SECT_COD").trim();
+ int gradiantCode = Integer.parseInt(reader.get("GRA_COD").trim());
+ String gradiantLibelle = reader.get("GRA_LIB").trim();
+ int zoneId = Integer.parseInt(reader.get("TSECT_COD").trim());
+ String zoneLibelle = reader.get("SECT_LIB").trim();
ActivityZone zone = profession.getActivityZone(zoneCode);
if (zone == null) {
- int gradiantCode = Integer.parseInt(reader.get("GRA_COD").trim());
- String gradiantLibelle = reader.get("GRA_LIB").trim();
- int zoneId = Integer.parseInt(reader.get("TSECT_COD").trim());
- String zoneLibelle = reader.get("SECT_LIB").trim();
-
ActivityZoneDAO zoneDAO =
SuiviObsmerModelDAOHelper.getActivityZoneDAO(transaction);
zone = zoneDAO.create(
- ActivityZone.ACTIVITY_PROFESSION, profession,
- ActivityZone.ZONE_ID, zoneId,
- ActivityZone.GRADIANT_CODE, gradiantCode,
- ActivityZone.GRADIANT_LIBELLE, gradiantLibelle,
ActivityZone.ZONE_CODE, zoneCode,
- ActivityZone.ZONE_LIBELLE, zoneLibelle);
+ ActivityZone.ACTIVITY_PROFESSION, profession);
- info("Création de la zone " + zoneCode + " [ mois " + monthNum + " ] " +
+ if (log.isDebugEnabled()) {
+ info("Création de la zone " + zoneCode + " [ mois " + monthNum + " ] " +
calendarCode, currRow);
+ }
profession.addActivityZone(zone);
- result++;
} else {
- warn("Zone déjà existante [" + zoneCode + "] ! :: " + Arrays.toString(reader.getValues()), currRow);
+ if (log.isDebugEnabled()) {
+ info("Ecrasement de la zone " + zoneCode + " [ mois " + monthNum + " ] " +
+ calendarCode, currRow);
+ }
+ //warn("Zone déjà existante [" + zoneCode + "] ! :: " + Arrays.toString(reader.getValues()), currRow);
}
+
+ zone.setZoneId(zoneId);
+ zone.setZoneLibelle(zoneLibelle);
+ zone.setGradiantCode(gradiantCode);
+ zone.setGradiantLibelle(gradiantLibelle);
+ } else {
+ info("Ligne inactif", currRow);
}
+ result++;
} else {
warn("Navire inexistant dans le référentiel : " + boatImmatriculation, currRow);
}
@@ -244,10 +249,12 @@
log.debug("Time : " + DurationFormatUtils.formatDurationHMS(tic - firstTic));
}
- transaction.commitTransaction();
- writer.flush();
+ if (result%500 == 0 && log.isInfoEnabled()) {
+ log.info("RUNNING... Import calendrier d'activité ligne " + currRow);
+ }
}
+ transaction.commitTransaction();
long stopTime = System.currentTimeMillis();
@@ -293,6 +300,7 @@
String ligne = numRow != -1 ? "Ligne (" + numRow + ") : " : "";
String msg = "[" + dateString + "] " + ligne + message;
writer.write(msg + "\n");
+ writer.flush();
if (log.isDebugEnabled()) {
log.debug("write log activityCalendar : " + msg);
}
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
1
0
[Suiviobsmer-commits] r129 - trunk/suiviobsmer-business
by fdesbois@users.labs.libre-entreprise.org 17 Dec '09
by fdesbois@users.labs.libre-entreprise.org 17 Dec '09
17 Dec '09
Author: fdesbois
Date: 2009-12-17 09:35:21 +0000 (Thu, 17 Dec 2009)
New Revision: 129
Modified:
trunk/suiviobsmer-business/pom.xml
Log:
Improve generation configuration
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2009-12-17 09:34:27 UTC (rev 128)
+++ trunk/suiviobsmer-business/pom.xml 2009-12-17 09:35:21 UTC (rev 129)
@@ -97,6 +97,7 @@
<executions>
<execution>
<phase>generate-sources</phase>
+ <!-- By default, generation from ObjectModel -->
<configuration>
<inputFiles>
<inputFile>zargo</inputFile>
1
0
[Suiviobsmer-commits] r128 - trunk/suiviobsmer-business
by fdesbois@users.labs.libre-entreprise.org 17 Dec '09
by fdesbois@users.labs.libre-entreprise.org 17 Dec '09
17 Dec '09
Author: fdesbois
Date: 2009-12-17 09:34:27 +0000 (Thu, 17 Dec 2009)
New Revision: 128
Modified:
trunk/suiviobsmer-business/pom.xml
Log:
Improve generation configuration
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2009-12-16 21:52:04 UTC (rev 127)
+++ trunk/suiviobsmer-business/pom.xml 2009-12-17 09:34:27 UTC (rev 128)
@@ -96,51 +96,25 @@
<version>${eugene.version}</version>
<executions>
<execution>
- <id>Zargo to object model</id>
<phase>generate-sources</phase>
<configuration>
- <!--modelType>objectmodel</modelType-->
<inputFiles>
- <include>zargo</include>
+ <inputFile>zargo</inputFile>
</inputFiles>
+<!-- <includes>**/*.objectmodel</includes>-->
+ <defaultPackage>fr.ifremer.suiviobsmer</defaultPackage>
<fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>
- <!--<outputDirectory>target/generated-sources-zargo2ObjectModel</outputDirectory>-->
+ <templates>
+ org.nuiton.topia.generator.TopiaMetaGenerator,
+ org.nuiton.topia.generator.InterfaceTransformer,
+ org.nuiton.topia.generator.BeanTransformer
+ </templates>
</configuration>
<goals>
<goal>generate-model-files</goal>
- </goals>
- </execution>
- <execution>
- <id>ObjectModel to Java</id>
- <phase>generate-sources</phase>
- <configuration>
- <!--reader>org.nuiton.eugene.ObjectModelReader</reader-->
- <!--includes>**/*.objectmodel</includes-->
- <templates>org.nuiton.topia.generator.TopiaMetaGenerator,org.nuiton.topia.generator.InterfaceTransformer,org.nuiton.topia.generator.BeanTransformer</templates>
- <!--<extractedPackages>fr.ifremer.suiviobsmer</extractedPackages>
- <fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>-->
- <defaultPackage>fr.ifremer.suiviobsmer</defaultPackage>
- <generatedPackages>fr.ifremer.suiviobsmer</generatedPackages>
- </configuration>
- <goals>
<goal>generate-from-models</goal>
</goals>
</execution>
- <!--<execution>
- <id>generate-statemodel</id>
- <phase>generate-test-sources</phase>
- <configuration>
- <reader>org.nuiton.eugene.StateModelReader</reader>
- <fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>
- <extractedPackages>fr.ifremer.suiviobsmer</extractedPackages>
- <includes>**/*.statemodel</includes>
- <extraClassPathDirectory>target/classes</extraClassPathDirectory>
- </configuration>
- <goals>
- <goal>zargo2xmi</goal>
- <goal>xmi2statemodel</goal>
- </goals>
- </execution>-->
</executions>
</plugin>
</plugins>
1
0
Author: tchemit
Date: 2009-12-16 21:52:04 +0000 (Wed, 16 Dec 2009)
New Revision: 127
Modified:
trunk/pom.xml
Log:
use chenillekit-tapestry 1.2.0
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-16 20:45:00 UTC (rev 126)
+++ trunk/pom.xml 2009-12-16 21:52:04 UTC (rev 127)
@@ -78,7 +78,7 @@
<dependency>
<groupId>org.chenillekit</groupId>
<artifactId>chenillekit-tapestry</artifactId>
- <version>1.0.0</version>
+ <version>1.2.0</version>
<exclusions>
<exclusion>
<groupId>jboss</groupId>
1
0
[Suiviobsmer-commits] r126 - trunk/suiviobsmer-business
by tchemit@users.labs.libre-entreprise.org 16 Dec '09
by tchemit@users.labs.libre-entreprise.org 16 Dec '09
16 Dec '09
Author: tchemit
Date: 2009-12-16 20:45:00 +0000 (Wed, 16 Dec 2009)
New Revision: 126
Modified:
trunk/suiviobsmer-business/pom.xml
Log:
use new eugeune goals
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2009-12-16 18:26:29 UTC (rev 125)
+++ trunk/suiviobsmer-business/pom.xml 2009-12-16 20:45:00 UTC (rev 126)
@@ -99,10 +99,10 @@
<id>Zargo to object model</id>
<phase>generate-sources</phase>
<configuration>
- <modelType>objectmodel</modelType>
- <includes>
+ <!--modelType>objectmodel</modelType-->
+ <inputFiles>
<include>zargo</include>
- </includes>
+ </inputFiles>
<fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>
<!--<outputDirectory>target/generated-sources-zargo2ObjectModel</outputDirectory>-->
</configuration>
@@ -114,8 +114,8 @@
<id>ObjectModel to Java</id>
<phase>generate-sources</phase>
<configuration>
- <reader>org.nuiton.eugene.ObjectModelReader</reader>
- <includes>**/*.objectmodel</includes>
+ <!--reader>org.nuiton.eugene.ObjectModelReader</reader-->
+ <!--includes>**/*.objectmodel</includes-->
<templates>org.nuiton.topia.generator.TopiaMetaGenerator,org.nuiton.topia.generator.InterfaceTransformer,org.nuiton.topia.generator.BeanTransformer</templates>
<!--<extractedPackages>fr.ifremer.suiviobsmer</extractedPackages>
<fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>-->
@@ -123,7 +123,7 @@
<generatedPackages>fr.ifremer.suiviobsmer</generatedPackages>
</configuration>
<goals>
- <goal>generate</goal>
+ <goal>generate-from-models</goal>
</goals>
</execution>
<!--<execution>
1
0
[Suiviobsmer-commits] r125 - in trunk: suiviobsmer-business/src/main/xmi suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/webapp suiviobsmer-ui/src/main/webapp/css
by fdesbois@users.labs.libre-entreprise.org 16 Dec '09
by fdesbois@users.labs.libre-entreprise.org 16 Dec '09
16 Dec '09
Author: fdesbois
Date: 2009-12-16 18:26:29 +0000 (Wed, 16 Dec 2009)
New Revision: 125
Modified:
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java
trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml
trunk/suiviobsmer-ui/src/main/webapp/Boats.tml
trunk/suiviobsmer-ui/src/main/webapp/css/boats.css
Log:
Page BoatActivityCalendar finished
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2009-12-16 13:47:02 UTC (rev 124)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2009-12-16 18:26:29 UTC (rev 125)
@@ -3,11 +3,20 @@
import fr.ifremer.suiviobsmer.SuiviObsmerException;
import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
+import fr.ifremer.suiviobsmer.entity.ActivityMonth;
+import fr.ifremer.suiviobsmer.entity.ActivityProfession;
+import fr.ifremer.suiviobsmer.entity.ActivityZone;
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.services.ServiceBoat;
import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import java.util.Collections;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.nuiton.util.DateUtils;
import org.slf4j.Logger;
/**
@@ -21,6 +30,7 @@
* Mise a jour: $Date$
* par : $Author$
*/
+ at IncludeStylesheet("context:css/boats.css")
public class BoatActivityCalendar implements SuiviObsmerPage {
@Inject
@@ -31,6 +41,18 @@
private ActivityCalendar activityCalendar;
+// @Property
+// private ActivityMonth activityMonth;
+
+ @Property
+ private int month;
+
+ @Property
+ private int professionIndex;
+
+ @Property
+ private int zoneIndex;
+
@Persist
private Boat boat;
@@ -47,13 +69,85 @@
this.boat = boat;
}
+ public Boat getBoat() {
+ return this.boat;
+ }
+
+ public List<Boat> getBoats() {
+ return Collections.singletonList(boat);
+ }
+
public ActivityCalendar getActivityCalendar() throws SuiviObsmerException {
if (activityCalendar == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getLastActivityCalendar]");
}
- this.activityCalendar = serviceBoat.getLastActivityCalendar(boat);
+ this.activityCalendar = serviceBoat.getLastActivityCalendar(getBoat());
}
return activityCalendar;
}
+
+ public ActivityMonth getActivityMonth() throws SuiviObsmerException {
+ return getActivityCalendar().getActivityMonth(month);
+ }
+
+ public String getMonthName() {
+ String libelle = DateUtils.getMonthLibelle(month);
+ return StringUtils.capitalize(libelle);
+ }
+
+ public int getProfessionIndexMax() {
+ int result = 0;
+ for (ActivityMonth month : activityCalendar.getActivityMonth()) {
+ int nbProfessions = month.sizeActivityProfession();
+ if (nbProfessions > result) {
+ result = nbProfessions;
+ }
+ }
+ return result-1;
+ }
+
+ public boolean hasProfessions() {
+ return getProfessionIndexMax() != -1;
+ }
+
+ public ActivityProfession getActivityProfession() throws SuiviObsmerException {
+ if (getActivityMonth() == null) {
+ return null;
+ }
+ if (professionIndex >= getActivityMonth().sizeActivityProfession()) {
+ return null;
+ }
+ return getActivityMonth().getActivityProfession().get(professionIndex);
+ }
+
+ public int getZoneIndexMax() throws SuiviObsmerException {
+ int result = 0;
+ for (ActivityMonth activityMonth : activityCalendar.getActivityMonth()) {
+ month = activityMonth.getMonth();
+ ActivityProfession profession = getActivityProfession();
+ if (profession != null) {
+ int nbZones = profession.sizeActivityZone();
+ if (nbZones > result) {
+ result = nbZones;
+ }
+ }
+ }
+ return result-1;
+ }
+
+// public boolean hasZones() {
+// return getZoneIndexMax() != -1;
+// }
+
+ public ActivityZone getActivityZone() throws SuiviObsmerException {
+ ActivityProfession profession = getActivityProfession();
+ if (profession == null) {
+ return null;
+ }
+ if (zoneIndex >= profession.sizeActivityZone()) {
+ return null;
+ }
+ return profession.getActivityZone().get(zoneIndex);
+ }
}
Modified: trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml 2009-12-16 13:47:02 UTC (rev 124)
+++ trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml 2009-12-16 18:26:29 UTC (rev 125)
@@ -3,7 +3,119 @@
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<t:if t:test="activityCalendar">
- <h1>Calendrier d'activité ${activityCalendar.year} du navire ${activityCalendar.boat.name}</h1>
+ <h1>Calendrier d'activité ${activityCalendar.year}</h1>
+
+ <table t:type="grid" id="so-activity-calendar-boat" t:source="boats" t:row="boat"
+ t:include="immatriculation, districtCode, name, boatLength, buildYear" />
+
+ <table id="so-activity-calendar-months">
+ <thead>
+ <tr>
+ <td class="none"> </td>
+ <td t:type="loop" class="month" t:source="1..12" t:value="month">
+ ${monthName}
+ </td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td class="title">Port exploit.</td>
+ <td t:type="loop" class="month" t:source="1..12" t:value="month">
+ <t:if t:test="activityMonth">
+ <span t:type="ck/Tooltip" title="Libelle"
+ t:value="prop:activityMonth.harbourLibelle" t:effect="appear">
+ ${activityMonth.harbourCode}
+ </span>
+ <p:else> </p:else>
+ </t:if>
+ </td>
+ </tr>
+ <tr>
+ <td class="title">Actif/Inactif</td>
+ <td t:type="loop" class="month" t:source="1..12" t:value="month">
+ <t:if t:test="activityMonth">
+ <t:booleanImage t:value="activityMonth.active" t:trueTitle="Actif" t:falseTitle="Inactif"/>
+ <p:else> </p:else>
+ </t:if>
+ </td>
+ </tr>
+ <tr>
+ <td class="title">Hommes emb.</td>
+ <td t:type="loop" class="month" t:source="1..12" t:value="month">
+ <t:if t:test="activityMonth">
+ ${activityMonth.nbBoardingPersons}
+ <p:else> </p:else>
+ </t:if>
+ </td>
+ </tr>
+ <tr>
+ <td class="title">J. Mer eff.</td>
+ <td t:type="loop" class="month" t:source="1..12" t:value="month">
+ <t:if t:test="activityMonth">
+ ${activityMonth.nbSeaDays}
+ <p:else> </p:else>
+ </t:if>
+ </td>
+ </tr>
+ <tr>
+ <td class="title">J. Pêche eff.</td>
+ <td t:type="loop" class="month" t:source="1..12" t:value="month">
+ <t:if t:test="activityMonth">
+ ${activityMonth.nbFishingDays}
+ <p:else> </p:else>
+ </t:if>
+ </td>
+ </tr>
+ <t:if t:test="hasProfessions()">
+ <t:loop t:source="0..${professionIndexMax}" t:index="professionIndex">
+ <tr class="profession">
+ <td class="title">Métier</td>
+ <td t:type="loop" class="month" t:source="1..12" t:value="month">
+ <t:if t:test="activityProfession">
+ <span t:type="ck/Tooltip" title="Libelle"
+ t:value="prop:activityProfession.libelle" t:effect="appear">
+ ${activityProfession.code}
+ </span>
+ <p:else> </p:else>
+ </t:if>
+ </td>
+ </tr>
+ <tr t:type="loop" t:source="0..${zoneIndexMax}" t:index="zoneIndex">
+ <td class="title">Zone/Grad.</td>
+ <td t:type="loop" class="zone month" t:source="1..12" t:value="month">
+ <t:if t:test="activityZone">
+ <span t:type="ck/Tooltip" title="Libelle"
+ t:value="prop:activityZone.zoneLibelle" t:effect="appear">
+ ${activityZone.zoneCode}
+ </span> |
+ ${activityZone.gradiantLibelle}
+ <p:else> </p:else>
+ </t:if>
+ </td>
+ </tr>
+ </t:loop>
+ </t:if>
+ </tbody>
+ </table>
+
+
+<!-- <p>Fiability : ${activityCalendar.fiability}</p>
+ <div t:type="loop" t:source="activityCalendar.activityMonth" t:value="activityMonth">
+ <p>Month : ${activityMonth.month}</p>
+ <p>Harbour : ${activityMonth.harbourCode} - ${activityMonth.harbourLibelle}</p>
+ <p>Nb Observants : ${activityMonth.nbBoardingPersons}</p>
+ <p>Nb Sea Days : ${activityMonth.nbSeaDays}</p>
+ <p>Nb Fishing Days : ${activityMonth.nbFishingDays}</p>
+ <p>Active : ${activityMonth.active}</p>
+ <div t:type="loop" t:source="activityMonth.activityProfession" t:value="activityProfession">
+ <p>Order : ${activityProfession.professionOrder}</p>
+ <p>Profession : ${activityProfession.code} - ${activityProfession.libelle}</p>
+ <div t:type="loop" t:source="activityProfession.activityZone" t:value="activityZone">
+ <p>Zone : ${activityZone.zoneCode} - ${activityZone.zoneLibelle}</p>
+ <p>Gradiant : ${activityZone.gradiantCode} - ${activityZone.gradiantLibelle}</p>
+ </div>
+ </div>
+ </div>-->
<p:else>
<div class="fb-error">
Aucun calendrier d'activité chargé !
Modified: trunk/suiviobsmer-ui/src/main/webapp/Boats.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2009-12-16 13:47:02 UTC (rev 124)
+++ trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2009-12-16 18:26:29 UTC (rev 125)
@@ -233,30 +233,33 @@
</t:if>
</p>
<p class="sep"> </p>
+ <p><label>Embarquements :</label></p>
<p>
<strong>${boatInfos.nbBoarding}</strong> embarquements
dont <strong>${boatInfos.nbBoardingForCompany}</strong> pour votre société
depuis le <strong><t:output value="boatInfos.firstBoardingDate" format="dateFormat" /></strong>
</p>
- <p class="sep"> </p>
- <label>Ligne(s) du plan :</label>
- <ul>
- <li t:type="loop" t:source="companyBoatInfos.elligibleBoatsValues" t:value="elligibleBoat">
- <span t:type="ck/Tooltip" title="Infos" t:value="prop:elligibleRowInfos" t:effect="appear">
- <span class="${elligibleRowClass}">
- ${elligibleBoat.sampleRow.code}
- </span>
- </span>
- <t:if t:test="canCreateNewContactFromElligibleBoat()">
- <a t:type="actionlink" t:id="addNewContactFromSampleRow" t:context="elligibleBoat.sampleRow.code">
- <img src="${asset:context:}/img/contact-22px.png" title="Créer un nouveau contact pour ce navire et cette ligne du plan"/>
- </a>
- </t:if>
- </li>
- </ul>
+ <t:if t:test="companyBoatInfos.elligibleBoatsValues.size()">
+ <p class="sep"> </p>
+ <label>Ligne(s) du plan :</label>
+ <ul>
+ <li t:type="loop" t:source="companyBoatInfos.elligibleBoatsValues" t:value="elligibleBoat">
+ <span t:type="ck/Tooltip" title="Infos" t:value="prop:elligibleRowInfos" t:effect="appear">
+ <span class="${elligibleRowClass}">
+ ${elligibleBoat.sampleRow.code}
+ </span>
+ </span>
+ <t:if t:test="canCreateNewContactFromElligibleBoat()">
+ <a t:type="actionlink" t:id="addNewContactFromSampleRow" t:context="elligibleBoat.sampleRow.code">
+ <img src="${asset:context:}/img/contact-22px.png" title="Créer un nouveau contact pour ce navire et cette ligne du plan"/>
+ </a>
+ </t:if>
+ </li>
+ </ul>
+ </t:if>
<t:if t:test="boatInfos.comment">
<p class="sep"> </p>
- <label>Commentaires : </label>
+ <label>Commentaire : </label>
<p class="comment">${boatInfos.comment}</p>
</t:if>
</div>
Modified: trunk/suiviobsmer-ui/src/main/webapp/css/boats.css
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/css/boats.css 2009-12-16 13:47:02 UTC (rev 124)
+++ trunk/suiviobsmer-ui/src/main/webapp/css/boats.css 2009-12-16 18:26:29 UTC (rev 125)
@@ -129,4 +129,69 @@
clear: both;
font-size: 0.8em;
font-weight: bold;
+}
+
+/***** ACTIVITY CALENDAR ******/
+div#so-activity-calendar {
+ width: 80%;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 20px;
+}
+
+div#so-activity-calendar h1 {
+ text-align: center;
+}
+
+table#so-activity-calendar-boat {
+ width: 80%;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 10px;
+}
+
+table#so-activity-calendar-months {
+ margin-top: 20px;
+ border-collapse: collapse;
+ font-size: 0.8em;
+}
+
+table#so-activity-calendar-months tr,
+table#so-activity-calendar-months td {
+ border: 1px solid silver;
+ padding: 2px;
+}
+
+table#so-activity-calendar-months thead {
+ background-color: #19a28d;
+ color: white;
+ font-weight: bold;
+ padding: 3px;
+ text-align: center;
+}
+
+table#so-activity-calendar-months thead tr {
+ border: 0;
+}
+
+table#so-activity-calendar-months td.none {
+ background-color: white;
+ border: 0;
+}
+
+table#so-activity-calendar-months td.month {
+ width: 200px;
+}
+
+table#so-activity-calendar-months td.title {
+ width: 180px;
+ font-weight: bold;
+}
+
+table#so-activity-calendar-months td.zone {
+ white-space: nowrap;
+}
+
+table#so-activity-calendar-months tr.profession {
+ background-color: silver;
}
\ No newline at end of file
1
0
[Suiviobsmer-commits] r124 - in trunk: suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer suiviobsmer-business/src/main/resources suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/business suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services suiviobsmer-ui/src/main/resources
by fdesbois@users.labs.libre-entreprise.org 16 Dec '09
by fdesbois@users.labs.libre-entreprise.org 16 Dec '09
16 Dec '09
Author: fdesbois
Date: 2009-12-16 13:47:02 +0000 (Wed, 16 Dec 2009)
New Revision: 124
Modified:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java
trunk/suiviobsmer-business/src/main/resources/SuiviObsmer.properties
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/business/SuiviObsmerRunnerTest.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java
trunk/suiviobsmer-ui/src/main/resources/log4j.properties
Log:
Change configuration managment to use ApplicationConfig from nuiton-utils
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2009-12-15 19:28:04 UTC (rev 123)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2009-12-16 13:47:02 UTC (rev 124)
@@ -23,9 +23,6 @@
package fr.ifremer.suiviobsmer;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
import java.util.Date;
import java.util.Properties;
import java.util.Random;
@@ -37,7 +34,6 @@
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaId;
-import org.nuiton.util.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,6 +59,9 @@
private static boolean activityCalendarImport;
public static void setRunner(SuiviObsmerRunner run) {
+ if (log.isDebugEnabled()) {
+ log.debug("set runner in context");
+ }
runner = run;
}
@@ -71,7 +70,7 @@
}
public static String getProperty(String key) {
- return runner.configuration().getProperty(key);
+ return runner.configuration().getOption(key);
}
public static TopiaContext getTopiaRootContext() throws SuiviObsmerException {
@@ -79,7 +78,8 @@
throw new SuiviObsmerException("Configuration must be set before initializing context");
}
try {
- return TopiaContextFactory.getContext(runner.configuration());
+ Properties props = runner.configuration().getOptions();
+ return TopiaContextFactory.getContext(props);
} catch (TopiaNotFoundException eee) {
serviceException(null, eee.getMessage(), eee);
}
@@ -94,33 +94,10 @@
return activityCalendarImport;
}
- /**
- * Property file loading
- * @param filename
- * @return
- * @throws java.net.URISyntaxException
- * @throws java.io.IOException
- */
- public static Properties loadConfiguration(String filename)
- throws URISyntaxException, IOException {
- Properties props = new Properties();
- URL url = Resource.getURL(filename);
+ public static void serviceException(TopiaContext transaction, String message, Exception eee) throws SuiviObsmerException {
if (log.isDebugEnabled()) {
- log.debug(url.toString());
+ log.debug("An error occured",eee);
}
- props.load(url.openStream());
- return props;
- //return PropertiesLoader.loadPropertiesFile(filename);
- }
-
- /*public static String convertId(String id) {
- return Convert.toWebId(id);
- }*/
-
- public static void serviceException(TopiaContext transaction, String message, Exception eee) throws SuiviObsmerException {
- if (log.isErrorEnabled()) {
- log.error("An error occured",eee);
- }
if (!(eee instanceof SuiviObsmerException)) {
if (!(eee instanceof TopiaException)) {
try {
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java 2009-12-15 19:28:04 UTC (rev 123)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java 2009-12-16 13:47:02 UTC (rev 124)
@@ -23,6 +23,7 @@
import java.util.Date;
import java.util.Properties;
+import org.nuiton.util.ApplicationConfig;
/**
* SuiviObsmerRun
@@ -43,6 +44,6 @@
public Date currentDate();
- public Properties configuration();
+ public ApplicationConfig configuration();
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java 2009-12-15 19:28:04 UTC (rev 123)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java 2009-12-16 13:47:02 UTC (rev 124)
@@ -22,9 +22,8 @@
package fr.ifremer.suiviobsmer;
import java.util.Date;
-import java.util.Properties;
import org.nuiton.topia.TopiaException;
-import org.nuiton.util.Resource;
+import org.nuiton.util.ApplicationConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,7 +42,7 @@
private static final Logger log = LoggerFactory.getLogger(SuiviObsmerRunnerImpl.class);
- private Properties _configuration;
+ private ApplicationConfig _configuration;
public SuiviObsmerRunnerImpl() {
}
@@ -51,15 +50,18 @@
@Override
public void start() throws SuiviObsmerException {
try {
- _configuration = Resource.getConfigProperties("SuiviObsmer.properties");
- _configuration.setProperty("topia.persistence.classes",
+ _configuration = new ApplicationConfig();
+ _configuration.setConfigFileName("SuiviObsmer.properties");
+ _configuration.parse(new String[]{});
+ _configuration.setOption("topia.persistence.classes",
SuiviObsmerModelDAOHelper.getImplementationClassesAsString());
-
+
+ _configuration.printConfig();
SuiviObsmerContext.setRunner(this);
SuiviObsmerGlobal.createDefaultAdmin();
} catch (Exception eee) {
SuiviObsmerContext.serviceException(null, "Error during loadConfiguration from " +
- "'TopiaContextSuiviObsmer.properties' file", eee);
+ "'SuiviObsmer.properties' file", eee);
}
}
@@ -78,8 +80,7 @@
}
@Override
- public Properties configuration() {
+ public ApplicationConfig configuration() {
return _configuration;
}
-
}
Modified: trunk/suiviobsmer-business/src/main/resources/SuiviObsmer.properties
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/SuiviObsmer.properties 2009-12-15 19:28:04 UTC (rev 123)
+++ trunk/suiviobsmer-business/src/main/resources/SuiviObsmer.properties 2009-12-16 13:47:02 UTC (rev 124)
@@ -6,7 +6,7 @@
hibernate.connection.username=sa
hibernate.connection.password=
hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:~/.suiviobsmer/h2data
+hibernate.connection.url=jdbc:h2:file:~/.local/suiviobsmer/h2data
suiviobsmer.log.activityCalendar=log/activity.log
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/business/SuiviObsmerRunnerTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/business/SuiviObsmerRunnerTest.java 2009-12-15 19:28:04 UTC (rev 123)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/business/SuiviObsmerRunnerTest.java 2009-12-16 13:47:02 UTC (rev 124)
@@ -34,6 +34,7 @@
import java.util.Properties;
import org.junit.Ignore;
import org.nuiton.topia.TopiaException;
+import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,7 +55,7 @@
private static final Logger log = LoggerFactory.getLogger(SuiviObsmerRunnerTest.class);
- private Properties _configuration;
+ private ApplicationConfig _configuration;
@Override
public void start() throws SuiviObsmerException {
@@ -62,9 +63,13 @@
log.debug("TEST START : loadConfiguration");
}
try {
- _configuration = loadFileProperties("TopiaContextSuiviObsmer.properties");
- _configuration.setProperty("topia.persistence.classes",
+ Properties options = loadFileProperties("TopiaContextSuiviObsmer.properties");
+ options.setProperty("topia.persistence.classes",
SuiviObsmerModelDAOHelper.getImplementationClassesAsString());
+
+ _configuration = new ApplicationConfig();
+ _configuration.setOptions(options);
+
SuiviObsmerContext.setRunner(this);
} catch (Exception eee) {
SuiviObsmerContext.serviceException(null, "Error during loadConfiguration from " +
@@ -102,7 +107,7 @@
}
@Override
- public Properties configuration() {
+ public ApplicationConfig configuration() {
return _configuration;
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java 2009-12-15 19:28:04 UTC (rev 123)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java 2009-12-16 13:47:02 UTC (rev 124)
@@ -24,11 +24,9 @@
import fr.ifremer.suiviobsmer.SuiviObsmerException;
import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
import fr.ifremer.suiviobsmer.SuiviObsmerRunnerImpl;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* SuiviObsmerManager
@@ -43,15 +41,22 @@
*/
public class SuiviObsmerManager implements Runnable, RegistryShutdownListener {
+ private static final Logger log = LoggerFactory.getLogger(SuiviObsmerManager.class);
+
private SuiviObsmerRunner runner;
@Override
public void run() {
runner = new SuiviObsmerRunnerImpl();
try {
+ if (log.isInfoEnabled()) {
+ log.info("Start SuiviObsmer");
+ }
runner.start();
} catch (SuiviObsmerException eee) {
- Logger.getLogger(SuiviObsmerManager.class.getName()).log(Level.SEVERE, null, eee);
+ if (log.isErrorEnabled()) {
+ log.error("Error on start", eee);
+ }
}
}
@@ -60,9 +65,14 @@
// No problem with reinstanciate the runner, all context is in SuiviObsmerContext which is static
runner = new SuiviObsmerRunnerImpl();
try {
+ if (log.isInfoEnabled()) {
+ log.info("Stop SuiviObsmer");
+ }
runner.stop();
} catch (SuiviObsmerException eee) {
- Logger.getLogger(SuiviObsmerManager.class.getName()).log(Level.SEVERE, null, eee);
+ if (log.isErrorEnabled()) {
+ log.error("Error on stop", eee);
+ }
}
}
Modified: trunk/suiviobsmer-ui/src/main/resources/log4j.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/log4j.properties 2009-12-15 19:28:04 UTC (rev 123)
+++ trunk/suiviobsmer-ui/src/main/resources/log4j.properties 2009-12-16 13:47:02 UTC (rev 124)
@@ -8,7 +8,7 @@
log4j.appender.console.Threshold=INFO
log4j.appender.globalfile=org.apache.log4j.RollingFileAppender
-log4j.appender.globalfile.File=${user.home}/.suiviobsmer/log/suiviobsmer.log
+log4j.appender.globalfile.File=${user.home}/.local/suiviobsmer/log/suiviobsmer.log
log4j.appender.globalfile.MaxFileSize=500KB
log4j.appender.globalfile.Append=true
log4j.appender.globalfile.MaxBackupIndex=10
@@ -21,4 +21,4 @@
log4j.logger.org.apache.tapestry5.TapestryFilter=INFO
log4j.logger.fr.ifremer.suiviobsmer=DEBUG
-log4j.logger.org.nuiton.util=INFO
+log4j.logger.org.nuiton.util=DEBUG
1
0
15 Dec '09
Author: fdesbois
Date: 2009-12-15 19:28:04 +0000 (Tue, 15 Dec 2009)
New Revision: 123
Added:
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
Modified:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DataLoader.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java
trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties
trunk/suiviobsmer-ui/src/main/webapp/Boats.tml
trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml
Log:
- BoatInfos last Contact show
- List for select an observer when editing a contact
- Constraint to create a new contact from boats page
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DataLoader.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DataLoader.java 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DataLoader.java 2009-12-15 19:28:04 UTC (rev 123)
@@ -67,5 +67,10 @@
}
}
}
+
+ public static void loadContactForBoatInfos(Contact contact) {
+ contact.getSampleRow();
+ contact.getUser();
+ }
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2009-12-15 19:28:04 UTC (rev 123)
@@ -21,10 +21,14 @@
package fr.ifremer.suiviobsmer.entity;
+import fr.ifremer.suiviobsmer.DataLoader;
import fr.ifremer.suiviobsmer.SuiviObsmerException;
import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.bean.ContactState;
import java.io.Serializable;
+import java.util.List;
+import org.apache.commons.lang.BooleanUtils;
import org.nuiton.topia.TopiaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -86,4 +90,89 @@
}
return boatInfos;
}
+
+ /**
+ * Get the last boat contact for the creator company.
+ * No test on contact state is done here.
+ * @param company which is the creator of the contact
+ * @return the last boat contact (opened or not)
+ * @throws SuiviObsmerException
+ */
+ @Override
+ @Deprecated
+ public Contact getLastContact(Company company) throws SuiviObsmerException {
+ TopiaContext transaction = null;
+ Contact contact = null;
+ try {
+ transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+
+ List results = transaction.find(
+ "FROM ContactImpl C1" +
+ " WHERE C1.user.company = :company AND C1.boat = :boat " +
+ " AND C1.topiaCreateDate = " +
+ " (SELECT MAX(C2.topiaCreateDate) FROM ContactImpl C2" +
+ " WHERE C2.user.company = :company AND C2.boat = C1.boat)",
+ "company", company,
+ "boat", this);
+
+ if (!results.isEmpty()) {
+ contact = (Contact)results.get(0);
+ DataLoader.loadContactForBoatInfos(contact);
+ }
+
+ transaction.closeContext();
+ } catch (Exception eee) {
+ SuiviObsmerContext.serviceException(transaction,
+ "Impossible de récupérer le dernier contact du navire " + this.getImmatriculation() +
+ " pour la société '" + company.getName() + "'",
+ eee);
+ }
+ return contact;
+ }
+
+ /**
+ * Check if a contact for this boat, company and sampleRow can be created.
+ * The state is tested for the last created contact.
+ * A new contact can be created only if the last state is final and is not 'Refus définitif'.
+ * @param company which is the creator of the contact
+ * @param row for the contact to be created
+ * @return true if the contact can be created, false either
+ * @throws SuiviObsmerException
+ */
+ @Override
+ public boolean canCreateContact(Company company, SampleRow row) throws SuiviObsmerException {
+ TopiaContext transaction = null;
+ boolean result = true;
+ try {
+ transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+
+ List results = transaction.find(
+ "FROM ContactImpl C1" +
+ " WHERE C1.user.company = :company" +
+ " AND C1.boat = :boat AND C1.sampleRow = :row" +
+ " AND C1.topiaCreateDate = " +
+ " (SELECT MAX(C2.topiaCreateDate) FROM ContactImpl C2" +
+ " WHERE C2.user.company = :company AND C2.boat = C1.boat)",
+ "company", company,
+ "boat", this,
+ "row", row);
+
+ if (!results.isEmpty()) {
+ Contact contact = (Contact)results.get(0);
+ boolean validation = contact.getValidationProgram() != null || BooleanUtils.isFalse(contact.getValidationCompany());
+ ContactState state = ContactState.createContactStateEnum(contact.getState());
+ result = validation && !state.equals(ContactState.BOAT_DEFINITIVE_REFUSED);
+ }
+
+ transaction.closeContext();
+ } catch (Exception eee) {
+ SuiviObsmerContext.serviceException(transaction,
+ "Impossible de récupérer les informations privées du navire lié à la société " +
+ "'" + company.getName() + "'",
+ eee);
+ }
+ return result;
+ }
+
+
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2009-12-15 19:28:04 UTC (rev 123)
@@ -175,6 +175,9 @@
@Override
public void addRealTideTime(Contact contact) throws SuiviObsmerException {
+ if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
+ return;
+ }
int nbDays = getDifferenceDays(contact);
SampleMonth month = getSampleMonth(contact.getTideBeginDate());
if (log.isDebugEnabled()) {
@@ -186,6 +189,9 @@
@Override
public void removeRealTideTime(Contact contact) throws SuiviObsmerException {
+ if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
+ return;
+ }
int nbDays = getDifferenceDays(contact);
SampleMonth month = getSampleMonth(contact.getTideBeginDate());
if (log.isDebugEnabled()) {
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java 2009-12-15 19:28:04 UTC (rev 123)
@@ -275,7 +275,23 @@
}
}
}
+ // Last contact
+ List results = transaction.find(
+ "FROM ContactImpl C1" +
+ " WHERE C1.user.company = :company AND C1.boat = :boat " +
+ " AND C1.topiaCreateDate = " +
+ " (SELECT MAX(C2.topiaCreateDate) FROM ContactImpl C2" +
+ " WHERE C2.user.company = :company AND C2.boat = C1.boat)",
+ "company", company,
+ "boat", boat);
+ if (!results.isEmpty()) {
+ Contact contact = (Contact)results.get(0);
+ DataLoader.loadContactForBoatInfos(contact);
+ result.setLastContact(contact);
+ }
+
+
transaction.closeContext();
} catch (Exception eee) {
SuiviObsmerContext.serviceException(transaction,
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Added: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java (rev 0)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java 2009-12-15 19:28:04 UTC (rev 123)
@@ -0,0 +1,220 @@
+
+package fr.ifremer.suiviobsmer.entity;
+
+import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
+import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
+import fr.ifremer.suiviobsmer.bean.ContactState;
+import fr.ifremer.suiviobsmer.business.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.impl.ServiceBoatImpl;
+import fr.ifremer.suiviobsmer.impl.ServiceContactImpl;
+import fr.ifremer.suiviobsmer.impl.ServiceSamplingImpl;
+import fr.ifremer.suiviobsmer.impl.ServiceUserImpl;
+import fr.ifremer.suiviobsmer.services.ServiceBoat;
+import fr.ifremer.suiviobsmer.services.ServiceContact;
+import fr.ifremer.suiviobsmer.services.ServiceSampling;
+import fr.ifremer.suiviobsmer.services.ServiceUser;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatImpl
+ *
+ * Created: 15 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BoatImplTest {
+
+ private static SuiviObsmerRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(BoatImplTest.class);
+
+ public BoatImplTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new SuiviObsmerRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ runner.stop();
+ }
+
+ /**
+ * Test of getBoatInfos method, of class BoatImpl.
+ */
+ //@Test
+ public void testGetBoatInfos() throws Exception {
+ System.out.println("getBoatInfos");
+ }
+
+ /**
+ * Test of getLastContact method, of class BoatImpl.
+ */
+ @Test
+ public void testGetLastContact() throws Exception {
+ log.info("getLastContact");
+
+ /** PREPARE DATA **/
+ ServiceUser serviceUser = new ServiceUserImpl();
+ Company company = new CompanyImpl();
+ company.setName("TARTANPION");
+ serviceUser.createUpdateCompany(company);
+ User user = new UserImpl();
+ user.setFirstName("Jean");
+ user.setLastName("Michmuche");
+ user.setCompany(company);
+ serviceUser.createUpdateUser(user, true);
+
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoats("174258");
+ Boat boat = boats.get(0);
+
+ TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+
+ FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZone zoneIId = zoneDAO.create(FishingZone.DISTRICT_CODE, "IId");
+ FishingZone zoneIV = zoneDAO.create(FishingZone.DISTRICT_CODE, "IV");
+ FishingZone zoneI = zoneDAO.create(FishingZone.DISTRICT_CODE, "I");
+
+ transaction.commitTransaction();
+
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ serviceSampling.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_1");
+ row.getCompany();
+ row.getProgram();
+ row.getProfession();
+ transaction.closeContext();
+
+ row.setCompany(company);
+ serviceSampling.createUpdateSampleRow(row, boats);
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ Contact contact1 = serviceContact.getNewContact(user, row, boat);
+ contact1.setState(ContactState.CONTACT_START.toString());
+ serviceContact.saveContact(contact1, false);
+
+ /** EXEC METHOD **/
+ Contact result = boat.getLastContact(company);
+ Assert.assertEquals(contact1.getTopiaId(), result.getTopiaId());
+ }
+
+ /**
+ * Test of canCreateContact method, of class BoatImpl.
+ */
+ @Test
+ public void testCanCreateContact() throws Exception {
+ log.info("canCreateContact");
+ /** PREPARE DATA **/
+ ServiceUser serviceUser = new ServiceUserImpl();
+ Company company = new CompanyImpl();
+ company.setName("TARTANPION");
+ serviceUser.createUpdateCompany(company);
+ User user = new UserImpl();
+ user.setFirstName("Jean");
+ user.setLastName("Michmuche");
+ user.setCompany(company);
+ serviceUser.createUpdateUser(user, true);
+
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoats("174258");
+ Boat boat = boats.get(0);
+
+ TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+
+ FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZone zoneIId = zoneDAO.create(FishingZone.DISTRICT_CODE, "IId");
+ FishingZone zoneIV = zoneDAO.create(FishingZone.DISTRICT_CODE, "IV");
+ FishingZone zoneI = zoneDAO.create(FishingZone.DISTRICT_CODE, "I");
+
+ transaction.commitTransaction();
+
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ serviceSampling.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_1");
+ row.getCompany();
+ row.getProgram();
+ row.getProfession();
+ transaction.closeContext();
+
+ row.setCompany(company);
+ serviceSampling.createUpdateSampleRow(row, boats);
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ Contact contact1 = serviceContact.getNewContact(user, row, boat);
+ contact1.setState(ContactState.CONTACT_START.toString());
+ serviceContact.saveContact(contact1, false);
+
+ /** EXEC METHOD **/
+ boolean result = boat.canCreateContact(company, row);
+ // contact still open
+ Assert.assertFalse(result);
+
+ contact1.setState(ContactState.BOAT_DEFINITIVE_REFUSED.toString());
+ contact1.setValidationProgram(Boolean.TRUE);
+ serviceContact.saveContact(contact1, false);
+
+ result = boat.canCreateContact(company, row);
+ // contact have a definitive refused for this boat
+ Assert.assertFalse(result);
+
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ serviceContact.saveContact(contact1, false);
+
+ result = boat.canCreateContact(company, row);
+ // contact is finished
+ Assert.assertTrue(result);
+
+ contact1.setState(ContactState.BOAT_UNAVAILABLE.toString());
+ serviceContact.saveContact(contact1, false);
+
+ result = boat.canCreateContact(company, row);
+ // contact is finished
+ Assert.assertTrue(result);
+
+ contact1.setState(ContactState.BOAT_REFUSED.toString());
+ serviceContact.saveContact(contact1, false);
+
+ result = boat.canCreateContact(company, row);
+ // contact is finished
+ Assert.assertTrue(result);
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2009-12-15 19:28:04 UTC (rev 123)
@@ -29,6 +29,7 @@
import fr.ifremer.suiviobsmer.bean.CompanyBoatInfos;
import fr.ifremer.suiviobsmer.entity.BoatInfos;
import fr.ifremer.suiviobsmer.entity.Company;
+import fr.ifremer.suiviobsmer.entity.Contact;
import fr.ifremer.suiviobsmer.entity.ElligibleBoat;
import fr.ifremer.suiviobsmer.entity.FishingZone;
import fr.ifremer.suiviobsmer.entity.Profession;
@@ -141,10 +142,6 @@
}
}
-// public User getUser() {
-// return layout.getCurrentUser();
-// }
-
void onActivate(EventContext ec) {
if (ec.getCount() > 0) {
sampleRowCode = ec.get(String.class, 0);
@@ -440,6 +437,13 @@
public DateFormat getDateFormat() {
return new SimpleDateFormat("dd/MM/yyyy");
}
+
+ public boolean canCreateNewContactFromList() throws SuiviObsmerException {
+ if (!user.getAdmin() && isSampleRowExists()) {
+ return boat.canCreateContact(user.getCompany(), getSampleRow());
+ }
+ return false;
+ }
Block onActionFromShowBoatInfos(Integer boatImma) {
boatSelectedImmatriculation = boatImma;
@@ -452,9 +456,6 @@
/**************************** Boat selected Infos *************************/
-// @Persist
-// private BoatInfos boatInfos;
-
@Persist
private CompanyBoatInfos companyBoatInfos;
@@ -486,6 +487,8 @@
/*@Persist
private SuiviObsmerPropertyChangeListener propertyChange;*/
+ /** /////////////////////// GLOBAL TO THE BLOCK /////////////////////// **/
+
public boolean isActivityCalendarImportRun() {
return SuiviObsmerContext.isActivityCalendarImportRun();
}
@@ -501,6 +504,25 @@
return displayBoatInfos;
}
+ public Company getCompany() throws SuiviObsmerException {
+ if (user.getAdmin() && companyId != null) {
+ return getCompanySelectModel().findObject(companyId);
+ }
+ return user.getCompany();
+ }
+
+ public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException {
+ if (companySelectModel == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("BUSINESS REQUEST [getCompanies]");
+ }
+ List<Company> companies = serviceUser.getCompanies();
+ companySelectModel = new GenericSelectModel<Company>(companies,Company.class,
+ "name","topiaId",propertyAccess);
+ }
+ return companySelectModel;
+ }
+
public CompanyBoatInfos getCompanyBoatInfos() throws SuiviObsmerException {
if (companyBoatInfos == null && boatSelectedImmatriculation != null) {
if (log.isInfoEnabled()) {
@@ -525,6 +547,8 @@
return getCompanyBoatInfos().getBoatInfos();
}
+ /** /////////////////////// FOR EACH ELLIGIBLEBOAT ROW ///////////////// **/
+
public String getElligibleRowInfos() {
return BusinessUtils.getTooltipSampleRow(elligibleBoat.getSampleRow());
}
@@ -533,31 +557,21 @@
return BooleanUtils.isFalse(elligibleBoat.getCompanyActive());
}
+ public boolean canCreateNewContactFromElligibleBoat() throws SuiviObsmerException {
+ if (!user.getAdmin() && !isElligibleBoatCompanyActiveFalse()) {
+ return getBoatInfos().getBoat().canCreateContact(user.getCompany(), elligibleBoat.getSampleRow());
+ }
+ return false;
+ }
+
public String getElligibleRowClass() {
boolean condition1 = elligibleBoat.getCompanyActive() == null && !elligibleBoat.getGlobalActive();
return condition1 || isElligibleBoatCompanyActiveFalse() ? "line-through" : "";
}
- public Company getCompany() throws SuiviObsmerException {
- if (user.getAdmin() && companyId != null) {
- return getCompanySelectModel().findObject(companyId);
- }
- return user.getCompany();
- }
+ /** /////////////////////// ACTIONS //////////////////////////////////// **/
- public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException {
- if (companySelectModel == null) {
- if (log.isDebugEnabled()) {
- log.debug("BUSINESS REQUEST [getCompanies]");
- }
- List<Company> companies = serviceUser.getCompanies();
- companySelectModel = new GenericSelectModel<Company>(companies,Company.class,
- "name","topiaId",propertyAccess);
- }
- return companySelectModel;
- }
-
Block onSuccessFromCompanySelectForm() throws SuiviObsmerException {
companyBoatInfos = null;
// boatSelectedImmatriculation is getting from Persist("flash")
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2009-12-15 19:28:04 UTC (rev 123)
@@ -26,19 +26,20 @@
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.entity.Company;
import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.SampleMonth;
import fr.ifremer.suiviobsmer.entity.SampleRow;
import fr.ifremer.suiviobsmer.entity.User;
import fr.ifremer.suiviobsmer.services.ServiceBoat;
import fr.ifremer.suiviobsmer.services.ServiceContact;
import fr.ifremer.suiviobsmer.services.ServiceSampling;
import fr.ifremer.suiviobsmer.ui.base.BusinessUtils;
+import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
import fr.ifremer.suiviobsmer.ui.components.Layout;
import fr.ifremer.suiviobsmer.ui.services.ContactModelFactory;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.List;
import java.util.Map;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
@@ -52,9 +53,9 @@
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
import org.apache.tapestry5.services.BeanModelSource;
import org.slf4j.Logger;
-import org.nuiton.util.DateUtils;
/**
* Contacts
@@ -120,6 +121,15 @@
private Contact contact;
private BeanModel<Contact> contactModel;
+
+ @Inject
+ private PropertyAccess propertyAccess;
+
+ private GenericSelectModel<User> userSelectModel;
+
+ @Property
+ @Persist("flash")
+ private String contactUserId;
private ContactState contactState;
@@ -153,6 +163,17 @@
return this.contactState;
}
+ public GenericSelectModel<User> getUserSelectModel() {
+ if (userSelectModel == null) {
+ List<User> users = user.getCompany().getUser();
+ if (log.isDebugEnabled()) {
+ log.debug("Nb users : " + users.size());
+ }
+ userSelectModel = new GenericSelectModel<User>(users, User.class, "fullName", "id", propertyAccess);
+ }
+ return userSelectModel;
+ }
+
public void setContactState(ContactState contactState) {
this.contactState = contactState;
}
@@ -264,7 +285,9 @@
}
}
- void onSelectedFromEditContact(String contactId) {
+ void onSelectedFromEditContact(String contactId) throws SuiviObsmerException {
+ contact = getContacts().get(contactId);
+ contactUserId = contact.getUser().getTopiaId();
editableContactId = contactId;
contactSelectedId = contactId;
contactEdited = true;
@@ -278,6 +301,8 @@
void onSelectedFromSaveContact(String contactId) throws SuiviObsmerException {
contact = getContacts().get(contactId);
contact.setState(contactState.toString());
+ User contactUser = getUserSelectModel().findObject(contactUserId);
+ contact.setUser(contactUser);
contactsForm.clearErrors();
if (!validateState()) {
if (log.isDebugEnabled()) {
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java 2009-12-15 19:28:04 UTC (rev 123)
@@ -52,7 +52,7 @@
BeanModel<Contact> contactModel = beanModelSource.createDisplayModel(Contact.class, resources.getMessages());
// New properties for contactModel
- contactModel.add("createdBy", getUserPropertyConduit());
+ contactModel.add("createdBy", null);
contactModel.add("sampleRow", getSampleRowPropertyConduit());
contactModel.add("boat", getBoatPropertyConduit());
contactModel.add("mammals", null);
@@ -79,7 +79,9 @@
public BeanModel<Contact> buildAdminContactModel(BeanModelSource beanModelSource, ComponentResources resources) {
BeanModel<Contact> contactModel = buildContactModel(beanModelSource, resources);
- contactModel.add(RelativePosition.BEFORE, "createdBy", "company", getCompanyPropertyConduit());
+ contactModel.exclude("createdBy");
+ contactModel.add(RelativePosition.AFTER,"topiaCreateDate", "observer", getUserPropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "observer", "company", getCompanyPropertyConduit());
contactModel.add(RelativePosition.AFTER, "sampleRow", "program", getProgramPropertyConduit());
contactModel.add(RelativePosition.AFTER, "program", "professionCode", getProfessionCodePropertyConduit());
contactModel.add(RelativePosition.AFTER, "professionCode", "professionLibelle", getProfessionLibellePropertyConduit());
Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties 2009-12-15 19:28:04 UTC (rev 123)
@@ -17,8 +17,13 @@
boatLength-label: Longueur
# BOAT INFOS
+topiaCreateDate-label: Date
+state-label: Etat
+createdBy-label: Observateur
+sampleRowCode-label: Code plan
contactFirstName-label: Pr\u00E9nom
contactLastName-label: Nom
contactPhoneNumber-label: T\u00E9l\u00E9phone
contactEmail-label: E-mail
+shipOwner-label: Armateur
dup-label: Capacit\u00E9 d'accueil du navire en personnels sp\u00E9cialis\u00E9s
\ No newline at end of file
Modified: trunk/suiviobsmer-ui/src/main/webapp/Boats.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2009-12-15 19:28:04 UTC (rev 123)
@@ -110,13 +110,11 @@
<div t:type="grid" t:source="boats.values()" t:row="boat"
t:include="name, immatriculation, districtCode, boatLength, buildYear" t:rowClass="prop:rowClass" t:rowsPerPage="20">
<p:nameCell>
- <t:unless t:test="user.admin">
- <t:if t:test="sampleRowExists">
- <a t:type="actionlink" t:id="addNewContactFromBoat" t:context="boat.immatriculation">
- <img src="${asset:context:}/img/contact-22px.png" title="Créer un nouveau contact pour ce navire et la ligne sélectionnée dans les filtres"/>
- </a>
- </t:if>
- </t:unless>
+ <t:if t:test="canCreateNewContactFromList()">
+ <a t:type="actionlink" t:id="addNewContactFromBoat" t:context="boat.immatriculation">
+ <img src="${asset:context:}/img/contact-22px.png" title="Créer un nouveau contact pour ce navire et la ligne sélectionnée dans les filtres"/>
+ </a>
+ </t:if>
<a t:type="actionlink" t:id="showBoatInfos" t:context="boat.immatriculation" t:zone="boatsZone">${boat.name}</a>
</p:nameCell>
<p:boatLengthCell>
@@ -192,24 +190,50 @@
</t:unless>
<!-- BODY - armateur, contact -->
- <fieldset id="so-boats-boat-infos-shipowner">
+<!-- <fieldset id="so-boats-boat-infos-shipowner">
<legend>Armateur</legend>
<div t:type="beandisplay" t:id="boatInfosShipOwner" t:object="boatInfos.boat.shipOwner"
t:include="firstName, lastName" />
- </fieldset>
+ </fieldset>-->
+ <t:if t:test="companyBoatInfos.lastContact">
+ <fieldset id="so-boats-boat-infos-shipowner">
+ <legend>Dernier contact avec le navire</legend>
+ <div t:type="beandisplay" t:id="boatInfosLastContact" t:object="companyBoatInfos.lastContact"
+ t:include="topiaCreateDate, state" t:add="createdBy, sampleRowCode">
+ <p:createdBy>
+ ${companyBoatInfos.lastContact.user.fullName}
+ </p:createdBy>
+ <p:sampleRowCode>
+ ${companyBoatInfos.lastContact.sampleRow.code}
+ </p:sampleRowCode>
+ </div>
+ </fieldset>
+ </t:if>
<fieldset id="so-boats-boat-infos-contact">
<legend>Contact</legend>
<div t:type="beandisplay" t:id="boatInfosContact" t:object="boatInfos"
t:include="contactFirstName, contactLastName, contactPhoneNumber, contactEmail" />
</fieldset>
+
<!-- BODY - autres -->
<fieldset id="so-boats-boat-infos-boarding">
<legend>Autres informations sur le navire</legend>
<div>
- <p><label>${message:dup-label} : </label>${boatInfos.dup}</p>
+ <p>
+ <label>${message:shipOwner-label} : </label>
+ ${boatInfos.boat.shipOwner.firstName} ${boatInfos.boat.shipOwner.lastName}
+ </p>
<p class="sep"> </p>
<p>
+ <label>${message:dup-label} : </label>
+ <t:if t:test="boatInfos.dup">
+ ${boatInfos.dup}
+ <p:else>aucun</p:else>
+ </t:if>
+ </p>
+ <p class="sep"> </p>
+ <p>
<strong>${boatInfos.nbBoarding}</strong> embarquements
dont <strong>${boatInfos.nbBoardingForCompany}</strong> pour votre société
depuis le <strong><t:output value="boatInfos.firstBoardingDate" format="dateFormat" /></strong>
@@ -223,13 +247,11 @@
${elligibleBoat.sampleRow.code}
</span>
</span>
- <t:unless t:test="user.admin">
- <t:unless t:test="elligibleBoatCompanyActiveFalse">
- <a t:type="actionlink" t:id="addNewContactFromSampleRow" t:context="elligibleBoat.sampleRow.code">
- <img src="${asset:context:}/img/contact-22px.png" title="Créer un nouveau contact pour ce navire et cette ligne du plan"/>
- </a>
- </t:unless>
- </t:unless>
+ <t:if t:test="canCreateNewContactFromElligibleBoat()">
+ <a t:type="actionlink" t:id="addNewContactFromSampleRow" t:context="elligibleBoat.sampleRow.code">
+ <img src="${asset:context:}/img/contact-22px.png" title="Créer un nouveau contact pour ce navire et cette ligne du plan"/>
+ </a>
+ </t:if>
</li>
</ul>
<t:if t:test="boatInfos.comment">
Modified: trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml 2009-12-15 16:03:30 UTC (rev 122)
+++ trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml 2009-12-15 19:28:04 UTC (rev 123)
@@ -8,6 +8,12 @@
<t:errors id="so-contact-form-errors" t:banner="message:contactsForm-errors-banner"/>
<div t:type="grid" t:source="contacts.values()" t:row="contact" class="t-data-grid ${gridClass}" t:model="contactModel" t:rowClass="prop:rowClass"
t:rowsPerPage="20">
+ <p:createdByCell>
+ <t:if t:test="editionMode">
+ <input t:type="select" t:model="userSelectModel" t:validate="required" t:value="contactUserId"/>
+ <p:else>${contact.user.fullName}</p:else>
+ </t:if>
+ </p:createdByCell>
<p:sampleRowCell>
<span t:type="ck/Tooltip" title="Infos" t:value="prop:sampleRowDescription" t:effect="appear">
${contact.sampleRow.code}
1
0
15 Dec '09
Author: fdesbois
Date: 2009-12-15 16:03:30 +0000 (Tue, 15 Dec 2009)
New Revision: 122
Added:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java
Removed:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DateUtils.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/PeriodDates.java
Modified:
trunk/pom.xml
trunk/suiviobsmer-business/pom.xml
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java
trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Contacts.properties
trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml
trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css
trunk/suiviobsmer-ui/src/main/webapp/js/dialog.js
Log:
- Use DateUtils and PeriodDates from Nuiton-utils 1.1.2-SNAPSHOT
- Refactor ContactState to use it properly in UI + Add state managment in contact form
- Add calcul for realTidesTime
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/pom.xml 2009-12-15 16:03:30 UTC (rev 122)
@@ -238,7 +238,7 @@
<labs.id>154</labs.id>
<!-- libraries version -->
- <nuitonutils.version>1.1.1</nuitonutils.version>
+ <nuitonutils.version>1.1.2-SNAPSHOT</nuitonutils.version>
<topia.version>2.3.0-beta-2-SNAPSHOT</topia.version>
<license.version>2.0.0</license.version>
<helper.version>1.1.0</helper.version>
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-business/pom.xml 2009-12-15 16:03:30 UTC (rev 122)
@@ -27,6 +27,10 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DateUtils.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DateUtils.java 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DateUtils.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -1,113 +0,0 @@
-package fr.ifremer.suiviobsmer;
-
-/**
- * *##%
- * SuiviObsmer Business
- * Copyright (C) 2009 Ifremer
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * ##%*
- */
-
-
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-/**
- * DateUtils.java
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-public class DateUtils {
-
- //private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
-
- public static final String DEFAULT_PATTERN = "dd/MM/yyyy";
-
- public static final String MONTH_PATTERN = "MM/yyyy";
-
- public static String formatDate(Date date, String pattern)
- {
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
- return simpleDateFormat.format(date);
- }
-
- public static Date parseDate(String date, String pattern) {
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
- Date result = null;
- try {
- result = simpleDateFormat.parse(date);
- } catch (ParseException eee) {
- }
- return result;
- }
-
- public static Date createDate(int dd, int mm, int yy) {
- Calendar calendar = new GregorianCalendar(yy,mm-1,dd);
- return calendar.getTime();
- }
-
- public static Date createDateAfterToday(int ddStep, int mmStep, int yyStep) {
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(new Date());
- calendar.add(Calendar.DAY_OF_MONTH, ddStep);
- calendar.add(Calendar.MONTH,mmStep);
- calendar.add(Calendar.YEAR, yyStep);
- return calendar.getTime();
- }
-
- public static Date setLastDayOfMonth(Date date) {
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(date);
- int maximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
- calendar.set(Calendar.DAY_OF_MONTH, maximum);
- return calendar.getTime();
- }
-
- public static Date setFirstDayOfMonth(Date date) {
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(date);
- calendar.set(Calendar.DAY_OF_MONTH, 1);
- return calendar.getTime();
- }
-
- public static boolean between(Date myDate, Date beforeDate, Date afterDate) {
- if (myDate == null) {
- return false;
- }
- boolean result = true;
- result &= myDate.after(beforeDate) || myDate.equals(beforeDate);
- result &= afterDate == null || myDate.before(afterDate) || myDate.equals(afterDate);
- return result;
- }
-
- public static boolean currentPeriod(Date beforeDate, Date afterDate) {
- return between(new Date(), beforeDate, afterDate);
- }
-
- public static int getMonth(Date date) {
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(date);
- return calendar.get(Calendar.MONTH);
- }
-}
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/PeriodDates.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/PeriodDates.java 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/PeriodDates.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -1,216 +0,0 @@
-package fr.ifremer.suiviobsmer;
-
-/**
- * *##%
- * SuiviObsmer Business
- * Copyright (C) 2009 Ifremer
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * ##%*
- */
-
-
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * PeriodDates.java
- *
- * Created on 2009-08-13
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-public class PeriodDates {
-
- private static final Log log = LogFactory.getLog(PeriodDates.class);
-
- private String pattern;
-
- private Date fromDate;
-
- private Calendar fromCalendar;
-
- private Date thruDate;
-
- private Calendar thruCalendar;
-
- public PeriodDates() {
- }
-
- public PeriodDates(Date fromDate, Date thruDate) {
- this.fromCalendar = new GregorianCalendar();
- setFromDate(fromDate);
-
- this.thruCalendar = new GregorianCalendar();
- setThruDate(thruDate);
-
- this.pattern = DateUtils.DEFAULT_PATTERN;
- }
-
- public PeriodDates(Calendar fromCalendar, Calendar thruCalendar) {
- this.fromDate = fromCalendar.getTime();
- this.fromCalendar = fromCalendar;
-
- this.thruDate = thruCalendar.getTime();
- this.thruCalendar = thruCalendar;
-
- this.pattern = DateUtils.DEFAULT_PATTERN;
- }
-
- public static PeriodDates createMonthsPeriodFromToday(int monthAfter) {
- Calendar calendarFrom = new GregorianCalendar();
- Calendar calendarThru = new GregorianCalendar();
-
- calendarFrom.set(Calendar.DAY_OF_MONTH, 1);
- calendarFrom.set(Calendar.AM_PM, Calendar.AM);
- calendarFrom.set(Calendar.HOUR, 0);
- calendarFrom.set(Calendar.MINUTE, 0);
- calendarFrom.set(Calendar.SECOND, 0);
- calendarFrom.set(Calendar.MILLISECOND, 0);
-
- calendarThru.setTime(calendarFrom.getTime());
- calendarThru.add(Calendar.MONTH, monthAfter);
- int maximum = calendarThru.getActualMaximum(Calendar.DAY_OF_MONTH);
- calendarThru.set(Calendar.DAY_OF_MONTH, maximum);
-
- PeriodDates period = new PeriodDates(calendarFrom, calendarThru);
- period.setPattern(DateUtils.MONTH_PATTERN);
- return period;
- }
-
- public String getPattern() {
- return pattern;
- }
-
- public void setPattern(String pattern) {
- this.pattern = pattern;
- }
-
- public void setFromDate(Date fromDate) {
- this.fromDate = fromDate;
- if (fromDate != null) {
- if (fromCalendar == null) {
- fromCalendar = new GregorianCalendar();
- }
- this.fromCalendar.setTime(fromDate);
- } else {
- this.fromCalendar = null;
- }
- }
-
- public Date getFromDate() {
- return this.fromDate;
- }
-
- public int getFromMonth() {
- return this.fromCalendar.get(Calendar.MONTH);
- }
-
- public void setThruDate(Date thruDate) {
- this.thruDate = thruDate;
- if (thruDate != null) {
- if (thruCalendar == null) {
- thruCalendar = new GregorianCalendar();
- }
- this.thruCalendar.setTime(thruDate);
- } else {
- this.thruCalendar = null;
- }
- }
-
- public Date getThruDate() {
- return this.thruDate;
- }
-
- public List<Date> getMonths() {
- List<Date> months = new ArrayList<Date>();
- if (fromCalendar == null || thruCalendar == null) {
- return months;
- }
-
- /*int mFrom = fromCalendar.get(Calendar.MONTH);
- int mThru = thruCalendar.get(Calendar.MONTH);
- int yFrom = fromCalendar.get(Calendar.YEAR);
- int yThru = thruCalendar.get(Calendar.YEAR);
-
- int nbYears = yThru - yFrom;
- int monthRatio = nbYears * 12;
-
- int y = yFrom;
- for(int i = mFrom; i <= mThru + monthRatio; i++) {
- Calendar result = new GregorianCalendar(y, i%12, 1);
- months.add(result.getTime());
- if (i != 0 && i%11 == 0) {
- y++;
- }
- }*/
-
- Calendar current = (Calendar) fromCalendar.clone();
- current.set(Calendar.DAY_OF_MONTH, 1);
- Calendar end = (Calendar) thruCalendar.clone();
- end.set(Calendar.DAY_OF_MONTH, 1);
- while (!current.equals(end)) {
- months.add(current.getTime());
- current.add(Calendar.MONTH, 1);
- }
- months.add(current.getTime());
-
- return months;
- }
-
- public List<String> getFormatedMonths() {
- List<String> results = new ArrayList<String>();
- for (Date date : getMonths()) {
- String str = DateUtils.formatDate(date, pattern);
- results.add(str);
- }
- return results;
- }
-
- public boolean beforeEnd(Calendar calendar) {
- return calendar.before(thruCalendar) || calendar.equals(thruCalendar);
- }
-
- public boolean afterEnd(Calendar calendar) {
- return calendar.after(thruCalendar);
- }
-
- public boolean afterBegin(Calendar calendar) {
- return calendar.after(fromCalendar) || calendar.equals(fromCalendar);
- }
-
- public boolean between(Calendar calendar) {
- return beforeEnd(calendar) && afterBegin(calendar);
- }
-
-
- @Override
- public String toString() {
- String fromStr = DateUtils.formatDate(fromDate, pattern);
- String thruStr = DateUtils.formatDate(thruDate, pattern);
- return "[ " + fromDate + " (pattern: " + fromStr + ") -> " + thruDate + " (pattern: " + thruStr + ") ]";
- }
-
-}
Added: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -0,0 +1,92 @@
+/*
+ * *##%
+ * SuiviObsmer Business
+ * Copyright (C) 2009 Ifremer
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * ##%*
+ */
+
+package fr.ifremer.suiviobsmer.bean;
+
+import fr.ifremer.suiviobsmer.bean.states.*;
+
+/**
+ * ContactState
+ *
+ * Created: 3 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author: fdesbois $
+ */
+public enum ContactState {
+ CONTACT_START("Contact pris", false, false),
+
+ BOARDING_EXPECTED("Embarquement prévu", false, false),
+
+ BOARDING_DONE("Embarquement réalisé", true, false),
+
+ BOAT_UNAVAILABLE("Non abouti", true, true),
+
+ BOAT_REFUSED("Refus", true ,true),
+
+ BOAT_DEFINITIVE_REFUSED("Refus définitif", true, true);
+
+ private String value;
+
+ private boolean finalState;
+
+ private boolean unfinishedState;
+
+ ContactState(String value, boolean finalState, boolean unfinishedState) {
+ this.value = value;
+ this.finalState = finalState;
+ this.unfinishedState = unfinishedState;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ public boolean isFinalState() {
+ return this.finalState;
+ }
+
+ public boolean isUnfinishedState() {
+ return this.unfinishedState;
+ }
+
+ public static ContactState createContactStateEnum(String value) {
+ if (value.equals(CONTACT_START.toString())) {
+ return CONTACT_START;
+ } else if (value.equals(BOARDING_EXPECTED.toString())) {
+ return BOARDING_EXPECTED;
+ } else if (value.equals(BOARDING_DONE.toString())) {
+ return BOARDING_DONE;
+ } else if (value.equals(BOAT_UNAVAILABLE.toString())) {
+ return BOAT_UNAVAILABLE;
+ } else if (value.equals(BOAT_REFUSED.toString())) {
+ return BOAT_REFUSED;
+ } else if (value.equals(BOAT_DEFINITIVE_REFUSED.toString())) {
+ return BOAT_DEFINITIVE_REFUSED;
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -21,10 +21,14 @@
package fr.ifremer.suiviobsmer.entity;
+import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import org.nuiton.topia.TopiaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,4 +57,42 @@
setPeriodYear(calendar.get(Calendar.YEAR));
}
+ /**
+ * Method could be use to add some time for realTidesValue or
+ * remove time with a negative nbDays.
+ * If nbDays is negative and superior to the current value,
+ * the real tides value will be set to 0.
+ * @param nbDays to add or remove (if negative)
+ * @throws SuiviObsmerException for saving problem
+ */
+ @Override
+ public void addRealTideTime(int nbDays) throws SuiviObsmerException {
+ int result = getRealTidesValue() + nbDays;
+ if (result < 0) {
+ result = 0;
+ }
+ TopiaContext transaction = null;
+ try {
+ transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+
+ // sux this.setTopiaContext(transaction) not allowed...
+// this.setTopiaContext(transaction);
+// setRealTidesValue(result);
+
+ SampleMonthDAO dao = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
+ SampleMonth month = dao.findByTopiaId(this.getTopiaId());
+ month.setRealTidesValue(result);
+ if (log.isDebugEnabled()) {
+ log.debug("Change realTideTime from " + getRealTidesValue() + " to " + result);
+ }
+
+ transaction.commitTransaction();
+ transaction.closeContext();
+ } catch (Exception eee) {
+ SuiviObsmerContext.serviceException(transaction,
+ "Impossible d'enregistrer le nombre de marées réels pour le mois de " +
+ this.getPeriodMonth() + "/" + this.getPeriodYear() + " [ligne : " + this.getSampleRow().getCode() + "]", eee);
+ }
+ }
+
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -21,12 +21,14 @@
package fr.ifremer.suiviobsmer.entity;
+import fr.ifremer.suiviobsmer.SuiviObsmerException;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.List;
+import org.nuiton.util.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -171,4 +173,33 @@
return false;
}
+ @Override
+ public void addRealTideTime(Contact contact) throws SuiviObsmerException {
+ int nbDays = getDifferenceDays(contact);
+ SampleMonth month = getSampleMonth(contact.getTideBeginDate());
+ if (log.isDebugEnabled()) {
+ log.debug("Add tide time " + nbDays + " for " +
+ month.getPeriodMonth() + "/" + month.getPeriodYear() + " [" + this.getCode() + "]");
+ }
+ month.addRealTideTime(nbDays);
+ }
+
+ @Override
+ public void removeRealTideTime(Contact contact) throws SuiviObsmerException {
+ int nbDays = getDifferenceDays(contact);
+ SampleMonth month = getSampleMonth(contact.getTideBeginDate());
+ if (log.isDebugEnabled()) {
+ log.debug("Remove tide time " + nbDays + " for " +
+ month.getPeriodMonth() + "/" + month.getPeriodYear() + " [" + this.getCode() + "]");
+ }
+ month.addRealTideTime(-nbDays);
+ }
+
+ protected int getDifferenceDays(Contact contact) {
+ int nbDays = DateUtils.getDifferenceInDays(contact.getTideBeginDate(), contact.getTideEndDate());
+ // difference nbDays + 1 for the first day
+ nbDays++;
+ return nbDays;
+ }
+
}
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -26,6 +26,7 @@
import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
import fr.ifremer.suiviobsmer.SuiviObsmerContext;
import fr.ifremer.suiviobsmer.business.SuiviObsmerRunnerTest;
+import java.util.Date;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -33,6 +34,7 @@
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.util.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
@@ -76,24 +78,14 @@
runner.stop();
}
-
- /**
- * Test of getSampleMonth method, of class SampleRowImpl.
- * @throws SuiviObsmerException
- * @throws TopiaException
- */
- @Test
- public void testGetSampleMonth() throws SuiviObsmerException, TopiaException {
- log.info("getSampleMonth");
-
- /** PREPARE DATA **/
+ private SampleRow prepareData() throws SuiviObsmerException, TopiaException {
TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = dao.create();
row.setCode("2010_1");
-
+
SampleMonthDAO monthDAO = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
SampleMonth month = monthDAO.create(SampleMonth.SAMPLE_ROW, row);
@@ -101,12 +93,34 @@
month.setPeriodYear(2009);
row.addSampleMonth(month);
- transaction.commitTransaction();
-
- /** EXEC METHOD **/
+ transaction.commitTransaction();
SampleRow myRow = dao.findByCode("2010_1");
transaction.closeContext();
-
+ return myRow;
+ }
+
+ private SampleRow getRowFromContext() throws SuiviObsmerException, TopiaException {
+ TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow resultRow = dao.findByCode("2010_1");
+ transaction.closeContext();
+ return resultRow;
+ }
+
+
+ /**
+ * Test of getSampleMonth method, of class SampleRowImpl.
+ * @throws SuiviObsmerException
+ * @throws TopiaException
+ */
+ @Test
+ public void testGetSampleMonth() throws SuiviObsmerException, TopiaException {
+ log.info("getSampleMonth");
+
+ /** PREPARE DATA **/
+ SampleRow myRow = prepareData();
+
+ /** EXEC METHOD **/
SampleMonth res = myRow.getSampleMonth(4, 2009);
assertNotNull(res);
@@ -114,4 +128,66 @@
assertNull(res);
}
+ @Test
+ public void testAddRealTideTime() throws Exception {
+ log.info("addRealTideTime");
+
+ /** PREPARE DATA **/
+ SampleRow row = prepareData();
+
+ Contact contact = new ContactImpl();
+ Date beginDate = DateUtils.createDate(12, 4, 2009);
+ Date endDate = DateUtils.createDate(12, 4, 2009);
+ contact.setTideBeginDate(beginDate);
+ contact.setTideEndDate(endDate);
+
+ /** EXEC METHOD **/
+ row.addRealTideTime(contact);
+ SampleMonth result = getRowFromContext().getSampleMonth(beginDate);
+ assertEquals(1, result.getRealTidesValue());
+
+ // Reinit result for next test
+ result.addRealTideTime(-1);
+
+ // Test with a more than one day interval dates from contact
+ endDate = DateUtils.createDate(18, 4, 2009);
+ contact.setTideEndDate(endDate);
+
+ getRowFromContext().addRealTideTime(contact);
+ result = getRowFromContext().getSampleMonth(beginDate);
+ assertEquals(7, result.getRealTidesValue());
+ }
+
+ @Test
+ public void testRemoveRealTideTime() throws Exception {
+ log.info("addRealTideTime");
+
+ /** PREPARE DATA **/
+ SampleRow row = prepareData();
+
+ Contact contact = new ContactImpl();
+ Date beginDate = DateUtils.createDate(12, 4, 2009);
+ Date endDate = DateUtils.createDate(12, 4, 2009);
+ contact.setTideBeginDate(beginDate);
+ contact.setTideEndDate(endDate);
+
+ /** EXEC METHOD **/
+ row.removeRealTideTime(contact);
+ SampleMonth result = getRowFromContext().getSampleMonth(beginDate);
+ // result stay at 0, can't remove 1 day from 0
+ assertEquals(0, result.getRealTidesValue());
+
+ // Reinit result for next test
+ result.addRealTideTime(12);
+
+ // Test with a more than one day interval dates from contact
+ endDate = DateUtils.createDate(18, 4, 2009);
+ contact.setTideEndDate(endDate);
+
+ getRowFromContext().removeRealTideTime(contact);
+ result = getRowFromContext().getSampleMonth(beginDate);
+ // result put to 5 : 12 - 7 (diff)
+ assertEquals(5, result.getRealTidesValue());
+ }
+
}
\ No newline at end of file
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -22,10 +22,11 @@
package fr.ifremer.suiviobsmer.ui.pages;
import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.bean.states.ContactStateEnum;
+import fr.ifremer.suiviobsmer.bean.ContactState;
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.entity.Company;
import fr.ifremer.suiviobsmer.entity.Contact;
+import fr.ifremer.suiviobsmer.entity.SampleMonth;
import fr.ifremer.suiviobsmer.entity.SampleRow;
import fr.ifremer.suiviobsmer.entity.User;
import fr.ifremer.suiviobsmer.services.ServiceBoat;
@@ -37,26 +38,23 @@
import fr.ifremer.suiviobsmer.ui.services.ContactModelFactory;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Date;
import java.util.Map;
import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.EventContext;
-import org.apache.tapestry5.OptionModel;
-import org.apache.tapestry5.SelectModel;
+import org.apache.tapestry5.Field;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.internal.OptionModelImpl;
-import org.apache.tapestry5.internal.SelectModelImpl;
+import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.BeanModelSource;
import org.slf4j.Logger;
+import org.nuiton.util.DateUtils;
/**
* Contacts
@@ -99,75 +97,11 @@
@Persist("flash")
private String editableContactId;
- @Property
- private String sampleRowId;
-
- @Property
- private String boatId;
-
void setupRender() throws SuiviObsmerException {
contacts = null;
getContacts();
}
- void onActivate(EventContext ec) {
- if (ec.getCount() > 0) {
- boatId = ec.get(String.class, 0);
- if (ec.getCount() > 1) {
- sampleRowId = ec.get(String.class, 1);
- }
- }
- }
-
- Object[] onPassivate() {
- return new String[] {boatId, sampleRowId};
- }
-
- /**************************** NEW CONTACT *********************************/
-
- private Contact newContact;
-
- private Boat boat;
-
- private SampleRow sampleRow;
-
- public Boat getBoat() throws SuiviObsmerException {
- if (boat == null && boatId != null) {
- boat = serviceBoat.getBoat(boatId);
- }
- return boat;
- }
-
- public SampleRow getSampleRow() throws SuiviObsmerException {
- if (sampleRow == null && sampleRowId != null) {
- sampleRow = serviceSampling.getSampleRow(sampleRowId);
- }
- return sampleRow;
- }
-
- public Contact getNewContact() throws SuiviObsmerException {
- if (newContact == null) {
- newContact = serviceContact.getNewContact(user, getSampleRow(), getBoat());
- }
- return newContact;
- }
-
- public boolean isSampleRowExists() {
- return sampleRowId != null;
- }
-
- public boolean isBoatExists() {
- return boatId != null;
- }
-
- public boolean canCreate() {
- return isSampleRowExists() && isBoatExists();
- }
-
- void onSelectedFromAddContact() {
- contact = newContact;
- }
-
/**************************** CONTACT LIST ********************************/
@Inject
@@ -186,13 +120,11 @@
private Contact contact;
private BeanModel<Contact> contactModel;
+
+ private ContactState contactState;
- private SelectModel stateSelectModel;
-
private boolean even = true;
-// private ContactContext contactContext;
-
public Map<String, Contact> getContacts() throws SuiviObsmerException {
if (contacts == null) {
if (log.isInfoEnabled()) {
@@ -213,28 +145,18 @@
return contactModel;
}
-// public ContactContext getContactContext() throws ContactStateException {
-// if (contactContext == null) {
-// contactContext = new ContactContextImpl(contact);
-// }
-// return contactContext;
-// }
-//
-// public List<ContactStateEnum> getContactStateAvailables() throws ContactStateException {
-// return getContactContext().getAvailableNextStatesAsEnum();
-// }
-
- public SelectModel getStateSelectModel() {
- if (stateSelectModel == null) {
- List<OptionModel> options = new ArrayList<OptionModel>();
- for (ContactStateEnum state : ContactStateEnum.values()) {
- options.add(new OptionModelImpl(state.getStringValue(), state.getStringValue()));
- }
- stateSelectModel = new SelectModelImpl(null, options);
+ public ContactState getContactState() {
+ if (contactState == null) {
+ // initialization
+ this.contactState = ContactState.createContactStateEnum(contact.getState());
}
- return stateSelectModel;
+ return this.contactState;
}
+ public void setContactState(ContactState contactState) {
+ this.contactState = contactState;
+ }
+
public String getSampleRowDescription() {
return BusinessUtils.getTooltipSampleRow(contact.getSampleRow());
}
@@ -275,25 +197,26 @@
/**************************** CONTACT ROW ACTION **************************/
+ /**
+ * Flag to know if it's only edition (=true) or save action (=false)
+ */
private boolean contactEdited;
private boolean contactDeleted;
public boolean hasActions() {
- // pour un non admin : affichage si aucune des deux validations ont été effectuées
+ return !user.getAdmin() && contact.getValidationCompany() == null;
+ }
+
+ public boolean canValidate() {
+ ContactState state = ContactState.createContactStateEnum(contact.getState());
+ boolean boardingDone = state.equals(ContactState.BOARDING_DONE) && contact.getDataInputDate() != null;
if (!user.getAdmin()) {
- return contact.getValidationCompany() == null &&
- contact.getValidationProgram() == null;
+ return contact.getValidationCompany() == null && (state.isUnfinishedState() || boardingDone);
}
-// if (!user.getAdmin()) {
-// return getContactStateAvailables().contains(ContactStateEnum.COMPANY_UNLOCKED);
-// }
- // pour un admin : affichage uniquement si la compagnie a validé la ligne
- return BooleanUtils.isTrue(contact.getValidationCompany());
-// return getContactStateAvailables().contains(ContactStateEnum.PROGRAM_UNLOCKED);
+ return contact.getValidationProgram() == null && BooleanUtils.isTrue(contact.getValidationCompany());
}
- @Log
public boolean canUnvalidate() {
if (!user.getAdmin()) {
return contact.getValidationCompany() != null &&
@@ -303,23 +226,41 @@
}
void onSelectedFromAcceptContact(String contactId) throws SuiviObsmerException {
- changeValidation(contactId, Boolean.TRUE);
+ contact = getContacts().get(contactId);
+ if (user.getAdmin()) {
+ contact.setValidationProgram(Boolean.TRUE);
+ } else {
+ // For company accepted, addRealTideTime
+ contact.getSampleRow().addRealTideTime(contact);
+ contact.setValidationCompany(Boolean.TRUE);
+ }
}
void onSelectedFromRefuseContact(String contactId) throws SuiviObsmerException {
- changeValidation(contactId, Boolean.FALSE);
+ contact = getContacts().get(contactId);
+ if (user.getAdmin()) {
+ // For program refused, removeRealTideTime
+ contact.getSampleRow().removeRealTideTime(contact);
+ contact.setValidationProgram(Boolean.FALSE);
+ } else {
+ contact.setValidationCompany(Boolean.FALSE);
+ }
}
void onSelectedFromUnvalidateContact(String contactId) throws SuiviObsmerException {
- changeValidation(contactId, null);
- }
-
- private void changeValidation(String contactId, Boolean value) throws SuiviObsmerException {
contact = getContacts().get(contactId);
if (user.getAdmin()) {
- contact.setValidationProgram(value);
+ // For program unvalidate from previous refused validation, addRealTideTime
+ if (BooleanUtils.isFalse(contact.getValidationProgram())) {
+ contact.getSampleRow().addRealTideTime(contact);
+ }
+ contact.setValidationProgram(null);
} else {
- contact.setValidationCompany(value);
+ // For company unvalidate from previous accepted validation, removeRealTideTime
+ if (BooleanUtils.isTrue(contact.getValidationCompany())) {
+ contact.getSampleRow().removeRealTideTime(contact);
+ }
+ contact.setValidationCompany(null);
}
}
@@ -335,7 +276,17 @@
}
void onSelectedFromSaveContact(String contactId) throws SuiviObsmerException {
- contact = getContacts().get(contactId);
+ contact = getContacts().get(contactId);
+ contact.setState(contactState.toString());
+ contactsForm.clearErrors();
+ if (!validateState()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Contact can't be saved with errors");
+ }
+ // The contact is not saved, the contact must be editable to show form and correct errors
+ contactEdited = true;
+ editableContactId = contact.getTopiaId();
+ }
}
void onSelectedFromCancelEditContact() throws SuiviObsmerException {
@@ -347,8 +298,23 @@
@Persist("flash")
private String contactSelectedId;
+ @InjectComponent
+ private Form contactsForm;
+
+ @InjectComponent
+ private Field beginDate;
+
+ @InjectComponent
+ private Field endDate;
+
+ @InjectComponent
+ private Field nbObservants;
+
+ @InjectComponent
+ private Field comment;
+
void onSuccessFromContactsForm() {
- if (!contactEdited) {
+ if (!contactEdited) {
try {
if (log.isDebugEnabled()) {
log.debug("Contact save : " + contact);
@@ -361,6 +327,44 @@
}
}
+ private boolean validateState() {
+ if (log.isInfoEnabled()) {
+ log.info("STATE SET : " + contactState);
+ }
+ // Non abouti, Refus ou Refus Définitif
+ if (contactState.isUnfinishedState()) {
+ if (!StringUtils.isEmpty(contact.getComment())) {
+ // RAZ des champs
+ contact.setTideBeginDate(null);
+ contact.setTideEndDate(null);
+ contact.setNbObservants(0);
+ contact.setMammalsCapture(false);
+ contact.setMammalsObservation(false);
+ } else {
+ contactsForm.recordError(comment, "Le commentaire est obligatoire pour l'état '" + contactState + "'");
+ }
+ // Embarquement Réalisé
+ } else if (contactState.equals(ContactState.BOARDING_DONE)) {
+ Date begin = contact.getTideBeginDate();
+ Date end = contact.getTideEndDate();
+ // TODO check program period borns for begin and end ????
+ if (begin == null) {
+ contactsForm.recordError(beginDate, "La date de début de marée est obligatoire pour l'état '" + contactState + "'");
+ }
+ if (end != null) {
+ if (begin != null && end.before(begin)) {
+ contactsForm.recordError(endDate, "La date de fin de la marée ne peut être antérieure à celle de début");
+ }
+ } else {
+ contactsForm.recordError(endDate, "La date de fin de marée est obligatoire pour l'état '" + contactState + "'");
+ }
+ if (contact.getNbObservants() == 0) {
+ contactsForm.recordError(nbObservants, "Il ne peut y avoir aucun observateur pour l'état '" + contactState + "'");
+ }
+ }
+ return !contactsForm.getHasErrors();
+ }
+
public void createNewContact(Boat boat, SampleRow sampleRow) throws SuiviObsmerException {
contact = serviceContact.getNewContact(user, sampleRow, boat);
serviceContact.saveContact(contact, Boolean.FALSE);
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -18,425 +18,425 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* ##%*
*/
-
-package fr.ifremer.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.PeriodDates;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.Profession;
-import fr.ifremer.suiviobsmer.entity.ProfessionImpl;
-import fr.ifremer.suiviobsmer.entity.Program;
-import fr.ifremer.suiviobsmer.entity.ProgramImpl;
-import fr.ifremer.suiviobsmer.entity.SampleMonth;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import fr.ifremer.suiviobsmer.services.ServiceReferential;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.Block;
-import org.apache.tapestry5.EventContext;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.corelib.components.Zone;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.slf4j.Logger;
-
-/**
- * SampleRowForm
- *
- * Created: 26 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/sampling.css")
-public class SampleRowForm implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return true;
- }
-
- @Inject
- private Logger log;
-
- @Inject
- private ServiceSampling serviceSampling;
-
- @Inject
- private ServiceReferential serviceReferential;
-
- @Inject
- private ServiceUser serviceUser;
-
- @Inject
- private ServiceBoat serviceBoat;
-
- @Inject
- private PropertyAccess propertyAccess;
-
- private boolean edited;
-
- void onActivate(EventContext ec) {
- if (ec.getCount() > 0) {
- sampleRowId = ec.get(String.class, 0);
- }
- }
-
- String onPassivate() {
- return sampleRowId;
- }
-
- void setupRender() throws SuiviObsmerException {
- // load models for select
- professionSelectModel = null;
- getProfessionSelectModel();
- programSelectModel = null;
- getProgramSelectModel();
- fishingZoneSelectModel = null;
- getFishingZoneSelectModel();
- // load main sampleRow (use of sampleRowId in url)
- sampleRow = null;
- getSampleRow();
- // initialize companyId if exist for companySelect
- Company company = getSampleRow().getCompany();
- if (company != null) {
- companyId = company.getTopiaId();
- }
- immatriculations = getSampleRow().getMainElligibleBoatsAsString();
- // Initialize fishingZones, programPeriod and sampleMonths for edition
- fishingZones = null;
- getFishingZones();
- period = null;
- getPeriod();
- sampleMonths = null;
- getSampleMonths();
- }
-
- /*************************** PROFESSION ***********************************/
-
- @Persist
- private GenericSelectModel<Profession> professionSelectModel;
-
- @Property
- private String professionId;
-
- @InjectComponent
- private Zone professionZone;
-
- public GenericSelectModel<Profession> getProfessionSelectModel() throws SuiviObsmerException {
- if (professionSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getProfessions]");
- }
- List<Profession> professions = serviceReferential.getProfessions();
- professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class,
- "code", "topiaId", propertyAccess);
- }
- return professionSelectModel;
- }
-
- void onSelectedFromSearchProfession() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("professionId : " + professionId);
- }
- Profession professionSelected = getProfessionSelectModel().findObject(professionId);
- sampleRow.setProfession(professionSelected);
- }
-
- void onSelectedFromAddNewProfession() {
- if (log.isDebugEnabled()) {
- log.debug("Add new profession");
- }
- sampleRow.setProfession(new ProfessionImpl());
- professionId = null;
- }
-
- Block onSuccessFromProfessionForm() throws SuiviObsmerException {
- return professionZone.getBody();
- }
-
- /*************************** FISHING ZONE *********************************/
-
- @Persist
- private GenericSelectModel<FishingZone> fishingZoneSelectModel;
-
- @Property
- private String fishingZoneId;
-
- @InjectComponent
- private Zone fishingZoneZone;
-
- @Property
- private FishingZone fishingZone;
-
- @Persist
- private List<FishingZone> fishingZones;
-
- @Property
- private int indexFishingZone;
-
- public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws SuiviObsmerException {
- if (fishingZoneSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getFishingZones]");
- }
- List<FishingZone> fishingZones = serviceReferential.getFishingZones();
- fishingZoneSelectModel = new GenericSelectModel<FishingZone>(fishingZones, FishingZone.class,
- "code", "topiaId", propertyAccess);
- }
- return fishingZoneSelectModel;
- }
-
- public List<FishingZone> getFishingZones() {
- if (fishingZones == null) {
- fishingZones = sampleRow.getFishingZone();
- }
- return fishingZones;
- }
-
- void onSelectedFromAddFishingZone() throws SuiviObsmerException {
- fishingZone = getFishingZoneSelectModel().findObject(fishingZoneId);
- if (!getFishingZones().contains(fishingZone)) {
- if (log.isDebugEnabled()) {
- log.debug("Add new fishingZone");
- }
- getFishingZones().add(fishingZone);
- }
- edited = true;
- }
-
- void onSelectedFromRemoveFishingZone(int index) {
- if (log.isDebugEnabled()) {
- log.debug("Remove fishingZone at position : " + index);
- }
- getFishingZones().remove(index);
- edited = true;
- }
-
- Block onSuccessFromFishingZoneForm() {
- if (!edited) {
- sampleRow.setFishingZone(fishingZones);
- }
- return fishingZoneZone.getBody();
- }
-
- /*************************** PROGRAM & MONTHS *****************************/
-
- @Persist
- private GenericSelectModel<Program> programSelectModel;
-
- @Property
- private String programName;
-
- @Property
- private String programId;
-
- @InjectComponent
- private Zone periodZone;
-
- private Program program;
-
- @Property
- private Date month;
-
- @Persist
- private PeriodDates period;
-
- @Persist
- private List<SampleMonth> sampleMonths;
-
- @Property
- private SampleMonth sampleMonth;
-
- public GenericSelectModel<Program> getProgramSelectModel() throws SuiviObsmerException {
- if (programSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getPrograms]");
- }
- List<Program> programs = serviceReferential.getPrograms();
- programSelectModel = new GenericSelectModel<Program>(programs, Program.class,
- "name", "topiaId", propertyAccess);
- }
- return programSelectModel;
- }
-
- public List<Date> getMonths() throws SuiviObsmerException {
- return period.getMonths();
- }
-
- public PeriodDates getPeriod() throws SuiviObsmerException {
- if (period == null) {
- program = getSampleRow().getProgram();
- if (program.getPeriodBegin() != null && program.getPeriodEnd() != null) {
- period = new PeriodDates(program.getPeriodBegin(), program.getPeriodEnd());
- } else {
- period = new PeriodDates();
- }
- }
- return period;
- }
-
- public List<SampleMonth> getSampleMonths() throws SuiviObsmerException {
- if (sampleMonths == null) {
- sampleMonths = new ArrayList<SampleMonth>();
- for (Date currMonth : getMonths()) {
- SampleMonth curr = getSampleRow().getSampleMonth(currMonth);
- if (curr == null) {
- curr = serviceSampling.getNewSampleMonth(currMonth, getSampleRow());
- }
- sampleMonths.add(curr);
- }
- }
- return sampleMonths;
- }
-
- public DateFormat getDateFormat() {
- return new SimpleDateFormat("MM/yyyy");
- }
-
- void onSelectedFromSearchProgram() throws SuiviObsmerException {
- // Reset programName
- programName = null;
- // Reset period to get the one from selected program
- period = null;
- // Reset sampleMonths for new period
- sampleMonths = null;
- edited = true;
- }
-
- void onSelectedFromRefreshMonths() throws SuiviObsmerException {
- // Reset sampleMonths cause of period modification
- sampleMonths = null;
- edited = true;
- }
-
- Block onSuccessFromPeriodForm() throws SuiviObsmerException {
- // New program
- if (isCreateMode()) {
- // Name not empty : suppress programId for select
- if (!StringUtils.isEmpty(programName)) {
- programId = null;
- }
-
- Program currentProgram = getSampleRow().getProgram();
- // Name changed : init new program with current periodBegin and periodEnd
- if (!StringUtils.isEmpty(programName) && !programName.equals(currentProgram.getName())) {
- program = new ProgramImpl();
- program.setName(programName);
- // ProgramId not empty in select : find program with id in selectModel
- } else if (!StringUtils.isEmpty(programId)) {
- program = getProgramSelectModel().findObject(programId);
- // Nor programId neither programName : reinit program object
- } else {
- program = new ProgramImpl();
- }
- // Set program to session with sampleRow
- getSampleRow().setProgram(program);
- }
- // Save sampleMonth
- if (sampleMonths != null) {
- getSampleRow().setSampleMonth(sampleMonths);
- }
- if (!edited) {
- // Save period dates
- program = getSampleRow().getProgram();
- program.setPeriodBegin(period.getFromDate());
- program.setPeriodEnd(period.getThruDate());
- }
-
- return periodZone.getBody();
- }
-
-
- /*************************** SAMPLE ROW ***********************************/
-
- private String sampleRowId;
-
- @Persist
- private SampleRow sampleRow;
-
- @Property
- private String updateComment;
-
- @Property
- private String immatriculations;
-
- @Property
- private String companyId;
-
- private GenericSelectModel<Company> companySelectModel;
-
- public SampleRow getSampleRow() throws SuiviObsmerException {
- if (sampleRow == null) {
- if (!StringUtils.isEmpty(sampleRowId)) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRow]");
- }
- sampleRow = serviceSampling.getSampleRow(sampleRowId);
- } else {
- sampleRow = serviceSampling.getNewSampleRow();
- }
- }
- return sampleRow;
- }
-
- public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException {
- if (companySelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getCompanies]");
- }
- List<Company> companies = serviceUser.getCompanies();
- companySelectModel = new GenericSelectModel<Company>(companies, Company.class,
- "name", "topiaId", propertyAccess);
- }
- return companySelectModel;
- }
-
- public boolean isCreateMode() throws SuiviObsmerException {
- return StringUtils.isEmpty(getSampleRow().getTopiaId());
- }
-
- void onSelectedFromCancelSave() {
- edited = true;
- }
-
- @Log
- Object onSuccessFromSampleRowForm() throws SuiviObsmerException {
- if (!edited) {
-
- Company company = getCompanySelectModel().findObject(companyId);
- getSampleRow().setCompany(company);
-
- List<Boat> boats = serviceBoat.getBoats(immatriculations);
-
- serviceSampling.createUpdateSampleRow(sampleRow, boats);
-
- return SamplingPlan.class;
-
- } else {
- sampleRow = null;
- }
- return null;
- }
-
-
-}
+
+package fr.ifremer.suiviobsmer.ui.pages;
+
+import org.nuiton.util.PeriodDates;
+import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.entity.Boat;
+import fr.ifremer.suiviobsmer.entity.Company;
+import fr.ifremer.suiviobsmer.entity.FishingZone;
+import fr.ifremer.suiviobsmer.entity.Profession;
+import fr.ifremer.suiviobsmer.entity.ProfessionImpl;
+import fr.ifremer.suiviobsmer.entity.Program;
+import fr.ifremer.suiviobsmer.entity.ProgramImpl;
+import fr.ifremer.suiviobsmer.entity.SampleMonth;
+import fr.ifremer.suiviobsmer.entity.SampleRow;
+import fr.ifremer.suiviobsmer.services.ServiceBoat;
+import fr.ifremer.suiviobsmer.services.ServiceReferential;
+import fr.ifremer.suiviobsmer.services.ServiceSampling;
+import fr.ifremer.suiviobsmer.services.ServiceUser;
+import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
+import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.EventContext;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.corelib.components.Zone;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+import org.slf4j.Logger;
+
+/**
+ * SampleRowForm
+ *
+ * Created: 26 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/sampling.css")
+public class SampleRowForm implements SuiviObsmerPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return true;
+ }
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ServiceSampling serviceSampling;
+
+ @Inject
+ private ServiceReferential serviceReferential;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Inject
+ private ServiceBoat serviceBoat;
+
+ @Inject
+ private PropertyAccess propertyAccess;
+
+ private boolean edited;
+
+ void onActivate(EventContext ec) {
+ if (ec.getCount() > 0) {
+ sampleRowId = ec.get(String.class, 0);
+ }
+ }
+
+ String onPassivate() {
+ return sampleRowId;
+ }
+
+ void setupRender() throws SuiviObsmerException {
+ // load models for select
+ professionSelectModel = null;
+ getProfessionSelectModel();
+ programSelectModel = null;
+ getProgramSelectModel();
+ fishingZoneSelectModel = null;
+ getFishingZoneSelectModel();
+ // load main sampleRow (use of sampleRowId in url)
+ sampleRow = null;
+ getSampleRow();
+ // initialize companyId if exist for companySelect
+ Company company = getSampleRow().getCompany();
+ if (company != null) {
+ companyId = company.getTopiaId();
+ }
+ immatriculations = getSampleRow().getMainElligibleBoatsAsString();
+ // Initialize fishingZones, programPeriod and sampleMonths for edition
+ fishingZones = null;
+ getFishingZones();
+ period = null;
+ getPeriod();
+ sampleMonths = null;
+ getSampleMonths();
+ }
+
+ /*************************** PROFESSION ***********************************/
+
+ @Persist
+ private GenericSelectModel<Profession> professionSelectModel;
+
+ @Property
+ private String professionId;
+
+ @InjectComponent
+ private Zone professionZone;
+
+ public GenericSelectModel<Profession> getProfessionSelectModel() throws SuiviObsmerException {
+ if (professionSelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getProfessions]");
+ }
+ List<Profession> professions = serviceReferential.getProfessions();
+ professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class,
+ "code", "topiaId", propertyAccess);
+ }
+ return professionSelectModel;
+ }
+
+ void onSelectedFromSearchProfession() throws SuiviObsmerException {
+ if (log.isDebugEnabled()) {
+ log.debug("professionId : " + professionId);
+ }
+ Profession professionSelected = getProfessionSelectModel().findObject(professionId);
+ sampleRow.setProfession(professionSelected);
+ }
+
+ void onSelectedFromAddNewProfession() {
+ if (log.isDebugEnabled()) {
+ log.debug("Add new profession");
+ }
+ sampleRow.setProfession(new ProfessionImpl());
+ professionId = null;
+ }
+
+ Block onSuccessFromProfessionForm() throws SuiviObsmerException {
+ return professionZone.getBody();
+ }
+
+ /*************************** FISHING ZONE *********************************/
+
+ @Persist
+ private GenericSelectModel<FishingZone> fishingZoneSelectModel;
+
+ @Property
+ private String fishingZoneId;
+
+ @InjectComponent
+ private Zone fishingZoneZone;
+
+ @Property
+ private FishingZone fishingZone;
+
+ @Persist
+ private List<FishingZone> fishingZones;
+
+ @Property
+ private int indexFishingZone;
+
+ public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws SuiviObsmerException {
+ if (fishingZoneSelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getFishingZones]");
+ }
+ List<FishingZone> fishingZones = serviceReferential.getFishingZones();
+ fishingZoneSelectModel = new GenericSelectModel<FishingZone>(fishingZones, FishingZone.class,
+ "code", "topiaId", propertyAccess);
+ }
+ return fishingZoneSelectModel;
+ }
+
+ public List<FishingZone> getFishingZones() {
+ if (fishingZones == null) {
+ fishingZones = sampleRow.getFishingZone();
+ }
+ return fishingZones;
+ }
+
+ void onSelectedFromAddFishingZone() throws SuiviObsmerException {
+ fishingZone = getFishingZoneSelectModel().findObject(fishingZoneId);
+ if (!getFishingZones().contains(fishingZone)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Add new fishingZone");
+ }
+ getFishingZones().add(fishingZone);
+ }
+ edited = true;
+ }
+
+ void onSelectedFromRemoveFishingZone(int index) {
+ if (log.isDebugEnabled()) {
+ log.debug("Remove fishingZone at position : " + index);
+ }
+ getFishingZones().remove(index);
+ edited = true;
+ }
+
+ Block onSuccessFromFishingZoneForm() {
+ if (!edited) {
+ sampleRow.setFishingZone(fishingZones);
+ }
+ return fishingZoneZone.getBody();
+ }
+
+ /*************************** PROGRAM & MONTHS *****************************/
+
+ @Persist
+ private GenericSelectModel<Program> programSelectModel;
+
+ @Property
+ private String programName;
+
+ @Property
+ private String programId;
+
+ @InjectComponent
+ private Zone periodZone;
+
+ private Program program;
+
+ @Property
+ private Date month;
+
+ @Persist
+ private PeriodDates period;
+
+ @Persist
+ private List<SampleMonth> sampleMonths;
+
+ @Property
+ private SampleMonth sampleMonth;
+
+ public GenericSelectModel<Program> getProgramSelectModel() throws SuiviObsmerException {
+ if (programSelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getPrograms]");
+ }
+ List<Program> programs = serviceReferential.getPrograms();
+ programSelectModel = new GenericSelectModel<Program>(programs, Program.class,
+ "name", "topiaId", propertyAccess);
+ }
+ return programSelectModel;
+ }
+
+ public List<Date> getMonths() throws SuiviObsmerException {
+ return period.getMonths();
+ }
+
+ public PeriodDates getPeriod() throws SuiviObsmerException {
+ if (period == null) {
+ program = getSampleRow().getProgram();
+ if (program.getPeriodBegin() != null && program.getPeriodEnd() != null) {
+ period = new PeriodDates(program.getPeriodBegin(), program.getPeriodEnd());
+ } else {
+ period = new PeriodDates();
+ }
+ }
+ return period;
+ }
+
+ public List<SampleMonth> getSampleMonths() throws SuiviObsmerException {
+ if (sampleMonths == null) {
+ sampleMonths = new ArrayList<SampleMonth>();
+ for (Date currMonth : getMonths()) {
+ SampleMonth curr = getSampleRow().getSampleMonth(currMonth);
+ if (curr == null) {
+ curr = serviceSampling.getNewSampleMonth(currMonth, getSampleRow());
+ }
+ sampleMonths.add(curr);
+ }
+ }
+ return sampleMonths;
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat("MM/yyyy");
+ }
+
+ void onSelectedFromSearchProgram() throws SuiviObsmerException {
+ // Reset programName
+ programName = null;
+ // Reset period to get the one from selected program
+ period = null;
+ // Reset sampleMonths for new period
+ sampleMonths = null;
+ edited = true;
+ }
+
+ void onSelectedFromRefreshMonths() throws SuiviObsmerException {
+ // Reset sampleMonths cause of period modification
+ sampleMonths = null;
+ edited = true;
+ }
+
+ Block onSuccessFromPeriodForm() throws SuiviObsmerException {
+ // New program
+ if (isCreateMode()) {
+ // Name not empty : suppress programId for select
+ if (!StringUtils.isEmpty(programName)) {
+ programId = null;
+ }
+
+ Program currentProgram = getSampleRow().getProgram();
+ // Name changed : init new program with current periodBegin and periodEnd
+ if (!StringUtils.isEmpty(programName) && !programName.equals(currentProgram.getName())) {
+ program = new ProgramImpl();
+ program.setName(programName);
+ // ProgramId not empty in select : find program with id in selectModel
+ } else if (!StringUtils.isEmpty(programId)) {
+ program = getProgramSelectModel().findObject(programId);
+ // Nor programId neither programName : reinit program object
+ } else {
+ program = new ProgramImpl();
+ }
+ // Set program to session with sampleRow
+ getSampleRow().setProgram(program);
+ }
+ // Save sampleMonth
+ if (sampleMonths != null) {
+ getSampleRow().setSampleMonth(sampleMonths);
+ }
+ if (!edited) {
+ // Save period dates
+ program = getSampleRow().getProgram();
+ program.setPeriodBegin(period.getFromDate());
+ program.setPeriodEnd(period.getThruDate());
+ }
+
+ return periodZone.getBody();
+ }
+
+
+ /*************************** SAMPLE ROW ***********************************/
+
+ private String sampleRowId;
+
+ @Persist
+ private SampleRow sampleRow;
+
+ @Property
+ private String updateComment;
+
+ @Property
+ private String immatriculations;
+
+ @Property
+ private String companyId;
+
+ private GenericSelectModel<Company> companySelectModel;
+
+ public SampleRow getSampleRow() throws SuiviObsmerException {
+ if (sampleRow == null) {
+ if (!StringUtils.isEmpty(sampleRowId)) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getSampleRow]");
+ }
+ sampleRow = serviceSampling.getSampleRow(sampleRowId);
+ } else {
+ sampleRow = serviceSampling.getNewSampleRow();
+ }
+ }
+ return sampleRow;
+ }
+
+ public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException {
+ if (companySelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getCompanies]");
+ }
+ List<Company> companies = serviceUser.getCompanies();
+ companySelectModel = new GenericSelectModel<Company>(companies, Company.class,
+ "name", "topiaId", propertyAccess);
+ }
+ return companySelectModel;
+ }
+
+ public boolean isCreateMode() throws SuiviObsmerException {
+ return StringUtils.isEmpty(getSampleRow().getTopiaId());
+ }
+
+ void onSelectedFromCancelSave() {
+ edited = true;
+ }
+
+ @Log
+ Object onSuccessFromSampleRowForm() throws SuiviObsmerException {
+ if (!edited) {
+
+ Company company = getCompanySelectModel().findObject(companyId);
+ getSampleRow().setCompany(company);
+
+ List<Boat> boats = serviceBoat.getBoats(immatriculations);
+
+ serviceSampling.createUpdateSampleRow(sampleRow, boats);
+
+ return SamplingPlan.class;
+
+ } else {
+ sampleRow = null;
+ }
+ return null;
+ }
+
+
+}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java 2009-12-15 16:03:30 UTC (rev 122)
@@ -43,7 +43,7 @@
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.upload.services.UploadedFile;
-import fr.ifremer.suiviobsmer.PeriodDates;
+import org.nuiton.util.PeriodDates;
import fr.ifremer.suiviobsmer.entity.Program;
import org.slf4j.Logger;
@@ -245,9 +245,9 @@
}
public boolean hasNbTidesReal() {
- // test with current month ????
Date current = new Date();
- return month.before(current) && !isCurrentMonth() && getNbTidesReal() != null;
+ boolean validMonth = month.before(current) || isCurrentMonth();
+ return validMonth && getNbTidesReal() != null;
}
public int getTotalTidesExpected() {
Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Contacts.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Contacts.properties 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Contacts.properties 2009-12-15 16:03:30 UTC (rev 122)
@@ -19,3 +19,12 @@
mammals-label: Observations et captures accidentelles
dataInputDate-label: Saisie des donn\u00E9es dans Allegro
comment-label: Commentaire
+
+# Form labels
+contactsForm-errors-banner: Le contact n'a pas \u00E9t\u00E9 sauvegard\u00E9 \u00E0 cause des erreurs suivantes :
+ContactState.BOAT_UNAVAILABLE: Non abouti
+ContactState.BOAT_DEFINITIVE_REFUSED: Refus d\u00E9finitif
+ContactState.BOAT_REFUSED: Refus
+ContactState.BOARDING_DONE: Embarquement r\u00E9alis\u00E9
+ContactState.BOARDING_EXPECTED: Embarquement pr\u00E9vu
+ContactState.CONTACT_START: Contact pris
Modified: trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml 2009-12-15 16:03:30 UTC (rev 122)
@@ -3,7 +3,9 @@
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<!--t:include="creationDate, lastState, boatName, boatImmatriculation, boatDistrictCode, beginTideDate, endTideDate,
nbObservants, mammals, editDate, comment, validation"-->
+
<form t:type="form" t:id="contactsForm">
+ <t:errors id="so-contact-form-errors" t:banner="message:contactsForm-errors-banner"/>
<div t:type="grid" t:source="contacts.values()" t:row="contact" class="t-data-grid ${gridClass}" t:model="contactModel" t:rowClass="prop:rowClass"
t:rowsPerPage="20">
<p:sampleRowCell>
@@ -21,25 +23,25 @@
</p:boatCell>
<p:stateCell>
<t:if t:test="editionMode">
- <input t:type="select" t:model="stateSelectModel" value="contact.state" />
+ <input t:type="select" t:id="contactState" t:validate="required"/>
<p:else>${contact.state}</p:else>
</t:if>
</p:stateCell>
<p:tideBeginDateCell>
<t:if t:test="editionMode">
- <input t:type="datefield" class="date" value="contact.tideBeginDate" />
+ <input t:type="datefield" t:id="beginDate" class="date" value="contact.tideBeginDate" />
<p:else><t:output value="contact.tideBeginDate" format="dateFormat" /></p:else>
</t:if>
</p:tideBeginDateCell>
<p:tideEndDateCell>
<t:if t:test="editionMode">
- <input t:type="datefield" class="date" value="contact.tideEndDate" />
+ <input t:type="datefield" t:id="endDate" class="date" value="contact.tideEndDate" />
<p:else><t:output value="contact.tideEndDate" format="dateFormat" /></p:else>
</t:if>
</p:tideEndDateCell>
<p:nbObservantsCell>
<t:if t:test="editionMode">
- <input t:type="textfield" class="nbObservants" value="contact.nbObservants" />
+ <input t:type="textfield" t:id="nbObservants" class="nbObservants" value="contact.nbObservants" />
<p:else>${contact.nbObservants}</p:else>
</t:if>
</p:nbObservantsCell>
@@ -71,13 +73,13 @@
</p:validationCell>
<p:dataInputDateCell>
<t:if t:test="editionMode">
- <input t:type="datefield" class="date" value="contact.dataInputDate" />
+ <input t:type="datefield" t:id="inputDate" class="date" value="contact.dataInputDate" />
<p:else><t:output value="contact.dataInputDate" format="dateFormat" /></p:else>
</t:if>
</p:dataInputDateCell>
<p:commentCell>
<t:if t:test="editionMode">
- <input t:type="textarea" cols="20" rows="2" value="contact.comment" />
+ <input t:type="textarea" t:id="comment" cols="20" rows="2" value="contact.comment" />
<p:else>
${contact.comment}
</p:else>
@@ -85,25 +87,25 @@
</p:commentCell>
<p:actionsCell>
<t:if t:test="hasActions()">
- <t:unless t:test="user.admin">
- <t:if t:test="editionMode">
- <input t:type="submit" t:id="cancelEditContact" class="ico22px undo22px" value="Undo"
- title="Annuler les modifications" />
- <input t:type="submitContext" t:id="saveContact" class="ico22px save22px" value="Save"
- t:context="contact.topiaId" title="Enregistrer le contact" />
- <p:else>
- <input t:type="submitContext" t:id="editContact" class="ico edit" value="Edit"
- t:context="contact.topiaId" title="Modifier le contact" />
- <input t:type="submitContext" t:id="deleteContact" class="ico22px delete" value="Delete"
- t:context="contact.topiaId" title="Supprimer le contact"
- t:mixins="confirm" t:message="Etes-vous sûr de vouloir supprimer définitivement ce contact ?" />
- </p:else>
- </t:if>
- </t:unless>
+ <t:if t:test="editionMode">
+ <input t:type="submit" t:id="cancelEditContact" class="ico22px undo22px" value="Undo"
+ title="Annuler les modifications" />
+ <input t:type="submitContext" t:id="saveContact" class="ico22px save22px" value="Save"
+ t:context="contact.topiaId" title="Enregistrer le contact" />
+ <p:else>
+ <input t:type="submitContext" t:id="editContact" class="ico edit" value="Edit"
+ t:context="contact.topiaId" title="Modifier le contact" />
+ <input t:type="submitContext" t:id="deleteContact" class="ico22px delete" value="Delete"
+ t:context="contact.topiaId" title="Supprimer le contact"
+ t:mixins="confirm" t:message="Etes-vous sûr de vouloir supprimer définitivement ce contact ?" />
+ </p:else>
+ </t:if>
+ </t:if>
+ <t:if t:test="canValidate()">
<input t:type="submitContext" t:id="acceptContact" class="ico22px accept" value="Accept"
- t:context="contact.topiaId" title="Valider le contact" />
+ t:context="contact.topiaId" title="Valider le contact" />
<input t:type="submitContext" t:id="refuseContact" class="ico22px refuse" value="Refuse"
- t:context="contact.topiaId" title="Refuser le contact" />
+ t:context="contact.topiaId" title="Refuser le contact" />
</t:if>
<t:if t:test="canUnvalidate()">
<input t:type="submitContext" t:id="unvalidateContact" class="ico22px unvalidate" value="Unvalidate"
Modified: trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css 2009-12-15 16:03:30 UTC (rev 122)
@@ -50,13 +50,13 @@
div#so-contacts table.t-data-grid thead tr th.dataInputDate,
div#so-contacts table.t-data-grid thead tr th.tideEndDate,
div#so-contacts table.t-data-grid thead tr th.tideBeginDate {
- width: 100px;
+ width: 120px;
white-space: normal;
text-align: center;
}
div#so-contacts table.t-data-grid thead tr th.nbObservants {
- width: 20px;
+ width: 40px;
white-space: normal;
text-align: center;
}
@@ -76,18 +76,25 @@
}
/** FORM **/
+div#so-contacts div.t-error {
+ width: 60%;
+ margin: 5px auto;
+}
+
+div#so-contacts div.t-error li {
+ margin-left: 20px;
+}
+
div#so-contacts-edit {
width: 40%;
margin-left: auto;
margin-right: auto;
}
-input.date, /* TEMP */
-div#so-contacts-edit div.t-beaneditor input.date {
+input.date {
width: 70px;
}
-input.nbObservants, /* TEMP */
-div#so-contacts-edit div.t-beaneditor input.nbObservants {
+input.nbObservants {
width: 18px;
}
Modified: trunk/suiviobsmer-ui/src/main/webapp/js/dialog.js
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/js/dialog.js 2009-12-15 10:16:12 UTC (rev 121)
+++ trunk/suiviobsmer-ui/src/main/webapp/js/dialog.js 2009-12-15 16:03:30 UTC (rev 122)
@@ -8,12 +8,12 @@
*/
initialize: function(element, message) {
this.message = message;
- Tapestry.debug('click ' + element);
Event.observe($(element), 'click', this.doConfirm.bindAsEventListener(this));
},
doConfirm: function(e) {
+ //Tapestry.debug('click ' + element);
if(! confirm(this.message)) {
- Tapestry.debug('STOP ' + e);
+ //Tapestry.debug('STOP ' + e);
Event.stop(e);
}
}
1
0