[Suiviobsmer-commits] r1203 - in trunk/wao-business/src: main/java/fr/ifremer/wao/service main/resources/i18n test/java/fr/ifremer/wao/service
Author: sletellier Date: 2011-04-14 10:14:48 +0000 (Thu, 14 Apr 2011) New Revision: 1203 Log: - Fill description and location on ical Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2011-04-14 09:32:09 UTC (rev 1202) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2011-04-14 10:14:48 UTC (rev 1203) @@ -99,6 +99,8 @@ import net.fortuna.ical4j.model.component.VTimeZone; import net.fortuna.ical4j.model.parameter.Value; import net.fortuna.ical4j.model.property.CalScale; +import net.fortuna.ical4j.model.property.Description; +import net.fortuna.ical4j.model.property.Location; import net.fortuna.ical4j.model.property.ProdId; import net.fortuna.ical4j.model.property.Uid; import net.fortuna.ical4j.model.property.Version; @@ -117,6 +119,7 @@ import org.nuiton.util.TimeLog; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderModelBuilder; +import org.omg.CORBA.NO_MEMORY; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -127,6 +130,7 @@ import java.io.InputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import java.net.URISyntaxException; import java.text.DateFormat; import java.text.NumberFormat; import java.text.ParseException; @@ -1549,11 +1553,27 @@ } for (SampleRow sampleRow : samplingPlan) { net.fortuna.ical4j.model.Date day = new net.fortuna.ical4j.model.Date(sampleRow.getDay()); - String eventTitle = "Observation ObsDeb"; + String eventTitle = WaoUtils.translate(n_("wao.export.ical.title")); String eventPlace = sampleRow.getObservationUnit().getDescription(); // liste des noms des observateurs (sauf le connected user) dans Property.Attendee - String eventDescription = "avec " + sampleRow.getObservers(); + Collection<WaoUser> observers = sampleRow.getObservers(); + observers.remove(connectedUser.getUser()); + String eventDescription = ""; + + if (!observers.isEmpty()) { + String observersNames = StringUtil.join(observers, new StringUtil.ToString<WaoUser>() { + + @Override + public String toString(WaoUser waoUser) { + return waoUser.getFullName(); + } + + }, ", ", true); + + eventDescription = WaoUtils.translate(n_("wao.export.ical.desc"), observersNames); + } + // au pire, tout mettre dans la description if (log.isDebugEnabled()) { @@ -1567,8 +1587,13 @@ event.getProperties().add(tz.getTimeZoneId()); // initialise as an all-day event.. - event.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE); + event.getProperty(Property.DTSTART).getParameters().add(Value.DATE); + if (!StringUtils.isEmpty(eventDescription)) { + event.getProperties().add(new Description(eventDescription)); + } + event.getProperties().add(new Location(eventPlace)); + // Generate a UID for the event.. Uid uid = new Uid(sampleRow.getTopiaId()); event.getProperties().add(uid); Modified: trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties 2011-04-14 09:32:09 UTC (rev 1202) +++ trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties 2011-04-14 10:14:48 UTC (rev 1203) @@ -253,3 +253,5 @@ wao.import.contact.failure.wrongTerrestrialLocation=There is no location of type '%s' with code '%s' wao.import.failure.wrongUser=There is no user with login '%s' wao.validation.sampleRow.conflictOnObserver=Observer %s cannot be associated to the line %s because he has to observer, on the same day, for row %s +wao.export.ical.title=ObsDeb Observation +wao.export.ical.desc=wtih %s \ No newline at end of file Modified: trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties 2011-04-14 09:32:09 UTC (rev 1202) +++ trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties 2011-04-14 10:14:48 UTC (rev 1203) @@ -253,3 +253,5 @@ wao.import.contact.failure.wrongTerrestrialLocation=Il n'y a pas de lieu de type '%s' ayant pour code '%s' wao.import.failure.wrongUser=Il n'y a pas d'utilisateur ayant pour identifiant '%s' wao.validation.sampleRow.conflictOnObserver=L'observateur %s ne peut \u00EAtre associ\u00E9 \u00E0 la ligne %s car il doit observer, le m\u00EAme jour, pour la ligne %s +wao.export.ical.title=Observation ObsDeb +wao.export.ical.desc=avec %s \ No newline at end of file Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java 2011-04-14 09:32:09 UTC (rev 1202) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java 2011-04-14 10:14:48 UTC (rev 1203) @@ -40,18 +40,9 @@ import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.entity.WaoUserImpl; import fr.ifremer.wao.io.ImportResults; -import net.fortuna.ical4j.model.Calendar; -import net.fortuna.ical4j.model.Date; -import net.fortuna.ical4j.model.component.VEvent; -import net.fortuna.ical4j.model.parameter.Cn; -import net.fortuna.ical4j.model.parameter.Role; -import net.fortuna.ical4j.model.property.CalScale; -import net.fortuna.ical4j.model.property.ProdId; -import net.fortuna.ical4j.model.property.Version; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.nuiton.util.DateUtil; import org.nuiton.util.PeriodDates; @@ -60,7 +51,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.URI; import java.util.List; /** @@ -401,11 +391,13 @@ String result = IOUtils.toString(in); if (log.isDebugEnabled()) { - log.debug("exported iCal for observer is " + result); + log.info("exported iCal for observer is " + result); } Assert.assertEquals(1, StringUtils.countMatches(result, "BEGIN:VEVENT")); Assert.assertTrue(result.contains("DTSTART;VALUE=DATE:20100213")); - Assert.assertTrue(result.contains("SUMMARY:GA-UO007 DESHAIES_POINTE NOIRE")); + Assert.assertTrue(result.contains("TZID:Europe/Paris")); + Assert.assertTrue(result.contains("LOCATION:GA-UO007 DESHAIES_POINTE NOIRE")); + Assert.assertTrue(result.contains("SUMMARY:Observation ObsDeb")); } }
participants (1)
-
sletellier@users.labs.libre-entreprise.org