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)