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] r141 - in trunk: suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity suiviobsmer-business/src/main/xmi suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/webapp suiviobsmer-ui/src/main/webapp/img
by fdesbois@users.labs.libre-entreprise.org 21 Dec '09
by fdesbois@users.labs.libre-entreprise.org 21 Dec '09
21 Dec '09
Author: fdesbois
Date: 2009-12-21 14:22:59 +0000 (Mon, 21 Dec 2009)
New Revision: 141
Added:
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java
trunk/suiviobsmer-ui/src/main/webapp/img/calendar-unavailable.png
Modified:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImplTest.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties
trunk/suiviobsmer-ui/src/main/webapp/Boats.tml
Log:
- Show activityCalendar fieldset even if no calendar is set
- Add calcul on boarding for boatInfos
- Remove old methods in BoatImpl
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-21 10:22:48 UTC (rev 140)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2009-12-21 14:22:59 UTC (rev 141)
@@ -50,92 +50,11 @@
private static final long serialVersionUID = 1L;
- @Override
- @Deprecated
- public BoatInfos getBoatInfos(Company company) throws SuiviObsmerException {
- TopiaContext transaction = null;
- BoatInfos boatInfos = null;
- try {
- if (company == null) {
- throw new IllegalArgumentException("company parameter can't be null to getBoatsInfos " +
- "for boat '" + this.getName() + "'");
- }
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- /*CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- Company companyFromDB = companyDAO.findByTopiaId(company.getTopiaId());*/
-
- BoatInfosDAO boatInfosDAO = SuiviObsmerModelDAOHelper.getBoatInfosDAO(transaction);
- boatInfos = boatInfosDAO.findByProperties(BoatInfos.BOAT, this, BoatInfos.COMPANY, company);
- if (boatInfos == null) {
- boatInfos = new BoatInfosImpl();
- boatInfos.setBoat(this);
- boatInfos.setCompany(company);
- } else {
- // load data
- boatInfos.getBoat();
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Boat infos : " + boatInfos);
- log.debug("Boat infos boat : " + boatInfos.getBoat());
- }
-
- 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 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
*/
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2009-12-21 10:22:48 UTC (rev 140)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2009-12-21 14:22:59 UTC (rev 141)
@@ -21,12 +21,17 @@
package fr.ifremer.suiviobsmer.entity;
+import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.bean.ContactState;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Calendar;
+import java.util.Arrays;
+import java.util.Collections;
+import org.nuiton.topia.TopiaContext;
import java.util.Date;
-import java.util.GregorianCalendar;
import java.util.List;
+import org.nuiton.topia.TopiaException;
/**
* BoatInfosImpl
@@ -43,46 +48,109 @@
private static final long serialVersionUID = 1L;
- protected Date firstBoardingDate;
- protected List<String> professionLibelles;
protected int nbBoarding;
protected int nbBoardingForCompany;
-
- @Override
- public List<String> getProfessionLibelles() {
- List<String> professions = new ArrayList<String>();
- professions.add("PTM DEF - Chalutage pélagique en bœuf à bar");
- professions.add("OTB DEF80-90 - Chalutage de fond côtier");
- // TODO get professions libelles from sampleRows (change method name, get sampleRows code)
- return professions;
- }
/**
- * @return
+ * Calculate the number of boarding done on the boat since the date in argument.
+ * Only the validate contacts by company will be count.
+ *
+ * @param fromDate the date to start calcul
+ * @return a number of boarding done on the boat for all companies
+ * @throws SuiviObsmerException
*/
@Override
- public int getNbBoarding() {
- // TODO : calculate total nbBoarding from getFirstBoardingDate
- return 18;
+ public int getNbBoarding(Date fromDate) throws SuiviObsmerException {
+ TopiaContext transaction = null;
+ int result = 0;
+ try {
+ transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+
+ result = countDoneContactsFromDate(transaction, fromDate, false);
+
+ transaction.closeContext();
+ } catch (Exception eee) {
+ SuiviObsmerContext.serviceException(transaction,
+ "Impossible de récupérer le nombre d'embarquements réels depuis le " +
+ "'" + fromDate + "'",
+ eee);
+ }
+ return result;
}
/**
- * @return
+ * Calculate the number of boarding done on the boat and the company since the date in argument.
+ * Only the validate contacts by company will be count.
+ *
+ * @param fromDate the date to start calcul
+ * @return a number of boarding done on the boat for the current company
+ * @throws SuiviObsmerException
*/
@Override
- public int getNbBoardingForCompany() {
- // TODO : calculate nbBoarding for Company
- //ContextUtil.getRootContext().beginTransaction();
- return 5;
+ public int getNbBoardingForCompany(Date fromDate) throws SuiviObsmerException {
+ TopiaContext transaction = null;
+ int result = 0;
+ try {
+ transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+
+ result = countDoneContactsFromDate(transaction, fromDate, true);
+
+ transaction.closeContext();
+ } catch (Exception eee) {
+ SuiviObsmerContext.serviceException(transaction,
+ "Impossible de récupérer le nombre d'embarquements réels depuis le " +
+ "'" + fromDate + "' pour la société '" + getCompany().getName() + "'",
+ eee);
+ }
+ return result;
}
/**
- * @return
+ * Execute the HQL query for counting contact with BoardingDone state since the fromDate.
+ * This query is used to get all boarding dones on this boat for all companies or only for the
+ * current one. Only the validate contacts by company will be count. The param fromDate can be null,
+ * in this case, all contacts will be counted (not matter which date then started).
+ *
+ * @param transaction TopiaContext to execute the query
+ * @param fromDate the date to start calcul
+ * @param companyOnly boolean used to filter by the current company or not
+ * @return the number of boarding done since fromDate
+ * @throws TopiaException
*/
- @Override
- public Date getFirstBoardingDate() {
- Calendar calendar = new GregorianCalendar();
- calendar.add(Calendar.MONTH, 12);
- return calendar.getTime();
+ protected int countDoneContactsFromDate(TopiaContext transaction, Date fromDate, boolean companyOnly) throws TopiaException {
+ int result = 0;
+
+ List<Object> params = new ArrayList<Object>();
+ String contactClassName = Contact.class.getName();
+ String query = "SELECT COUNT(*)" +
+ " FROM " + contactClassName +
+ " WHERE boat = :boat AND state = :boardingDone" +
+ " AND validationCompany = :booleanTrue" +
+ " AND (validationProgram IS NULL OR validationProgram = :booleanTrue)";
+
+ params.add("boat"); params.add(getBoat());
+ params.add("boardingDone"); params.add(ContactState.BOARDING_DONE.toString());
+ params.add("booleanTrue"); params.add(Boolean.TRUE);
+
+ if (fromDate != null) {
+ query += " AND tideBeginDate >= :fromDate";
+ params.add("fromDate");
+ params.add(fromDate);
+ }
+
+ if (companyOnly) {
+ query+= " AND user.company = :company";
+ params.add("company");
+ params.add(getCompany());
+ }
+
+ List results = transaction.find(query, params.toArray());
+
+ if (!results.isEmpty()) {
+ Long tmp = (Long) results.get(0);
+ result += tmp.intValue();
+ }
+
+ return result;
}
}
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java 2009-12-21 10:22:48 UTC (rev 140)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java 2009-12-21 14:22:59 UTC (rev 141)
@@ -28,7 +28,7 @@
import org.slf4j.LoggerFactory;
/**
- * BoatImpl
+ * BoatImplTest
*
* Created: 15 déc. 2009
*
@@ -67,71 +67,6 @@
}
/**
- * 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
Added: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java (rev 0)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java 2009-12-21 14:22:59 UTC (rev 141)
@@ -0,0 +1,170 @@
+
+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.services.ServiceBoat;
+import fr.ifremer.suiviobsmer.services.ServiceContact;
+import org.nuiton.topia.TopiaContext;
+import java.io.InputStream;
+import java.util.Date;
+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.util.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatInfosImplTest
+ *
+ * Created: 21 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BoatInfosImplTest {
+
+ private static SuiviObsmerRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(BoatInfosImplTest.class);
+
+ public BoatInfosImplTest() {
+ }
+
+ @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 getNbBoarding method, of class BoatInfosImpl.
+ */
+ @Test
+ public void testGetNbBoarding() throws Exception {
+ log.info("getNbBoarding");
+
+ /** PREPARE DATA **/
+ 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();
+
+ CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.create(Company.NAME, "TARTANPION");
+ Company company2 = companyDAO.create(Company.NAME, "BIS");
+
+ UserDAO userDAO = SuiviObsmerModelDAOHelper.getUserDAO(transaction);
+ User user = userDAO.create(User.FIRST_NAME,"Jean", User.LAST_NAME, "Michmuche",
+ User.COMPANY, company);
+ company.addUser(user);
+ User user2 = userDAO.create(User.FIRST_NAME,"Bill", User.LAST_NAME, "Murray",
+ User.COMPANY, company2);
+ company2.addUser(user2);
+
+ BoatInfosDAO boatInfosDAO = SuiviObsmerModelDAOHelper.getBoatInfosDAO(transaction);
+ BoatInfos boatInfos = boatInfosDAO.create(BoatInfos.BOAT, boat, BoatInfos.COMPANY, company);
+
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ // First contact : OK
+ Contact contact1 = new ContactImpl();
+ contact1.setBoat(boat);
+ contact1.setUser(user);
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ Date begin = DateUtils.createDate(3, 3, 2009);
+ contact1.setTideBeginDate(begin);
+ contact1.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact1, false);
+
+ /** EXEC METHOD **/
+
+ Date fromDate = DateUtils.createDate(1, 1, 2009);
+ int result = boatInfos.getNbBoarding(fromDate);
+ Assert.assertEquals(1, result);
+
+ Contact contact2 = new ContactImpl();
+ // Second contact with ValidationProgram = FALSE
+ contact2.setBoat(boat);
+ contact2.setUser(user);
+ contact2.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 8, 2009);
+ contact2.setTideBeginDate(begin);
+ contact2.setValidationCompany(Boolean.TRUE);
+ contact2.setValidationProgram(Boolean.FALSE);
+ serviceContact.saveContact(contact2, false);
+
+ result = boatInfos.getNbBoarding(fromDate);
+ Assert.assertEquals(1, result);
+
+ Contact contact3 = new ContactImpl();
+ // Third contact with tideBeginDate < fromDate
+ contact3.setBoat(boat);
+ contact3.setUser(user);
+ contact3.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 8, 2008);
+ contact3.setTideBeginDate(begin);
+ contact3.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact3, false);
+
+ result = boatInfos.getNbBoarding(fromDate);
+ Assert.assertEquals(1, result);
+
+ Contact contact4 = new ContactImpl();
+ // Fourth contact : OK with an other company
+ contact4.setBoat(boat);
+ contact4.setUser(user2);
+ contact4.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 4, 2009);
+ contact4.setTideBeginDate(begin);
+ contact4.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact4, false);
+
+ result = boatInfos.getNbBoarding(fromDate);
+ Assert.assertEquals(2, result);
+
+ // Calcul with a fromDate null
+ result = boatInfos.getNbBoarding(null);
+ Assert.assertEquals(3, result);
+ }
+
+ /**
+ * Test of getNbBoardingForCompany method, of class BoatInfosImpl.
+ */
+ //@Test
+ public void testGetNbBoardingForCompany() {
+ System.out.println("getNbBoardingForCompany");
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImplTest.java 2009-12-21 10:22:48 UTC (rev 140)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImplTest.java 2009-12-21 14:22:59 UTC (rev 141)
@@ -29,6 +29,7 @@
import fr.ifremer.suiviobsmer.business.SuiviObsmerRunnerTest;
import fr.ifremer.suiviobsmer.bean.BoatFilter;
import fr.ifremer.suiviobsmer.bean.CompanyBoatInfos;
+import fr.ifremer.suiviobsmer.bean.ContactState;
import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
import fr.ifremer.suiviobsmer.entity.ActivityCalendarDAO;
import fr.ifremer.suiviobsmer.entity.Boat;
@@ -37,11 +38,16 @@
import fr.ifremer.suiviobsmer.entity.Company;
import fr.ifremer.suiviobsmer.entity.CompanyDAO;
import fr.ifremer.suiviobsmer.entity.CompanyImpl;
+import fr.ifremer.suiviobsmer.entity.Contact;
import fr.ifremer.suiviobsmer.entity.ElligibleBoat;
import fr.ifremer.suiviobsmer.entity.SampleRow;
import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
+import fr.ifremer.suiviobsmer.entity.User;
+import fr.ifremer.suiviobsmer.entity.UserImpl;
+import fr.ifremer.suiviobsmer.services.ServiceContact;
import fr.ifremer.suiviobsmer.services.ServiceReferential;
import fr.ifremer.suiviobsmer.services.ServiceSampling;
+import fr.ifremer.suiviobsmer.services.ServiceUser;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
@@ -211,19 +217,37 @@
service.importBoatCsv(input);
List<Boat> boats = service.getBoats("174592");
+ Boat boat = boats.get(0);
// Two rows created : 2009_3 & 2010_4 and one Company : "TARTANPION"
+ 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);
List<SampleRow> rows = prepareSampleRows(company);
+
+ TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_1");
+ row.getCompany();
+ row.getProgram();
+ row.getProfession();
+ transaction.closeContext();
- Boat boat = boats.get(0);
- // Return new BoatInfos
- BoatInfos boatInfos = boat.getBoatInfos(company);
+ ServiceContact serviceContact = new ServiceContactImpl();
+ Contact contact1 = serviceContact.getNewContact(user, row, boat);
+ contact1.setState(ContactState.CONTACT_START.toString());
+ serviceContact.saveContact(contact1, false);
CompanyBoatInfos companyBoatInfos = service.getCompanyBoatInfos(174592, company);
/** EXEC METHOD **/
+ BoatInfos boatInfos = companyBoatInfos.getBoatInfos();
boatInfos.setDup(2);
boatInfos.setContactFirstName("Jean-Paul");
@@ -266,7 +290,11 @@
assertNull(elligible.getCompanyActive());
assertTrue(elligible.getGlobalActive());
+ /** EXEC METHOD **/
+ Contact result = companyBoatInfos.getLastContact();
+ Assert.assertEquals(contact1.getTopiaId(), result.getTopiaId());
+
}
/**
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-21 10:22:48 UTC (rev 140)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2009-12-21 14:22:59 UTC (rev 141)
@@ -29,7 +29,6 @@
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;
@@ -49,6 +48,9 @@
import java.io.InputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.BooleanUtils;
@@ -451,6 +453,12 @@
//boatInfos = null;
companyBoatInfos = null;
//companyId = null;
+
+ // Initialize from Date for boarding calcul in BoatInfos
+ Calendar calendar = new GregorianCalendar();
+ calendar.add(Calendar.MONTH, -12);
+ boardingFromDate = calendar.getTime();
+
return boatsZone.getBody();
}
@@ -484,6 +492,9 @@
@Property
private String companyId;
+ @Property
+ private Date boardingFromDate;
+
/*@Persist
private SuiviObsmerPropertyChangeListener propertyChange;*/
@@ -626,6 +637,10 @@
return boatInfosZone.getBody();
}
+ Block onSuccessFromCalculateBoardings() {
+ return boatInfosZone.getBody();
+ }
+
/**************************** Create new contact **************************/
@InjectPage
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-21 10:22:48 UTC (rev 140)
+++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties 2009-12-21 14:22:59 UTC (rev 141)
@@ -26,4 +26,5 @@
contactPhoneNumber-label: T\u00E9l\u00E9phone
contactEmail-label: E-mail
shipOwner-label: Armateur
+fromDate-label: Embarquements depuis le
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-21 10:22:48 UTC (rev 140)
+++ trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2009-12-21 14:22:59 UTC (rev 141)
@@ -125,52 +125,50 @@
<!-- BOATINFOS:: Informations du navire sélectionné -->
<t:if t:test="boatSelectedImmatriculation">
- <t:zone t:id="boatInfosZone" t:update="show" class="fleft" id="so-boats-boat-infos">
- <t:unless t:test="activityCalendarImportRun">
- <!-- HEADER For admin -->
- <t:if t:test="user.admin">
- <h2>Informations sur <!--${companyBoatInfos.boatInfos.boat.name}-->${boatName}</h2>
- <form t:type="form" t:id="companySelectForm" t:zone="so-boats-boat-infos">
- <t:label t:for="company" /> :
- <input t:type="select" t:id="company" t:model="companySelectModel" t:value="companyId" />
- <input t:type="submit" class="ico search" t:id="searchCompany" value="Search" />
- </form>
- </t:if>
- <!-- BODY - delegator -->
- <t:if t:test="canShowActiveBoatInfos()">
- <t:delegate to="activeBoatInfosBlock" />
- </t:if>
- <!-- BODY - activity calendar -->
- <t:if t:test="hasActivityCalendar()">
- <fieldset id="so-boats-boat-infos-calendar">
- <legend>Calendrier d'activité</legend>
- <p>
+ <t:zone t:id="boatInfosZone" t:update="show" class="fleft" id="so-boats-boat-infos">
+ <!-- HEADER For admin -->
+ <t:if t:test="user.admin">
+ <h2>Informations sur <!--${companyBoatInfos.boatInfos.boat.name}-->${boatName}</h2>
+ <form t:type="form" t:id="companySelectForm" t:zone="so-boats-boat-infos">
+ <t:label t:for="company" /> :
+ <input t:type="select" t:id="company" t:model="companySelectModel" t:value="companyId" />
+ <input t:type="submit" class="ico search" t:id="searchCompany" value="Search" />
+ </form>
+ </t:if>
+ <!-- BODY - delegator -->
+ <t:if t:test="canShowActiveBoatInfos()">
+ <t:delegate to="activeBoatInfosBlock" />
+ </t:if>
+ <!-- BODY - activity calendar -->
+ <fieldset id="so-boats-boat-infos-calendar">
+ <legend>Calendrier d'activité</legend>
+ <t:unless t:test="activityCalendarImportRun">
+ <p>
+ <t:if t:test="hasActivityCalendar()">
<a t:type="actionlink" t:id="showLastActivityCalendar">
<img src="${asset:context:}/img/calendar.png" title="Calendrier d'activité"/>
</a>
- </p>
- </fieldset>
- </t:if>
- <!-- FOOTER For user -->
- <t:unless t:test="user.admin">
- <div id="so-boats-boat-infos-message">
- Les informations saisies sont confidentielles et propriété de la société. <br />
- Elles sont néanmoins consultables par un administrateur
- </div>
+ <p:else>
+ <img src="${asset:context:}/img/calendar-unavailable.png" title="Calendrier d'activité indisponible"/>
+ </p:else>
+ </t:if>
+ </p>
+ <p:else>
+ <div class="fb-info">
+ Le chargement des calendriers d'activité dans l'application est actuellement en cours d'exécution...
+ </div>
+ </p:else>
</t:unless>
-
- <p:else>
- <div class="fb-info">
- Le chargement des calendriers d'activité est en cours. <br />
- Vous ne pouvez pas accéder aux informations du navire pour l'instant. <br />
- Veuillez réessayer ultérieurement.
- </div>
- </p:else>
+ </fieldset>
+ <!-- FOOTER For user -->
+ <t:unless t:test="user.admin">
+ <div id="so-boats-boat-infos-message">
+ Les informations saisies sont confidentielles et propriété de la société. <br />
+ Elles sont néanmoins consultables par un administrateur
+ </div>
</t:unless>
</t:zone>
-
-
<!-- BOATINFOS:: DISPLAY MODE -->
<t:block t:id="displayBoatInfos">
@@ -233,12 +231,17 @@
</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>
+ <form t:type="form" t:id="CalculateBoardings" t:zone="so-boats-boat-infos">
+ <t:label t:for="fromDate"/> :
+ <input t:type="datefield" t:id="fromDate" value="boardingFromDate" />
+ <input t:type="submit" class="ico refresh" t:id="refreshBoardings" value="Refresh" title="Recalculer les embarquements"/>
+ </form>
</p>
+ <p>
+ <strong>${boatInfos.getNbBoarding(boardingFromDate)}</strong> embarquements
+ dont <strong>${boatInfos.getNbBoardingForCompany(boardingFromDate)}</strong> dans votre société
+ </p>
<t:if t:test="companyBoatInfos.elligibleBoatsValues.size()">
<p class="sep"> </p>
<label>Ligne(s) du plan :</label>
@@ -306,11 +309,15 @@
<div>
<p><t:label t:for="dup"/> : <input t:type="textfield" t:id="dup" class="dup" value="boatInfos.dup" /></p>
<p class="sep"> </p>
+<!-- <p>
+ <t:label t:for="fromDate"/> :
+ <input t:type="datefield" t:id="fromDate" value="boardingFromDate" />
+ <input t:type="submit" class="ico refresh" t:id="refreshBoardings" value="Refresh" title="Recalculer les embarquements"/>
+ </p>
<p>
- <strong>${boatInfos.nbBoarding}</strong> embarquements
- dont <strong>${boatInfos.nbBoardingForCompany}</strong> dans votre société
- depuis le <strong><t:output value="boatInfos.firstBoardingDate" format="dateFormat" /></strong>
- </p>
+ <strong>${boatInfos.getNbBoarding(boardingFromDate)}</strong> embarquements
+ dont <strong>${boatInfos.getNbBoardingForCompany(boardingFromDate)}</strong> dans votre société
+ </p>-->
<p class="sep"> </p>
<label>Ligne(s) du plan :</label>
<ul>
Added: trunk/suiviobsmer-ui/src/main/webapp/img/calendar-unavailable.png
===================================================================
(Binary files differ)
Property changes on: trunk/suiviobsmer-ui/src/main/webapp/img/calendar-unavailable.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
[Suiviobsmer-commits] r140 - in trunk: . suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl suiviobsmer-business/src/main/xmi suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/webapp/img
by fdesbois@users.labs.libre-entreprise.org 21 Dec '09
by fdesbois@users.labs.libre-entreprise.org 21 Dec '09
21 Dec '09
Author: fdesbois
Date: 2009-12-21 10:22:48 +0000 (Mon, 21 Dec 2009)
New Revision: 140
Added:
trunk/suiviobsmer-ui/src/main/webapp/img/logo_WAO.png
Modified:
trunk/changelog.txt
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
Log:
Correction canCreateContact condition
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2009-12-20 19:50:20 UTC (rev 139)
+++ trunk/changelog.txt 2009-12-21 10:22:48 UTC (rev 140)
@@ -24,7 +24,7 @@
[15-12-2009] [fdesbois] EVO IHM #1941 (Boats / BoatActivityCalendar)
Ajout du champ d'import pour les calendriers d'activité + accès au fichier de log des imports
-[13-12-2009] [fdesbois] EVO METIER
+[13-12-2009] [fdesbois] EVO METIER #1941 (Boats / BoatActivityCalendar)
* Renommage classe SuiviObsmerUtils par SuiviObsmerContext plus approprié
* Ajout gestion import des calendriers d'activité (Lancé en arrière-plan)
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-20 19:50:20 UTC (rev 139)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2009-12-21 10:22:48 UTC (rev 140)
@@ -140,31 +140,29 @@
* @throws SuiviObsmerException
*/
@Override
- public boolean canCreateContact(Company company, SampleRow row) throws SuiviObsmerException {
+ public boolean canCreateContact(Company company) throws SuiviObsmerException {
TopiaContext transaction = null;
- // 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;
+ boolean result = true;
try {
transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
- // Return the last contact for this boat, sampleRow and company
+ String contactClassName = Contact.class.getName();
+ // Return the last contact for this boat and company
List results = transaction.find(
- "FROM ContactImpl C1" +
+ "FROM " + contactClassName + " C1" +
" WHERE C1.user.company = :company" +
- " AND C1.boat = :boat AND C1.sampleRow = :row" +
+ " AND C1.boat = :boat" +
" AND C1.topiaCreateDate = " +
- " (SELECT MAX(C2.topiaCreateDate) FROM ContactImpl C2" +
+ " (SELECT MAX(C2.topiaCreateDate) FROM " + contactClassName + " C2" +
" WHERE C2.user.company = :company AND C2.boat = C1.boat)",
"company", company,
- "boat", this,
- "row", row);
+ "boat", this);
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);
+ result = validation/* && !state.equals(ContactState.BOAT_DEFINITIVE_REFUSED)*/;
}
transaction.closeContext();
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-20 19:50:20 UTC (rev 139)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java 2009-12-21 10:22:48 UTC (rev 140)
@@ -276,11 +276,12 @@
}
}
// Last contact
+ String contactClassName = Contact.class.getName();
List results = transaction.find(
- "FROM ContactImpl C1" +
+ "FROM " + contactClassName + " C1" +
" WHERE C1.user.company = :company AND C1.boat = :boat " +
" AND C1.topiaCreateDate = " +
- " (SELECT MAX(C2.topiaCreateDate) FROM ContactImpl C2" +
+ " (SELECT MAX(C2.topiaCreateDate) FROM " + contactClassName + " C2" +
" WHERE C2.user.company = :company AND C2.boat = C1.boat)",
"company", company,
"boat", boat);
@@ -508,9 +509,11 @@
// "Le navire avec l'identifiant '" + boatId + "' n'existe pas");
// }
+ String activityCalendarClassName = ActivityCalendar.class.getName();
List results = transaction.find(
- "FROM ActivityCalendarImpl A WHERE A.boat = :boat AND A.year = " +
- "(SELECT MAX(B.year) FROM ActivityCalendarImpl B WHERE B.boat = A.boat GROUP BY B.boat)",
+ "FROM " + activityCalendarClassName + " A WHERE A.boat = :boat AND A.year = " +
+ "(SELECT MAX(B.year) FROM " + activityCalendarClassName + " B " +
+ " WHERE B.boat = A.boat GROUP BY B.boat)",
"boat", boat);
result = (ActivityCalendar) results.get(0);
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java 2009-12-20 19:50:20 UTC (rev 139)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java 2009-12-21 10:22:48 UTC (rev 140)
@@ -183,7 +183,7 @@
serviceContact.saveContact(contact1, false);
/** EXEC METHOD **/
- boolean result = boat.canCreateContact(company, row);
+ boolean result = boat.canCreateContact(company);
// contact still open
Assert.assertFalse(result);
@@ -191,28 +191,28 @@
contact1.setValidationProgram(Boolean.TRUE);
serviceContact.saveContact(contact1, false);
- result = boat.canCreateContact(company, row);
+ result = boat.canCreateContact(company);
// contact have a definitive refused for this boat
- Assert.assertFalse(result);
+ Assert.assertTrue(result);
contact1.setState(ContactState.BOARDING_DONE.toString());
serviceContact.saveContact(contact1, false);
- result = boat.canCreateContact(company, row);
+ result = boat.canCreateContact(company);
// contact is finished
Assert.assertTrue(result);
contact1.setState(ContactState.BOAT_UNAVAILABLE.toString());
serviceContact.saveContact(contact1, false);
- result = boat.canCreateContact(company, row);
+ result = boat.canCreateContact(company);
// contact is finished
Assert.assertTrue(result);
contact1.setState(ContactState.BOAT_REFUSED.toString());
serviceContact.saveContact(contact1, false);
- result = boat.canCreateContact(company, row);
+ result = boat.canCreateContact(company);
// contact is finished
Assert.assertTrue(result);
}
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-20 19:50:20 UTC (rev 139)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2009-12-21 10:22:48 UTC (rev 140)
@@ -440,7 +440,7 @@
public boolean canCreateNewContactFromList() throws SuiviObsmerException {
if (!user.getAdmin() && isSampleRowExists()) {
- return boat.canCreateContact(user.getCompany(), getSampleRow());
+ return boat.canCreateContact(user.getCompany());
}
return false;
}
@@ -559,7 +559,8 @@
public boolean canCreateNewContactFromElligibleBoat() throws SuiviObsmerException {
if (!user.getAdmin() && !isElligibleBoatCompanyActiveFalse()) {
- return getBoatInfos().getBoat().canCreateContact(user.getCompany(), elligibleBoat.getSampleRow());
+ Boat boat = getBoatInfos().getBoat();
+ return boat.canCreateContact(user.getCompany());
}
return false;
}
Added: trunk/suiviobsmer-ui/src/main/webapp/img/logo_WAO.png
===================================================================
(Binary files differ)
Property changes on: trunk/suiviobsmer-ui/src/main/webapp/img/logo_WAO.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
Author: tchemit
Date: 2009-12-20 19:50:20 +0000 (Sun, 20 Dec 2009)
New Revision: 139
Modified:
trunk/pom.xml
Log:
use last stable version of ToPIA
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-20 19:03:08 UTC (rev 138)
+++ trunk/pom.xml 2009-12-20 19:50:20 UTC (rev 139)
@@ -239,7 +239,7 @@
<!-- libraries version -->
<nuitonutils.version>1.1.2-SNAPSHOT</nuitonutils.version>
- <topia.version>2.3.0-beta-2-SNAPSHOT</topia.version>
+ <topia.version>2.3.0-beta-2</topia.version>
<license.version>2.0.0</license.version>
<helper.version>1.1.0</helper.version>
<eugene.version>2.0.0-beta-2</eugene.version>
1
0
[Suiviobsmer-commits] r138 - in trunk: . suiviobsmer-business suiviobsmer-ui
by tchemit@users.labs.libre-entreprise.org 20 Dec '09
by tchemit@users.labs.libre-entreprise.org 20 Dec '09
20 Dec '09
Author: tchemit
Date: 2009-12-20 19:03:08 +0000 (Sun, 20 Dec 2009)
New Revision: 138
Modified:
trunk/
trunk/suiviobsmer-business/
trunk/suiviobsmer-ui/
Log:
svn ignore on idea files
Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
- target
+ target
*.iml
*.ipr
*.iws
Property changes on: trunk/suiviobsmer-business
___________________________________________________________________
Modified: svn:ignore
- target
+ target
*.iml
*.ipr
*.iws
Property changes on: trunk/suiviobsmer-ui
___________________________________________________________________
Modified: svn:ignore
- target
+ target
*.iml
*.ipr
*.iws
1
0
[Suiviobsmer-commits] r137 - in trunk: . suiviobsmer-business
by tchemit@users.labs.libre-entreprise.org 20 Dec '09
by tchemit@users.labs.libre-entreprise.org 20 Dec '09
20 Dec '09
Author: tchemit
Date: 2009-12-20 18:58:41 +0000 (Sun, 20 Dec 2009)
New Revision: 137
Modified:
trunk/pom.xml
trunk/suiviobsmer-business/pom.xml
Log:
use pluginManagements for eugene plugin + add as dependency topia-persistence + use last stable version of eugene
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-20 16:35:00 UTC (rev 136)
+++ trunk/pom.xml 2009-12-20 18:58:41 UTC (rev 137)
@@ -242,7 +242,7 @@
<topia.version>2.3.0-beta-2-SNAPSHOT</topia.version>
<license.version>2.0.0</license.version>
<helper.version>1.1.0</helper.version>
- <eugene.version>2.0.0-beta-2-SNAPSHOT</eugene.version>
+ <eugene.version>2.0.0-beta-2</eugene.version>
<tapestry.version>5.1.0.5</tapestry.version>
<!-- default license to use -->
@@ -470,6 +470,23 @@
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <version>${eugene.version}</version>
+ <configuration>
+ <inputs>zargo</inputs>
+ <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${topia.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
</plugins>
</pluginManagement>
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2009-12-20 16:35:00 UTC (rev 136)
+++ trunk/suiviobsmer-business/pom.xml 2009-12-20 18:58:41 UTC (rev 137)
@@ -93,13 +93,13 @@
<plugin>
<groupId>org.nuiton.eugene</groupId>
<artifactId>maven-eugene-plugin</artifactId>
- <version>${eugene.version}</version>
+ <!--<version>${eugene.version}</version>-->
<executions>
<execution>
<phase>generate-sources</phase>
<!-- By default, generation from ObjectModel -->
<configuration>
- <inputs>zargo</inputs>
+ <!--<inputs>zargo</inputs>-->
<!-- Corresponding to extracted package from zargo file -->
<fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>
<!-- DefaultPackage used for DAOHelper generation -->
1
0
[Suiviobsmer-commits] r136 - trunk/suiviobsmer-business
by tchemit@users.labs.libre-entreprise.org 20 Dec '09
by tchemit@users.labs.libre-entreprise.org 20 Dec '09
20 Dec '09
Author: tchemit
Date: 2009-12-20 16:35:00 +0000 (Sun, 20 Dec 2009)
New Revision: 136
Modified:
trunk/suiviobsmer-business/pom.xml
Log:
use last TopiaMetaTransformer template
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2009-12-19 18:13:48 UTC (rev 135)
+++ trunk/suiviobsmer-business/pom.xml 2009-12-20 16:35:00 UTC (rev 136)
@@ -105,7 +105,7 @@
<!-- DefaultPackage used for DAOHelper generation -->
<defaultPackage>fr.ifremer.suiviobsmer</defaultPackage>
<templates>
- org.nuiton.topia.generator.TopiaMetaGenerator,
+ org.nuiton.topia.generator.TopiaMetaTransformer,
org.nuiton.topia.generator.InterfaceTransformer,
org.nuiton.topia.generator.BeanTransformer
</templates>
1
0
[Suiviobsmer-commits] r135 - trunk/suiviobsmer-business
by tchemit@users.labs.libre-entreprise.org 19 Dec '09
by tchemit@users.labs.libre-entreprise.org 19 Dec '09
19 Dec '09
Author: tchemit
Date: 2009-12-19 18:13:48 +0000 (Sat, 19 Dec 2009)
New Revision: 135
Modified:
trunk/suiviobsmer-business/pom.xml
Log:
update eugene 2.0.0 configuration
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2009-12-18 12:34:07 UTC (rev 134)
+++ trunk/suiviobsmer-business/pom.xml 2009-12-19 18:13:48 UTC (rev 135)
@@ -99,9 +99,7 @@
<phase>generate-sources</phase>
<!-- By default, generation from ObjectModel -->
<configuration>
- <inputs>
- <input>zargo</input>
- </inputs>
+ <inputs>zargo</inputs>
<!-- Corresponding to extracted package from zargo file -->
<fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>
<!-- DefaultPackage used for DAOHelper generation -->
1
0
18 Dec '09
Author: fdesbois
Date: 2009-12-18 12:34:07 +0000 (Fri, 18 Dec 2009)
New Revision: 134
Modified:
trunk/changelog.txt
Log:
Update changelog
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2009-12-18 11:21:29 UTC (rev 133)
+++ trunk/changelog.txt 2009-12-18 12:34:07 UTC (rev 134)
@@ -1,24 +1,51 @@
0.0.1-alpha-2
-------------
-[10-12-2009] [fdesbois] EVO #1938 (Boats / BoatInfos)
+[18-12-2009] [fdesbois] EVO METIER #1957 (Boats / BoatInfos)
+ Ajout d'un attribut tideNbDays dans l'entité Contact (calculé automatiquement à chaque changement de date)
+
+[17-12-2009] [fdesbois] EVO TECHNIQUE
+ * Mise à jour de la configuration de génération pour ToPIA 2.3 et EUGene 2.0
+ * Ajout d'un index sur l'attribut "immatriculation" de l'entité Boat
+
+[16-12-2009] [tchemit] EVO TECHNIQUE
+ Migration version ChenilleKit vers 1.2.0
+[16-12-2009] [fdesbois] EVO IHM #1941 (Boats / BoatActivityCalendar)
+ Ajout page BoatActivityCalendar pour l'affichage d'un calendrier d'activité pour un navire
+[16-12-2009] [fdesbois] EVO TECHNIQUE
+ Utilisation d'ApplicationConfig de nuiton-utils pour gérer les fichiers de configuration
+
+[15-12-2009] [fdesbois] EVO IHM #1958 (Boats / BoatInfos)
+ Ajout du dernier contact du navire pour la société
+[15-12-2009] [fdesbois] EVO IHM (Contacts)
+ Ajout d'une liste déroulante pour choisir l'observateur en mode édition d'un contact
+[15-12-2009] [fdesbois] EVO IHM #1953 (Contacts)
+ Validations pour les changements d'état d'un contact + calcul des jours réels d'embarquements
+[15-12-2009] [fdesbois] EVO IHM #1941 (Boats / BoatActivityCalendar)
+ Ajout du champ d'import pour les calendriers d'activité + accès au fichier de log des imports
+
+[13-12-2009] [fdesbois] EVO METIER
+ * Renommage classe SuiviObsmerUtils par SuiviObsmerContext plus approprié
+ * Ajout gestion import des calendriers d'activité (Lancé en arrière-plan)
+
+[10-12-2009] [fdesbois] EVO IHM #1938 (Boats / BoatInfos)
* Ajout d'un message lorsque l'utilisateur vient de la page "SamplingPlan" pour sélection d'un navire
* Ajout d'un texte en bas des informations sur le navire sélectionnée pour informer l'utilisateur de la confidentialité de ses saisies
* Le code de l'armateur n'est plus visible
-[09-12-2009] [fdesbois] EVO #1951 (SamplingPlan)
+[09-12-2009] [fdesbois] EVO IHM #1951 (SamplingPlan)
Ajout d'un lien sur les programmes pour filtrer la période
-[08-12-2009] [fdesbois] ANO (BoatInfos)
+[08-12-2009] [fdesbois] ANO IHM (BoatInfos)
En mode admin le champ de sélection des sociétés ne charge pas les données
-[08-12-2009] [fdesbois] EVO
+[08-12-2009] [fdesbois] EVO TECHNIQUE
Ajout d'une config pour logger les erreurs/debugs dans un fichier
-[08-12-2009] [fdesbois] ANO (SamplingPlan)
+[08-12-2009] [fdesbois] ANO IHM (SamplingPlan)
Caractère de fin manquant sur l'affichage des zones de pêche
-[08-12-2009] [fdesbois] EVO (Contacts)
+[08-12-2009] [fdesbois] EVO IHM (Contacts)
Renommage colonne "Mammifères" en "Observations et captures accidentelles"
-[08-12-2009] [fdesbois] EVO (BoatInfos)
+[08-12-2009] [fdesbois] EVO IHM (BoatInfos)
Renomage texte "... embarquements dont X dans votre société..." par "... embarquements
dont X pour votre société..."
-[08-12-2009] [fdesbois] ANO (BoatInfos)
+[08-12-2009] [fdesbois] ANO IHM (BoatInfos)
Lien présent pour la création d'un contact lorsque la ligne du plan est barré
1
0
[Suiviobsmer-commits] r133 - in trunk/suiviobsmer-business: . src/main/java/fr/ifremer/suiviobsmer/entity src/main/xmi
by fdesbois@users.labs.libre-entreprise.org 18 Dec '09
by fdesbois@users.labs.libre-entreprise.org 18 Dec '09
18 Dec '09
Author: fdesbois
Date: 2009-12-18 11:21:29 +0000 (Fri, 18 Dec 2009)
New Revision: 133
Added:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java
Modified:
trunk/suiviobsmer-business/pom.xml
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
Log:
- Add tideNbDays attribute in Contact entity to save calculate value from difference between tide dates
- Refactor save realTideValues in SampleRowImpl
- Use a protected (calculTideNbDays) method in model to not generate ContactImpl and implemented it by hand
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2009-12-17 18:58:07 UTC (rev 132)
+++ trunk/suiviobsmer-business/pom.xml 2009-12-18 11:21:29 UTC (rev 133)
@@ -99,12 +99,13 @@
<phase>generate-sources</phase>
<!-- By default, generation from ObjectModel -->
<configuration>
- <inputFiles>
- <inputFile>zargo</inputFile>
- </inputFiles>
-<!-- <includes>**/*.objectmodel</includes>-->
+ <inputs>
+ <input>zargo</input>
+ </inputs>
+ <!-- Corresponding to extracted package from zargo file -->
+ <fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>
+ <!-- DefaultPackage used for DAOHelper generation -->
<defaultPackage>fr.ifremer.suiviobsmer</defaultPackage>
- <fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>
<templates>
org.nuiton.topia.generator.TopiaMetaGenerator,
org.nuiton.topia.generator.InterfaceTransformer,
@@ -112,8 +113,7 @@
</templates>
</configuration>
<goals>
- <goal>generate-model-files</goal>
- <goal>generate-from-models</goal>
+ <goal>smart-generate</goal>
</goals>
</execution>
</executions>
Added: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java 2009-12-18 11:21:29 UTC (rev 133)
@@ -0,0 +1,55 @@
+
+package fr.ifremer.suiviobsmer.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import org.nuiton.util.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ContactImpl
+ *
+ * Created: 18 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactImpl extends ContactAbstract implements Serializable, Contact {
+
+ private static final Logger log = LoggerFactory.getLogger(ContactImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setTideBeginDate(Date beginDate) {
+ super.setTideBeginDate(beginDate);
+ calculTideNbDays();
+ }
+
+ @Override
+ public void setTideEndDate(Date beginDate) {
+ super.setTideEndDate(beginDate);
+ calculTideNbDays();
+ }
+
+ /**
+ * Calculate the number of days between the tideBeginDate and the tideEndDate.
+ * Automatically called when tideBeginDate or tideEndDate are modified.
+ * The value of tideNbDays is always up to date.
+ */
+ @Override
+ protected void calculTideNbDays() {
+ Date beginDate = getTideBeginDate();
+ Date endDate = getTideEndDate();
+ if (beginDate != null && endDate != null) {
+ int nbDays = DateUtils.getDifferenceInDays(beginDate, endDate);
+ // nbDays + 1 to have the first day
+ setTideNbDays(nbDays + 1);
+ }
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
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-17 18:58:07 UTC (rev 132)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2009-12-18 11:21:29 UTC (rev 133)
@@ -178,7 +178,7 @@
if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
return;
}
- int nbDays = getDifferenceDays(contact);
+ int nbDays = contact.getTideNbDays(); //getDifferenceDays(contact);
SampleMonth month = getSampleMonth(contact.getTideBeginDate());
if (log.isDebugEnabled()) {
log.debug("Add tide time " + nbDays + " for " +
@@ -192,7 +192,7 @@
if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
return;
}
- int nbDays = getDifferenceDays(contact);
+ int nbDays = contact.getTideNbDays(); //getDifferenceDays(contact);
SampleMonth month = getSampleMonth(contact.getTideBeginDate());
if (log.isDebugEnabled()) {
log.debug("Remove tide time " + nbDays + " for " +
@@ -201,11 +201,11 @@
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;
- }
+// 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)
1
0
[Suiviobsmer-commits] r132 - in trunk/suiviobsmer-ui/src/main: java/fr/ifremer/suiviobsmer/ui/pages webapp
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:58:07 +0000 (Thu, 17 Dec 2009)
New Revision: 132
Modified:
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java
trunk/suiviobsmer-ui/src/main/webapp/SampleRowForm.tml
Log:
Refactor form in proceed... Tapestry problem on refreshing zone with sampleMonths table
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-17 18:57:17 UTC (rev 131)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java 2009-12-17 18:58:07 UTC (rev 132)
@@ -21,10 +21,7 @@
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;
@@ -44,16 +41,21 @@
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.Block;
+import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventContext;
+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.corelib.components.Zone;
+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.nuiton.util.DateUtils;
+import org.nuiton.util.PeriodDates;
import org.slf4j.Logger;
/**
@@ -109,26 +111,32 @@
// load models for select
professionSelectModel = null;
getProfessionSelectModel();
- programSelectModel = null;
- getProgramSelectModel();
+// programSelectModel = null;
+// getProgramSelectModel();
fishingZoneSelectModel = null;
getFishingZoneSelectModel();
// load main sampleRow (use of sampleRowId in url)
sampleRow = null;
getSampleRow();
+
+ if (!isCreateMode()) {
+ programId = getSampleRow().getProgram().getTopiaId();
+ }
+
+
// initialize companyId if exist for companySelect
- Company company = getSampleRow().getCompany();
- if (company != null) {
- companyId = company.getTopiaId();
- }
- immatriculations = getSampleRow().getMainElligibleBoatsAsString();
+// 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();
+// fishingZones = null;
+// getFishingZones();
+// period = null;
+// getPeriod();
+// sampleMonths = null;
+// getSampleMonths();
}
/*************************** PROFESSION ***********************************/
@@ -136,11 +144,17 @@
@Persist
private GenericSelectModel<Profession> professionSelectModel;
+ @Inject
+ private BeanModelSource beanModelSource;
+
+ @Inject
+ private ComponentResources resources;
+
@Property
private String professionId;
- @InjectComponent
- private Zone professionZone;
+// @InjectComponent
+// private Zone professionZone;
public GenericSelectModel<Profession> getProfessionSelectModel() throws SuiviObsmerException {
if (professionSelectModel == null) {
@@ -154,25 +168,36 @@
return professionSelectModel;
}
- void onSelectedFromSearchProfession() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("professionId : " + professionId);
- }
- Profession professionSelected = getProfessionSelectModel().findObject(professionId);
- sampleRow.setProfession(professionSelected);
+ public BeanModel<Profession> getProfessionModel() {
+ return beanModelSource.createDisplayModel(Profession.class, resources.getMessages());
}
- void onSelectedFromAddNewProfession() {
- if (log.isDebugEnabled()) {
- log.debug("Add new profession");
+// void onSelectedFromSearchProfession() throws SuiviObsmerException {
+// if (log.isDebugEnabled()) {
+// log.debug("professionId : " + professionId);
+// }
+// Profession professionSelected = getProfessionSelectModel().findObject(professionId);
+// sampleRow.setProfession(professionSelected);
+// }
+
+ void onSelectedFromAddNewProfession() throws SuiviObsmerException {
+ Profession profession = new ProfessionImpl();
+ if (!StringUtils.isEmpty(professionId)) {
+ profession = getProfessionSelectModel().findObject(professionId);
+ if (log.isDebugEnabled()) {
+ log.debug("Add new profession from : " + profession);
+ }
+ // TODO add this method in Business to copy attributes from the profession in
+ // argument to a new one
+ //serviceSampling.getNewProfession(profession);
}
- sampleRow.setProfession(new ProfessionImpl());
- professionId = null;
+ getSampleRow().setProfession(profession);
+ edited = true;
}
- Block onSuccessFromProfessionForm() throws SuiviObsmerException {
- return professionZone.getBody();
- }
+// Block onSuccessFromProfessionForm() throws SuiviObsmerException {
+// return professionZone.getBody();
+// }
/*************************** FISHING ZONE *********************************/
@@ -182,13 +207,13 @@
@Property
private String fishingZoneId;
- @InjectComponent
- private Zone fishingZoneZone;
+// @InjectComponent
+// private Zone fishingZoneZone;
@Property
private FishingZone fishingZone;
- @Persist
+ //@Persist
private List<FishingZone> fishingZones;
@Property
@@ -199,16 +224,16 @@
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getFishingZones]");
}
- List<FishingZone> fishingZones = serviceReferential.getFishingZones();
- fishingZoneSelectModel = new GenericSelectModel<FishingZone>(fishingZones, FishingZone.class,
+ List<FishingZone> zones = serviceReferential.getFishingZones();
+ fishingZoneSelectModel = new GenericSelectModel<FishingZone>(zones, FishingZone.class,
"code", "topiaId", propertyAccess);
}
return fishingZoneSelectModel;
}
- public List<FishingZone> getFishingZones() {
+ public List<FishingZone> getFishingZones() throws SuiviObsmerException {
if (fishingZones == null) {
- fishingZones = sampleRow.getFishingZone();
+ fishingZones = getSampleRow().getFishingZone();
}
return fishingZones;
}
@@ -224,7 +249,7 @@
edited = true;
}
- void onSelectedFromRemoveFishingZone(int index) {
+ void onSelectedFromRemoveFishingZone(int index) throws SuiviObsmerException {
if (log.isDebugEnabled()) {
log.debug("Remove fishingZone at position : " + index);
}
@@ -232,12 +257,12 @@
edited = true;
}
- Block onSuccessFromFishingZoneForm() {
- if (!edited) {
- sampleRow.setFishingZone(fishingZones);
- }
- return fishingZoneZone.getBody();
- }
+// Block onSuccessFromFishingZoneForm() {
+// if (!edited) {
+// sampleRow.setFishingZone(fishingZones);
+// }
+// return fishingZoneZone.getBody();
+// }
/*************************** PROGRAM & MONTHS *****************************/
@@ -250,23 +275,32 @@
@Property
private String programId;
- @InjectComponent
- private Zone periodZone;
+// @InjectComponent
+// private Zone periodZone;
+ /** Program to saved **/
private Program program;
@Property
private Date month;
- @Persist
+ //@Persist
private PeriodDates period;
- @Persist
+ //@Persist
private List<SampleMonth> sampleMonths;
@Property
private SampleMonth sampleMonth;
+ @InjectComponent
+ private Field programPeriodBegin;
+
+ @InjectComponent
+ private Field programPeriodEnd;
+
+ private boolean programChanged;
+
public GenericSelectModel<Program> getProgramSelectModel() throws SuiviObsmerException {
if (programSelectModel == null) {
if (log.isInfoEnabled()) {
@@ -280,17 +314,23 @@
}
public List<Date> getMonths() throws SuiviObsmerException {
- return period.getMonths();
+ return getPeriod().getMonths();
}
+ public Program getProgram() throws SuiviObsmerException {
+ return getSampleRow().getProgram();
+ }
+
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();
- }
+ Date begin = getProgram().getPeriodBegin();
+ Date end = getProgram().getPeriodEnd();
+ period = new PeriodDates(begin, end);
+// if (begin != null && end != null) {
+// period = new PeriodDates(begin, end);
+// } else {
+// period = new PeriodDates();
+// }
}
return period;
}
@@ -313,60 +353,97 @@
return new SimpleDateFormat("MM/yyyy");
}
+ /**
+ * Search a program from the list.
+ * The program will be set from the one selected. If no selection, a new one will be set.
+ * @throws SuiviObsmerException
+ */
void onSelectedFromSearchProgram() throws SuiviObsmerException {
- // Reset programName
- programName = null;
+ program = new ProgramImpl();
+ if (!StringUtils.isEmpty(programId)) {
+ program = getProgramSelectModel().findObject(programId);
+ }
+ // Period will be reinitialized from program params
+ //getSampleRow().setProgram(program);
+
+
+ // SampleMonths ??
+
+ //programName = null;
// Reset period to get the one from selected program
- period = null;
+ //period = null;
// Reset sampleMonths for new period
- sampleMonths = null;
- edited = true;
+ //sampleMonths = null;
+ //saveProgramAndSampleMonths();
+ programChanged = true;
}
+ /**
+ * Refresh months from program period.
+ * If the programName is not empty, a new program will be set.
+ * The period dates will be saved in program (validation will be done in onSuccess).
+ * @throws SuiviObsmerException
+ */
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
+ if (!StringUtils.isEmpty(programName)) {
+ // New program
+ program = new ProgramImpl();
+ program.setName(programName);
+ //getSampleRow().setProgram(program);
+ //programId = null;
+ } else {
program = getSampleRow().getProgram();
- program.setPeriodBegin(period.getFromDate());
- program.setPeriodEnd(period.getThruDate());
}
- return periodZone.getBody();
+ program.setPeriodBegin(period.getFromDate());
+ program.setPeriodEnd(period.getThruDate());
+
+ // SampleMonths ??
+
+ // Reset sampleMonths cause of period modification
+ //sampleMonths = null;
+ //saveProgramAndSampleMonths();
+ programChanged = true;
}
+// private void saveProgramAndSampleMonths() throws SuiviObsmerException {
+// // New program
+// if (!getSampleRow().hasSampleMonthRealTideTime()) {
+// // 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;
@@ -374,17 +451,20 @@
@Persist
private SampleRow sampleRow;
- @Property
- private String updateComment;
+ @InjectComponent
+ private Form sampleRowForm;
- @Property
- private String immatriculations;
+// @Property
+// private String updateComment;
+//
+// @Property
+// private String immatriculations;
+//
+// @Property
+// private String companyId;
+//
+// private GenericSelectModel<Company> companySelectModel;
- @Property
- private String companyId;
-
- private GenericSelectModel<Company> companySelectModel;
-
public SampleRow getSampleRow() throws SuiviObsmerException {
if (sampleRow == null) {
if (!StringUtils.isEmpty(sampleRowId)) {
@@ -395,21 +475,21 @@
} 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 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());
@@ -421,21 +501,76 @@
@Log
Object onSuccessFromSampleRowForm() throws SuiviObsmerException {
- if (!edited) {
+ sampleRowForm.clearErrors();
+ if (programChanged) {
+ String programTopiaId = program.getTopiaId();
+ // Reinitialize programId for select if it's not the current one
+ if (programTopiaId != null && !programTopiaId.equals(programId)) {
+ programId = null;
+ // Reinitialize programName, period and sampleMonths if it's the one selected
+ } else {
+ programName = null;
+ period = null;
+ sampleMonths = null;
+ }
- Company company = getCompanySelectModel().findObject(companyId);
- getSampleRow().setCompany(company);
+ Date periodBegin = program.getPeriodBegin();
+ Date periodEnd = program.getPeriodEnd();
- List<Boat> boats = serviceBoat.getBoats(immatriculations);
+ // Validation for period dates
+ if (periodBegin == null) {
+ sampleRowForm.recordError(programPeriodBegin,
+ "Vous ne pouvez pas rafraîchir les mois avec une date de début de programme vide");
+ }
+ if (periodEnd == null) {
+ sampleRowForm.recordError(programPeriodEnd,
+ "Vous ne pouvez pas rafraîchir les mois avec une date de fin de programme vide");
+ }
- serviceSampling.createUpdateSampleRow(sampleRow, boats);
+ if (periodBegin != null && periodEnd != null) {
- return SamplingPlan.class;
+ int size = getSampleMonths().size();
- } else {
- sampleRow = null;
+ SampleMonth firstMonth = getSampleMonths().get(0);
+ SampleMonth lastMonth = getSampleMonths().get(size-1);
+
+ Date firstDate = DateUtils.createDate(
+ 1, firstMonth.getPeriodMonth(), firstMonth.getPeriodYear());
+
+ if (periodBegin.after(firstDate) && firstMonth.getRealTidesValue() != 0) {
+ sampleRowForm.recordError(programPeriodBegin,
+ "Vous ne pouvez pas réduire la période du programme. " +
+ "Il existe des enregistrements de marées réels.");
+ }
+ }
+
+ if (!sampleRowForm.getHasErrors()) {
+ // Save program
+ getSampleRow().setProgram(program);
+ // Save sampleMonths
+ //getSampleRow().setSampleMonth(sampleMonths);
+ }
+ } else if (!edited) {
+ //sampleRow.setFishingZone(fishingZones); USEFUL ?
+
+ // Save period dates
+ //program = getSampleRow().getProgram();
+ //program.setPeriodBegin(period.getFromDate());
+ //program.setPeriodEnd(period.getThruDate());
+ return null;
+// Company company = getCompanySelectModel().findObject(companyId);
+// getSampleRow().setCompany(company);
+//
+// List<Boat> boats = serviceBoat.getBoats(immatriculations);
+//
+// serviceSampling.createUpdateSampleRow(sampleRow, boats);
+//
+// return SamplingPlan.class;
+ } else {
+ // Reinitialize professionId for select to avoid selection from existing Profession
+ professionId = null;
}
- return null;
+ return sampleRowForm;
}
Modified: trunk/suiviobsmer-ui/src/main/webapp/SampleRowForm.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/SampleRowForm.tml 2009-12-17 18:57:17 UTC (rev 131)
+++ trunk/suiviobsmer-ui/src/main/webapp/SampleRowForm.tml 2009-12-17 18:58:07 UTC (rev 132)
@@ -1,6 +1,127 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<t:layout t:pageTitle="Modification d'une ligne du plan" t:contentId="so-samplerow-form"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+ <t:zone t:id="globalZone"><!--t:update="show"-->
+ <form t:type="form" t:id="sampleRowForm" t:zone="globalZone">
+
+ <p> LIGNE DU PLAN : ${sampleRow.code} </p>
+ <t:errors />
+
+ <!-- PROFESSION -->
+ <fieldset>
+ <legend>Métier</legend>
+ <t:if t:test="sampleRow.hasSampleMonthRealTideTime()">
+ <!-- DISPLAY -->
+ <t:beandisplay t:id="professionDisplay" t:model="professionModel" t:object="sampleRow.profession"
+ t:include="codeDCF5, meshSize, size, other, libelle, species" />
+ <p:else>
+ <!-- EDITION -->
+ <div class="select">
+ <t:label t:for="professionSelect" /> :
+ <input t:type="select" t:id="professionSelect" t:model="professionSelectModel"
+ t:value="professionId" />
+ <input t:type="submit" class="ico add"
+ t:id="addNewProfession" value="Ajouter un nouveau métier" />
+ </div>
+ <div class="t-beaneditor">
+ <t:beaneditor t:id="professionEditor" t:object="sampleRow.profession"
+ t:include="codeDCF5, meshSize, size, other, libelle, species" />
+ </div>
+ </p:else>
+ </t:if>
+ </fieldset>
+
+ <!-- FISHING ZONES -->
+ <fieldset>
+ <legend>Zone(s) de pêche</legend>
+ <t:if t:test="sampleRow.hasSampleMonthRealTideTime()">
+ <!-- DISPLAY -->
+ <ul>
+ <li t:type="loop" t:source="fishingZones" t:volatile="true" t:value="fishingZone">
+ ${fishingZone.code}
+ </li>
+ </ul>
+ <p:else>
+ <!-- EDITION -->
+ <div class="select">
+ <t:label t:for="fishingZoneSelect" /> :
+ <input t:type="select" t:id="fishingZoneSelect" t:model="fishingZoneSelectModel"
+ t:value="fishingZoneId" />
+ <input t:type="submit" class="ico add" t:id="addFishingZone" value="Add"
+ title="Ajouter la zone sélectionnée à la ligne d'échantillonnage" />
+ </div>
+ <div class="clearfix fishingzone-row" t:type="loop" volatile="true" t:source="fishingZones"
+ t:value="fishingZone" t:index="indexFishingZone">
+ <div class="fleft width50">
+ <input t:type="submitContext" class="ico remove" t:context="indexFishingZone"
+ t:id="removeFishingZone" value="Remove" title="Retirer cette zone de la liste liée à la ligne d'échantillonnage"/>
+ </div>
+ <div class="fleft">
+ ${fishingZone.code}
+ </div>
+ </div>
+ <div class="select">
+ <t:label t:for="fishingZonesInfos" /> :
+ <input t:type="textfield" class="width300" t:id="fishingZonesInfos" value="sampleRow.fishingZonesInfos" />
+ </div>
+ </p:else>
+ </t:if>
+ </fieldset>
+
+ <!-- PROGRAM and SAMPLE MONTHS -->
+ <fieldset>
+ <legend>Programme et données des marées par mois</legend>
+ <div class="select">
+ <t:if t:test="sampleRow.hasSampleMonthRealTideTime()">
+ <!-- DISPLAY PROGRAM -->
+ Programme : ${sampleRow.program.name}
+ <p:else>
+ <!-- EDITION PROGRAM -->
+ <div class="select">
+ <t:label t:for="program"/> :
+ <input t:type="select" t:id="program" t:model="programSelectModel" value="programId" />
+ <input t:type="submit" class="ico search" t:id="searchProgram" value="Search"
+ title="Afficher les détails du programme"/>
+ ou <input t:type="textfield" t:id="programName" value="programName" />
+ </div>
+ </p:else>
+ </t:if>
+ </div>
+ <!-- EDITION PROGRAM PERIOD -->
+ <div class="select">
+ <t:label t:for="programPeriodBegin"/> :
+ du <input t:type="datefield" t:id="programPeriodBegin" value="period.fromDate" />
+ jusqu'au <input t:type="datefield" t:id="programPeriodEnd" value="period.thruDate" />
+ <input t:type="submit" class="ico refresh" t:id="refreshMonths" value="Refresh" title="Rafraîchir les mois"/>
+ </div>
+ <!-- EDITION SAMPLE MONTHS -->
+ <div class="acenter">
+ <table id="so-samplerow-form-months">
+ <tr class="firstRow">
+ <td t:type="loop" t:source="months" t:value="month" volatile="true">
+ <t:output value="month" format="dateFormat" />
+ </td>
+ </tr>
+ <tr>
+ <td t:type="loop" class="acenter" volatile="true" t:source="sampleMonths" t:value="sampleMonth">
+ <input t:type="textfield" class="width40" t:id="sampleMonth" value="sampleMonth.expectedTidesValue" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ </fieldset>
+
+ <div class="actions">
+ <input t:type="submit" t:id="saveData" class="ico save" value="Save" />
+ <input t:type="submit" t:id="cancelSave" class="ico undo" value="Undo" />
+ </div>
+ </form>
+ </t:zone>
+
+
+<!--
+
<t:if t:test="createMode">
<div t:type="zone" t:id="professionZone" class="formPart" id="so-samplerow-form-profession">
<form t:type="form" t:id="professionForm" t:zone="so-samplerow-form-profession">
@@ -25,11 +146,11 @@
</form>
</div>
<p:else>
- <!--fieldset class="user-form">
+ fieldset class="user-form">
<legend>Métier</legend>
<div t:type="beandisplay" t:object="sampleRow.profession"
t:include="codeDCF5, meshSize, size, other, libelle, species" />
- </fieldset-->
+ </fieldset
</p:else>
</t:if>
<t:if t:test="createMode">
@@ -62,7 +183,7 @@
</fieldset>
</form>
</div>
- <!-- TODO else show fishingZone + fishingZoneInfos -->
+ TODO else show fishingZone + fishingZoneInfos
</t:if>
<div t:type="zone" t:id="periodZone" class="formPart" id="so-samplerow-form-period">
<form t:type="form" t:id="periodForm" t:zone="so-samplerow-form-period">
@@ -105,7 +226,7 @@
</fieldset>
</form>
</div>
- <!---div t:type="zone" t:id="sampleRowZone" class="formPart" id="so-samplerow-form-other" t:update="show"-->
+ -div t:type="zone" t:id="sampleRowZone" class="formPart" id="so-samplerow-form-other" t:update="show"
<form t:type="form" t:id="sampleRowForm">
<fieldset class="user-form">
<legend>Autres données de la ligne d'échantillonnage</legend>
@@ -132,8 +253,8 @@
</div>
</fieldset>
</form>
- <!--/div-->
- <!--t:zone t:id="sampleRowZone">
+ /div
+ t:zone t:id="sampleRowZone">
<form t:type="form" t:id="sampleRowForm" t:zone="sampleRowZone">
<p>
1
0