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
June 2014
- 6 participants
- 139 discussions
r2079 - in branches/wao-4.0-obsvente: wao-persistence/src/main/java/fr/ifremer/wao/entity wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/main/resources/i18n wao-web/src/main/java/fr/ifremer/wao/web/action wao-web/src/main/resources/i18n wao-web/src/main/webapp/WEB-INF/content
by bleny@users.forge.codelutin.com 20 Jun '14
by bleny@users.forge.codelutin.com 20 Jun '14
20 Jun '14
Author: bleny
Date: 2014-06-20 21:20:31 +0200 (Fri, 20 Jun 2014)
New Revision: 2079
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2079
Log:
refs #4488 contacts for obsvente, finished ?
Added:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalAcceptationException.java
Modified:
branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationImpl.java
branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocations.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_en_GB.properties
branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_en_GB.properties
branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp
Modified: branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationImpl.java
===================================================================
--- branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationImpl.java 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationImpl.java 2014-06-20 19:20:31 UTC (rev 2079)
@@ -23,6 +23,8 @@
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.nuiton.i18n.I18n;
+import java.util.Locale;
+
public class TerrestrialLocationImpl extends TerrestrialLocationAbstract {
@Override
@@ -78,7 +80,7 @@
} else { // it's a port or an auction
description.append(getName()).append(" (")
.append(getCode()).append(", ")
- .append(getLocationType()).append(", ");
+ .append(I18n.l(Locale.FRANCE, getLocationType().getI18nKey())).append(", ");
// add the port name only if it's different of the name
// because most of the time it's redundant
if (getPortName() != null && ! getPortName().equals(getName())) {
Modified: branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocations.java
===================================================================
--- branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocations.java 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocations.java 2014-06-20 19:20:31 UTC (rev 2079)
@@ -22,7 +22,10 @@
*/
import com.google.common.base.Function;
+import com.google.common.collect.Ordering;
+import java.util.Comparator;
+
public class TerrestrialLocations {
public static Function<TerrestrialLocation, String> getDistrictCode() {
@@ -37,6 +40,14 @@
return new GetRegionIfremerCode();
}
+ public static Comparator<TerrestrialLocation> nameComparator() {
+ return Ordering.natural().onResultOf(getName());
+ }
+
+ public static Function<TerrestrialLocation, String> getName() {
+ return new GetName();
+ }
+
protected static class GetDistrictCode implements Function<TerrestrialLocation, String> {
@Override
@@ -60,4 +71,12 @@
return input.getRegionIfremerCode();
}
}
+
+ protected static class GetName implements Function<TerrestrialLocation, String> {
+
+ @Override
+ public String apply(TerrestrialLocation input) {
+ return input.getName();
+ }
+ }
}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-06-20 19:20:31 UTC (rev 2079)
@@ -423,6 +423,9 @@
} catch (MissingContactTerrestrialLocationException e) {
String message = l(l, "wao.import.contact.failure.missingTerrestrialLocation", lineNumber);
throw new ImportErrorException(message);
+ } catch (IllegalAcceptationException e) {
+ String message = l(l, "wao.import.contact.failure.illegalAcceptation", lineNumber);
+ throw new ImportErrorException(message);
}
save0(updateContactCommand);
@@ -472,7 +475,7 @@
MissingContactDataInputDateException,
ContactRestitutionDateBeforeDataInputDateException,
MissingContactDataReliabilityException,
- MissingContactCommentAdminException, MissingContactTerrestrialLocationException {
+ MissingContactCommentAdminException, MissingContactTerrestrialLocationException, IllegalAcceptationException {
if (needUpdate) {
Preconditions.checkState(!updateContactCommand.isCreation());
@@ -661,16 +664,16 @@
//---
if (ContactState.OBSERVATION_DONE == contactState) {
- if (contact.getObservedDataControl() == null) {
+ if (contact.getObsProgram().isObsMer() && contact.getObservedDataControl() == null) {
throw new MissingContactObservedDataControlException(contact);
- } else if (contact.getObservedDataControl().equals(ObservedDataControl.CORRECTION_ASKED)) {
+ } else if (ObservedDataControl.CORRECTION_ASKED.equals(contact.getObservedDataControl())) {
throw new ContactWithObservedDataControlToCorrectionAskedException(contact);
}
}
// Pour valider un contact société, il faut que le contact aie une date de transmission
Date restitution = contact.getRestitution();
- if (ObservedDataControl.ACCEPTED == contact.getObservedDataControl() && restitution == null) {
+ if (ObservedDataControl.ACCEPTED.equals(contact.getObservedDataControl()) && restitution == null) {
throw new MissingContactRestitutionException(contact);
}
if (dataInputDate == null && restitution != null) {
@@ -687,6 +690,11 @@
throw new MissingContactCommentAdminException(contact);
}
+ if (contact.getValidationProgram() != null && contact.getValidationCompany() == null) {
+
+ throw new IllegalAcceptationException(contact);
+ }
+
if (BooleanUtils.isTrue(contact.getValidationProgram())) {
//---
Added: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalAcceptationException.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalAcceptationException.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalAcceptationException.java 2014-06-20 19:20:31 UTC (rev 2079)
@@ -0,0 +1,10 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+public class IllegalAcceptationException extends WaoContactValidationException {
+
+ public IllegalAcceptationException(Contact contact) {
+ super(contact);
+ }
+}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_en_GB.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-06-20 19:20:31 UTC (rev 2079)
@@ -40,6 +40,7 @@
wao.import.contact.failure.dataInputDateBeforeToday=La date de saisie des données doit être antérieur à la date du jour
wao.import.contact.failure.districtMissing=You need to precise the boat district
wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=Main observer can not be also a secondary observer
+wao.import.contact.failure.illegalAcceptation=
wao.import.contact.failure.invalidObservationBeginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
wao.import.contact.failure.locationTypeMissing=The type of the location must be filled
wao.import.contact.failure.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s
Modified: branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-06-20 19:20:31 UTC (rev 2079)
@@ -37,6 +37,7 @@
wao.import.contact.failure.dataInputDateBeforeObservationEndDate=La date de saisie des données doit être postérieure à la date de fin d'observation
wao.import.contact.failure.districtMissing=Il faut préciser le code d'un quartier maritime
wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires
+wao.import.contact.failure.illegalAcceptation=
wao.import.contact.failure.invalidObservationBeginDate=Ligne %s \: La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
wao.import.contact.failure.locationTypeMissing=Le type du lieu doit être renseigné
wao.import.contact.failure.mismatchCompanyForObserver=Ligne %s \: L'observateur %s n'est pas membre de la société %s
Modified: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java 2014-06-20 19:20:31 UTC (rev 2079)
@@ -32,6 +32,7 @@
import fr.ifremer.wao.entity.ObservedDataControl;
import fr.ifremer.wao.entity.SamplingStrategy;
import fr.ifremer.wao.entity.TerrestrialLocation;
+import fr.ifremer.wao.entity.TerrestrialLocations;
import fr.ifremer.wao.entity.WaoUser;
import fr.ifremer.wao.entity.WaoUsers;
import fr.ifremer.wao.services.AuthenticatedWaoUser;
@@ -44,6 +45,7 @@
import fr.ifremer.wao.services.service.ContactWithObservedDataControlToCorrectionAskedException;
import fr.ifremer.wao.services.service.ContactsService;
import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException;
+import fr.ifremer.wao.services.service.IllegalAcceptationException;
import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException;
import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException;
import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException;
@@ -75,6 +77,7 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import java.util.TreeSet;
/**
* Created on 4/6/14.
@@ -237,7 +240,9 @@
terrestrialLocations = new LinkedHashMap<>();
List<TerrestrialLocation> terrestrialLocationInDistricts = referentialService.getTerrestrialLocationInDistricts(updateContactCommand.getContact().getSampleRow().getTerrestrialLocations());
- for (TerrestrialLocation terrestrialLocation : terrestrialLocationInDistricts) {
+ Set<TerrestrialLocation> sortedTerrestrialLocations = new TreeSet<>(TerrestrialLocations.nameComparator());
+ sortedTerrestrialLocations.addAll(terrestrialLocationInDistricts);
+ for (TerrestrialLocation terrestrialLocation : sortedTerrestrialLocations) {
terrestrialLocations.put(terrestrialLocation.getTopiaId(), terrestrialLocation.getDescription());
}
}
@@ -334,6 +339,8 @@
} catch (MissingContactTerrestrialLocationException e) {
throw new UnsupportedOperationException();
+ } catch (IllegalAcceptationException e) {
+ throw new IllegalStateException("should never occur", e);
}
}
Modified: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java 2014-06-20 19:20:31 UTC (rev 2079)
@@ -37,6 +37,7 @@
import fr.ifremer.wao.services.service.ContactWithObservedDataControlToCorrectionAskedException;
import fr.ifremer.wao.services.service.ContactsService;
import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException;
+import fr.ifremer.wao.services.service.IllegalAcceptationException;
import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException;
import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException;
import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException;
@@ -238,6 +239,9 @@
} catch (MissingContactMammalsInfoException e) {
errorMessage = t("wao.ui.form.Contact.error.missingContactMammalsInfo");
+ } catch (IllegalAcceptationException e) {
+ errorMessage = t("wao.ui.form.Contact.error.illegalAcceptationException");
+
}
if (isSuccessful()) {
Modified: branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_en_GB.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-20 19:20:31 UTC (rev 2079)
@@ -286,6 +286,7 @@
wao.ui.form.Contact.error.dataInputDateAfterToday=The data input date cannot be after tomorrow
wao.ui.form.Contact.error.dataInputDateBeforeObservationEndDate=The data input date cannot be before observation end date
wao.ui.form.Contact.error.duplicatedMainObserverInSecondaryObservers=The main observer cannot also be a secondary observer
+wao.ui.form.Contact.error.illegalAcceptationException=
wao.ui.form.Contact.error.invalidObservationBeginDate=The observation begin date must be a date in a month with an expected effort in the sampling plan
wao.ui.form.Contact.error.mismatchCompanyForObserver=Observers must belong to the company attached to the sample row
wao.ui.form.Contact.error.missingComment=The comment is mandatory
Modified: branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-20 19:20:31 UTC (rev 2079)
@@ -286,6 +286,7 @@
wao.ui.form.Contact.error.dataInputDateAfterToday=La date de saisie des données doit être antérieure à la date du jour
wao.ui.form.Contact.error.dataInputDateBeforeObservationEndDate=La date de saisie des données doit être postérieure à la date de fin d'observation
wao.ui.form.Contact.error.duplicatedMainObserverInSecondaryObservers=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires
+wao.ui.form.Contact.error.illegalAcceptationException=
wao.ui.form.Contact.error.invalidObservationBeginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne
wao.ui.form.Contact.error.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s
wao.ui.form.Contact.error.missingComment=Il faut préciser un commentaire pour l'état '%s'
Modified: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp 2014-06-20 19:20:31 UTC (rev 2079)
@@ -60,6 +60,13 @@
filterLabel: "<s:text name="wao.ui.field.FishingZone.sectorName"/>",
filterValuesField: 'sampleRowsFilterValues.fishingZoneSectorNames',
},
+ <s:if test="obsVente">
+ {
+ filterName: 'terrestrialLocationIds',
+ filterLabel: "<s:text name="wao.ui.field.Contact.terrestrialLocation"/>",
+ filterValuesField: 'terrestrialLocations'
+ },
+ </s:if>
{
filterName: 'sampleRowFilter.fishingGearDcfIds',
filterLabel: "<s:text name="wao.ui.entity.fishingGearDCF"/>",
@@ -103,12 +110,31 @@
filterLabel: "<s:text name="wao.ui.field.Contact.validationProgram"/>",
filterValuesField: 'programAcceptations'
},
+ <s:if test="obsMer">
+ {
+ filterName: 'observedDataControls',
+ filterLabel: "<s:text name="wao.ui.field.Contact.observedDataControl"/>",
+ filterValuesField: 'observedDataControls'
+ },
+ </s:if>
+ <s:if test="obsVente">
+ {
+ filterName: 'sampleRowFilter.samplingStrategies',
+ filterLabel: "<s:text name="wao.ui.field.SampleRow.samplingStrategy"/>",
+ filterValuesField: 'sampleRowsFilterValues.samplingStrategies'
+ },
+ {
+ filterName: 'actualSamplingStrategies',
+ filterLabel: "<s:text name="wao.ui.field.Contact.samplingStrategy"/>",
+ filterValuesField: 'actualSamplingStrategies'
+ },
+ {
+ filterName: 'completeSamplings',
+ filterLabel: "<s:text name="wao.ui.field.Contact.completeSampling"/>",
+ filterValuesField: 'completeSamplings'
+ },
+ </s:if>
{
- filterName: 'observedDataControls',
- filterLabel: "<s:text name="wao.ui.field.Contact.observedDataControl"/>",
- filterValuesField: 'observedDataControls'
- },
- {
filterName: 'dataReliabilities',
filterLabel: "<s:text name="wao.ui.field.Contact.dataReliability"/>",
filterValuesField: 'dataReliabilities'
@@ -318,6 +344,7 @@
<th class="only-in-full-view"><s:text name="wao.ui.contacts.division"/></th>
<s:if test="obsVente">
<th><s:text name="wao.ui.field.Contact.terrestrialLocation"/></th>
+ <th><s:text name="wao.ui.field.SampleRow.samplingStrategy"/></th>
</s:if>
<th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.company"/></th>
<th><s:text name="wao.ui.contacts.observers"/></th>
@@ -413,6 +440,11 @@
<td>
<s:property value="terrestrialLocation.description"/>
</td>
+ <td>
+ <s:if test="sampleRow.samplingStrategy != null">
+ <s:text name="%{sampleRow.samplingStrategy.i18nKey}"/>
+ </s:if>
+ </td>
</s:if>
<td class="only-in-full-view">
<s:property value="sampleRow.company.name"/>
Modified: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp 2014-06-20 17:38:35 UTC (rev 2078)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp 2014-06-20 19:20:31 UTC (rev 2079)
@@ -243,7 +243,7 @@
list="terrestrialLocations"
emptyOption="true"
disabled="%{!#editObservationReport}"
- cssClass="input-xxlarge select2"
+ cssClass="input-xxlarge"
/>
<s:select name="updateContactCommand.contact.samplingStrategy"
1
0
20 Jun '14
Author: bleny
Date: 2014-06-20 19:38:35 +0200 (Fri, 20 Jun 2014)
New Revision: 2078
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2078
Log:
refs #4488 start contacts
Added:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactTerrestrialLocationException.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java
branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ContactsServiceTest.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsFilterValuesJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/CreateContactAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/DeleteContactAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportContactsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ImportContactsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/ContactsAction-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp
Removed:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java
branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsFilterValuesJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteContactAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportContactsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ImportContactsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/ContactsAction-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp
Modified:
branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationTopiaDao.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java
branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_en_GB.properties
branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties
branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_en_GB.properties
branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp
branches/wao-4.0-obsvente/wao-web/src/main/webapp/endpoints-js.jsp
Modified: branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationTopiaDao.java
===================================================================
--- branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationTopiaDao.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationTopiaDao.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -21,8 +21,10 @@
* #L%
*/
+import fr.ifremer.wao.WaoUtils;
import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -39,4 +41,8 @@
return forLocationTypeOrdinalEquals(locationType.ordinal());
}
+ public TopiaQueryBuilderAddCriteriaOrRunQueryStep<TerrestrialLocation> forLocationTypeIn(Collection<LocationType> locationTypes) {
+ return forLocationTypeOrdinalIn(WaoUtils.toOrdinals(locationTypes));
+ }
+
}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -36,8 +36,8 @@
import fr.ifremer.wao.entity.WaoUser;
import fr.ifremer.wao.entity.WaoUserImpl;
import fr.ifremer.wao.entity.WaoUserTopiaDao;
+import fr.ifremer.wao.services.service.ContactsService;
import fr.ifremer.wao.services.service.ImportErrorException;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
import fr.ifremer.wao.services.service.ObsMerSamplingPlanService;
import fr.ifremer.wao.services.service.administration.ReferentialService;
import org.apache.commons.io.IOUtils;
@@ -199,7 +199,7 @@
InputStream input = null;
try {
input = getClass().getResourceAsStream("/import/contacts.csv");
- serviceContext.newService(ObsMerContactsService.class).importContacts(admin(), input);
+ serviceContext.newService(ContactsService.class).importContacts(admin(), input);
} catch (ImportErrorException e) {
throw new WaoTechnicalException(e);
} finally {
Deleted: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,65 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-import com.google.common.collect.ImmutableSet;
-import fr.ifremer.wao.ContactsFilter;
-import fr.ifremer.wao.services.AuthenticatedWaoUser;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-
-public class ContactsService extends WaoServiceSupport {
-
- private static final Log log = LogFactory.getLog(ContactsService.class);
-
- public ContactsFilter newContactFilter(AuthenticatedWaoUser authenticatedWaoUser) {
-
- ContactsFilter newContactsFilter = new ContactsFilter();
-
- newContactsFilter.getSampleRowFilter().setObsProgram(authenticatedWaoUser.getObsProgram());
-
- // DO NOT REMOVE THIS
- if (authenticatedWaoUser.isCoordinatorOrObserver()) {
- String authenticatedWaoUserCompanyTopiaId = authenticatedWaoUser.getWaoUser().getCompany().getTopiaId();
- newContactsFilter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId));
- }
-
- Calendar periodFromCalendar = Calendar.getInstance();
- periodFromCalendar.setTime(serviceContext.getNow());
-
- // in the firsts months of a new year go from now to 6 months before
- // in the rest of the year, just start at the beginning of the current year
- if (periodFromCalendar.get(Calendar.MONTH) < 3) {
- periodFromCalendar.add(Calendar.MONTH, -6);
- } else {
- periodFromCalendar.set(Calendar.DAY_OF_YEAR, 1);
- }
-
- Date periodFrom = periodFromCalendar.getTime();
- Date periodTo = DateUtils.addYears(periodFromCalendar.getTime(), 1);
-
- newContactsFilter.setPeriodFrom(periodFrom);
- newContactsFilter.setPeriodTo(periodTo);
-
- if (authenticatedWaoUser.isProfessional()) {
- // Pour le profesionnel, on restreint d'office à la liste des contacts portant sur les bateaux qu'il peut voir
- Collection<String> canReadBoatsTopiaIds = authenticatedWaoUser.getWaoUser().getCanReadBoatsTopiaIds();
- if (CollectionUtils.isEmpty(canReadBoatsTopiaIds)) {
- if (log.isWarnEnabled()) {
- log.warn("user " + authenticatedWaoUser.getWaoUser() + " is professional but can't read any boat");
- }
- } else {
- newContactsFilter.getBoatFilter().setBoatIds(new HashSet<>(canReadBoatsTopiaIds));
- }
- }
-
- return newContactsFilter;
-
- }
-
-}
Copied: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java (from rev 2077, branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,1026 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
+import fr.ifremer.wao.ContactsFilter;
+import fr.ifremer.wao.WaoTechnicalException;
+import fr.ifremer.wao.WaoUtils;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ContactImpl;
+import fr.ifremer.wao.entity.ContactState;
+import fr.ifremer.wao.entity.ContactStateMotif;
+import fr.ifremer.wao.entity.ContactTopiaDao;
+import fr.ifremer.wao.entity.DataReliability;
+import fr.ifremer.wao.entity.ElligibleBoat;
+import fr.ifremer.wao.entity.ElligibleBoatTopiaDao;
+import fr.ifremer.wao.entity.LocationType;
+import fr.ifremer.wao.entity.ObsProgram;
+import fr.ifremer.wao.entity.ObservedDataControl;
+import fr.ifremer.wao.entity.SampleMonth;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.TerrestrialLocation;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.WaoUserTopiaDao;
+import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import fr.ifremer.wao.services.service.csv.ContactImportExportModel;
+import fr.ifremer.wao.services.service.mail.AddBoatToUserAllegroWalletEmail;
+import fr.ifremer.wao.services.service.mail.EmailService;
+import fr.ifremer.wao.services.service.mail.MammalsObservationEmail;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.csv.AbstractImportErrorInfo;
+import org.nuiton.csv.Export;
+import org.nuiton.csv.ExportModel;
+import org.nuiton.csv.Import2;
+import org.nuiton.csv.ImportConf;
+import org.nuiton.csv.ImportModel;
+import org.nuiton.csv.ImportRow;
+import org.nuiton.i18n.I18n;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.DateUtil;
+import org.nuiton.util.StringUtil;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+import org.nuiton.util.pagination.PaginationParameter;
+import org.nuiton.util.pagination.PaginationResult;
+
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n.l;
+
+public class ContactsService extends WaoServiceSupport {
+
+ private static final Log log = LogFactory.getLog(ContactsService.class);
+
+ public ContactsFilter newContactFilter(AuthenticatedWaoUser authenticatedWaoUser) {
+
+ ContactsFilter newContactsFilter = new ContactsFilter();
+
+ newContactsFilter.getSampleRowFilter().setObsProgram(authenticatedWaoUser.getObsProgram());
+
+ // DO NOT REMOVE THIS
+ if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ String authenticatedWaoUserCompanyTopiaId = authenticatedWaoUser.getWaoUser().getCompany().getTopiaId();
+ newContactsFilter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId));
+ }
+
+ Calendar periodFromCalendar = Calendar.getInstance();
+ periodFromCalendar.setTime(serviceContext.getNow());
+
+ // in the firsts months of a new year go from now to 6 months before
+ // in the rest of the year, just start at the beginning of the current year
+ if (periodFromCalendar.get(Calendar.MONTH) < 3) {
+ periodFromCalendar.add(Calendar.MONTH, -6);
+ } else {
+ periodFromCalendar.set(Calendar.DAY_OF_YEAR, 1);
+ }
+
+ Date periodFrom = periodFromCalendar.getTime();
+ Date periodTo = DateUtils.addYears(periodFromCalendar.getTime(), 1);
+
+ newContactsFilter.setPeriodFrom(periodFrom);
+ newContactsFilter.setPeriodTo(periodTo);
+
+ if (authenticatedWaoUser.isProfessional()) {
+ // Pour le profesionnel, on restreint d'office à la liste des contacts portant sur les bateaux qu'il peut voir
+ Collection<String> canReadBoatsTopiaIds = authenticatedWaoUser.getWaoUser().getCanReadBoatsTopiaIds();
+ if (CollectionUtils.isEmpty(canReadBoatsTopiaIds)) {
+ if (log.isWarnEnabled()) {
+ log.warn("user " + authenticatedWaoUser.getWaoUser() + " is professional but can't read any boat");
+ }
+ } else {
+ newContactsFilter.getBoatFilter().setBoatIds(new HashSet<>(canReadBoatsTopiaIds));
+ }
+ }
+
+ return newContactsFilter;
+
+ }
+
+ public ContactsFilterValues getContactsFilterValues(AuthenticatedWaoUser authenticatedWaoUser, ContactsFilter filter) {
+
+ ContactTopiaDao dao = getContactDao();
+ List<Contact> contacts = dao.forFilter(filter, false).findAll();
+
+ Optional<String> optionalCompanyId = Optional.absent();
+ if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ optionalCompanyId = Optional.of(authenticatedWaoUser.getCompany().getTopiaId());
+ }
+ ContactsFilterValues contactsFilterValues = new ContactsFilterValues(serviceContext.getLocale(), authenticatedWaoUser.getObsProgram(), optionalCompanyId);
+
+ for (Contact contact : contacts) {
+ contactsFilterValues.addContact(contact);
+ }
+
+ return contactsFilterValues;
+ }
+
+ public ObsMerContactsList getContactsList(AuthenticatedWaoUser authenticatedWaoUser,
+ ContactsFilter filter,
+ PaginationParameter queryPager) {
+
+ ContactTopiaDao dao = getContactDao();
+
+ // Need to copy to add sort attributes
+ PaginationParameter.PaginationParameterBuilder builder = PaginationParameter.builder(queryPager.getPageNumber(), queryPager.getPageSize());
+ if (filter.isSortedByBoardingDate()) {
+ builder.addOrder(Contact.PROPERTY_OBSERVATION_BEGIN_DATE, true);
+ } else {
+ builder.addOrder(Contact.PROPERTY_CREATION_DATE, true);
+ }
+ PaginationParameter pager = builder.build();
+
+ PaginationResult<Contact> contacts = dao.forFilter(filter, false).findPage(pager);
+
+ ContactsFilterValues filterValues = getContactsFilterValues(authenticatedWaoUser, filter);
+
+ ObsMerContactsList contactsList = new ObsMerContactsList();
+ contactsList.setContacts(contacts);
+ contactsList.setFilterValues(filterValues);
+ return contactsList;
+ }
+
+ public PaginationParameter newContactsPaginationParameter(int pageNumber, int pageSize) {
+ PaginationParameter result = PaginationParameter.of(pageNumber, pageSize);
+ return result;
+ }
+
+ public UpdateContactCommand newUpdateContactCommand(AuthenticatedWaoUser authenticatedWaoUser, Optional<String> optionalContactId) {
+
+ //FIXME Should we apply some security rules (can create, update, import) ?
+ //Preconditions.checkState(authenticatedWaoUser.isAuthorizedToCreateSampleRow());
+
+ UpdateContactCommand updateContactCommand = new UpdateContactCommand();
+
+ updateContactCommand.setAdmin(authenticatedWaoUser.isAdmin());
+
+ Contact contact;
+
+ if (optionalContactId.isPresent()) {
+
+ String contactId = optionalContactId.get();
+
+ contact = getContact(contactId);
+
+ updateContactCommand.setContact(contact);
+
+ updateContactCommand.setCreation(false);
+
+ String mainObserverId = contact.getMainObserver().getTopiaId();
+ updateContactCommand.setMainObserverId(mainObserverId);
+ Set<String> secondaryObserversTopiaIds = contact.getSecondaryObserversTopiaIds();
+ updateContactCommand.setSecondaryObserverIds(secondaryObserversTopiaIds);
+
+ String terrestrialLocationId = contact.getTerrestrialLocation().getTopiaId();
+ updateContactCommand.setTerrestrialLocationId(terrestrialLocationId);
+
+ } else {
+
+ contact = new ContactImpl();
+
+ contact.setObsProgram(authenticatedWaoUser.getObsProgram());
+
+ contact.setCreationDate(getNow());
+
+ updateContactCommand.setContact(contact);
+
+ updateContactCommand.setCreation(true);
+ }
+
+ return updateContactCommand;
+ }
+
+ public Contact getContact(String contactId) {
+ return getContactDao().forTopiaIdEquals(contactId).findUnique();
+ }
+
+ public InputStream exportContacts(ContactsFilter filter) {
+ ContactTopiaDao dao = getContactDao();
+
+ List<Contact> contacts = dao.forFilter(filter, true).findAll();
+
+ ExportModel<Contact> exportModel = ContactImportExportModel.forExport(getLocale(),
+ filter.getSampleRowFilter().getObsProgram());
+
+ Export<Contact> export = Export.newExport(exportModel, contacts);
+
+ try {
+
+ String csvContent = export.toString(Charsets.UTF_8);
+
+ InputStream csvInputStream = IOUtils.toInputStream(csvContent, Charsets.UTF_8);
+
+ return csvInputStream;
+
+ } catch (Exception e) {
+ throw new WaoTechnicalException(e);
+ }
+ }
+
+ public void importContacts(AuthenticatedWaoUser authenticatedWaoUser,
+ InputStream csv) throws ImportErrorException {
+
+ ObsProgram obsProgram = authenticatedWaoUser.getObsProgram();
+
+ List<SampleRow> sampleRows =
+ getSampleRowDao().forObsProgramOrdinalEquals(obsProgram.ordinal()).findAll();
+ List<WaoUser> waoUsers = getWaoUserDao().findAll();
+ List<Boat> boats = getBoatDao().findAll();
+ List<ContactStateMotif> motives = getContactStateMotifDao().findAll();
+ List<TerrestrialLocation> terrestrialLocations =
+ getTerrestrialLocationDao().forLocationTypeIn(ImmutableSet.of(LocationType.AUCTION, LocationType.PORT)).findAll();
+
+ Locale l = getLocale();
+ ImportModel<Contact> contactImportModel =
+ ContactImportExportModel.forImport(l,
+ obsProgram,
+ waoUsers,
+ sampleRows,
+ boats,
+ motives,
+ terrestrialLocations);
+
+ ImportConf importConf = new ImportConf();
+ importConf.setStrictMode(true);
+
+ Import2<Contact> contactImport = Import2.newImport(importConf, contactImportModel, csv);
+
+ for (ImportRow<Contact> contactRow : contactImport) {
+
+ if (!contactRow.isValid()) {
+ // throw first error
+ Set<AbstractImportErrorInfo<Contact>> errors = contactRow.getErrors();
+ AbstractImportErrorInfo<Contact> errorInfo = errors.iterator().next();
+ throw new ImportErrorException(errorInfo.getCause());
+ }
+ long lineNumber = contactRow.getLineNumber();
+
+ Contact contact = contactRow.getBean();
+
+ String contactId = contact.getTopiaId();
+
+ if (StringUtils.isEmpty(contactId)) {
+ contactId = null;
+ }
+
+ Optional<String> optionalContactId = Optional.fromNullable(contactId);
+ UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser,
+ optionalContactId);
+
+ if (updateContactCommand.isCreation()) {
+
+ updateContactCommand.setContact(contact);
+
+ // Prevent that someone who is not admin change data that only admin
+ // must be able to modify
+ if ( ! authenticatedWaoUser.isAdmin()) {
+ contact.setCommentAdmin(null);
+ contact.setValidationProgram(null);
+ contact.setDataReliability(DataReliability.UNKNOWN);
+ }
+
+ } else {
+
+ Contact contactToUpdate = updateContactCommand.getContact();
+
+ // TODO brendan 20/06/14 create to binders
+ Binder<Contact, Contact> binder = BinderFactory.newBinder(Contact.class);
+ binder.copyExcluding(contact, contactToUpdate, TopiaEntity.PROPERTY_TOPIA_ID, TopiaEntity.PROPERTY_TOPIA_VERSION,
+ TopiaEntity.PROPERTY_TOPIA_CREATE_DATE, Contact.PROPERTY_SAMPLE_ROW);
+
+ // Prevent that someone who is not admin change data that only admin
+ // must be able to modify
+ if ( ! authenticatedWaoUser.isAdmin()) {
+ contactToUpdate.setCommentAdmin(contact.getCommentAdmin());
+ contactToUpdate.setValidationProgram(contact.getValidationProgram());
+ contactToUpdate.setDataReliability(contact.getDataReliability());
+ }
+
+ }
+
+ try {
+ validate(authenticatedWaoUser, updateContactCommand, false);
+ } catch (ContactNotUpdatableException e) {
+ String message = l(l, "wao.import.contact.failure.not.updatable", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (UnwantedContactContactStateMotifException e) {
+ String message = l(l, "wao.import.contact.failure.unwantedContactStateMotif", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactNbObservantsException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObserver", lineNumber, state);
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservationEndDateException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObservationEndDate", lineNumber, state);
+ throw new ImportErrorException(message);
+ } catch (ContactDataInputDateBeforeObservationEndDateException e) {
+ String message = l(l, "wao.import.contact.failure.dataInputDateBeforeObservationEndDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (InvalidContactObservationBeginDateException e) {
+ String message = l(l, "wao.import.contact.failure.invalidObservationBeginDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactRestitutionException e) {
+ String message = l(l, "wao.import.contact.failure.missingRestitution", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (ContactDataInputDateAfterTodayException e) {
+ String message = l(l, "wao.import.contact.failure.dataInputDateAfterToday", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactCommentException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingComment", state, lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MismatchContactMainObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", lineNumber, observerLogin, companyName);
+ throw new ImportErrorException(message);
+ } catch (ContactRestitutionDateBeforeDataInputDateException e) {
+ String message = l(l, "wao.import.contact.failure.transmissionDateBeforeDataInputDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (ContactObservationEndDateBeforeBeginDateException e) {
+ String message = l(l, "wao.import.contact.failure.observationEndDateBeforeBeginDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
+ String message = l(l, "wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactDataReliabilityException e) {
+ String message = l(l, "wao.import.contact.failure.missingDataReliability", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MismatchContactSecondaryObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", lineNumber, observerLogin, companyName);
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservedDataControlException e) {
+ String message = l(l, "wao.import.contact.failure.missingObservedDataControl", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (ContactWithObservedDataControlToCorrectionAskedException e) {
+ String message = l(l, "wao.import.contact.failure.observedDataControlToCorrectionAsked", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactStateMotifException e) {
+ String message = l(l, "wao.import.contact.failure.missingContactStateMotif", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactDataInputDateException e) {
+ String message = l(l, "wao.import.contact.failure.missingDataInputDate", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactMainObserverException e) {
+ String message = l(l, "wao.import.contact.failure.missingMainObserver", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactCommentAdminException e) {
+ String dataReliability = WaoUtils.l(l, e.getContact().getDataReliability());
+ String message = l(l, "wao.import.contact.failure.missingCommentAdmin", lineNumber, dataReliability);
+ throw new ImportErrorException(message);
+ } catch (ContactObservationEndDateAfterTodayException e) {
+ String message = l(l, "wao.import.contact.failure.observationEndDateAfterToday", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactObservationBeginDateException e) {
+ String state = WaoUtils.l(l, e.getContact().getContactState());
+ String message = l(l, "wao.import.contact.failure.missingObservationBeginDate", lineNumber, state);
+ throw new ImportErrorException(message);
+ } catch (MissingContactMammalsInfoException e) {
+ String message = l(l, "wao.import.contact.failure.missingContactMammalsInfo", lineNumber);
+ throw new ImportErrorException(message);
+ } catch (MissingContactTerrestrialLocationException e) {
+ String message = l(l, "wao.import.contact.failure.missingTerrestrialLocation", lineNumber);
+ throw new ImportErrorException(message);
+ }
+
+ save0(updateContactCommand);
+ }
+
+ commit();
+ }
+
+ public void preValidate(UpdateContactCommand updateContactCommand) {
+
+ String mainObserverId = updateContactCommand.getMainObserverId();
+
+ WaoUser mainObserver = getWaoUserDao().forTopiaIdEquals(mainObserverId).findUnique();
+ updateContactCommand.getContact().setMainObserver(mainObserver);
+
+ List<WaoUser> secondaryObservers = getWaoUserDao().forTopiaIdIn(updateContactCommand.getSecondaryObserverIds()).findAll();
+ updateContactCommand.getContact().setSecondaryObservers(new HashSet<>(secondaryObservers));
+
+ TerrestrialLocation terrestrialLocation = getTerrestrialLocationDao().forTopiaIdEquals(updateContactCommand.getTerrestrialLocationId()).findUnique();
+ updateContactCommand.getContact().setTerrestrialLocation(terrestrialLocation);
+
+ }
+
+ public void validate(AuthenticatedWaoUser authenticatedWaoUser,
+ UpdateContactCommand updateContactCommand,
+ boolean needUpdate) throws
+ ContactNotUpdatableException,
+ MissingContactMainObserverException,
+ MismatchContactMainObserverCompanyException,
+ DuplicatedContactMainObserverInSecondaryObserversException,
+ MismatchContactSecondaryObserverCompanyException,
+ InvalidContactObservationBeginDateException,
+ ContactObservationEndDateBeforeBeginDateException,
+ ContactObservationEndDateAfterTodayException,
+ ContactDataInputDateBeforeObservationEndDateException,
+ ContactDataInputDateAfterTodayException,
+ MissingContactCommentException,
+ MissingContactObservationBeginDateException,
+ MissingContactObservationEndDateException,
+ MissingContactNbObservantsException,
+ MissingContactStateMotifException,
+ UnwantedContactContactStateMotifException,
+ MissingContactObservedDataControlException,
+ MissingContactMammalsInfoException,
+ ContactWithObservedDataControlToCorrectionAskedException,
+ MissingContactRestitutionException,
+ MissingContactDataInputDateException,
+ ContactRestitutionDateBeforeDataInputDateException,
+ MissingContactDataReliabilityException,
+ MissingContactCommentAdminException, MissingContactTerrestrialLocationException {
+
+ if (needUpdate) {
+ Preconditions.checkState(!updateContactCommand.isCreation());
+ }
+
+ //FIXME Do some security checks about authenticatedWaoUser
+
+ // Check if contact can be updated
+ boolean canUpdateContact = updateContactCommand.canUpdateContact(authenticatedWaoUser);
+ if (!canUpdateContact) {
+ throw new ContactNotUpdatableException();
+ }
+
+ // Check if a validation controls are required
+ boolean mustValidateContact = updateContactCommand.mustValidateContact();
+
+ if (mustValidateContact) {
+
+ // Pass validation controls
+ Contact contact = updateContactCommand.getContact();
+
+ Company company = contact.getSampleRow().getCompany();
+
+ WaoUser mainObserver = contact.getMainObserver();
+
+ {
+ //---
+ // mainObserver
+ //---
+
+ if (mainObserver == null) {
+ throw new MissingContactMainObserverException(contact);
+ }
+
+ boolean observerWorksForCompanyInSampleRow = mainObserver.getCompany().equals(company);
+ if (!observerWorksForCompanyInSampleRow) {
+ throw new MismatchContactMainObserverCompanyException(contact, mainObserver, company);
+ }
+ }
+
+ if (contact.isSecondaryObserversNotEmpty()) {
+
+ //---
+ // secondaryObservers
+ //---
+
+ if (contact.getSecondaryObservers().contains(mainObserver)) {
+ throw new DuplicatedContactMainObserverInSecondaryObserversException(contact);
+ }
+
+ for (WaoUser observer : contact.getSecondaryObservers()) {
+ boolean observerWorksForCompanyInSampleRow = observer.getCompany().equals(company);
+ if (!observerWorksForCompanyInSampleRow) {
+ throw new MismatchContactSecondaryObserverCompanyException(contact, observer, company);
+ }
+ }
+ }
+
+ Date observationBeginDate = contact.getObservationBeginDate();
+ Date observationEndDate = contact.getObservationEndDate();
+ Date dataInputDate = contact.getDataInputDate();
+
+ SampleRow sampleRow = contact.getSampleRow();
+
+ if (observationBeginDate != null) {
+
+ //---
+ // observationBeginDate
+ //---
+
+ SampleMonth month = sampleRow.getSampleMonth(observationBeginDate);
+ boolean operationBeginDateIsValid = month != null;
+
+ if (!operationBeginDateIsValid) {
+ throw new InvalidContactObservationBeginDateException(contact);
+ }
+ }
+
+ Date currentDate = serviceContext.getNow();
+
+ if (observationEndDate != null) {
+
+ //---
+ // observationEndDate
+ //---
+
+ if (observationBeginDate != null
+ && observationEndDate.before(observationBeginDate)) {
+ throw new ContactObservationEndDateBeforeBeginDateException(contact);
+ }
+
+ if (observationEndDate.after(currentDate)) {
+ throw new ContactObservationEndDateAfterTodayException(contact, currentDate);
+ }
+
+ }
+
+ if (dataInputDate != null) {
+
+ //---
+ // dataInputDate
+ //---
+
+ if (observationEndDate != null) {
+
+ // Here, we check that the date input date is after the end of the
+ // observation. Since the first is a day (at 00:00) and the second
+ // is date-time, there may be a bug if the data input day is the same
+ // as the end of observation
+ boolean dataInputDateAfterObservationEndDate =
+ observationEndDate.after(DateUtil.setMaxTimeOfDay(dataInputDate));
+
+ if (dataInputDateAfterObservationEndDate) {
+ throw new ContactDataInputDateBeforeObservationEndDateException(contact);
+ }
+ }
+
+ if (dataInputDate.after(currentDate)) {
+ throw new ContactDataInputDateAfterTodayException(contact, currentDate);
+ }
+ }
+
+ //---
+ // contactState
+ //---
+
+ ContactState contactState = contact.getContactState();
+
+ boolean contactMustHaveAMotif = false;
+ switch (contactState) {
+ case OBSERVATION_CANCELLED:
+
+ // Non abouti
+
+ if (StringUtils.isBlank(contact.getComment())) {
+ throw new MissingContactCommentException(contact);
+ }
+ break;
+ case OBSERVATION_DONE:
+
+ // Observation réalisée
+
+ if (observationBeginDate == null) {
+ throw new MissingContactObservationBeginDateException(contact);
+ }
+ if (observationEndDate == null) {
+ throw new MissingContactObservationEndDateException(contact);
+ }
+ if (contact.getNbObservants() == 0) {
+ throw new MissingContactNbObservantsException(contact);
+ }
+ if (contact.getObsProgram().isObsVente() && contact.getTerrestrialLocation() == null) {
+ throw new MissingContactTerrestrialLocationException(contact);
+ }
+ break;
+
+ case CONTACT_REFUSED:
+ contactMustHaveAMotif = true;
+ break;
+ case CONTACT_DEFINITELY_REFUSED:
+ contactMustHaveAMotif = true;
+ break;
+
+ }
+
+ //---
+ // contactStateMotif
+ //---
+
+ if (contactMustHaveAMotif && contact.getContactStateMotif() == null) {
+ throw new MissingContactStateMotifException(contact);
+ }
+
+ if (!contactMustHaveAMotif && contact.getContactStateMotif() != null) {
+ throw new UnwantedContactContactStateMotifException(contact);
+ }
+
+ if (contact.isMammalsCapture() && StringUtils.isBlank(contact.getMammalsInfo())) {
+ throw new MissingContactMammalsInfoException(contact);
+ }
+
+ if (BooleanUtils.isTrue(contact.getValidationCompany())) {
+
+ //---
+ // validationCompany
+ //---
+
+ if (ContactState.OBSERVATION_DONE == contactState) {
+ if (contact.getObservedDataControl() == null) {
+ throw new MissingContactObservedDataControlException(contact);
+ } else if (contact.getObservedDataControl().equals(ObservedDataControl.CORRECTION_ASKED)) {
+ throw new ContactWithObservedDataControlToCorrectionAskedException(contact);
+ }
+ }
+
+ // Pour valider un contact société, il faut que le contact aie une date de transmission
+ Date restitution = contact.getRestitution();
+ if (ObservedDataControl.ACCEPTED == contact.getObservedDataControl() && restitution == null) {
+ throw new MissingContactRestitutionException(contact);
+ }
+ if (dataInputDate == null && restitution != null) {
+ throw new MissingContactDataInputDateException(contact);
+ }
+ if (dataInputDate != null && restitution != null && restitution.before(dataInputDate)) {
+ throw new ContactRestitutionDateBeforeDataInputDateException(contact);
+ }
+ }
+
+ DataReliability dataReliability = contact.getDataReliability();
+
+ if (dataReliability != null && dataReliability.isCommentRequired() && StringUtils.isBlank(contact.getCommentAdmin())) {
+ throw new MissingContactCommentAdminException(contact);
+ }
+
+ if (BooleanUtils.isTrue(contact.getValidationProgram())) {
+
+ //---
+ // validationProgram
+ //---
+
+ // it's an admin validation, data-reliability field must be filled
+
+ if (dataReliability == null || DataReliability.UNKNOWN == dataReliability) {
+ throw new MissingContactDataReliabilityException(contact);
+ }
+ }
+ }
+ }
+
+ public void save(UpdateContactCommand updateContactCommand,
+ boolean needUpdate) throws ContactNotUpdatableException {
+
+ if (needUpdate) {
+ Preconditions.checkState(!updateContactCommand.isCreation());
+ }
+
+ save0(updateContactCommand);
+
+ commit();
+
+ updateAllegroWalletIfNecessary(updateContactCommand);
+
+ notifyMammalsObservationIfNecessary(updateContactCommand);
+
+ }
+
+ protected void notifyMammalsObservationIfNecessary(UpdateContactCommand updateContactCommand) {
+
+ if (updateContactCommand.isMammalsInfosChanged()) {
+
+ Contact contact = updateContactCommand.getContact();
+
+ MammalsObservationEmail email = getEmailService().newMammalsObservationEmail();
+ email.setContact(contact);
+
+ // now trying to find to what user we need to send the mail
+ WaoUserTopiaDao userDao = getWaoUserDao();
+ // users contains all the user we need to notify for the capture
+ List<WaoUser> waoUsers = userDao.forMammalsNotificationsEquals(true).addEquals(WaoUser.PROPERTY_ACTIVE, true).findAll();
+
+ for (WaoUser waoUser : waoUsers) {
+ if (StringUtil.isEmail(waoUser.getLogin())) {
+ email.addBcc(waoUser);
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("will not send mammals capture notification to user " + waoUser + ". login is not an email");
+ }
+ }
+ }
+
+ getEmailService().send(email);
+
+ }
+
+ }
+
+ public void delete(String contactId) throws IllegalDeletionException {
+
+ Contact contact = getContact(contactId);
+
+ // Execute delete
+ ContactTopiaDao dao = getContactDao();
+
+ Map<Class<? extends TopiaEntity>, List<? extends TopiaEntity>> allUsages = dao.findAllUsages(contact);
+
+ if (!allUsages.isEmpty()) {
+ throw new IllegalDeletionException(allUsages);
+ }
+
+ ObsMerSamplingPlanService samplingPlanService = newService(ObsMerSamplingPlanService.class);
+
+ samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
+
+ dao.delete(contact);
+
+ commit();
+ }
+
+ protected void save0(UpdateContactCommand updateContactCommand) {
+
+ // Get contact to validate (must exist)
+ Contact contact = updateContactCommand.getContact();
+
+ ContactTopiaDao dao = getContactDao();
+
+ ObsMerSamplingPlanService samplingPlanService = newService(ObsMerSamplingPlanService.class);
+
+ if (updateContactCommand.isCreation()) {
+
+ //Update the elligible boat depends on contact creation. The
+ //{@code contact} reference can only be created for a sampleRow and a
+ //boat if both are linked with an elligibleBoat. So this method is
+ //used to create the link if needed during contacts import. This
+ //elligibleBoat is needed for the contact owned by a company, so
+ //the companyActive property of ElligibleBoat will be set to TRUE. No
+ //admin has decided to explicitly create this link.
+
+ ElligibleBoatTopiaDao elligibleDAO = getElligibleBoatDao();
+ ElligibleBoat elligible = elligibleDAO.findUniqueOrNull(contact);
+
+ if (elligible == null) {
+ // Create new elligible boat not active in a global way
+ elligible = elligibleDAO.create(contact);
+ }
+ elligible.setCompanyActive(Boolean.TRUE);
+
+ if (contact.getCreationDate() == null) {
+ contact.setCreationDate(serviceContext.getNow());
+ }
+
+ samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
+
+ dao.create(contact);
+
+ } else {
+
+ samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
+
+ dao.update(contact);
+ }
+
+ }
+
+ protected void updateAllegroWalletIfNecessary(UpdateContactCommand updateContactCommand) {
+
+ Contact contact = updateContactCommand.getContact();
+ ContactState contactState = contact.getContactState();
+ ObsProgram obsProgram = contact.getObsProgram();
+
+ boolean addBoatToObserversAllegroWallet = false;
+
+ if (obsProgram == ObsProgram.OBSMER) {
+ addBoatToObserversAllegroWallet = contactState == ContactState.OBSERVATION_DONE
+ || contactState == ContactState.OBSERVATION_EXPECTED;
+ } else if (obsProgram == ObsProgram.OBSVENTE) {
+ addBoatToObserversAllegroWallet = ContactState.OBSERVATION_DONE == contactState;
+ }
+
+ if (addBoatToObserversAllegroWallet) {
+
+ Boat boat = contact.getBoat();
+
+ String info;
+
+ if (contactState == ContactState.OBSERVATION_EXPECTED) {
+ info = I18n.l(
+ serviceContext.getLocale(),
+ "wao.email.addBoatToUserAllegroWallet.contactExpected",
+ WaoUtils.formatDate(serviceContext.getLocale(), contact.getObservationBeginDate()));
+ } else if (contactState == ContactState.OBSERVATION_DONE) {
+ info = I18n.l(
+ serviceContext.getLocale(),
+ "wao.email.addBoatToUserAllegroWallet.contactDone",
+ WaoUtils.formatDateTime(serviceContext.getLocale(), contact.getObservationBeginDate()),
+ WaoUtils.formatDateTime(serviceContext.getLocale(), contact.getObservationEndDate()));
+ } else {
+ throw new IllegalStateException(contactState + " should not lead to a mail sent");
+ }
+
+ // in obsvente, only the main observer
+ Collection<WaoUser> observers;
+ if (ObsProgram.OBSVENTE.equals(obsProgram)) {
+ observers = ImmutableSet.of(contact.getMainObserver());
+ } else if (ObsProgram.OBSMER.equals(obsProgram)) {
+ observers = contact.getAllObservers();
+ } else {
+ throw new IllegalStateException();
+ }
+
+ EmailService emailService = getEmailService();
+
+ WaoUserTopiaDao waoUserDao = getWaoUserDao();
+
+ for (WaoUser observer : observers) {
+
+ boolean boatAlreadyInWallet = observer.containsAllegroWallet(boat);
+
+ if (boatAlreadyInWallet) {
+
+ if (log.isInfoEnabled()) {
+ log.info("user " + observer + " already has " + boat + " in his allegroWallet");
+ }
+
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("user " + observer + " miss " + boat + " in his allegro wallet, adding");
+ }
+
+ String observerLogin = observer.getLogin();
+ String emailToUpdateAllegroWallets = getApplicationConfig().getEmailToUpdateAllegroWallets();
+
+ AddBoatToUserAllegroWalletEmail email =
+ emailService.newAddBoatToUserAllegroWalletEmail();
+
+ email.setBoat(boat);
+ email.setObserver(observer);
+ email.setInfo(info);
+ email.setObsProgram(contact.getObsProgram());
+
+ if ( ! StringUtil.isEmail(observerLogin)) {
+ if (log.isInfoEnabled()) {
+ log.info("user login is not a email, won't send anything: " + observerLogin + " email=" + email);
+ }
+ } else if ( ! observer.isActive()) {
+ if (log.isInfoEnabled()) {
+ log.info("observer is no longer active, won't send " + email);
+ }
+ } else if (StringUtils.isBlank(emailToUpdateAllegroWallets)) {
+ if (log.isInfoEnabled()) {
+ log.info("no email to update allegro wallets provided in configuration, won't send " + email);
+ }
+ } else if ( ! StringUtil.isEmail(emailToUpdateAllegroWallets)) {
+ if (log.isWarnEnabled()) {
+ log.warn("email to update allegro wallets provided in configuration is not valid, won't send " + emailToUpdateAllegroWallets);
+ }
+ } else {
+
+ email.addBcc(observer);
+
+ email.addTo(emailToUpdateAllegroWallets);
+
+ emailService.send(email);
+
+ observer.addAllegroWallet(boat);
+ waoUserDao.update(observer);
+ commit();
+
+ }
+ }
+ }
+ }
+ }
+
+ public Contact createContact(AuthenticatedWaoUser authenticatedWaoUser, String sampleRowId, String boatId) {
+
+ if (log.isInfoEnabled()) {
+ log.info(authenticatedWaoUser.getWaoUser() + " is creating a contact for " + sampleRowId + " and " + boatId);
+ }
+
+ UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser, Optional.<String>absent());
+
+ Boat boat = getBoatDao().findByTopiaId(boatId);
+ Preconditions.checkState(boat.isActive(), "boat must be active");
+
+ SampleRow sampleRow = getSampleRowDao().findByTopiaId(sampleRowId);
+ ObsProgram obsProgram = sampleRow.getObsProgram();
+
+ WaoUser observer = authenticatedWaoUser.getWaoUser();
+ Contact mostRecentContactOrNull = getContactDao().findMostRecentContactOrNull(obsProgram, boatId, observer.getCompany().getTopiaId());
+ Preconditions.checkState(
+ mostRecentContactOrNull == null || mostRecentContactOrNull.getContactState().isFinalState(),
+ "contact already exists");
+
+ Date now = serviceContext.getNow();
+
+ Contact newContact = updateContactCommand.getContact();
+ newContact.setDataReliability(DataReliability.UNKNOWN);
+ newContact.setBoat(boat);
+ newContact.setMainObserver(observer);
+ newContact.setSampleRow(sampleRow);
+ newContact.setCreationDate(now);
+
+ // initial contact state depends on the program
+ if (obsProgram == ObsProgram.OBSMER) {
+ newContact.setContactState(ContactState.CONTACT_START);
+ } else if (obsProgram == ObsProgram.OBSVENTE) {
+ newContact.setContactState(ContactState.OBSERVATION_EXPECTED);
+ }
+
+ // we can suppose a new contact default values are the one
+ // expected in the sampling plan
+
+ if (newContact.getObsProgram() == ObsProgram.OBSVENTE) {
+ // we hope in this contact, user used expected sampling strategy
+ newContact.setSamplingStrategy(sampleRow.getSamplingStrategy());
+ }
+
+ // In the case of ObsVente, we may have a user who wants to create
+ // multiple contact for a same day. Here we try, to ease the input
+ // of data by trying to pre-fill some field using data given
+ // in a previous entered contact
+
+ if (newContact.getObsProgram() == ObsProgram.OBSVENTE) {
+ // try to pre-fill some field for user-experience
+
+ // let's try to find a recent similar contact
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(Contact.PROPERTY_OBS_PROGRAM_ORDINAL, newContact.getObsProgram().ordinal());
+ properties.put(Contact.PROPERTY_SAMPLE_ROW, sampleRow);
+ properties.put(Contact.PROPERTY_MAIN_OBSERVER, observer);
+
+ List<Contact> candidates = getContactDao().forProperties(properties).findAll();
+
+ Contact similarContact = null; // to be found among candidates
+ for (Contact candidate : candidates) {
+ if (DateUtil.getDifferenceInDays(candidate.getCreationDate(), now) <= 1) {
+ similarContact = candidate;
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ String logMessage;
+ if (similarContact == null) {
+ logMessage = "no similar contact found";
+ } else {
+ logMessage = "similar contact found to pre-fill values of contact : "
+ + similarContact.getTopiaId() + " boat = " + similarContact.getBoat().getName();
+ }
+ log.debug(logMessage);
+ }
+
+ if (similarContact != null) {
+ newContact.setObservationBeginDate(similarContact.getObservationBeginDate());
+ newContact.setObservationEndDate(similarContact.getObservationEndDate());
+ newContact.setTerrestrialLocation(similarContact.getTerrestrialLocation());
+ newContact.clearSecondaryObservers();
+ newContact.addAllSecondaryObservers(similarContact.getSecondaryObservers());
+ newContact.setDataInputDate(similarContact.getDataInputDate());
+ }
+ }
+
+ save0(updateContactCommand);
+
+ commit();
+
+ return newContact;
+
+ }
+
+}
Added: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactTerrestrialLocationException.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactTerrestrialLocationException.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactTerrestrialLocationException.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,10 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Contact;
+
+public class MissingContactTerrestrialLocationException extends WaoContactValidationException {
+
+ public MissingContactTerrestrialLocationException(Contact contact) {
+ super(contact);
+ }
+}
Deleted: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,976 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableSet;
-import fr.ifremer.wao.ContactsFilter;
-import fr.ifremer.wao.WaoTechnicalException;
-import fr.ifremer.wao.WaoUtils;
-import fr.ifremer.wao.entity.Boat;
-import fr.ifremer.wao.entity.Company;
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.entity.ContactImpl;
-import fr.ifremer.wao.entity.ContactState;
-import fr.ifremer.wao.entity.ContactStateMotif;
-import fr.ifremer.wao.entity.ContactTopiaDao;
-import fr.ifremer.wao.entity.DataReliability;
-import fr.ifremer.wao.entity.ElligibleBoat;
-import fr.ifremer.wao.entity.ElligibleBoatTopiaDao;
-import fr.ifremer.wao.entity.ObsProgram;
-import fr.ifremer.wao.entity.ObservedDataControl;
-import fr.ifremer.wao.entity.SampleMonth;
-import fr.ifremer.wao.entity.SampleRow;
-import fr.ifremer.wao.entity.WaoUser;
-import fr.ifremer.wao.entity.WaoUserTopiaDao;
-import fr.ifremer.wao.services.AuthenticatedWaoUser;
-import fr.ifremer.wao.services.service.csv.ObsMerContactImportExportModel;
-import fr.ifremer.wao.services.service.mail.AddBoatToUserAllegroWalletEmail;
-import fr.ifremer.wao.services.service.mail.EmailService;
-import fr.ifremer.wao.services.service.mail.MammalsObservationEmail;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.csv.AbstractImportErrorInfo;
-import org.nuiton.csv.Export;
-import org.nuiton.csv.ExportModel;
-import org.nuiton.csv.Import2;
-import org.nuiton.csv.ImportConf;
-import org.nuiton.csv.ImportModel;
-import org.nuiton.csv.ImportRow;
-import org.nuiton.i18n.I18n;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.util.DateUtil;
-import org.nuiton.util.StringUtil;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderFactory;
-import org.nuiton.util.pagination.PaginationParameter;
-import org.nuiton.util.pagination.PaginationResult;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n.l;
-
-public class ObsMerContactsService extends ContactsService {
-
- private static final Log log = LogFactory.getLog(ObsMerContactsService.class);
-
- public ContactsFilterValues getContactsFilterValues(AuthenticatedWaoUser authenticatedWaoUser, ContactsFilter filter) {
-
- ContactTopiaDao dao = getContactDao();
- List<Contact> contacts = dao.forFilter(filter, false).findAll();
-
- Optional<String> optionalCompanyId = Optional.absent();
- if (authenticatedWaoUser.isCoordinatorOrObserver()) {
- optionalCompanyId = Optional.of(authenticatedWaoUser.getCompany().getTopiaId());
- }
- ContactsFilterValues contactsFilterValues = new ContactsFilterValues(serviceContext.getLocale(), authenticatedWaoUser.getObsProgram(), optionalCompanyId);
-
- for (Contact contact : contacts) {
- contactsFilterValues.addContact(contact);
- }
-
- return contactsFilterValues;
- }
-
- public ObsMerContactsList getContactsList(AuthenticatedWaoUser authenticatedWaoUser,
- ContactsFilter filter,
- PaginationParameter queryPager) {
-
- ContactTopiaDao dao = getContactDao();
-
- // Need to copy to add sort attributes
- PaginationParameter.PaginationParameterBuilder builder = PaginationParameter.builder(queryPager.getPageNumber(), queryPager.getPageSize());
- if (filter.isSortedByBoardingDate()) {
- builder.addOrder(Contact.PROPERTY_OBSERVATION_BEGIN_DATE, true);
- } else {
- builder.addOrder(Contact.PROPERTY_CREATION_DATE, true);
- }
- PaginationParameter pager = builder.build();
-
- PaginationResult<Contact> contacts = dao.forFilter(filter, false).findPage(pager);
-
- ContactsFilterValues filterValues = getContactsFilterValues(authenticatedWaoUser, filter);
-
- ObsMerContactsList contactsList = new ObsMerContactsList();
- contactsList.setContacts(contacts);
- contactsList.setFilterValues(filterValues);
- return contactsList;
- }
-
- public PaginationParameter newContactsPaginationParameter(int pageNumber, int pageSize) {
- PaginationParameter result = PaginationParameter.of(pageNumber, pageSize);
- return result;
- }
-
- public UpdateContactCommand newUpdateContactCommand(AuthenticatedWaoUser authenticatedWaoUser, Optional<String> optionalContactId) {
-
- //FIXME Should we apply some security rules (can create, update, import) ?
- //Preconditions.checkState(authenticatedWaoUser.isAuthorizedToCreateSampleRow());
-
- UpdateContactCommand updateContactCommand = new UpdateContactCommand();
-
- updateContactCommand.setAdmin(authenticatedWaoUser.isAdmin());
-
- Contact contact;
-
- if (optionalContactId.isPresent()) {
-
- String contactId = optionalContactId.get();
-
- contact = getContact(contactId);
-
- updateContactCommand.setContact(contact);
-
- updateContactCommand.setCreation(false);
-
- String mainObserverId = contact.getMainObserver().getTopiaId();
- updateContactCommand.setMainObserverId(mainObserverId);
- Set<String> secondaryObserversTopiaIds = contact.getSecondaryObserversTopiaIds();
- updateContactCommand.setSecondaryObserverIds(secondaryObserversTopiaIds);
-
- } else {
-
- contact = new ContactImpl();
-
- contact.setObsProgram(authenticatedWaoUser.getObsProgram());
-
- updateContactCommand.setContact(contact);
-
- updateContactCommand.setCreation(true);
- }
-
- return updateContactCommand;
- }
-
- public Contact getContact(String contactId) {
- return getContactDao().forTopiaIdEquals(contactId).findUnique();
- }
-
- public InputStream exportContacts(ContactsFilter filter) {
- ContactTopiaDao dao = getContactDao();
-
- List<Contact> contacts = dao.forFilter(filter, true).findAll();
-
- ExportModel<Contact> exportModel = ObsMerContactImportExportModel.forExport(getLocale(),
- filter.getSampleRowFilter().getObsProgram());
-
- Export<Contact> export = Export.newExport(exportModel, contacts);
-
- try {
-
- String csvContent = export.toString(Charsets.UTF_8);
-
- InputStream csvInputStream = IOUtils.toInputStream(csvContent, Charsets.UTF_8);
-
- return csvInputStream;
-
- } catch (Exception e) {
- throw new WaoTechnicalException(e);
- }
- }
-
- public void importContacts(AuthenticatedWaoUser authenticatedWaoUser,
- InputStream csv) throws ImportErrorException {
-
- ObsProgram obsProgram = authenticatedWaoUser.getObsProgram();
-
- List<SampleRow> sampleRows =
- getSampleRowDao().forObsProgramOrdinalEquals(obsProgram.ordinal()).findAll();
- List<WaoUser> waoUsers = getWaoUserDao().findAll();
- List<Boat> boats = getBoatDao().findAll();
- List<ContactStateMotif> motives = getContactStateMotifDao().findAll();
-
- Locale l = getLocale();
- ImportModel<Contact> contactImportModel =
- ObsMerContactImportExportModel.forImport(l,
- obsProgram,
- waoUsers,
- sampleRows,
- boats,
- motives);
-
- ImportConf importConf = new ImportConf();
- importConf.setStrictMode(true);
-
- Import2<Contact> contactImport = Import2.newImport(importConf, contactImportModel, csv);
-
- for (ImportRow<Contact> contactRow : contactImport) {
-
- if (!contactRow.isValid()) {
- // throw first error
- Set<AbstractImportErrorInfo<Contact>> errors = contactRow.getErrors();
- AbstractImportErrorInfo<Contact> errorInfo = errors.iterator().next();
- throw new ImportErrorException(errorInfo.getCause());
- }
- long lineNumber = contactRow.getLineNumber();
-
- Contact contact = contactRow.getBean();
-
- String contactId = contact.getTopiaId();
-
- if (StringUtils.isEmpty(contactId)) {
- contactId = null;
- }
-
- Optional<String> optionalContactId = Optional.fromNullable(contactId);
- UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser,
- optionalContactId);
-
- if (updateContactCommand.isCreation()) {
-
- updateContactCommand.setContact(contact);
-
- // Prevent that someone who is not admin change data that only admin
- // must be able to modify
- if ( ! authenticatedWaoUser.isAdmin()) {
- contact.setCommentAdmin(null);
- contact.setValidationProgram(null);
- contact.setDataReliability(DataReliability.UNKNOWN);
- }
-
- } else {
-
- Contact contactToUpdate = updateContactCommand.getContact();
- Binder<Contact, Contact> binder = BinderFactory.newBinder(Contact.class);
- binder.copy(contact, contactToUpdate,
- Contact.PROPERTY_CREATION_DATE,
- Contact.PROPERTY_MAIN_OBSERVER,
- Contact.PROPERTY_SECONDARY_OBSERVERS,
- "contactState",
- Contact.PROPERTY_OBSERVATION_BEGIN_DATE,
- Contact.PROPERTY_OBSERVATION_END_DATE,
- Contact.PROPERTY_DATA_INPUT_DATE,
- Contact.PROPERTY_COMMENT,
- Contact.PROPERTY_COMMENT_COORDINATOR,
- Contact.PROPERTY_COMMENT_ADMIN,
- Contact.PROPERTY_BOAT,
- Contact.PROPERTY_VALIDATION_COMPANY,
- Contact.PROPERTY_VALIDATION_PROGRAM,
- Contact.PROPERTY_SAMPLE_ROW,
- Contact.PROPERTY_MAMMALS_OBSERVATION,
- Contact.PROPERTY_MAMMALS_CAPTURE,
- Contact.PROPERTY_MAMMALS_INFO,
- Contact.PROPERTY_CONTACT_STATE_MOTIF,
- Contact.PROPERTY_RESTITUTION,
- Contact.PROPERTY_OBSERVED_DATA_CONTROL);
-
- // Prevent that someone who is not admin change data that only admin
- // must be able to modify
- if ( ! authenticatedWaoUser.isAdmin()) {
- contactToUpdate.setCommentAdmin(contact.getCommentAdmin());
- contactToUpdate.setValidationProgram(contact.getValidationProgram());
- contactToUpdate.setDataReliability(contact.getDataReliability());
- }
-
- }
-
- try {
- validate(authenticatedWaoUser, updateContactCommand, false);
- } catch (ContactNotUpdatableException e) {
- String message = l(l, "wao.import.contact.failure.not.updatable", lineNumber);
- throw new ImportErrorException(message);
- } catch (UnwantedContactContactStateMotifException e) {
- String message = l(l, "wao.import.contact.failure.unwantedContactStateMotif", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactNbObservantsException e) {
- String state = WaoUtils.l(l, e.getContact().getContactState());
- String message = l(l, "wao.import.contact.failure.missingObserver", lineNumber, state);
- throw new ImportErrorException(message);
- } catch (MissingContactObservationEndDateException e) {
- String state = WaoUtils.l(l, e.getContact().getContactState());
- String message = l(l, "wao.import.contact.failure.missingObservationEndDate", lineNumber, state);
- throw new ImportErrorException(message);
- } catch (ContactDataInputDateBeforeObservationEndDateException e) {
- String message = l(l, "wao.import.contact.failure.dataInputDateBeforeObservationEndDate", lineNumber);
- throw new ImportErrorException(message);
- } catch (InvalidContactObservationBeginDateException e) {
- String message = l(l, "wao.import.contact.failure.invalidObservationBeginDate", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactRestitutionException e) {
- String message = l(l, "wao.import.contact.failure.missingRestitution", lineNumber);
- throw new ImportErrorException(message);
- } catch (ContactDataInputDateAfterTodayException e) {
- String message = l(l, "wao.import.contact.failure.dataInputDateAfterToday", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactCommentException e) {
- String state = WaoUtils.l(l, e.getContact().getContactState());
- String message = l(l, "wao.import.contact.failure.missingComment", state, lineNumber);
- throw new ImportErrorException(message);
- } catch (MismatchContactMainObserverCompanyException e) {
- String companyName = e.getCompany().getName();
- String observerLogin = e.getObserver().getLogin();
- String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", lineNumber, observerLogin, companyName);
- throw new ImportErrorException(message);
- } catch (ContactRestitutionDateBeforeDataInputDateException e) {
- String message = l(l, "wao.import.contact.failure.transmissionDateBeforeDataInputDate", lineNumber);
- throw new ImportErrorException(message);
- } catch (ContactObservationEndDateBeforeBeginDateException e) {
- String message = l(l, "wao.import.contact.failure.observationEndDateBeforeBeginDate", lineNumber);
- throw new ImportErrorException(message);
- } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
- String message = l(l, "wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactDataReliabilityException e) {
- String message = l(l, "wao.import.contact.failure.missingDataReliability", lineNumber);
- throw new ImportErrorException(message);
- } catch (MismatchContactSecondaryObserverCompanyException e) {
- String companyName = e.getCompany().getName();
- String observerLogin = e.getObserver().getLogin();
- String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", lineNumber, observerLogin, companyName);
- throw new ImportErrorException(message);
- } catch (MissingContactObservedDataControlException e) {
- String message = l(l, "wao.import.contact.failure.missingObservedDataControl", lineNumber);
- throw new ImportErrorException(message);
- } catch (ContactWithObservedDataControlToCorrectionAskedException e) {
- String message = l(l, "wao.import.contact.failure.observedDataControlToCorrectionAsked", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactStateMotifException e) {
- String message = l(l, "wao.import.contact.failure.missingContactStateMotif", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactDataInputDateException e) {
- String message = l(l, "wao.import.contact.failure.missingDataInputDate", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactMainObserverException e) {
- String message = l(l, "wao.import.contact.failure.missingMainObserver", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactCommentAdminException e) {
- String dataReliability = WaoUtils.l(l, e.getContact().getDataReliability());
- String message = l(l, "wao.import.contact.failure.missingCommentAdmin", lineNumber, dataReliability);
- throw new ImportErrorException(message);
- } catch (ContactObservationEndDateAfterTodayException e) {
- String message = l(l, "wao.import.contact.failure.observationEndDateAfterToday", lineNumber);
- throw new ImportErrorException(message);
- } catch (MissingContactObservationBeginDateException e) {
- String state = WaoUtils.l(l, e.getContact().getContactState());
- String message = l(l, "wao.import.contact.failure.missingObservationBeginDate", lineNumber, state);
- throw new ImportErrorException(message);
- } catch (MissingContactMammalsInfoException e) {
- String message = l(l, "wao.import.contact.failure.missingContactMammalsInfo", lineNumber);
- throw new ImportErrorException(message);
- }
-
- save0(updateContactCommand);
- }
-
- commit();
- }
-
- public void preValidate(UpdateContactCommand updateContactCommand) {
-
- String mainObserverId = updateContactCommand.getMainObserverId();
-
- WaoUser mainObserver = getWaoUserDao().forTopiaIdEquals(mainObserverId).findUnique();
- updateContactCommand.getContact().setMainObserver(mainObserver);
-
- List<WaoUser> secondaryObservers = getWaoUserDao().forTopiaIdIn(updateContactCommand.getSecondaryObserverIds()).findAll();
- updateContactCommand.getContact().setSecondaryObservers(new HashSet<>(secondaryObservers));
-
- }
-
- public void validate(AuthenticatedWaoUser authenticatedWaoUser,
- UpdateContactCommand updateContactCommand,
- boolean needUpdate) throws
- ContactNotUpdatableException,
- MissingContactMainObserverException,
- MismatchContactMainObserverCompanyException,
- DuplicatedContactMainObserverInSecondaryObserversException,
- MismatchContactSecondaryObserverCompanyException,
- InvalidContactObservationBeginDateException,
- ContactObservationEndDateBeforeBeginDateException,
- ContactObservationEndDateAfterTodayException,
- ContactDataInputDateBeforeObservationEndDateException,
- ContactDataInputDateAfterTodayException,
- MissingContactCommentException,
- MissingContactObservationBeginDateException,
- MissingContactObservationEndDateException,
- MissingContactNbObservantsException,
- MissingContactStateMotifException,
- UnwantedContactContactStateMotifException,
- MissingContactObservedDataControlException,
- MissingContactMammalsInfoException,
- ContactWithObservedDataControlToCorrectionAskedException,
- MissingContactRestitutionException,
- MissingContactDataInputDateException,
- ContactRestitutionDateBeforeDataInputDateException,
- MissingContactDataReliabilityException,
- MissingContactCommentAdminException {
-
- if (needUpdate) {
- Preconditions.checkState(!updateContactCommand.isCreation());
- }
-
- //FIXME Do some security checks about authenticatedWaoUser
-
- // Check if contact can be updated
- boolean canUpdateContact = updateContactCommand.canUpdateContact(authenticatedWaoUser);
- if (!canUpdateContact) {
- throw new ContactNotUpdatableException();
- }
-
- // Check if a validation controls are required
- boolean mustValidateContact = updateContactCommand.mustValidateContact();
-
- if (mustValidateContact) {
-
- // Pass validation controls
- Contact contact = updateContactCommand.getContact();
-
- Company company = contact.getSampleRow().getCompany();
-
- WaoUser mainObserver = contact.getMainObserver();
-
- {
- //---
- // mainObserver
- //---
-
- if (mainObserver == null) {
- throw new MissingContactMainObserverException(contact);
- }
-
- boolean observerWorksForCompanyInSampleRow = mainObserver.getCompany().equals(company);
- if (!observerWorksForCompanyInSampleRow) {
- throw new MismatchContactMainObserverCompanyException(contact, mainObserver, company);
- }
- }
-
- if (contact.isSecondaryObserversNotEmpty()) {
-
- //---
- // secondaryObservers
- //---
-
- if (contact.getSecondaryObservers().contains(mainObserver)) {
- throw new DuplicatedContactMainObserverInSecondaryObserversException(contact);
- }
-
- for (WaoUser observer : contact.getSecondaryObservers()) {
- boolean observerWorksForCompanyInSampleRow = observer.getCompany().equals(company);
- if (!observerWorksForCompanyInSampleRow) {
- throw new MismatchContactSecondaryObserverCompanyException(contact, observer, company);
- }
- }
- }
-
- Date observationBeginDate = contact.getObservationBeginDate();
- Date observationEndDate = contact.getObservationEndDate();
- Date dataInputDate = contact.getDataInputDate();
-
- SampleRow sampleRow = contact.getSampleRow();
-
- if (observationBeginDate != null) {
-
- //---
- // observationBeginDate
- //---
-
- SampleMonth month = sampleRow.getSampleMonth(observationBeginDate);
- boolean operationBeginDateIsValid = month != null;
-
- if (!operationBeginDateIsValid) {
- throw new InvalidContactObservationBeginDateException(contact);
- }
- }
-
- Date currentDate = serviceContext.getNow();
-
- if (observationEndDate != null) {
-
- //---
- // observationEndDate
- //---
-
- if (observationBeginDate != null
- && observationEndDate.before(observationBeginDate)) {
- throw new ContactObservationEndDateBeforeBeginDateException(contact);
- }
-
- if (observationEndDate.after(currentDate)) {
- throw new ContactObservationEndDateAfterTodayException(contact, currentDate);
- }
-
- }
-
- if (dataInputDate != null) {
-
- //---
- // dataInputDate
- //---
-
- if (observationEndDate != null) {
-
- // Here, we check that the date input date is after the end of the
- // observation. Since the first is a day (at 00:00) and the second
- // is date-time, there may be a bug if the data input day is the same
- // as the end of observation
- boolean dataInputDateAfterObservationEndDate =
- observationEndDate.after(DateUtil.setMaxTimeOfDay(dataInputDate));
-
- if (dataInputDateAfterObservationEndDate) {
- throw new ContactDataInputDateBeforeObservationEndDateException(contact);
- }
- }
-
- if (dataInputDate.after(currentDate)) {
- throw new ContactDataInputDateAfterTodayException(contact, currentDate);
- }
- }
-
- //---
- // contactState
- //---
-
- ContactState contactState = contact.getContactState();
-
- boolean contactMustHaveAMotif = false;
- switch (contactState) {
- case OBSERVATION_CANCELLED:
-
- // Non abouti
-
- if (StringUtils.isBlank(contact.getComment())) {
- throw new MissingContactCommentException(contact);
- }
- break;
- case OBSERVATION_DONE:
-
- // Observation réalisée
-
- if (observationBeginDate == null) {
- throw new MissingContactObservationBeginDateException(contact);
- }
- if (observationEndDate == null) {
- throw new MissingContactObservationEndDateException(contact);
- }
- if (contact.getNbObservants() == 0) {
- throw new MissingContactNbObservantsException(contact);
- }
- break;
-
- case CONTACT_REFUSED:
- contactMustHaveAMotif = true;
- break;
- case CONTACT_DEFINITELY_REFUSED:
- contactMustHaveAMotif = true;
- break;
-
- }
-
- //---
- // contactStateMotif
- //---
-
- if (contactMustHaveAMotif && contact.getContactStateMotif() == null) {
- throw new MissingContactStateMotifException(contact);
- }
-
- if (!contactMustHaveAMotif && contact.getContactStateMotif() != null) {
- throw new UnwantedContactContactStateMotifException(contact);
- }
-
- if (contact.isMammalsCapture() && StringUtils.isBlank(contact.getMammalsInfo())) {
- throw new MissingContactMammalsInfoException(contact);
- }
-
- if (BooleanUtils.isTrue(contact.getValidationCompany())) {
-
- //---
- // validationCompany
- //---
-
- if (ContactState.OBSERVATION_DONE == contactState) {
- if (contact.getObservedDataControl() == null) {
- throw new MissingContactObservedDataControlException(contact);
- } else if (contact.getObservedDataControl().equals(ObservedDataControl.CORRECTION_ASKED)) {
- throw new ContactWithObservedDataControlToCorrectionAskedException(contact);
- }
- }
-
- // Pour valider un contact société, il faut que le contact aie une date de transmission
- Date restitution = contact.getRestitution();
- if (ObservedDataControl.ACCEPTED == contact.getObservedDataControl() && restitution == null) {
- throw new MissingContactRestitutionException(contact);
- }
- if (dataInputDate == null && restitution != null) {
- throw new MissingContactDataInputDateException(contact);
- }
- if (dataInputDate != null && restitution != null && restitution.before(dataInputDate)) {
- throw new ContactRestitutionDateBeforeDataInputDateException(contact);
- }
- }
-
- DataReliability dataReliability = contact.getDataReliability();
-
- if (dataReliability != null && dataReliability.isCommentRequired() && StringUtils.isBlank(contact.getCommentAdmin())) {
- throw new MissingContactCommentAdminException(contact);
- }
-
- if (BooleanUtils.isTrue(contact.getValidationProgram())) {
-
- //---
- // validationProgram
- //---
-
- // it's an admin validation, data-reliability field must be filled
-
- if (dataReliability == null || DataReliability.UNKNOWN == dataReliability) {
- throw new MissingContactDataReliabilityException(contact);
- }
- }
- }
- }
-
- public void save(UpdateContactCommand updateContactCommand,
- boolean needUpdate) throws ContactNotUpdatableException {
-
- if (needUpdate) {
- Preconditions.checkState(!updateContactCommand.isCreation());
- }
-
- save0(updateContactCommand);
-
- commit();
-
- updateAllegroWalletIfNecessary(updateContactCommand);
-
- notifyMammalsObservationIfNecessary(updateContactCommand);
-
- }
-
- protected void notifyMammalsObservationIfNecessary(UpdateContactCommand updateContactCommand) {
-
- if (updateContactCommand.isMammalsInfosChanged()) {
-
- Contact contact = updateContactCommand.getContact();
-
- MammalsObservationEmail email = getEmailService().newMammalsObservationEmail();
- email.setContact(contact);
-
- // now trying to find to what user we need to send the mail
- WaoUserTopiaDao userDao = getWaoUserDao();
- // users contains all the user we need to notify for the capture
- List<WaoUser> waoUsers = userDao.forMammalsNotificationsEquals(true).addEquals(WaoUser.PROPERTY_ACTIVE, true).findAll();
-
- for (WaoUser waoUser : waoUsers) {
- if (StringUtil.isEmail(waoUser.getLogin())) {
- email.addBcc(waoUser);
- } else {
- if (log.isWarnEnabled()) {
- log.warn("will not send mammals capture notification to user " + waoUser + ". login is not an email");
- }
- }
- }
-
- getEmailService().send(email);
-
- }
-
- }
-
- public void delete(String contactId) throws IllegalDeletionException {
-
- Contact contact = getContact(contactId);
-
- // Execute delete
- ContactTopiaDao dao = getContactDao();
-
- Map<Class<? extends TopiaEntity>, List<? extends TopiaEntity>> allUsages = dao.findAllUsages(contact);
-
- if (!allUsages.isEmpty()) {
- throw new IllegalDeletionException(allUsages);
- }
-
- ObsMerSamplingPlanService samplingPlanService = newService(ObsMerSamplingPlanService.class);
-
- samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
-
- dao.delete(contact);
-
- commit();
- }
-
- protected void save0(UpdateContactCommand updateContactCommand) {
-
- // Get contact to validate (must exist)
- Contact contact = updateContactCommand.getContact();
-
- ContactTopiaDao dao = getContactDao();
-
- ObsMerSamplingPlanService samplingPlanService = newService(ObsMerSamplingPlanService.class);
-
- if (updateContactCommand.isCreation()) {
-
- //Update the elligible boat depends on contact creation. The
- //{@code contact} reference can only be created for a sampleRow and a
- //boat if both are linked with an elligibleBoat. So this method is
- //used to create the link if needed during contacts import. This
- //elligibleBoat is needed for the contact owned by a company, so
- //the companyActive property of ElligibleBoat will be set to TRUE. No
- //admin has decided to explicitly create this link.
-
- ElligibleBoatTopiaDao elligibleDAO = getElligibleBoatDao();
- ElligibleBoat elligible = elligibleDAO.findUniqueOrNull(contact);
-
- if (elligible == null) {
- // Create new elligible boat not active in a global way
- elligible = elligibleDAO.create(contact);
- }
- elligible.setCompanyActive(Boolean.TRUE);
-
- if (contact.getCreationDate() == null) {
- contact.setCreationDate(serviceContext.getNow());
- }
-
- samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
-
- dao.create(contact);
-
- } else {
-
- samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
-
- dao.update(contact);
- }
-
- }
-
- protected void updateAllegroWalletIfNecessary(UpdateContactCommand updateContactCommand) {
-
- Contact contact = updateContactCommand.getContact();
- ContactState contactState = contact.getContactState();
- ObsProgram obsProgram = contact.getObsProgram();
-
- boolean addBoatToObserversAllegroWallet = false;
-
- if (obsProgram == ObsProgram.OBSMER) {
- addBoatToObserversAllegroWallet = contactState == ContactState.OBSERVATION_DONE
- || contactState == ContactState.OBSERVATION_EXPECTED;
- } else if (obsProgram == ObsProgram.OBSVENTE) {
- addBoatToObserversAllegroWallet = ContactState.OBSERVATION_DONE == contactState;
- }
-
- if (addBoatToObserversAllegroWallet) {
-
- Boat boat = contact.getBoat();
-
- String info;
-
- if (contactState == ContactState.OBSERVATION_EXPECTED) {
- info = I18n.l(
- serviceContext.getLocale(),
- "wao.email.addBoatToUserAllegroWallet.contactExpected",
- WaoUtils.formatDate(serviceContext.getLocale(), contact.getObservationBeginDate()));
- } else if (contactState == ContactState.OBSERVATION_DONE) {
- info = I18n.l(
- serviceContext.getLocale(),
- "wao.email.addBoatToUserAllegroWallet.contactDone",
- WaoUtils.formatDateTime(serviceContext.getLocale(), contact.getObservationBeginDate()),
- WaoUtils.formatDateTime(serviceContext.getLocale(), contact.getObservationEndDate()));
- } else {
- throw new IllegalStateException(contactState + " should not lead to a mail sent");
- }
-
- // in obsvente, only the main observer
- Collection<WaoUser> observers;
- if (ObsProgram.OBSVENTE.equals(obsProgram)) {
- observers = ImmutableSet.of(contact.getMainObserver());
- } else if (ObsProgram.OBSMER.equals(obsProgram)) {
- observers = contact.getAllObservers();
- } else {
- throw new IllegalStateException();
- }
-
- EmailService emailService = getEmailService();
-
- WaoUserTopiaDao waoUserDao = getWaoUserDao();
-
- for (WaoUser observer : observers) {
-
- boolean boatAlreadyInWallet = observer.containsAllegroWallet(boat);
-
- if (boatAlreadyInWallet) {
-
- if (log.isInfoEnabled()) {
- log.info("user " + observer + " already has " + boat + " in his allegroWallet");
- }
-
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("user " + observer + " miss " + boat + " in his allegro wallet, adding");
- }
-
- String observerLogin = observer.getLogin();
- String emailToUpdateAllegroWallets = getApplicationConfig().getEmailToUpdateAllegroWallets();
-
- AddBoatToUserAllegroWalletEmail email =
- emailService.newAddBoatToUserAllegroWalletEmail();
-
- email.setBoat(boat);
- email.setObserver(observer);
- email.setInfo(info);
- email.setObsProgram(contact.getObsProgram());
-
- if ( ! StringUtil.isEmail(observerLogin)) {
- if (log.isInfoEnabled()) {
- log.info("user login is not a email, won't send anything: " + observerLogin + " email=" + email);
- }
- } else if ( ! observer.isActive()) {
- if (log.isInfoEnabled()) {
- log.info("observer is no longer active, won't send " + email);
- }
- } else if (StringUtils.isBlank(emailToUpdateAllegroWallets)) {
- if (log.isInfoEnabled()) {
- log.info("no email to update allegro wallets provided in configuration, won't send " + email);
- }
- } else if ( ! StringUtil.isEmail(emailToUpdateAllegroWallets)) {
- if (log.isWarnEnabled()) {
- log.warn("email to update allegro wallets provided in configuration is not valid, won't send " + emailToUpdateAllegroWallets);
- }
- } else {
-
- email.addBcc(observer);
-
- email.addTo(emailToUpdateAllegroWallets);
-
- emailService.send(email);
-
- observer.addAllegroWallet(boat);
- waoUserDao.update(observer);
- commit();
-
- }
- }
- }
- }
- }
-
- public Contact createContact(AuthenticatedWaoUser authenticatedWaoUser, String sampleRowId, String boatId) {
-
- if (log.isInfoEnabled()) {
- log.info(authenticatedWaoUser.getWaoUser() + " is creating a contact for " + sampleRowId + " and " + boatId);
- }
-
- UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser, Optional.<String>absent());
-
- Boat boat = getBoatDao().findByTopiaId(boatId);
- Preconditions.checkState(boat.isActive(), "boat must be active");
-
- SampleRow sampleRow = getSampleRowDao().findByTopiaId(sampleRowId);
- ObsProgram obsProgram = sampleRow.getObsProgram();
-
- WaoUser observer = authenticatedWaoUser.getWaoUser();
- Contact mostRecentContactOrNull = getContactDao().findMostRecentContactOrNull(obsProgram, boatId, observer.getCompany().getTopiaId());
- Preconditions.checkState(
- mostRecentContactOrNull == null || mostRecentContactOrNull.getContactState().isFinalState(),
- "contact already exists");
-
- Date now = serviceContext.getNow();
-
- Contact newContact = updateContactCommand.getContact();
- newContact.setDataReliability(DataReliability.UNKNOWN);
- newContact.setBoat(boat);
- newContact.setMainObserver(observer);
- newContact.setSampleRow(sampleRow);
- newContact.setCreationDate(now);
-
- // initial contact state depends on the program
- if (obsProgram == ObsProgram.OBSMER) {
- newContact.setContactState(ContactState.CONTACT_START);
- } else if (obsProgram == ObsProgram.OBSVENTE) {
- newContact.setContactState(ContactState.OBSERVATION_EXPECTED);
- }
-
- // we can suppose a new contact default values are the one
- // expected in the sampling plan
-
- if (newContact.getObsProgram() == ObsProgram.OBSVENTE) {
- // we hope in this contact, user used expected sampling strategy
- newContact.setSamplingStrategy(sampleRow.getSamplingStrategy());
- }
-
- // In the case of ObsVente, we may have a user who wants to create
- // multiple contact for a same day. Here we try, to ease the input
- // of data by trying to pre-fill some field using data given
- // in a previous entered contact
-
- if (newContact.getObsProgram() == ObsProgram.OBSVENTE) {
- // try to pre-fill some field for user-experience
-
- // let's try to find a recent similar contact
- Map<String, Object> properties = new HashMap<>();
- properties.put(Contact.PROPERTY_OBS_PROGRAM_ORDINAL, newContact.getObsProgram().ordinal());
- properties.put(Contact.PROPERTY_SAMPLE_ROW, sampleRow);
- properties.put(Contact.PROPERTY_MAIN_OBSERVER, observer);
-
- List<Contact> candidates = getContactDao().forProperties(properties).findAll();
-
- Contact similarContact = null; // to be found among candidates
- for (Contact candidate : candidates) {
- if (DateUtil.getDifferenceInDays(candidate.getCreationDate(), now) <= 1) {
- similarContact = candidate;
- }
- }
-
- if (log.isDebugEnabled()) {
- String logMessage;
- if (similarContact == null) {
- logMessage = "no similar contact found";
- } else {
- logMessage = "similar contact found to pre-fill values of contact : "
- + similarContact.getTopiaId() + " boat = " + similarContact.getBoat().getName();
- }
- log.debug(logMessage);
- }
-
- if (similarContact != null) {
- newContact.setObservationBeginDate(similarContact.getObservationBeginDate());
- newContact.setObservationEndDate(similarContact.getObservationEndDate());
- newContact.setTerrestrialLocation(similarContact.getTerrestrialLocation());
- newContact.clearSecondaryObservers();
- newContact.addAllSecondaryObservers(similarContact.getSecondaryObservers());
- newContact.setDataInputDate(similarContact.getDataInputDate());
- }
- }
-
- save0(updateContactCommand);
-
- commit();
-
- return newContact;
-
- }
-
-}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -46,7 +46,7 @@
public ContactsFilter newFilter(AuthenticatedWaoUser authenticatedWaoUser) {
- ContactsService contactsService = newService(ObsMerContactsService.class);
+ ContactsService contactsService = newService(ContactsService.class);
ContactsFilter newFilter = contactsService.newContactFilter(authenticatedWaoUser);
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -57,6 +57,8 @@
protected Set<String> secondaryObserverIds = new HashSet<>();
+ private String terrestrialLocationId;
+
public boolean isCreation() {
return creation;
}
@@ -180,4 +182,12 @@
public void setSecondaryObserverIds(Set<String> secondaryObserverIds) {
this.secondaryObserverIds = secondaryObserverIds;
}
+
+ public String getTerrestrialLocationId() {
+ return terrestrialLocationId;
+ }
+
+ public void setTerrestrialLocationId(String terrestrialLocationId) {
+ this.terrestrialLocationId = terrestrialLocationId;
+ }
}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -96,6 +96,7 @@
import java.io.InputStream;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -1130,4 +1131,21 @@
return dcf5Codes;
}
+
+ public List<TerrestrialLocation> getTerrestrialLocationInDistricts(Collection<TerrestrialLocation> terrestrialDistricts) {
+
+ Set districtCodes = new HashSet();
+ for (TerrestrialLocation terrestrialDistrict : terrestrialDistricts) {
+ Preconditions.checkArgument(terrestrialDistrict.isDistrict());
+ districtCodes.add(terrestrialDistrict.getDistrictCode());
+ }
+
+ TerrestrialLocationTopiaDao dao = getTerrestrialLocationDao();
+
+ List<TerrestrialLocation> locationsInDistricts = dao.forLocationTypeIn(ImmutableSet.of(LocationType.PORT, LocationType.AUCTION)).addIn(TerrestrialLocation.PROPERTY_DISTRICT_CODE, districtCodes).findAll();
+
+ return locationsInDistricts;
+
+ }
+
}
Deleted: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,332 +0,0 @@
-/*
- * #%L
- * Wao :: Business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2011 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.wao.services.service.csv;
-
-import fr.ifremer.wao.entity.Boat;
-import fr.ifremer.wao.entity.Company;
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.entity.ContactImpl;
-import fr.ifremer.wao.entity.ContactState;
-import fr.ifremer.wao.entity.ContactStateMotif;
-import fr.ifremer.wao.entity.DataReliability;
-import fr.ifremer.wao.entity.LocationType;
-import fr.ifremer.wao.entity.ObsDebCode;
-import fr.ifremer.wao.entity.ObsProgram;
-import fr.ifremer.wao.entity.ObservationType;
-import fr.ifremer.wao.entity.ObservedDataControl;
-import fr.ifremer.wao.entity.SampleRow;
-import fr.ifremer.wao.entity.TerrestrialLocation;
-import fr.ifremer.wao.entity.WaoUser;
-import fr.ifremer.wao.services.service.csv.operations.BoatParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.CompanyParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.ContactStateMotivesParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.I18nAbleParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.LocationTypeParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.ObsDebCodeParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.SampleRowParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.UserParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.UsersParserFormatter;
-import org.apache.commons.lang3.StringUtils;
-import org.nuiton.csv.Common;
-import org.nuiton.csv.ExportableColumn;
-import org.nuiton.csv.ImportExportModel;
-import org.nuiton.csv.ImportableColumn;
-import org.nuiton.csv.ModelBuilder;
-import org.nuiton.csv.ValueFormatter;
-import org.nuiton.csv.ValueGetter;
-import org.nuiton.csv.ValueGetterSetter;
-import org.nuiton.csv.ValueParserFormatter;
-import org.nuiton.i18n.I18n;
-
-import java.text.ParseException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-public class ContactImportExportModel implements ImportExportModel<Contact> {
-
- /** will get terrestrial location depending on location code and pushed location type */
- static class TerrestrialLocationParserFormatter implements ValueParserFormatter<TerrestrialLocation> {
-
- protected Map<LocationType, Map<String, TerrestrialLocation>> indexedLocations;
-
- protected List<TerrestrialLocation> terrestrialLocations;
-
- protected ValueGetter<Contact, LocationType> locationTypeGetter;
-
- TerrestrialLocationParserFormatter(List<TerrestrialLocation> terrestrialLocations,
- ValueGetter<Contact, LocationType> locationTypeGetter) {
- this.terrestrialLocations = terrestrialLocations;
- this.locationTypeGetter = locationTypeGetter;
- }
-
- @Override
- public String format(TerrestrialLocation terrestrialLocation) {
- String code = "";
- if (terrestrialLocation != null) {
- code = terrestrialLocation.getCode();
- }
- return code;
- }
-
- @Override
- public TerrestrialLocation parse(String code) throws ParseException {
- if (indexedLocations == null) {
- indexedLocations = new HashMap<>();
- for (TerrestrialLocation terrestrialLocation : terrestrialLocations) {
- LocationType locationType = terrestrialLocation.getLocationType();
- Map<String, TerrestrialLocation> locationsForType = indexedLocations.get(locationType);
- if (locationsForType == null) {
- locationsForType = new HashMap<>();
- }
- locationsForType.put(terrestrialLocation.getCode(), terrestrialLocation);
- indexedLocations.put(locationType, locationsForType);
- }
- }
- TerrestrialLocation terrestrialLocation = null;
- if (StringUtils.isNotBlank(code)) {
- LocationType locationType;
- try {
- locationType = locationTypeGetter.get(null);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- if (locationType == null) {
- throw new IllegalArgumentException(I18n.t("wao.import.contact.failure.locationTypeMissing"));
- }
- terrestrialLocation = indexedLocations.get(locationType).get(code);
- if (terrestrialLocation == null) {
- throw new IllegalArgumentException(I18n.t("wao.import.contact.failure.wrongTerrestrialLocation",
- locationType.toString(), code));
- }
- }
- return terrestrialLocation;
- }
- }
-
- protected final Locale locale;
-
- protected ObsProgram obsProgram;
-
- protected List<WaoUser> waoUsers;
-
- protected List<TerrestrialLocation> terrestrialLocations;
-
- protected List<SampleRow> sampleRows;
-
- protected List<Boat> boats;
-
- protected List<ObsDebCode> obsDebCodes;
-
- protected List<ContactStateMotif> motives;
-
- /** for export */
- public ContactImportExportModel(Locale locale, ObsProgram obsProgram) {
- this.locale = locale;
- this.obsProgram = obsProgram;
- }
-
- /** for import */
- public ContactImportExportModel(Locale locale, ObsProgram obsProgram, List<WaoUser> waoUsers,
- List<TerrestrialLocation> terrestrialLocations,
- List<SampleRow> sampleRows, List<Boat> boats,
- List<ObsDebCode> obsDebCodes, List<ContactStateMotif> motives) {
- this.locale = locale;
- this.obsProgram = obsProgram;
- this.waoUsers = waoUsers;
- this.terrestrialLocations = terrestrialLocations;
- this.sampleRows = sampleRows;
- this.boats = boats;
- this.obsDebCodes = obsDebCodes;
- this.motives = motives;
- }
-
- @Override
- public char getSeparator() {
- return ';';
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> headerNames) {
- // nothing to do
- }
-
- @Override
- public Contact newEmptyInstance() {
- Contact newContact = new ContactImpl();
- newContact.setObsProgram(obsProgram);
- return newContact;
- }
-
- protected ModelBuilder<Contact> getModel() {
- ModelBuilder<Contact> modelBuilder = new ModelBuilder<>();
- modelBuilder.newColumnForImportExport("CONTACT_ID", Contact.PROPERTY_TOPIA_ID);
- modelBuilder.newColumnForImportExport("CONTACT_DATE_CREATION", Contact.PROPERTY_CREATION_DATE, Common.DAY_TIME);
- modelBuilder.newColumnForImportExport("CONTACT_OBSERVATEUR_PRINCIPAL", Contact.PROPERTY_MAIN_OBSERVER, new UserParserFormatter(locale, waoUsers));
- modelBuilder.newColumnForImportExport("CONTACT_OBSERVATEURS_SECONDAIRES", Contact.PROPERTY_SECONDARY_OBSERVERS, new UsersParserFormatter(locale, waoUsers));
- modelBuilder.newIgnoredColumn("CONTACT_OBSERVATEURS_NOMS");
- modelBuilder.newColumnForExport(
- "CONTACT_OBSERVATEURS_NOMS",
- "allObservers",
- new ValueFormatter<List<WaoUser>>() {
- @Override
- public String format(List<WaoUser> value) {
- List<String> fullNames = new LinkedList<>();
- for (WaoUser waoUser : value) {
- fullNames.add(waoUser.getFullName());
- }
- return StringUtils.join(fullNames, ", ");
- }
- }
- );
- modelBuilder.newIgnoredColumn("CONTACT_OBSERVATEURS_SOCIETE");
- modelBuilder.newColumnForExport(
- "CONTACT_OBSERVATEURS_SOCIETE",
- new ValueGetter<Contact, Company>() {
- @Override
- public Company get(Contact contact) {
- return contact.getMainObserver().getCompany();
- }
- },
- new CompanyParserFormatter(locale, null)
- );
- modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new I18nAbleParserFormatter<>(locale, ContactState.getAllowedStates(obsProgram)));
- modelBuilder.newColumnForImportExport("CONTACT_DEBUT_OBSERVATION", Contact.PROPERTY_OBSERVATION_BEGIN_DATE, Common.DAY_TIME);
- modelBuilder.newColumnForImportExport("CONTACT_FIN_OBSERVATION", Contact.PROPERTY_OBSERVATION_END_DATE, Common.DAY_TIME);
- modelBuilder.newColumnForImportExport("CONTACT_SAISIE_DONNEES", Contact.PROPERTY_DATA_INPUT_DATE, Common.DAY);
- modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_OBSERVATEUR", Contact.PROPERTY_COMMENT);
- modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_COORDINATEUR", Contact.PROPERTY_COMMENT_COORDINATOR);
- modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_PROGRAMME", Contact.PROPERTY_COMMENT_ADMIN);
-
- modelBuilder.newColumnForImportExport("NAVIRE_IMMATRICULATION", Contact.PROPERTY_BOAT, new BoatParserFormatter(boats, locale));
- modelBuilder.newIgnoredColumn("NAVIRE_NOM");
- modelBuilder.newColumnForExport("NAVIRE_NOM", new ValueGetter<Contact, String>() {
- @Override
- public String get(Contact contact) throws Exception {
- return contact.getBoat().getName();
- }
- });
- modelBuilder.newColumnForImportExport("CONTACT_VALIDATION_SOCIETE", Contact.PROPERTY_VALIDATION_COMPANY, Common.BOOLEAN);
- modelBuilder.newColumnForImportExport("CONTACT_VALIDATION_PROGRAMME", Contact.PROPERTY_VALIDATION_PROGRAM, Common.BOOLEAN);
-
- modelBuilder.newColumnForImportExport("PLAN_CODE", Contact.PROPERTY_SAMPLE_ROW, new SampleRowParserFormatter(locale, sampleRows));
-
- if (obsProgram == ObsProgram.OBSMER) {
- modelBuilder.newColumnForImportExport("CONTACT_QUALITE_DONNEE", "dataReliability",
- new I18nAbleParserFormatter<>(locale, DataReliability.values()));
- modelBuilder.newColumnForImportExport("CONTACT_OBSERVATION_MAMMIFERE", Contact.PROPERTY_MAMMALS_OBSERVATION, Common.BOOLEAN);
- modelBuilder.newColumnForImportExport("CONTACT_CAPTURE_ACCIDENTELLE", Contact.PROPERTY_MAMMALS_CAPTURE, Common.BOOLEAN);
- modelBuilder.newIgnoredColumn("CONTACT_CAPTURE_ACCIDENTELLE_DETAILS");
- modelBuilder.newColumnForExport("CONTACT_CAPTURE_ACCIDENTELLE_DETAILS", Contact.PROPERTY_MAMMALS_INFO);
- modelBuilder.newColumnForImportExport("CONTACT_ETAT_MOTIF_CODE", Contact.PROPERTY_CONTACT_STATE_MOTIF, new ContactStateMotivesParserFormatter(locale, motives));
- modelBuilder.newIgnoredColumn("CONTACT_ETAT_MOTIF_NOM");
- modelBuilder.newColumnForExport("CONTACT_ETAT_MOTIF_NOM", new ValueGetter<Contact, String>() {
- @Override
- public String get(Contact contact) throws Exception {
- String name = "";
- if (contact.getContactStateMotif() != null) {
- name = contact.getContactStateMotif().getName();
- }
- return name;
- }
- });
- modelBuilder.newColumnForImportExport("CONTACT_TRANSMISSION_RESTITUTION", Contact.PROPERTY_RESTITUTION, Common.DAY);
-
- List<ObservedDataControl> observedDataControlsValues = new LinkedList<>();
- Collections.addAll(observedDataControlsValues, ObservedDataControl.values());
- observedDataControlsValues.add(null);
- I18nAbleParserFormatter<ObservedDataControl> valueParserFormatter = new I18nAbleParserFormatter<>(locale, observedDataControlsValues);
- valueParserFormatter.setAcceptNullValues(true);
- modelBuilder.newColumnForImportExport("CONTACT_DONNEES_ALLEGRO_VALIDEES", Contact.PROPERTY_OBSERVED_DATA_CONTROL, valueParserFormatter);
- } else {
- // FIXME 20110606 bleny contact.getTerrestrialLocation() may be null, export will fail
-
- // terrestrial location for both ObsVente and ObsDeb
- ValueGetterSetter<Contact, LocationType> locationTypeGetter = new Common.ValueSaver<>();
- LocationTypeParserFormatter locationTypeParserFormatter = new LocationTypeParserFormatter(locale);
- modelBuilder.newMandatoryColumn(
- "CONTACT_LIEU_TYPE",
- locationTypeParserFormatter,
- locationTypeGetter);
- modelBuilder.newColumnForExport(
- "CONTACT_LIEU_TYPE",
- new ValueGetter<Contact, LocationType>() {
- @Override
- public LocationType get(Contact contact) throws Exception {
- LocationType locationType = null;
- if (contact.getTerrestrialLocation() != null) {
- locationType = contact.getTerrestrialLocation()
- .getLocationType();
- }
- return locationType;
- }
- },
- locationTypeParserFormatter
- );
- modelBuilder.newColumnForImportExport(
- "CONTACT_LIEU_CODE",
- Contact.PROPERTY_TERRESTRIAL_LOCATION,
- new TerrestrialLocationParserFormatter(terrestrialLocations, locationTypeGetter));
-
- modelBuilder.newIgnoredColumn("CONTACT_LIEU_DESCRIPTION");
- modelBuilder.newColumnForExport("CONTACT_LIEU_DESCRIPTION", new ValueGetter<Contact, String>() {
- @Override
- public String get(Contact contact) throws Exception {
- String description = "";
- if (contact.getTerrestrialLocation() != null) {
- description = contact.getTerrestrialLocation()
- .getDescription();
- }
- return description;
- }
- });
- }
-
- if (obsProgram == ObsProgram.OBSVENTE) {
- modelBuilder.newColumnForImportExport("CONTACT_ECHANTILLONNAGE_COMPLET", Contact.PROPERTY_COMPLETE_SAMPLING, Common.BOOLEAN);
- }
-
- if (obsProgram == ObsProgram.OBSDEB) {
- modelBuilder.newColumnForImportExport("CONTACT_DATE_DEBARQUEMENT", Contact.PROPERTY_LANDING_DATE, Common.DAY_TIME);
- modelBuilder.newColumnForImportExport("CONTACT_TYPE_OBSERVATION", "observationType", new I18nAbleParserFormatter<>(locale, ObservationType.values()));
- modelBuilder.newColumnForImportExport("CONTACT_METIER", Contact.PROPERTY_OBS_DEB_CODE, new ObsDebCodeParserFormatter(locale, obsDebCodes));
- }
-
- return modelBuilder;
- }
-
- @Override
- public Iterable<ExportableColumn<Contact, Object>> getColumnsForExport() {
- return (Iterable) getModel().getColumnsForExport();
- }
-
- @Override
- public Iterable<ImportableColumn<Contact, Object>> getColumnsForImport() {
- return (Iterable) getModel().getColumnsForImport();
- }
-
-}
Copied: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java (from rev 2075, branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,344 @@
+/*
+ * #%L
+ * Wao :: Business
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2011 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.wao.services.service.csv;
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.wao.WaoUtils;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ContactImpl;
+import fr.ifremer.wao.entity.ContactState;
+import fr.ifremer.wao.entity.ContactStateMotif;
+import fr.ifremer.wao.entity.DataReliability;
+import fr.ifremer.wao.entity.LocationType;
+import fr.ifremer.wao.entity.ObsProgram;
+import fr.ifremer.wao.entity.ObservedDataControl;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.TerrestrialLocation;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.services.service.csv.operations.BoatParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.CompanyParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.ContactStateMotivesParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.I18nAbleParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.LocationTypeParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.SampleRowParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.UserParserFormatter;
+import fr.ifremer.wao.services.service.csv.operations.UsersParserFormatter;
+import org.apache.commons.lang3.StringUtils;
+import org.nuiton.csv.Common;
+import org.nuiton.csv.ExportableColumn;
+import org.nuiton.csv.ImportExportModel;
+import org.nuiton.csv.ImportableColumn;
+import org.nuiton.csv.ModelBuilder;
+import org.nuiton.csv.ValueFormatter;
+import org.nuiton.csv.ValueGetter;
+import org.nuiton.csv.ValueGetterSetter;
+import org.nuiton.csv.ValueParserFormatter;
+import org.nuiton.i18n.I18n;
+
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+public class ContactImportExportModel implements ImportExportModel<Contact> {
+
+ protected final Locale locale;
+
+ protected ObsProgram obsProgram;
+
+ protected List<WaoUser> waoUsers;
+
+ protected List<SampleRow> sampleRows;
+
+ protected List<Boat> boats;
+
+ protected List<ContactStateMotif> motives;
+
+ private List<TerrestrialLocation> terrestrialLocations;
+
+ public static ContactImportExportModel forExport(Locale locale,
+ ObsProgram obsProgram) {
+ return new ContactImportExportModel(locale, obsProgram, null, null, null, null, null);
+ }
+
+ public static ContactImportExportModel forImport(Locale locale,
+ ObsProgram obsProgram,
+ List<WaoUser> waoUsers,
+ List<SampleRow> sampleRows,
+ List<Boat> boats,
+ List<ContactStateMotif> motives,
+ List<TerrestrialLocation> terrestrialLocations) {
+
+ Preconditions.checkState(waoUsers != null, "To import must have waoUsers");
+ Preconditions.checkState(boats != null, "To import must have boats");
+ Preconditions.checkState(sampleRows != null, "To import must have sampleRows");
+ Preconditions.checkState(motives != null, "To import must have motives");
+ Preconditions.checkState(terrestrialLocations != null, "To import must have motives");
+ return new ContactImportExportModel(locale, obsProgram, waoUsers, sampleRows, boats, motives, terrestrialLocations);
+ }
+
+ protected ContactImportExportModel(Locale locale,
+ ObsProgram obsProgram,
+ List<WaoUser> waoUsers,
+ List<SampleRow> sampleRows,
+ List<Boat> boats,
+ List<ContactStateMotif> motives,
+ List<TerrestrialLocation> terrestrialLocations) {
+ this.locale = locale;
+ this.obsProgram = obsProgram;
+ this.waoUsers = waoUsers;
+ this.sampleRows = sampleRows;
+ this.boats = boats;
+ this.motives = motives;
+ this.terrestrialLocations = terrestrialLocations;
+ }
+
+ @Override
+ public char getSeparator() {
+ return ';';
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> headerNames) {
+ // nothing to do
+ }
+
+ @Override
+ public Contact newEmptyInstance() {
+ Contact newContact = new ContactImpl();
+ newContact.setObsProgram(obsProgram);
+ return newContact;
+ }
+
+ protected ModelBuilder<Contact> getModel() {
+ ModelBuilder<Contact> modelBuilder = new ModelBuilder<>();
+ modelBuilder.newColumnForImportExport("CONTACT_ID", Contact.PROPERTY_TOPIA_ID);
+ modelBuilder.newColumnForImportExport("CONTACT_DATE_CREATION", Contact.PROPERTY_CREATION_DATE, Common.DAY_TIME);
+ modelBuilder.newColumnForImportExport("CONTACT_OBSERVATEUR_PRINCIPAL", Contact.PROPERTY_MAIN_OBSERVER, new UserParserFormatter(locale, waoUsers));
+ modelBuilder.newColumnForImportExport("CONTACT_OBSERVATEURS_SECONDAIRES", Contact.PROPERTY_SECONDARY_OBSERVERS, new UsersParserFormatter(locale, waoUsers));
+
+ modelBuilder.newIgnoredColumn("CONTACT_OBSERVATEURS_NOMS");
+ modelBuilder.newColumnForExport(
+ "CONTACT_OBSERVATEURS_NOMS",
+ "allObservers",
+ new ValueFormatter<List<WaoUser>>() {
+ @Override
+ public String format(List<WaoUser> value) {
+ List<String> fullNames = new LinkedList<>();
+ for (WaoUser waoUser : value) {
+ fullNames.add(waoUser.getFullName());
+ }
+ return StringUtils.join(fullNames, ", ");
+ }
+ }
+ );
+ modelBuilder.newIgnoredColumn("CONTACT_OBSERVATEURS_SOCIETE");
+ modelBuilder.newColumnForExport(
+ "CONTACT_OBSERVATEURS_SOCIETE",
+ new ValueGetter<Contact, Company>() {
+ @Override
+ public Company get(Contact contact) {
+ return contact.getMainObserver().getCompany();
+ }
+ },
+ new CompanyParserFormatter(locale, null)
+ );
+ modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new I18nAbleParserFormatter<>(locale, ContactState.getAllowedStates(obsProgram)));
+ modelBuilder.newColumnForImportExport("CONTACT_DEBUT_OBSERVATION", Contact.PROPERTY_OBSERVATION_BEGIN_DATE, Common.DAY_TIME);
+ modelBuilder.newColumnForImportExport("CONTACT_FIN_OBSERVATION", Contact.PROPERTY_OBSERVATION_END_DATE, Common.DAY_TIME);
+ modelBuilder.newColumnForImportExport("CONTACT_SAISIE_DONNEES", Contact.PROPERTY_DATA_INPUT_DATE, Common.DAY);
+ modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_OBSERVATEUR", Contact.PROPERTY_COMMENT);
+ modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_COORDINATEUR", Contact.PROPERTY_COMMENT_COORDINATOR);
+ modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_PROGRAMME", Contact.PROPERTY_COMMENT_ADMIN);
+
+ modelBuilder.newColumnForImportExport("NAVIRE_IMMATRICULATION", Contact.PROPERTY_BOAT, new BoatParserFormatter(boats, locale));
+ modelBuilder.newIgnoredColumn("NAVIRE_NOM");
+ modelBuilder.newColumnForExport("NAVIRE_NOM", new ValueGetter<Contact, String>() {
+ @Override
+ public String get(Contact contact) throws Exception {
+ return contact.getBoat().getName();
+ }
+ });
+ modelBuilder.newColumnForImportExport("CONTACT_VALIDATION_SOCIETE", Contact.PROPERTY_VALIDATION_COMPANY, Common.BOOLEAN);
+ modelBuilder.newColumnForImportExport("CONTACT_VALIDATION_PROGRAMME", Contact.PROPERTY_VALIDATION_PROGRAM, Common.BOOLEAN);
+
+ modelBuilder.newColumnForImportExport("PLAN_CODE", Contact.PROPERTY_SAMPLE_ROW, new SampleRowParserFormatter(locale, sampleRows));
+
+ if (obsProgram.isObsMer()) {
+ modelBuilder.newColumnForImportExport("CONTACT_QUALITE_DONNEE", "dataReliability",
+ new I18nAbleParserFormatter<>(locale, DataReliability.values()));
+ modelBuilder.newColumnForImportExport("CONTACT_OBSERVATION_MAMMIFERE", Contact.PROPERTY_MAMMALS_OBSERVATION, Common.BOOLEAN);
+ modelBuilder.newColumnForImportExport("CONTACT_CAPTURE_ACCIDENTELLE", Contact.PROPERTY_MAMMALS_CAPTURE, Common.BOOLEAN);
+ modelBuilder.newIgnoredColumn("CONTACT_CAPTURE_ACCIDENTELLE_DETAILS");
+ modelBuilder.newColumnForExport("CONTACT_CAPTURE_ACCIDENTELLE_DETAILS", Contact.PROPERTY_MAMMALS_INFO);
+ modelBuilder.newColumnForImportExport("CONTACT_ETAT_MOTIF_CODE", Contact.PROPERTY_CONTACT_STATE_MOTIF, new ContactStateMotivesParserFormatter(locale, motives));
+ modelBuilder.newIgnoredColumn("CONTACT_ETAT_MOTIF_NOM");
+ modelBuilder.newColumnForExport("CONTACT_ETAT_MOTIF_NOM", new ValueGetter<Contact, String>() {
+
+ @Override
+ public String get(Contact contact) throws Exception {
+ String name = "";
+ if (contact.getContactStateMotif() != null) {
+ name = contact.getContactStateMotif().getName();
+ }
+ return name;
+ }
+ });
+ modelBuilder.newColumnForImportExport("CONTACT_TRANSMISSION_RESTITUTION", Contact.PROPERTY_RESTITUTION, Common.DAY);
+
+ List<ObservedDataControl> observedDataControlsValues = new LinkedList<>();
+ Collections.addAll(observedDataControlsValues, ObservedDataControl.values());
+ observedDataControlsValues.add(null);
+ I18nAbleParserFormatter<ObservedDataControl> valueParserFormatter = new I18nAbleParserFormatter<>(locale, observedDataControlsValues);
+ valueParserFormatter.setAcceptNullValues(true);
+ modelBuilder.newColumnForImportExport("CONTACT_DONNEES_ALLEGRO_VALIDEES", Contact.PROPERTY_OBSERVED_DATA_CONTROL, valueParserFormatter);
+ }
+
+ if (obsProgram.isObsVente()) {
+ modelBuilder.newColumnForImportExport("CONTACT_ECHANTILLONNAGE_COMPLET", Contact.PROPERTY_COMPLETE_SAMPLING, Common.BOOLEAN);
+
+ // FIXME 20110606 bleny contact.getTerrestrialLocation() may be null, export will fail
+
+ // terrestrial location for both ObsVente and ObsDeb
+ ValueGetterSetter<Contact, LocationType> locationTypeGetter = new Common.ValueSaver<>();
+ LocationTypeParserFormatter locationTypeParserFormatter = new LocationTypeParserFormatter(locale);
+ modelBuilder.newMandatoryColumn(
+ "CONTACT_LIEU_TYPE",
+ locationTypeParserFormatter,
+ locationTypeGetter);
+ modelBuilder.newColumnForExport(
+ "CONTACT_LIEU_TYPE",
+ new ValueGetter<Contact, LocationType>() {
+ @Override
+ public LocationType get(Contact contact) throws Exception {
+ LocationType locationType = null;
+ if (contact.getTerrestrialLocation() != null) {
+ locationType = contact.getTerrestrialLocation()
+ .getLocationType();
+ }
+ return locationType;
+ }
+ },
+ locationTypeParserFormatter);
+ modelBuilder.newColumnForImportExport(
+ "CONTACT_LIEU_CODE",
+ Contact.PROPERTY_TERRESTRIAL_LOCATION,
+ new TerrestrialLocationParserFormatter(locale, terrestrialLocations, locationTypeGetter));
+
+ modelBuilder.newIgnoredColumn("CONTACT_LIEU_DESCRIPTION");
+ modelBuilder.newColumnForExport("CONTACT_LIEU_DESCRIPTION", new ValueGetter<Contact, String>() {
+ @Override
+ public String get(Contact contact) throws Exception {
+ String description = "";
+ if (contact.getTerrestrialLocation() != null) {
+ description = contact.getTerrestrialLocation()
+ .getDescription();
+ }
+ return description;
+ }
+ });
+
+ }
+
+ return modelBuilder;
+ }
+
+ @Override
+ public Iterable<ExportableColumn<Contact, Object>> getColumnsForExport() {
+ return (Iterable) getModel().getColumnsForExport();
+ }
+
+ @Override
+ public Iterable<ImportableColumn<Contact, Object>> getColumnsForImport() {
+ return (Iterable) getModel().getColumnsForImport();
+ } /** will get terrestrial location depending on location code and pushed location type */
+
+ protected static class TerrestrialLocationParserFormatter implements ValueParserFormatter<TerrestrialLocation> {
+
+ protected Locale locale;
+
+ protected Map<LocationType, Map<String, TerrestrialLocation>> indexedLocations;
+
+ protected List<TerrestrialLocation> terrestrialLocations;
+
+ protected ValueGetter<Contact, LocationType> locationTypeGetter;
+
+ TerrestrialLocationParserFormatter(Locale locale,
+ List<TerrestrialLocation> terrestrialLocations,
+ ValueGetter<Contact, LocationType> locationTypeGetter) {
+ this.locale = locale;
+ this.terrestrialLocations = terrestrialLocations;
+ this.locationTypeGetter = locationTypeGetter;
+ }
+
+ @Override
+ public String format(TerrestrialLocation terrestrialLocation) {
+ String code = "";
+ if (terrestrialLocation != null) {
+ code = terrestrialLocation.getCode();
+ }
+ return code;
+ }
+
+ @Override
+ public TerrestrialLocation parse(String code) throws ParseException {
+ if (indexedLocations == null) {
+ indexedLocations = new HashMap<>();
+ for (TerrestrialLocation terrestrialLocation : terrestrialLocations) {
+ LocationType locationType = terrestrialLocation.getLocationType();
+ Map<String, TerrestrialLocation> locationsForType = indexedLocations.get(locationType);
+ if (locationsForType == null) {
+ locationsForType = new HashMap<>();
+ }
+ locationsForType.put(terrestrialLocation.getCode(), terrestrialLocation);
+ indexedLocations.put(locationType, locationsForType);
+ }
+ }
+ TerrestrialLocation terrestrialLocation = null;
+ if (StringUtils.isNotBlank(code)) {
+ LocationType locationType;
+ try {
+ locationType = locationTypeGetter.get(null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ if (locationType == null) {
+ throw new IllegalArgumentException(I18n.l(locale, "wao.import.contact.failure.locationTypeMissing"));
+ }
+ terrestrialLocation = indexedLocations.get(locationType).get(code);
+ if (terrestrialLocation == null) {
+ throw new IllegalArgumentException(I18n.l(locale, "wao.import.contact.failure.wrongTerrestrialLocation",
+ WaoUtils.l(locale, locationType), code));
+ }
+ }
+ return terrestrialLocation;
+ }
+ }
+
+}
Deleted: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerContactImportExportModel.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,217 +0,0 @@
-/*
- * #%L
- * Wao :: Business
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2011 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.wao.services.service.csv;
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.wao.entity.Boat;
-import fr.ifremer.wao.entity.Company;
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.entity.ContactImpl;
-import fr.ifremer.wao.entity.ContactState;
-import fr.ifremer.wao.entity.ContactStateMotif;
-import fr.ifremer.wao.entity.DataReliability;
-import fr.ifremer.wao.entity.ObsProgram;
-import fr.ifremer.wao.entity.ObservedDataControl;
-import fr.ifremer.wao.entity.SampleRow;
-import fr.ifremer.wao.entity.WaoUser;
-import fr.ifremer.wao.services.service.csv.operations.BoatParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.CompanyParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.ContactStateMotivesParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.I18nAbleParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.SampleRowParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.UserParserFormatter;
-import fr.ifremer.wao.services.service.csv.operations.UsersParserFormatter;
-import org.apache.commons.lang3.StringUtils;
-import org.nuiton.csv.Common;
-import org.nuiton.csv.ExportableColumn;
-import org.nuiton.csv.ImportExportModel;
-import org.nuiton.csv.ImportableColumn;
-import org.nuiton.csv.ModelBuilder;
-import org.nuiton.csv.ValueFormatter;
-import org.nuiton.csv.ValueGetter;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-
-public class ObsMerContactImportExportModel implements ImportExportModel<Contact> {
-
- protected final Locale locale;
-
- protected ObsProgram obsProgram;
-
- protected List<WaoUser> waoUsers;
-
- protected List<SampleRow> sampleRows;
-
- protected List<Boat> boats;
-
- protected List<ContactStateMotif> motives;
-
- public static ObsMerContactImportExportModel forExport(Locale locale,
- ObsProgram obsProgram) {
- return new ObsMerContactImportExportModel(locale, obsProgram, null, null, null, null);
- }
-
- public static ObsMerContactImportExportModel forImport(Locale locale,
- ObsProgram obsProgram,
- List<WaoUser> waoUsers,
- List<SampleRow> sampleRows,
- List<Boat> boats,
- List<ContactStateMotif> motives) {
-
- Preconditions.checkState(waoUsers != null, "To import must have waoUsers");
- Preconditions.checkState(boats != null, "To import must have boats");
- Preconditions.checkState(sampleRows != null, "To import must have sampleRows");
- Preconditions.checkState(motives != null, "To import must have motives");
- return new ObsMerContactImportExportModel(locale, obsProgram, waoUsers, sampleRows, boats, motives);
- }
-
- protected ObsMerContactImportExportModel(Locale locale,
- ObsProgram obsProgram,
- List<WaoUser> waoUsers,
- List<SampleRow> sampleRows,
- List<Boat> boats,
- List<ContactStateMotif> motives) {
- this.locale = locale;
- this.obsProgram = obsProgram;
- this.waoUsers = waoUsers;
- this.sampleRows = sampleRows;
- this.boats = boats;
- this.motives = motives;
- }
-
- @Override
- public char getSeparator() {
- return ';';
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> headerNames) {
- // nothing to do
- }
-
- @Override
- public Contact newEmptyInstance() {
- Contact newContact = new ContactImpl();
- newContact.setObsProgram(obsProgram);
- return newContact;
- }
-
- protected ModelBuilder<Contact> getModel() {
- ModelBuilder<Contact> modelBuilder = new ModelBuilder<>();
- modelBuilder.newColumnForImportExport("CONTACT_ID", Contact.PROPERTY_TOPIA_ID);
- modelBuilder.newColumnForImportExport("CONTACT_DATE_CREATION", Contact.PROPERTY_CREATION_DATE, Common.DAY_TIME);
- modelBuilder.newColumnForImportExport("CONTACT_OBSERVATEUR_PRINCIPAL", Contact.PROPERTY_MAIN_OBSERVER, new UserParserFormatter(locale, waoUsers));
- modelBuilder.newColumnForImportExport("CONTACT_OBSERVATEURS_SECONDAIRES", Contact.PROPERTY_SECONDARY_OBSERVERS, new UsersParserFormatter(locale, waoUsers));
-
- modelBuilder.newIgnoredColumn("CONTACT_OBSERVATEURS_NOMS");
- modelBuilder.newColumnForExport(
- "CONTACT_OBSERVATEURS_NOMS",
- "allObservers",
- new ValueFormatter<List<WaoUser>>() {
- @Override
- public String format(List<WaoUser> value) {
- List<String> fullNames = new LinkedList<>();
- for (WaoUser waoUser : value) {
- fullNames.add(waoUser.getFullName());
- }
- return StringUtils.join(fullNames, ", ");
- }
- }
- );
- modelBuilder.newIgnoredColumn("CONTACT_OBSERVATEURS_SOCIETE");
- modelBuilder.newColumnForExport(
- "CONTACT_OBSERVATEURS_SOCIETE",
- new ValueGetter<Contact, Company>() {
- @Override
- public Company get(Contact contact) {
- return contact.getMainObserver().getCompany();
- }
- },
- new CompanyParserFormatter(locale, null)
- );
- modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new I18nAbleParserFormatter<>(locale, ContactState.getAllowedStates(obsProgram)));
- modelBuilder.newColumnForImportExport("CONTACT_DEBUT_OBSERVATION", Contact.PROPERTY_OBSERVATION_BEGIN_DATE, Common.DAY_TIME);
- modelBuilder.newColumnForImportExport("CONTACT_FIN_OBSERVATION", Contact.PROPERTY_OBSERVATION_END_DATE, Common.DAY_TIME);
- modelBuilder.newColumnForImportExport("CONTACT_SAISIE_DONNEES", Contact.PROPERTY_DATA_INPUT_DATE, Common.DAY);
- modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_OBSERVATEUR", Contact.PROPERTY_COMMENT);
- modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_COORDINATEUR", Contact.PROPERTY_COMMENT_COORDINATOR);
- modelBuilder.newColumnForImportExport("CONTACT_COMMENTAIRE_PROGRAMME", Contact.PROPERTY_COMMENT_ADMIN);
-
- modelBuilder.newColumnForImportExport("NAVIRE_IMMATRICULATION", Contact.PROPERTY_BOAT, new BoatParserFormatter(boats, locale));
- modelBuilder.newIgnoredColumn("NAVIRE_NOM");
- modelBuilder.newColumnForExport("NAVIRE_NOM", new ValueGetter<Contact, String>() {
- @Override
- public String get(Contact contact) throws Exception {
- return contact.getBoat().getName();
- }
- });
- modelBuilder.newColumnForImportExport("CONTACT_VALIDATION_SOCIETE", Contact.PROPERTY_VALIDATION_COMPANY, Common.BOOLEAN);
- modelBuilder.newColumnForImportExport("CONTACT_VALIDATION_PROGRAMME", Contact.PROPERTY_VALIDATION_PROGRAM, Common.BOOLEAN);
-
- modelBuilder.newColumnForImportExport("PLAN_CODE", Contact.PROPERTY_SAMPLE_ROW, new SampleRowParserFormatter(locale, sampleRows));
-
- modelBuilder.newColumnForImportExport("CONTACT_QUALITE_DONNEE", "dataReliability",
- new I18nAbleParserFormatter<>(locale, DataReliability.values()));
- modelBuilder.newColumnForImportExport("CONTACT_OBSERVATION_MAMMIFERE", Contact.PROPERTY_MAMMALS_OBSERVATION, Common.BOOLEAN);
- modelBuilder.newColumnForImportExport("CONTACT_CAPTURE_ACCIDENTELLE", Contact.PROPERTY_MAMMALS_CAPTURE, Common.BOOLEAN);
- modelBuilder.newIgnoredColumn("CONTACT_CAPTURE_ACCIDENTELLE_DETAILS");
- modelBuilder.newColumnForExport("CONTACT_CAPTURE_ACCIDENTELLE_DETAILS", Contact.PROPERTY_MAMMALS_INFO);
- modelBuilder.newColumnForImportExport("CONTACT_ETAT_MOTIF_CODE", Contact.PROPERTY_CONTACT_STATE_MOTIF, new ContactStateMotivesParserFormatter(locale, motives));
- modelBuilder.newIgnoredColumn("CONTACT_ETAT_MOTIF_NOM");
- modelBuilder.newColumnForExport("CONTACT_ETAT_MOTIF_NOM", new ValueGetter<Contact, String>() {
- @Override
- public String get(Contact contact) throws Exception {
- String name = "";
- if (contact.getContactStateMotif() != null) {
- name = contact.getContactStateMotif().getName();
- }
- return name;
- }
- });
- modelBuilder.newColumnForImportExport("CONTACT_TRANSMISSION_RESTITUTION", Contact.PROPERTY_RESTITUTION, Common.DAY);
-
- List<ObservedDataControl> observedDataControlsValues = new LinkedList<>();
- Collections.addAll(observedDataControlsValues, ObservedDataControl.values());
- observedDataControlsValues.add(null);
- I18nAbleParserFormatter<ObservedDataControl> valueParserFormatter = new I18nAbleParserFormatter<>(locale, observedDataControlsValues);
- valueParserFormatter.setAcceptNullValues(true);
- modelBuilder.newColumnForImportExport("CONTACT_DONNEES_ALLEGRO_VALIDEES", Contact.PROPERTY_OBSERVED_DATA_CONTROL, valueParserFormatter);
-
- return modelBuilder;
- }
-
- @Override
- public Iterable<ExportableColumn<Contact, Object>> getColumnsForExport() {
- return (Iterable) getModel().getColumnsForExport();
- }
-
- @Override
- public Iterable<ImportableColumn<Contact, Object>> getColumnsForImport() {
- return (Iterable) getModel().getColumnsForImport();
- }
-
-}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_en_GB.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-06-20 17:38:35 UTC (rev 2078)
@@ -57,6 +57,7 @@
wao.import.contact.failure.missingObservedDataControl=You must provide a value for observed data control
wao.import.contact.failure.missingObserver=Il ne peut y avoir aucun observateur pour l'état '%s'
wao.import.contact.failure.missingRestitution=You must provide the restitution forward date
+wao.import.contact.failure.missingTerrestrialLocation=
wao.import.contact.failure.not.updatable=Insufficient credentials to update contact
wao.import.contact.failure.observationEndDateAfterToday=La date de fin de la marée ne peut pas être postérieure à la date du jour
wao.import.contact.failure.observationEndDateBeforeBeginDate=La date de fin d'observation ne peut pas être antérieure à celle du début
Modified: branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-06-20 17:38:35 UTC (rev 2078)
@@ -54,6 +54,7 @@
wao.import.contact.failure.missingObservedDataControl=Ligne %s \: Il faut préciser une valeur pour le contrôle des données observées
wao.import.contact.failure.missingObserver=Ligne %s \: Il ne peut y avoir aucun observateur pour l'état '%s'
wao.import.contact.failure.missingRestitution=Ligne %s \: Il faut préciser une date de transmission de la restitution de la donnée avant de valider
+wao.import.contact.failure.missingTerrestrialLocation=
wao.import.contact.failure.not.updatable=Ligne %s \: Vous n'avez pas les droits suffisants pour modifier le contact
wao.import.contact.failure.observationEndDateAfterToday=Ligne %s \: La date de fin de la marée doit être antérieure à la date du jour
wao.import.contact.failure.observationEndDateBeforeBeginDate=Ligne %s \: La date de fin d'observation doit être postérieure à celle du début
Copied: branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ContactsServiceTest.java (from rev 2075, branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ContactsServiceTest.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ContactsServiceTest.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,101 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.ContactsFilter;
+import fr.ifremer.wao.services.AbstractWaoServiceTest;
+import fr.ifremer.wao.services.ObsMerFixtures;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.util.DateUtil;
+import org.nuiton.util.pagination.PaginationParameter;
+
+import java.io.InputStream;
+
+public class ContactsServiceTest extends AbstractWaoServiceTest {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ContactsServiceTest.class);
+
+ protected ContactsService service;
+
+ protected ObsMerFixtures fixtures;
+
+ @Before
+ public void setUp() {
+ service = newService(ContactsService.class);
+ fixtures = new ObsMerFixtures(newServiceContext());
+ }
+
+ protected boolean isDatabaseWithReferential() {
+ return true;
+ }
+
+ @Test
+ public void testGetContactsFilterValues() {
+
+ ContactsFilter filter = service.newContactFilter(fixtures.admin());
+
+ ContactsFilterValues filterValues = service.getContactsFilterValues(fixtures.admin(), filter);
+ }
+
+ @Test
+ public void testGetContactsList() {
+
+ ContactsFilter filter = service.newContactFilter(fixtures.admin());
+
+ PaginationParameter pager = service.newContactsPaginationParameter(0, 50);
+
+ ObsMerContactsList contactsList = service.getContactsList(fixtures.admin(), filter, pager);
+ }
+
+ @Test
+ public void testImportContacts() {
+ fixtures.samplingPlan();
+ fixtures.jmichmuche();
+ fixtures.navires();
+
+ // today must be after the observation end date
+ applicationContext.setDate(DateUtil.createDate(1, 2, 2011));
+
+ InputStream input = null;
+ try {
+
+ Assert.assertEquals(0, service.getContactDao().count());
+ input = getClass().getResourceAsStream("/import/contacts.csv");
+ service.importContacts(fixtures.admin(), input);
+ Assert.assertEquals(2, service.getContactDao().count());
+ } catch (ImportErrorException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("unexpected exception raised", e);
+ }
+ Assert.fail("exception should not be raised");
+ } finally {
+ IOUtils.closeQuietly(input);
+ }
+ }
+
+}
Deleted: branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,101 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.ContactsFilter;
-import fr.ifremer.wao.services.AbstractWaoServiceTest;
-import fr.ifremer.wao.services.ObsMerFixtures;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.nuiton.util.DateUtil;
-import org.nuiton.util.pagination.PaginationParameter;
-
-import java.io.InputStream;
-
-public class ObsMerContactsServiceTest extends AbstractWaoServiceTest {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ObsMerContactsServiceTest.class);
-
- protected ObsMerContactsService service;
-
- protected ObsMerFixtures fixtures;
-
- @Before
- public void setUp() {
- service = newService(ObsMerContactsService.class);
- fixtures = new ObsMerFixtures(newServiceContext());
- }
-
- protected boolean isDatabaseWithReferential() {
- return true;
- }
-
- @Test
- public void testGetContactsFilterValues() {
-
- ContactsFilter filter = service.newContactFilter(fixtures.admin());
-
- ContactsFilterValues filterValues = service.getContactsFilterValues(fixtures.admin(), filter);
- }
-
- @Test
- public void testGetContactsList() {
-
- ContactsFilter filter = service.newContactFilter(fixtures.admin());
-
- PaginationParameter pager = service.newContactsPaginationParameter(0, 50);
-
- ObsMerContactsList contactsList = service.getContactsList(fixtures.admin(), filter, pager);
- }
-
- @Test
- public void testImportContacts() {
- fixtures.samplingPlan();
- fixtures.jmichmuche();
- fixtures.navires();
-
- // today must be after the observation end date
- applicationContext.setDate(DateUtil.createDate(1, 2, 2011));
-
- InputStream input = null;
- try {
-
- Assert.assertEquals(0, service.getContactDao().count());
- input = getClass().getResourceAsStream("/import/contacts.csv");
- service.importContacts(fixtures.admin(), input);
- Assert.assertEquals(2, service.getContactDao().count());
- } catch (ImportErrorException e) {
- if (log.isDebugEnabled()) {
- log.debug("unexpected exception raised", e);
- }
- Assert.fail("exception should not be raised");
- } finally {
- IOUtils.closeQuietly(input);
- }
- }
-
-}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,249 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Objects;
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.ContactsFilter;
+import fr.ifremer.wao.WaoUtils;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ContactState;
+import fr.ifremer.wao.entity.DCF5Code;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.services.service.ContactsFilterValues;
+import fr.ifremer.wao.services.service.ContactsService;
+import fr.ifremer.wao.services.service.ObsMerContactsList;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.commons.lang3.time.DateUtils;
+import org.nuiton.util.pagination.PaginationParameter;
+import org.nuiton.util.pagination.PaginationResult;
+
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created on 4/3/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ContactsAction extends WaoJspActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient ContactsService service;
+
+ protected int pageNumber;
+
+ protected long firstRangePage;
+
+ protected long lastRangePage;
+
+ /**
+ * Contacts filter.
+ */
+ protected ContactsFilter filter;
+
+ /**
+ * List of contacts according to the input pager and filter.
+ */
+ protected ObsMerContactsList contactsList;
+
+ public void setService(ContactsService service) {
+ this.service = service;
+ }
+
+ public void setPageNumber(int pageNumber) {
+ this.pageNumber = pageNumber;
+ }
+
+ public long getFirstRangePage() {
+ return firstRangePage;
+ }
+
+ public long getLastRangePage() {
+ return lastRangePage;
+ }
+
+ public ContactsFilter getFilter() {
+ if (filter == null) {
+ prepare();
+ }
+ return filter;
+ }
+
+ public List<Contact> getContacts() {
+ return contactsList.getContacts().getElements();
+ }
+
+ public ContactsFilterValues getFilterValues() {
+ return contactsList.getFilterValues();
+ }
+
+ public PaginationResult<Contact> getPagination() {
+ return contactsList.getContacts();
+ }
+
+ @Override
+ public void prepare() {
+
+ if (filter == null) {
+ filter = service.newContactFilter(getAuthenticatedWaoUser());
+ }
+
+ }
+
+ @Override
+ public String execute() {
+
+ filter = Objects.firstNonNull(session.getContactsFilter(), filter);
+
+ return applyFilter();
+
+ }
+
+ public String resetFilter() {
+
+ filter = service.newContactFilter(getAuthenticatedWaoUser());
+
+ return applyFilter();
+
+ }
+
+ public String applyFilter() {
+
+ getSession().setContactsFilter(filter);
+
+ PaginationParameter pager = service.newContactsPaginationParameter(pageNumber, 25);
+ contactsList = service.getContactsList(getAuthenticatedWaoUser(), filter, pager);
+
+ firstRangePage = getPaginationFirstPage(contactsList.getContacts(), 10);
+ lastRangePage = getPaginationLastPage(contactsList.getContacts(), 10, firstRangePage);
+
+ return SUCCESS;
+
+ }
+
+ protected Date now = new Date();
+
+ public String getFilterPeriodFromPlaceholder() {
+ String placeholder = formatDateTime(DateUtils.addMonths(now, 1));
+ return placeholder;
+ }
+
+ public String getFilterPeriodToPlaceholder() {
+ String placeholder = formatDateTime(DateUtils.addYears(now, 1));
+ return placeholder;
+ }
+
+ public boolean isFullView() {
+ boolean fullView = getAuthenticatedWaoUser().isAdmin() || getAuthenticatedWaoUser().isProfessional();
+ return fullView;
+ }
+
+ public String getMammalsInfo(Contact contact) {
+ return escapeForToolTip(contact.getMammalsInfo());
+ }
+
+ public boolean isBoardingDone(Contact contact) {
+ return ContactState.OBSERVATION_DONE == contact.getContactState();
+ }
+
+ public String getDivision(SampleRow sampleRow) {
+ String result = "";
+ for (FishingZone zone : sampleRow.getFishingZone()) {
+ result += zone.getDistrictCode() + " ";
+ }
+ return result;
+ }
+
+ /**
+ * Devrait résoudre un problème que pose le composant ck/tooltip.
+ * <p/>
+ * Voir ANO#606
+ */
+ public static String escapeForToolTip(String str) {
+ String result = str.replaceAll("\r\n", "\n");
+ result = result.replaceAll("\n", "<br />");
+ result = result.replaceAll("'", "’");
+ result = result.replaceAll("\"", """);
+ result = result.replaceAll("%", "%");
+ return result;
+ }
+
+ public String getContactToHighlightId() {
+ return session.getContactToHighlightId();
+ }
+
+ public Map<String, String> getDcf5CodesAndDescriptions(SampleRow sampleRow) {
+ Map<String, String> dcf5CodesAndDescriptions = new LinkedHashMap<>();
+ for (DCF5Code dcf5Code : sampleRow.getdCF5Code()) {
+ String key = dcf5Code.getCode();
+ String description = dcf5Code.getFishingGearCode() + " - " + WaoUtils.l(getLocale(), dcf5Code.getFishingGearDCF());
+ if (dcf5Code.getTargetSpeciesCode() != null) {
+ description += " ; " + dcf5Code.getTargetSpeciesCode() + " - " + WaoUtils.l(getLocale(), dcf5Code.getTargetSpeciesDCF());
+ }
+ dcf5CodesAndDescriptions.put(key, description);
+ }
+ return dcf5CodesAndDescriptions;
+ }
+
+ public boolean isAcceptable(Contact contact) {
+ boolean acceptable;
+ if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
+ acceptable = contact.isAcceptableByCompany();
+ } else if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
+ acceptable = contact.isAcceptableByProgram();
+ } else {
+ throw new IllegalStateException();
+ }
+ return acceptable;
+ }
+
+ public boolean isRefusable(Contact contact) {
+ boolean refuseable;
+ if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
+ refuseable = contact.isRefusableByCompany();
+ } else if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
+ refuseable = contact.isRefusableByProgram();
+ } else {
+ throw new IllegalStateException();
+ }
+ return refuseable;
+ }
+
+ public boolean isUnacceptable(Contact contact) {
+ boolean unacceptable;
+ if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
+ unacceptable = contact.isUnacceptableByCompany();
+ } else if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
+ unacceptable = contact.isUnacceptableByProgram();
+ } else {
+ throw new IllegalStateException();
+ }
+ return unacceptable;
+ }
+
+}
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsFilterValuesJsonAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsFilterValuesJsonAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsFilterValuesJsonAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsFilterValuesJsonAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,76 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.ContactsFilter;
+import fr.ifremer.wao.services.service.ContactsFilterValues;
+import fr.ifremer.wao.services.service.ContactsService;
+import fr.ifremer.wao.web.WaoJsonActionSupport;
+
+/**
+ * Created on 4/3/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ContactsFilterValuesJsonAction extends WaoJsonActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient ContactsService service;
+
+ protected ContactsFilter filter;
+
+ protected ContactsFilterValues filterValues;
+
+ public void setService(ContactsService service) {
+ this.service = service;
+ }
+
+ public ContactsFilter getFilter() {
+ if (filter == null) {
+ prepare();
+ }
+ return filter;
+ }
+
+ public ContactsFilterValues getFilterValues() {
+ return filterValues;
+ }
+
+ @Override
+ public void prepare() {
+
+ filter = service.newContactFilter(session.getAuthenticatedWaoUser());
+ }
+
+ @Override
+ public String execute() {
+
+ filterValues = service.getContactsFilterValues(session.getAuthenticatedWaoUser(), filter);
+
+ return SUCCESS;
+
+ }
+
+}
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/CreateContactAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/CreateContactAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/CreateContactAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,45 @@
+package fr.ifremer.wao.web.action;
+
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.services.service.ContactsService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+
+@Results({
+ @Result(name="success", type="redirectAction", params = { "actionName", "contacts" })
+})
+public class CreateContactAction extends WaoJspActionSupport {
+
+ protected ContactsService service;
+
+ protected String boatId;
+
+ protected String sampleRowId;
+
+ public void setService(ContactsService service) {
+ this.service = service;
+ }
+
+ public void setBoatId(String boatId) {
+ this.boatId = boatId;
+ }
+
+ public void setSampleRowId(String sampleRowId) {
+ this.sampleRowId = sampleRowId;
+ }
+
+ @Override
+ public String execute() {
+
+ Contact contact = service.createContact(getAuthenticatedWaoUser(), sampleRowId, boatId);
+
+ session.setStartBoatSelectionForSampleRowId(null);
+
+ session.setContactToHighlightId(contact.getTopiaId());
+
+ return SUCCESS;
+
+ }
+
+}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/DeleteContactAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteContactAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/DeleteContactAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/DeleteContactAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,84 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.services.service.ContactsService;
+import fr.ifremer.wao.services.service.IllegalDeletionException;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+
+/**
+ * Created on 4/3/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+@Results({
+ @Result(name = "error", type = "redirectAction", params = {"actionName", "edit-contact!input", "contactId", "%{contactId}"}),
+ @Result(name = "success", type = "redirectAction", params = {"actionName", "contacts"})
+ })
+public class DeleteContactAction extends WaoJspActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String contactId;
+
+ protected transient ContactsService service;
+
+ public void setService(ContactsService service) {
+ this.service = service;
+ }
+
+ public void setContactId(String contactId) {
+ this.contactId = contactId;
+ }
+
+ public String getContactId() {
+ return contactId;
+ }
+
+ @Override
+ public String execute() {
+
+ Contact contact = service.getContact(contactId);
+ String contactCode = contact.getMainObserver().getFullName();
+
+ String result;
+ try {
+ service.delete(contactId);
+
+ session.addMessage(t("wao.ui.action.deleteContact.success", contactCode));
+
+ result = SUCCESS;
+
+ } catch (IllegalDeletionException e) {
+
+ session.addErrorMessages(t("wao.ui.action.deleteContact.failure", contactCode));
+ session.addErrorMessages(e.getExplanation(getLocale()));
+
+ result = ERROR;
+ }
+ return result;
+ }
+}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,351 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+import com.google.common.collect.Sets;
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.WaoUtils;
+import fr.ifremer.wao.entity.ContactState;
+import fr.ifremer.wao.entity.ContactStateMotif;
+import fr.ifremer.wao.entity.DataReliability;
+import fr.ifremer.wao.entity.ObservedDataControl;
+import fr.ifremer.wao.entity.SamplingStrategy;
+import fr.ifremer.wao.entity.TerrestrialLocation;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.WaoUsers;
+import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException;
+import fr.ifremer.wao.services.service.ContactDataInputDateBeforeObservationEndDateException;
+import fr.ifremer.wao.services.service.ContactNotUpdatableException;
+import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException;
+import fr.ifremer.wao.services.service.ContactObservationEndDateBeforeBeginDateException;
+import fr.ifremer.wao.services.service.ContactRestitutionDateBeforeDataInputDateException;
+import fr.ifremer.wao.services.service.ContactWithObservedDataControlToCorrectionAskedException;
+import fr.ifremer.wao.services.service.ContactsService;
+import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException;
+import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException;
+import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException;
+import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException;
+import fr.ifremer.wao.services.service.MissingContactCommentAdminException;
+import fr.ifremer.wao.services.service.MissingContactCommentException;
+import fr.ifremer.wao.services.service.MissingContactDataInputDateException;
+import fr.ifremer.wao.services.service.MissingContactDataReliabilityException;
+import fr.ifremer.wao.services.service.MissingContactMainObserverException;
+import fr.ifremer.wao.services.service.MissingContactMammalsInfoException;
+import fr.ifremer.wao.services.service.MissingContactNbObservantsException;
+import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException;
+import fr.ifremer.wao.services.service.MissingContactObservationEndDateException;
+import fr.ifremer.wao.services.service.MissingContactObservedDataControlException;
+import fr.ifremer.wao.services.service.MissingContactRestitutionException;
+import fr.ifremer.wao.services.service.MissingContactStateMotifException;
+import fr.ifremer.wao.services.service.MissingContactTerrestrialLocationException;
+import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException;
+import fr.ifremer.wao.services.service.UpdateContactCommand;
+import fr.ifremer.wao.services.service.administration.ReferentialService;
+import fr.ifremer.wao.services.service.administration.WaoUsersService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+
+import java.util.Date;
+import java.util.EnumMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * Created on 4/6/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+@Results({@Result(name = "success", type = "redirectAction", params = {"actionName", "contacts"})})
+public class EditContactAction extends WaoJspActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Id of contact to edit.
+ */
+ protected Optional<String> optionalContactId = Optional.absent();
+
+ protected Map<String, String> observers;
+
+ protected Map<String, String> terrestrialLocations;
+
+ protected Map<ContactState, String> contactStates;
+
+ protected Map<String, String> contactStateMotives;
+
+ protected Map<ObservedDataControl, String> observedDataControls;
+
+ protected Map<DataReliability, String> dataReliabilities;
+
+ protected Map<SamplingStrategy, String> samplingStrategies;
+
+ protected transient ContactsService service;
+
+ protected transient WaoUsersService waoUsersService;
+
+ protected transient ReferentialService referentialService;
+
+ protected UpdateContactCommand updateContactCommand;
+
+ public void setService(ContactsService service) {
+ this.service = service;
+ }
+
+ public void setWaoUsersService(WaoUsersService waoUsersService) {
+ this.waoUsersService = waoUsersService;
+ }
+
+ public void setReferentialService(ReferentialService referentialService) {
+ this.referentialService = referentialService;
+ }
+
+ public void setContactId(String contactId) {
+ this.optionalContactId = Optional.fromNullable(Strings.emptyToNull(contactId));
+ }
+
+ public String getContactId() {
+ return optionalContactId.orNull();
+ }
+
+ public UpdateContactCommand getUpdateContactCommand() {
+ if (updateContactCommand == null) {
+ prepare();
+ }
+ return updateContactCommand;
+ }
+
+ public Map<String, String> getObservers() {
+ if (observers == null) {
+ prepare();
+ }
+ return observers;
+ }
+
+ public Map<ContactState, String> getContactStates() {
+ if (contactStates == null) {
+ prepare();
+ }
+ return contactStates;
+ }
+
+ public Map<String, String> getContactStateMotives() {
+ if (contactStateMotives == null) {
+ prepare();
+ }
+ return contactStateMotives;
+ }
+
+ public Map<ObservedDataControl, String> getObservedDataControls() {
+ if (observedDataControls == null) {
+ prepare();
+ }
+ return observedDataControls;
+ }
+
+ public Map<DataReliability, String> getDataReliabilities() {
+ if (dataReliabilities == null) {
+ prepare();
+ }
+ return dataReliabilities;
+ }
+
+ public Map<String, String> getTerrestrialLocations() {
+ if (terrestrialLocations == null) {
+ prepare();
+ }
+ return terrestrialLocations;
+ }
+
+ public Map<SamplingStrategy, String> getSamplingStrategies() {
+ if (samplingStrategies == null) {
+ prepare();
+ }
+ return samplingStrategies;
+ }
+
+ public String getDateTimePlaceholder() {
+ return formatDateTime(new Date());
+ }
+
+ public String getDatePlaceholder() {
+ return formatDate(new Date());
+ }
+
+ @Override
+ public void prepare() {
+
+ updateContactCommand = service.newUpdateContactCommand(getAuthenticatedWaoUser(), optionalContactId);
+
+ List<WaoUser> waoUsers = waoUsersService.getActiveWaoUsers(Optional.of(updateContactCommand.getContact().getSampleRow().getCompany().getTopiaId()));
+ Set<WaoUser> sortedWaoUsers = Sets.newTreeSet(WaoUsers.fullNameComparator());
+ sortedWaoUsers.addAll(waoUsers);
+ observers = new LinkedHashMap<>();
+ for (WaoUser waoUser : sortedWaoUsers) {
+ observers.put(waoUser.getTopiaId(), waoUser.getFullName());
+ }
+ contactStates = new EnumMap<>(ContactState.class);
+ for (ContactState contactState : ContactState.getAllowedStates(getAuthenticatedWaoUser().getObsProgram())) {
+ contactStates.put(contactState, WaoUtils.l(getLocale(), contactState));
+ }
+
+ contactStateMotives = new TreeMap<>();
+ for (ContactStateMotif contactStateMotif : referentialService.getAllContactStateMotifs(null)) {
+ contactStateMotives.put(contactStateMotif.getTopiaId(), contactStateMotif.getName());
+ }
+
+ observedDataControls = new EnumMap<>(ObservedDataControl.class);
+ for (ObservedDataControl observedDataControl : ObservedDataControl.values()) {
+ observedDataControls.put(observedDataControl, WaoUtils.l(getLocale(), observedDataControl));
+ }
+
+ dataReliabilities = new EnumMap<>(DataReliability.class);
+ for (DataReliability dataReliability : DataReliability.values()) {
+ dataReliabilities.put(dataReliability, WaoUtils.l(getLocale(), dataReliability));
+ }
+
+ samplingStrategies = new EnumMap<>(SamplingStrategy.class);
+ for (SamplingStrategy samplingStrategy : SamplingStrategy.values()) {
+ samplingStrategies.put(samplingStrategy, WaoUtils.l(getLocale(), samplingStrategy));
+ }
+
+ terrestrialLocations = new LinkedHashMap<>();
+ List<TerrestrialLocation> terrestrialLocationInDistricts = referentialService.getTerrestrialLocationInDistricts(updateContactCommand.getContact().getSampleRow().getTerrestrialLocations());
+ for (TerrestrialLocation terrestrialLocation : terrestrialLocationInDistricts) {
+ terrestrialLocations.put(terrestrialLocation.getTopiaId(), terrestrialLocation.getDescription());
+ }
+ }
+
+ @Override
+ public void validate() {
+
+ service.preValidate(updateContactCommand);
+
+ AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser();
+
+ try {
+ service.validate(authenticatedWaoUser, updateContactCommand, true);
+ } catch (ContactNotUpdatableException e) {
+ session.addErrorMessages(t("wao.ui.contacts.validation.failure.not.updatable"));
+
+ } catch (UnwantedContactContactStateMotifException e) {
+ addFieldError("updateContactCommand.contact.contactStateMotif", t("wao.ui.form.Contact.error.unwantedContactStateMotif"));
+
+ } catch (MissingContactNbObservantsException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ addFieldError("updateContactCommand.contact.nbObservants", t("wao.ui.form.Contact.error.missingObserver", state));
+
+ } catch (MissingContactObservationEndDateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ addFieldError("updateContactCommand.contact.observationEndDate", t("wao.ui.form.Contact.error.missingObservationEndDate", state));
+
+ } catch (ContactDataInputDateBeforeObservationEndDateException e) {
+ addFieldError("updateContactCommand.contact.dataInputDate", t("wao.ui.form.Contact.error.dataInputDateBeforeObservationEndDate"));
+
+ } catch (InvalidContactObservationBeginDateException e) {
+ addFieldError("updateContactCommand.contact.observationBeginDate", t("wao.ui.form.Contact.error.invalidObservationBeginDate"));
+
+ } catch (MissingContactRestitutionException e) {
+ addFieldError("updateContactCommand.contact.restitution", t("wao.ui.form.Contact.error.missingRestitution"));
+
+ } catch (ContactDataInputDateAfterTodayException e) {
+ addFieldError("updateContactCommand.contact.dataInputDate", t("wao.ui.form.Contact.error.dataInputDateAfterToday"));
+
+ } catch (MissingContactCommentException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ addFieldError("updateContactCommand.contact.comment", t("wao.ui.form.Contact.error.missingComment", state));
+
+ } catch (MismatchContactMainObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ addFieldError("updateContactCommand.contact.mainObserver", t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName));
+
+ } catch (ContactRestitutionDateBeforeDataInputDateException e) {
+ addFieldError("updateContactCommand.contact.restitution", t("wao.ui.form.Contact.error.transmissionDateBeforeDataInputDate"));
+
+ } catch (ContactObservationEndDateBeforeBeginDateException e) {
+ addFieldError("updateContactCommand.contact.observationEndDate", t("wao.ui.form.Contact.error.observationEndDateBeforeBeginDate"));
+
+ } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
+ addFieldError("updateContactCommand.contact.secondaryObservers", t("wao.ui.form.Contact.error.duplicatedMainObserverInSecondaryObservers"));
+
+ } catch (MissingContactDataReliabilityException e) {
+ addFieldError("updateContactCommand.contact.dataReliability", t("wao.ui.form.Contact.error.missingDataReliability"));
+
+ } catch (MismatchContactSecondaryObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ addFieldError("updateContactCommand.contact.secondaryObservers", t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName));
+
+ } catch (MissingContactObservedDataControlException e) {
+ addFieldError("updateContactCommand.contact.observedDataControl", t("wao.ui.form.Contact.error.missingObservedDataControl"));
+
+ } catch (ContactWithObservedDataControlToCorrectionAskedException e) {
+ addFieldError("updateContactCommand.contact.observedDataControl", t("wao.ui.form.Contact.error.observedDataControlToCorrectionAsked"));
+
+ } catch (MissingContactStateMotifException e) {
+ addFieldError("updateContactCommand.contact.contactStateMotif", t("wao.ui.form.Contact.error.missingContactStateMotif"));
+
+ } catch (MissingContactDataInputDateException e) {
+ addFieldError("updateContactCommand.contact.dataInputDate", t("wao.ui.form.Contact.error.missingDataInputDate"));
+
+ } catch (MissingContactMainObserverException e) {
+ addFieldError("updateContactCommand.contact.mainObserver", t("wao.ui.form.Contact.error.missingMainObserver"));
+
+ } catch (MissingContactCommentAdminException e) {
+ String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability());
+ addFieldError("updateContactCommand.contact.commentAdmin", t("wao.ui.form.Contact.error.missingCommentAdmin", dataReliability));
+
+ } catch (ContactObservationEndDateAfterTodayException e) {
+ addFieldError("updateContactCommand.contact.observationEndDate", t("wao.ui.form.Contact.error.observationEndDateAfterToday"));
+
+ } catch (MissingContactObservationBeginDateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ addFieldError("updateContactCommand.contact.observationBeginDate", t("wao.ui.form.Contact.error.missingObservationBeginDate", state));
+
+ } catch (MissingContactMammalsInfoException e) {
+ addFieldError("updateContactCommand.contact.mammalsInfo", t("wao.ui.form.Contact.error.missingMammalsInfo"));
+
+ } catch (MissingContactTerrestrialLocationException e) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ service.save(updateContactCommand, false);
+
+ session.addMessage(t("wao.ui.form.updateContactCommand.success"));
+
+ session.setContactToHighlightId(updateContactCommand.getContact().getTopiaId());
+ return SUCCESS;
+ }
+
+}
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportContactsAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportContactsAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportContactsAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportContactsAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,74 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.ContactsFilter;
+import fr.ifremer.wao.services.service.ContactsService;
+
+import java.io.InputStream;
+import java.util.Date;
+
+/**
+ * Created on 4/3/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ExportContactsAction extends AbstractDownloadCsvAction implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient ContactsService service;
+
+ protected ContactsFilter filter;
+
+ public void setService(ContactsService service) {
+ this.service = service;
+ }
+
+ public ContactsFilter getFilter() {
+ if (filter == null) {
+ prepare();
+ }
+ return filter;
+ }
+
+ @Override
+ public void prepare() {
+
+ filter = service.newContactFilter(getAuthenticatedWaoUser());
+ }
+
+ @Override
+ public String getFileName() {
+
+ return "contacts_" + getObsProgram().name() + "_" + dateFormat.format(new Date()) + ".csv";
+ }
+
+ @Override
+ public InputStream getInputStream() {
+
+ return service.exportContacts(filter);
+ }
+
+}
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ImportContactsAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ImportContactsAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ImportContactsAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ImportContactsAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,61 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.services.service.ContactsService;
+import fr.ifremer.wao.services.service.ImportErrorException;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+
+import java.io.InputStream;
+
+/**
+ * Created on 4/3/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+@Results({
+ @Result(name = "error", type = "redirectAction", params = {"actionName", "import-contacts!input"}),
+ @Result(name = "success", type = "redirectAction", params = {"actionName", "contacts"})
+ })
+public class ImportContactsAction extends AbstractImportCsvAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient ContactsService contactsService;
+
+ public void setContactsService(ContactsService contactsService) {
+ this.contactsService = contactsService;
+ }
+
+ @Override
+ protected void importCsv(InputStream csvInputStream) throws ImportErrorException {
+ contactsService.importContacts(getAuthenticatedWaoUser(), csvInputStream);
+ }
+
+ @Override
+ protected String getSuccessMessage() {
+ return t("wao.ui.import.contacts.success");
+ }
+
+}
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,306 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.WaoTechnicalException;
+import fr.ifremer.wao.WaoUtils;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import fr.ifremer.wao.services.service.ContactDataInputDateBeforeObservationEndDateException;
+import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException;
+import fr.ifremer.wao.services.service.ContactNotUpdatableException;
+import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException;
+import fr.ifremer.wao.services.service.ContactObservationEndDateBeforeBeginDateException;
+import fr.ifremer.wao.services.service.ContactRestitutionDateBeforeDataInputDateException;
+import fr.ifremer.wao.services.service.ContactWithObservedDataControlToCorrectionAskedException;
+import fr.ifremer.wao.services.service.ContactsService;
+import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException;
+import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException;
+import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException;
+import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException;
+import fr.ifremer.wao.services.service.MissingContactCommentAdminException;
+import fr.ifremer.wao.services.service.MissingContactCommentException;
+import fr.ifremer.wao.services.service.MissingContactDataInputDateException;
+import fr.ifremer.wao.services.service.MissingContactDataReliabilityException;
+import fr.ifremer.wao.services.service.MissingContactMainObserverException;
+import fr.ifremer.wao.services.service.MissingContactMammalsInfoException;
+import fr.ifremer.wao.services.service.MissingContactNbObservantsException;
+import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException;
+import fr.ifremer.wao.services.service.MissingContactObservationEndDateException;
+import fr.ifremer.wao.services.service.MissingContactObservedDataControlException;
+import fr.ifremer.wao.services.service.MissingContactRestitutionException;
+import fr.ifremer.wao.services.service.MissingContactStateMotifException;
+import fr.ifremer.wao.services.service.MissingContactTerrestrialLocationException;
+import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException;
+import fr.ifremer.wao.services.service.UpdateContactCommand;
+import fr.ifremer.wao.web.WaoJsonActionSupport;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Created on 4/3/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ValidateContactJsonAction extends WaoJsonActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ValidateContactJsonAction.class);
+
+ /**
+ * Id of contact to treat.
+ */
+ protected String contactId;
+
+ /**
+ * New validation state.
+ */
+ protected Boolean validationState;
+
+ /**
+ * Success message
+ */
+ protected String successMessage;
+
+ /**
+ * Error message if validation, or any was wrong while update.
+ */
+ protected String errorMessage;
+
+ protected transient ContactsService service;
+
+ protected UpdateContactCommand updateContactCommand;
+
+ public void setService(ContactsService service) {
+ this.service = service;
+ }
+
+ public void setContactId(String contactId) {
+ this.contactId = contactId;
+ }
+
+ public void setValidationState(Boolean validationState) {
+ this.validationState = validationState;
+ }
+
+ public String getContactId() {
+ return contactId;
+ }
+
+ public Boolean getValidationState() {
+ return validationState;
+ }
+
+ public String getSuccessMessage() {
+ return successMessage;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public boolean isSuccessful() {
+ return errorMessage == null;
+ }
+
+ @Override
+ public void prepare() {
+
+ Preconditions.checkState(StringUtils.isNotEmpty(contactId));
+
+ AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser();
+
+ updateContactCommand = service.newUpdateContactCommand(
+ session.getAuthenticatedWaoUser(),
+ Optional.of(contactId));
+
+ if (authenticatedWaoUser.isAdmin()) {
+ updateContactCommand.setValidationProgram(validationState);
+ } else {
+ updateContactCommand.setValidationCompany(validationState);
+ }
+ }
+
+ @Override
+ public String execute() {
+
+ AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser();
+
+ try {
+ service.validate(authenticatedWaoUser, updateContactCommand, true);
+ } catch (ContactNotUpdatableException e) {
+ session.addErrorMessages(t("wao.ui.contacts.validation.failure.not.updatable"));
+
+ } catch (UnwantedContactContactStateMotifException e) {
+ errorMessage = t("wao.ui.form.Contact.error.unwantedContactStateMotif");
+
+ } catch (MissingContactNbObservantsException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ errorMessage = t("wao.ui.form.Contact.error.missingObserver", state);
+
+ } catch (MissingContactObservationEndDateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ errorMessage = t("wao.ui.form.Contact.error.missingObservationEndDate", state);
+
+ } catch (ContactDataInputDateBeforeObservationEndDateException e) {
+ errorMessage = t("wao.ui.form.Contact.error.dataInputDateBeforeObservationEndDate");
+
+ } catch (InvalidContactObservationBeginDateException e) {
+ errorMessage = t("wao.ui.form.Contact.error.invalidObservationBeginDate");
+
+ } catch (MissingContactRestitutionException e) {
+ errorMessage = t("wao.ui.form.Contact.error.missingRestitution");
+
+ } catch (ContactDataInputDateAfterTodayException e) {
+ errorMessage = t("wao.ui.form.Contact.error.dataInputDateAfterToday");
+
+ } catch (MissingContactCommentException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ errorMessage = t("wao.ui.form.Contact.error.missingComment", state);
+
+ } catch (MismatchContactMainObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ errorMessage = t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName);
+
+ } catch (ContactRestitutionDateBeforeDataInputDateException e) {
+ errorMessage = t("wao.ui.form.Contact.error.transmissionDateBeforeDataInputDate");
+
+ } catch (ContactObservationEndDateBeforeBeginDateException e) {
+ errorMessage = t("wao.ui.form.Contact.error.observationEndDateBeforeBeginDate");
+
+ } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
+ errorMessage = t("wao.ui.form.Contact.error.duplicatedMainObserverInSecondaryObservers");
+
+ } catch (MissingContactDataReliabilityException e) {
+ errorMessage = t("wao.ui.form.Contact.error.missingDataReliability");
+
+ } catch (MismatchContactSecondaryObserverCompanyException e) {
+ String companyName = e.getCompany().getName();
+ String observerLogin = e.getObserver().getLogin();
+ errorMessage = t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName);
+
+ } catch (MissingContactObservedDataControlException e) {
+ errorMessage = t("wao.ui.form.Contact.error.missingObservedDataControl");
+
+ } catch (ContactWithObservedDataControlToCorrectionAskedException e) {
+ errorMessage = t("wao.ui.form.Contact.error.observedDataControlToCorrectionAsked");
+
+ } catch (MissingContactStateMotifException e) {
+ errorMessage = t("wao.ui.form.Contact.error.missingContactStateMotif");
+
+ } catch (MissingContactDataInputDateException e) {
+ errorMessage = t("wao.ui.form.Contact.error.missingDataInputDate");
+
+ } catch (MissingContactMainObserverException e) {
+ errorMessage = t("wao.ui.form.Contact.error.missingMainObserver");
+
+ } catch (MissingContactCommentAdminException e) {
+ String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability());
+ errorMessage = t("wao.ui.form.Contact.error.missingCommentAdmin", dataReliability);
+
+ } catch (ContactObservationEndDateAfterTodayException e) {
+ errorMessage = t("wao.ui.form.Contact.error.observationEndDateAfterToday");
+
+ } catch (MissingContactObservationBeginDateException e) {
+ String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
+ errorMessage = t("wao.ui.form.Contact.error.missingObservationBeginDate", state);
+
+ } catch (MissingContactTerrestrialLocationException e) {
+ errorMessage = t("wao.ui.form.Contact.error.missingContactTerrestrialLocation");
+
+ } catch (MissingContactMammalsInfoException e) {
+ errorMessage = t("wao.ui.form.Contact.error.missingContactMammalsInfo");
+
+ }
+
+ if (isSuccessful()) {
+
+ try {
+ service.save(updateContactCommand, true);
+ } catch (ContactNotUpdatableException e) {
+ throw new WaoTechnicalException("should never occur", e);
+ }
+ if (validationState == null) {
+ successMessage = t("wao.ui.contacts.validation.to.unvalidate.state.success");
+ } else if (validationState) {
+ successMessage = t("wao.ui.contacts.validation.to.accept.state.success");
+ } else {
+ successMessage = t("wao.ui.contacts.validation.to.reject.state.success");
+ }
+ }
+
+ return SUCCESS;
+ }
+
+ public boolean isAcceptable(Contact contact) {
+ boolean acceptable;
+ if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
+ acceptable = contact.isAcceptableByCompany();
+ } else if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
+ acceptable = contact.isAcceptableByProgram();
+ } else {
+ throw new IllegalStateException();
+ }
+ return acceptable;
+ }
+
+ public boolean isRefusable(Contact contact) {
+ boolean refuseable;
+ if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
+ refuseable = contact.isRefusableByCompany();
+ } else if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
+ refuseable = contact.isRefusableByProgram();
+ } else {
+ throw new IllegalStateException();
+ }
+ return refuseable;
+ }
+
+ public boolean isUnacceptable(Contact contact) {
+ boolean unacceptable;
+ if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
+ unacceptable = contact.isUnacceptableByCompany();
+ } else if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
+ unacceptable = contact.isUnacceptableByProgram();
+ } else {
+ throw new IllegalStateException();
+ }
+ return unacceptable;
+ }
+
+ public Boolean getValidationProgram() {
+ return updateContactCommand.getContact().getValidationProgram();
+ }
+
+ public Boolean getValidationCompany() {
+ return updateContactCommand.getContact().getValidationCompany();
+ }
+
+}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,249 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.base.Objects;
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.ContactsFilter;
-import fr.ifremer.wao.WaoUtils;
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.entity.ContactState;
-import fr.ifremer.wao.entity.DCF5Code;
-import fr.ifremer.wao.entity.FishingZone;
-import fr.ifremer.wao.entity.SampleRow;
-import fr.ifremer.wao.services.service.ContactsFilterValues;
-import fr.ifremer.wao.services.service.ObsMerContactsList;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-import org.apache.commons.lang3.time.DateUtils;
-import org.nuiton.util.pagination.PaginationParameter;
-import org.nuiton.util.pagination.PaginationResult;
-
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created on 4/3/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ContactsAction extends WaoJspActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- protected transient ObsMerContactsService service;
-
- protected int pageNumber;
-
- protected long firstRangePage;
-
- protected long lastRangePage;
-
- /**
- * Contacts filter.
- */
- protected ContactsFilter filter;
-
- /**
- * List of contacts according to the input pager and filter.
- */
- protected ObsMerContactsList contactsList;
-
- public void setService(ObsMerContactsService service) {
- this.service = service;
- }
-
- public void setPageNumber(int pageNumber) {
- this.pageNumber = pageNumber;
- }
-
- public long getFirstRangePage() {
- return firstRangePage;
- }
-
- public long getLastRangePage() {
- return lastRangePage;
- }
-
- public ContactsFilter getFilter() {
- if (filter == null) {
- prepare();
- }
- return filter;
- }
-
- public List<Contact> getContacts() {
- return contactsList.getContacts().getElements();
- }
-
- public ContactsFilterValues getFilterValues() {
- return contactsList.getFilterValues();
- }
-
- public PaginationResult<Contact> getPagination() {
- return contactsList.getContacts();
- }
-
- @Override
- public void prepare() {
-
- if (filter == null) {
- filter = service.newContactFilter(getAuthenticatedWaoUser());
- }
-
- }
-
- @Override
- public String execute() {
-
- filter = Objects.firstNonNull(session.getContactsFilter(), filter);
-
- return applyFilter();
-
- }
-
- public String resetFilter() {
-
- filter = service.newContactFilter(getAuthenticatedWaoUser());
-
- return applyFilter();
-
- }
-
- public String applyFilter() {
-
- getSession().setContactsFilter(filter);
-
- PaginationParameter pager = service.newContactsPaginationParameter(pageNumber, 25);
- contactsList = service.getContactsList(getAuthenticatedWaoUser(), filter, pager);
-
- firstRangePage = getPaginationFirstPage(contactsList.getContacts(), 10);
- lastRangePage = getPaginationLastPage(contactsList.getContacts(), 10, firstRangePage);
-
- return SUCCESS;
-
- }
-
- protected Date now = new Date();
-
- public String getFilterPeriodFromPlaceholder() {
- String placeholder = formatDateTime(DateUtils.addMonths(now, 1));
- return placeholder;
- }
-
- public String getFilterPeriodToPlaceholder() {
- String placeholder = formatDateTime(DateUtils.addYears(now, 1));
- return placeholder;
- }
-
- public boolean isFullView() {
- boolean fullView = getAuthenticatedWaoUser().isAdmin() || getAuthenticatedWaoUser().isProfessional();
- return fullView;
- }
-
- public String getMammalsInfo(Contact contact) {
- return escapeForToolTip(contact.getMammalsInfo());
- }
-
- public boolean isBoardingDone(Contact contact) {
- return ContactState.OBSERVATION_DONE == contact.getContactState();
- }
-
- public String getDivision(SampleRow sampleRow) {
- String result = "";
- for (FishingZone zone : sampleRow.getFishingZone()) {
- result += zone.getDistrictCode() + " ";
- }
- return result;
- }
-
- /**
- * Devrait résoudre un problème que pose le composant ck/tooltip.
- * <p/>
- * Voir ANO#606
- */
- public static String escapeForToolTip(String str) {
- String result = str.replaceAll("\r\n", "\n");
- result = result.replaceAll("\n", "<br />");
- result = result.replaceAll("'", "’");
- result = result.replaceAll("\"", """);
- result = result.replaceAll("%", "%");
- return result;
- }
-
- public String getContactToHighlightId() {
- return session.getContactToHighlightId();
- }
-
- public Map<String, String> getDcf5CodesAndDescriptions(SampleRow sampleRow) {
- Map<String, String> dcf5CodesAndDescriptions = new LinkedHashMap<>();
- for (DCF5Code dcf5Code : sampleRow.getdCF5Code()) {
- String key = dcf5Code.getCode();
- String description = dcf5Code.getFishingGearCode() + " - " + WaoUtils.l(getLocale(), dcf5Code.getFishingGearDCF());
- if (dcf5Code.getTargetSpeciesCode() != null) {
- description += " ; " + dcf5Code.getTargetSpeciesCode() + " - " + WaoUtils.l(getLocale(), dcf5Code.getTargetSpeciesDCF());
- }
- dcf5CodesAndDescriptions.put(key, description);
- }
- return dcf5CodesAndDescriptions;
- }
-
- public boolean isAcceptable(Contact contact) {
- boolean acceptable;
- if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
- acceptable = contact.isAcceptableByCompany();
- } else if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
- acceptable = contact.isAcceptableByProgram();
- } else {
- throw new IllegalStateException();
- }
- return acceptable;
- }
-
- public boolean isRefusable(Contact contact) {
- boolean refuseable;
- if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
- refuseable = contact.isRefusableByCompany();
- } else if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
- refuseable = contact.isRefusableByProgram();
- } else {
- throw new IllegalStateException();
- }
- return refuseable;
- }
-
- public boolean isUnacceptable(Contact contact) {
- boolean unacceptable;
- if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
- unacceptable = contact.isUnacceptableByCompany();
- } else if (getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
- unacceptable = contact.isUnacceptableByProgram();
- } else {
- throw new IllegalStateException();
- }
- return unacceptable;
- }
-
-}
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsFilterValuesJsonAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsFilterValuesJsonAction.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsFilterValuesJsonAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,77 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.ContactsFilter;
-import fr.ifremer.wao.services.service.ContactsFilterValues;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
-import fr.ifremer.wao.web.WaoJsonActionSupport;
-
-/**
- * Created on 4/3/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ContactsFilterValuesJsonAction extends WaoJsonActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- protected transient ObsMerContactsService service;
-
- protected ContactsFilter filter;
-
- protected ContactsFilterValues filterValues;
-
- public void setService(ObsMerContactsService service) {
- this.service = service;
- }
-
-
- public ContactsFilter getFilter() {
- if (filter == null) {
- prepare();
- }
- return filter;
- }
-
- public ContactsFilterValues getFilterValues() {
- return filterValues;
- }
-
- @Override
- public void prepare() {
-
- filter = service.newContactFilter(session.getAuthenticatedWaoUser());
- }
-
- @Override
- public String execute() {
-
- filterValues = service.getContactsFilterValues(session.getAuthenticatedWaoUser(), filter);
-
- return SUCCESS;
-
- }
-
-}
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CreateContactAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,45 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-import org.apache.struts2.convention.annotation.Result;
-import org.apache.struts2.convention.annotation.Results;
-
-@Results({
- @Result(name="success", type="redirectAction", params = { "actionName", "contacts" })
-})
-public class CreateContactAction extends WaoJspActionSupport {
-
- protected ObsMerContactsService service;
-
- protected String boatId;
-
- protected String sampleRowId;
-
- public void setService(ObsMerContactsService service) {
- this.service = service;
- }
-
- public void setBoatId(String boatId) {
- this.boatId = boatId;
- }
-
- public void setSampleRowId(String sampleRowId) {
- this.sampleRowId = sampleRowId;
- }
-
- @Override
- public String execute() {
-
- Contact contact = service.createContact(getAuthenticatedWaoUser(), sampleRowId, boatId);
-
- session.setStartBoatSelectionForSampleRowId(null);
-
- session.setContactToHighlightId(contact.getTopiaId());
-
- return SUCCESS;
-
- }
-
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteContactAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteContactAction.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteContactAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,84 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.services.service.IllegalDeletionException;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-import org.apache.struts2.convention.annotation.Result;
-import org.apache.struts2.convention.annotation.Results;
-
-/**
- * Created on 4/3/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-@Results({
- @Result(name = "error", type = "redirectAction", params = {"actionName", "edit-contact!input", "contactId", "%{contactId}"}),
- @Result(name = "success", type = "redirectAction", params = {"actionName", "contacts"})
- })
-public class DeleteContactAction extends WaoJspActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- protected String contactId;
-
- protected transient ObsMerContactsService service;
-
- public void setService(ObsMerContactsService service) {
- this.service = service;
- }
-
- public void setContactId(String contactId) {
- this.contactId = contactId;
- }
-
- public String getContactId() {
- return contactId;
- }
-
- @Override
- public String execute() {
-
- Contact contact = service.getContact(contactId);
- String contactCode = contact.getMainObserver().getFullName();
-
- String result;
- try {
- service.delete(contactId);
-
- session.addMessage(t("wao.ui.action.deleteContact.success", contactCode));
-
- result = SUCCESS;
-
- } catch (IllegalDeletionException e) {
-
- session.addErrorMessages(t("wao.ui.action.deleteContact.failure", contactCode));
- session.addErrorMessages(e.getExplanation(getLocale()));
-
- result = ERROR;
- }
- return result;
- }
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,317 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-import com.google.common.collect.Sets;
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.WaoUtils;
-import fr.ifremer.wao.entity.ContactState;
-import fr.ifremer.wao.entity.ContactStateMotif;
-import fr.ifremer.wao.entity.DataReliability;
-import fr.ifremer.wao.entity.ObservedDataControl;
-import fr.ifremer.wao.entity.WaoUser;
-import fr.ifremer.wao.entity.WaoUsers;
-import fr.ifremer.wao.services.AuthenticatedWaoUser;
-import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException;
-import fr.ifremer.wao.services.service.ContactDataInputDateBeforeObservationEndDateException;
-import fr.ifremer.wao.services.service.ContactNotUpdatableException;
-import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException;
-import fr.ifremer.wao.services.service.ContactObservationEndDateBeforeBeginDateException;
-import fr.ifremer.wao.services.service.ContactRestitutionDateBeforeDataInputDateException;
-import fr.ifremer.wao.services.service.ContactWithObservedDataControlToCorrectionAskedException;
-import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException;
-import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException;
-import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException;
-import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException;
-import fr.ifremer.wao.services.service.MissingContactCommentAdminException;
-import fr.ifremer.wao.services.service.MissingContactCommentException;
-import fr.ifremer.wao.services.service.MissingContactDataInputDateException;
-import fr.ifremer.wao.services.service.MissingContactDataReliabilityException;
-import fr.ifremer.wao.services.service.MissingContactMainObserverException;
-import fr.ifremer.wao.services.service.MissingContactMammalsInfoException;
-import fr.ifremer.wao.services.service.MissingContactNbObservantsException;
-import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException;
-import fr.ifremer.wao.services.service.MissingContactObservationEndDateException;
-import fr.ifremer.wao.services.service.MissingContactObservedDataControlException;
-import fr.ifremer.wao.services.service.MissingContactRestitutionException;
-import fr.ifremer.wao.services.service.MissingContactStateMotifException;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
-import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException;
-import fr.ifremer.wao.services.service.UpdateContactCommand;
-import fr.ifremer.wao.services.service.administration.ReferentialService;
-import fr.ifremer.wao.services.service.administration.WaoUsersService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-import org.apache.struts2.convention.annotation.Result;
-import org.apache.struts2.convention.annotation.Results;
-
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-/**
- * Created on 4/6/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-@Results({@Result(name = "success", type = "redirectAction", params = {"actionName", "contacts"})})
-public class EditContactAction extends WaoJspActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Id of contact to edit.
- */
- protected Optional<String> optionalContactId = Optional.absent();
-
- protected Map<String, String> observers;
-
- protected Map<ContactState, String> contactStates;
-
- protected Map<String, String> contactStateMotives;
-
- protected Map<ObservedDataControl, String> observedDataControls;
-
- protected Map<DataReliability, String> dataReliabilities;
-
- protected transient ObsMerContactsService service;
-
- protected transient WaoUsersService waoUsersService;
-
- protected transient ReferentialService referentialService;
-
- protected UpdateContactCommand updateContactCommand;
-
- public void setService(ObsMerContactsService service) {
- this.service = service;
- }
-
- public void setWaoUsersService(WaoUsersService waoUsersService) {
- this.waoUsersService = waoUsersService;
- }
-
- public void setReferentialService(ReferentialService referentialService) {
- this.referentialService = referentialService;
- }
-
- public void setContactId(String contactId) {
- this.optionalContactId = Optional.fromNullable(Strings.emptyToNull(contactId));
- }
-
- public String getContactId() {
- return optionalContactId.orNull();
- }
-
- public UpdateContactCommand getUpdateContactCommand() {
- if (updateContactCommand == null) {
- prepare();
- }
- return updateContactCommand;
- }
-
- public Map<String, String> getObservers() {
- if (observers == null) {
- prepare();
- }
- return observers;
- }
-
- public Map<ContactState, String> getContactStates() {
- if (contactStates == null) {
- prepare();
- }
- return contactStates;
- }
-
- public Map<String, String> getContactStateMotives() {
- if (contactStateMotives == null) {
- prepare();
- }
- return contactStateMotives;
- }
-
- public Map<ObservedDataControl, String> getObservedDataControls() {
- if (observedDataControls == null) {
- prepare();
- }
- return observedDataControls;
- }
-
- public Map<DataReliability, String> getDataReliabilities() {
- if (dataReliabilities == null) {
- prepare();
- }
- return dataReliabilities;
- }
-
- public String getDateTimePlaceholder() {
- return formatDateTime(new Date());
- }
-
- public String getDatePlaceholder() {
- return formatDate(new Date());
- }
-
- @Override
- public void prepare() {
-
- updateContactCommand = service.newUpdateContactCommand(getAuthenticatedWaoUser(), optionalContactId);
-
- List<WaoUser> waoUsers = waoUsersService.getActiveWaoUsers(Optional.of(updateContactCommand.getContact().getSampleRow().getCompany().getTopiaId()));
- Set<WaoUser> sortedWaoUsers = Sets.newTreeSet(WaoUsers.fullNameComparator());
- sortedWaoUsers.addAll(waoUsers);
- observers = new LinkedHashMap<>();
- for (WaoUser waoUser : sortedWaoUsers) {
- observers.put(waoUser.getTopiaId(), waoUser.getFullName());
- }
- contactStates = new EnumMap<>(ContactState.class);
- for (ContactState contactState : ContactState.getAllowedStates(getAuthenticatedWaoUser().getObsProgram())) {
- contactStates.put(contactState, WaoUtils.l(getLocale(), contactState));
- }
-
- contactStateMotives = new TreeMap<>();
- for (ContactStateMotif contactStateMotif : referentialService.getAllContactStateMotifs(null)) {
- contactStateMotives.put(contactStateMotif.getTopiaId(), contactStateMotif.getName());
- }
-
- observedDataControls = new EnumMap<>(ObservedDataControl.class);
- for (ObservedDataControl observedDataControl : ObservedDataControl.values()) {
- observedDataControls.put(observedDataControl, WaoUtils.l(getLocale(), observedDataControl));
- }
-
- dataReliabilities = new EnumMap<>(DataReliability.class);
- for (DataReliability dataReliability : DataReliability.values()) {
- dataReliabilities.put(dataReliability, WaoUtils.l(getLocale(), dataReliability));
- }
- }
-
- @Override
- public void validate() {
-
- service.preValidate(updateContactCommand);
-
- AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser();
-
- try {
- service.validate(authenticatedWaoUser, updateContactCommand, true);
- } catch (ContactNotUpdatableException e) {
- session.addErrorMessages(t("wao.ui.contacts.validation.failure.not.updatable"));
-
- } catch (UnwantedContactContactStateMotifException e) {
- addFieldError("updateContactCommand.contact.contactStateMotif", t("wao.ui.form.Contact.error.unwantedContactStateMotif"));
-
- } catch (MissingContactNbObservantsException e) {
- String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- addFieldError("updateContactCommand.contact.nbObservants", t("wao.ui.form.Contact.error.missingObserver", state));
-
- } catch (MissingContactObservationEndDateException e) {
- String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- addFieldError("updateContactCommand.contact.observationEndDate", t("wao.ui.form.Contact.error.missingObservationEndDate", state));
-
- } catch (ContactDataInputDateBeforeObservationEndDateException e) {
- addFieldError("updateContactCommand.contact.dataInputDate", t("wao.ui.form.Contact.error.dataInputDateBeforeObservationEndDate"));
-
- } catch (InvalidContactObservationBeginDateException e) {
- addFieldError("updateContactCommand.contact.observationBeginDate", t("wao.ui.form.Contact.error.invalidObservationBeginDate"));
-
- } catch (MissingContactRestitutionException e) {
- addFieldError("updateContactCommand.contact.restitution", t("wao.ui.form.Contact.error.missingRestitution"));
-
- } catch (ContactDataInputDateAfterTodayException e) {
- addFieldError("updateContactCommand.contact.dataInputDate", t("wao.ui.form.Contact.error.dataInputDateAfterToday"));
-
- } catch (MissingContactCommentException e) {
- String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- addFieldError("updateContactCommand.contact.comment", t("wao.ui.form.Contact.error.missingComment", state));
-
- } catch (MismatchContactMainObserverCompanyException e) {
- String companyName = e.getCompany().getName();
- String observerLogin = e.getObserver().getLogin();
- addFieldError("updateContactCommand.contact.mainObserver", t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName));
-
- } catch (ContactRestitutionDateBeforeDataInputDateException e) {
- addFieldError("updateContactCommand.contact.restitution", t("wao.ui.form.Contact.error.transmissionDateBeforeDataInputDate"));
-
- } catch (ContactObservationEndDateBeforeBeginDateException e) {
- addFieldError("updateContactCommand.contact.observationEndDate", t("wao.ui.form.Contact.error.observationEndDateBeforeBeginDate"));
-
- } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
- addFieldError("updateContactCommand.contact.secondaryObservers", t("wao.ui.form.Contact.error.duplicatedMainObserverInSecondaryObservers"));
-
- } catch (MissingContactDataReliabilityException e) {
- addFieldError("updateContactCommand.contact.dataReliability", t("wao.ui.form.Contact.error.missingDataReliability"));
-
- } catch (MismatchContactSecondaryObserverCompanyException e) {
- String companyName = e.getCompany().getName();
- String observerLogin = e.getObserver().getLogin();
- addFieldError("updateContactCommand.contact.secondaryObservers", t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName));
-
- } catch (MissingContactObservedDataControlException e) {
- addFieldError("updateContactCommand.contact.observedDataControl", t("wao.ui.form.Contact.error.missingObservedDataControl"));
-
- } catch (ContactWithObservedDataControlToCorrectionAskedException e) {
- addFieldError("updateContactCommand.contact.observedDataControl", t("wao.ui.form.Contact.error.observedDataControlToCorrectionAsked"));
-
- } catch (MissingContactStateMotifException e) {
- addFieldError("updateContactCommand.contact.contactStateMotif", t("wao.ui.form.Contact.error.missingContactStateMotif"));
-
- } catch (MissingContactDataInputDateException e) {
- addFieldError("updateContactCommand.contact.dataInputDate", t("wao.ui.form.Contact.error.missingDataInputDate"));
-
- } catch (MissingContactMainObserverException e) {
- addFieldError("updateContactCommand.contact.mainObserver", t("wao.ui.form.Contact.error.missingMainObserver"));
-
- } catch (MissingContactCommentAdminException e) {
- String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability());
- addFieldError("updateContactCommand.contact.commentAdmin", t("wao.ui.form.Contact.error.missingCommentAdmin", dataReliability));
-
- } catch (ContactObservationEndDateAfterTodayException e) {
- addFieldError("updateContactCommand.contact.observationEndDate", t("wao.ui.form.Contact.error.observationEndDateAfterToday"));
-
- } catch (MissingContactObservationBeginDateException e) {
- String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- addFieldError("updateContactCommand.contact.observationBeginDate", t("wao.ui.form.Contact.error.missingObservationBeginDate", state));
-
- } catch (MissingContactMammalsInfoException e) {
- addFieldError("updateContactCommand.contact.mammalsInfo", t("wao.ui.form.Contact.error.missingMammalsInfo"));
-
- }
- }
-
- @Override
- public String execute() throws Exception {
-
- service.save(updateContactCommand, false);
-
- session.addMessage(t("wao.ui.form.updateContactCommand.success"));
-
- session.setContactToHighlightId(updateContactCommand.getContact().getTopiaId());
- return SUCCESS;
- }
-
-}
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportContactsAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportContactsAction.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportContactsAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,75 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.ContactsFilter;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
-import fr.ifremer.wao.web.action.AbstractDownloadCsvAction;
-
-import java.io.InputStream;
-import java.util.Date;
-
-/**
- * Created on 4/3/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ExportContactsAction extends AbstractDownloadCsvAction implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- protected transient ObsMerContactsService service;
-
- protected ContactsFilter filter;
-
- public void setService(ObsMerContactsService service) {
- this.service = service;
- }
-
- public ContactsFilter getFilter() {
- if (filter == null) {
- prepare();
- }
- return filter;
- }
-
- @Override
- public void prepare() {
-
- filter = service.newContactFilter(getAuthenticatedWaoUser());
- }
-
- @Override
- public String getFileName() {
-
- return "contacts_" + getObsProgram().name() + "_" + dateFormat.format(new Date()) + ".csv";
- }
-
- @Override
- public InputStream getInputStream() {
-
- return service.exportContacts(filter);
- }
-
-}
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ImportContactsAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ImportContactsAction.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ImportContactsAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,62 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.services.service.ImportErrorException;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
-import fr.ifremer.wao.web.action.AbstractImportCsvAction;
-import org.apache.struts2.convention.annotation.Result;
-import org.apache.struts2.convention.annotation.Results;
-
-import java.io.InputStream;
-
-/**
- * Created on 4/3/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-@Results({
- @Result(name = "error", type = "redirectAction", params = {"actionName", "import-contacts!input"}),
- @Result(name = "success", type = "redirectAction", params = {"actionName", "contacts"})
- })
-public class ImportContactsAction extends AbstractImportCsvAction {
-
- private static final long serialVersionUID = 1L;
-
- protected transient ObsMerContactsService contactsService;
-
- public void setService(ObsMerContactsService contactsService) {
- this.contactsService = contactsService;
- }
-
- @Override
- protected void importCsv(InputStream csvInputStream) throws ImportErrorException {
- contactsService.importContacts(getAuthenticatedWaoUser(), csvInputStream);
- }
-
- @Override
- protected String getSuccessMessage() {
- return t("wao.ui.import.contacts.success");
- }
-
-}
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,303 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.WaoTechnicalException;
-import fr.ifremer.wao.WaoUtils;
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.services.AuthenticatedWaoUser;
-import fr.ifremer.wao.services.service.ContactDataInputDateBeforeObservationEndDateException;
-import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException;
-import fr.ifremer.wao.services.service.ContactNotUpdatableException;
-import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException;
-import fr.ifremer.wao.services.service.ContactObservationEndDateBeforeBeginDateException;
-import fr.ifremer.wao.services.service.ContactRestitutionDateBeforeDataInputDateException;
-import fr.ifremer.wao.services.service.ContactWithObservedDataControlToCorrectionAskedException;
-import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException;
-import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException;
-import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException;
-import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException;
-import fr.ifremer.wao.services.service.MissingContactCommentAdminException;
-import fr.ifremer.wao.services.service.MissingContactCommentException;
-import fr.ifremer.wao.services.service.MissingContactDataInputDateException;
-import fr.ifremer.wao.services.service.MissingContactDataReliabilityException;
-import fr.ifremer.wao.services.service.MissingContactMainObserverException;
-import fr.ifremer.wao.services.service.MissingContactNbObservantsException;
-import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException;
-import fr.ifremer.wao.services.service.MissingContactObservationEndDateException;
-import fr.ifremer.wao.services.service.MissingContactObservedDataControlException;
-import fr.ifremer.wao.services.service.MissingContactRestitutionException;
-import fr.ifremer.wao.services.service.MissingContactStateMotifException;
-import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException;
-import fr.ifremer.wao.services.service.ObsMerContactsService;
-import fr.ifremer.wao.services.service.UpdateContactCommand;
-import fr.ifremer.wao.web.WaoJsonActionSupport;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Created on 4/3/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ValidateContactJsonAction extends WaoJsonActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ValidateContactJsonAction.class);
-
- /**
- * Id of contact to treat.
- */
- protected String contactId;
-
- /**
- * New validation state.
- */
- protected Boolean validationState;
-
- /**
- * Success message
- */
- protected String successMessage;
-
- /**
- * Error message if validation, or any was wrong while update.
- */
- protected String errorMessage;
-
- protected transient ObsMerContactsService service;
-
- protected UpdateContactCommand updateContactCommand;
-
- public void setService(ObsMerContactsService service) {
- this.service = service;
- }
-
- public void setContactId(String contactId) {
- this.contactId = contactId;
- }
-
- public void setValidationState(Boolean validationState) {
- this.validationState = validationState;
- }
-
- public String getContactId() {
- return contactId;
- }
-
- public Boolean getValidationState() {
- return validationState;
- }
-
- public String getSuccessMessage() {
- return successMessage;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public boolean isSuccessful() {
- return errorMessage == null;
- }
-
- @Override
- public void prepare() {
-
- Preconditions.checkState(StringUtils.isNotEmpty(contactId));
-
- AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser();
-
- updateContactCommand = service.newUpdateContactCommand(
- session.getAuthenticatedWaoUser(),
- Optional.of(contactId));
-
- if (authenticatedWaoUser.isAdmin()) {
- updateContactCommand.setValidationProgram(validationState);
- } else {
- updateContactCommand.setValidationCompany(validationState);
- }
- }
-
- @Override
- public String execute() {
-
- AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser();
-
- try {
- service.validate(authenticatedWaoUser, updateContactCommand, true);
- } catch (ContactNotUpdatableException e) {
- session.addErrorMessages(t("wao.ui.contacts.validation.failure.not.updatable"));
-
- } catch (UnwantedContactContactStateMotifException e) {
- errorMessage = t("wao.ui.form.Contact.error.unwantedContactStateMotif");
-
- } catch (MissingContactNbObservantsException e) {
- String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- errorMessage = t("wao.ui.form.Contact.error.missingObserver", state);
-
- } catch (MissingContactObservationEndDateException e) {
- String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- errorMessage = t("wao.ui.form.Contact.error.missingObservationEndDate", state);
-
- } catch (ContactDataInputDateBeforeObservationEndDateException e) {
- errorMessage = t("wao.ui.form.Contact.error.dataInputDateBeforeObservationEndDate");
-
- } catch (InvalidContactObservationBeginDateException e) {
- errorMessage = t("wao.ui.form.Contact.error.invalidObservationBeginDate");
-
- } catch (MissingContactRestitutionException e) {
- errorMessage = t("wao.ui.form.Contact.error.missingRestitution");
-
- } catch (ContactDataInputDateAfterTodayException e) {
- errorMessage = t("wao.ui.form.Contact.error.dataInputDateAfterToday");
-
- } catch (MissingContactCommentException e) {
- String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- errorMessage = t("wao.ui.form.Contact.error.missingComment", state);
-
- } catch (MismatchContactMainObserverCompanyException e) {
- String companyName = e.getCompany().getName();
- String observerLogin = e.getObserver().getLogin();
- errorMessage = t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName);
-
- } catch (ContactRestitutionDateBeforeDataInputDateException e) {
- errorMessage = t("wao.ui.form.Contact.error.transmissionDateBeforeDataInputDate");
-
- } catch (ContactObservationEndDateBeforeBeginDateException e) {
- errorMessage = t("wao.ui.form.Contact.error.observationEndDateBeforeBeginDate");
-
- } catch (DuplicatedContactMainObserverInSecondaryObserversException e) {
- errorMessage = t("wao.ui.form.Contact.error.duplicatedMainObserverInSecondaryObservers");
-
- } catch (MissingContactDataReliabilityException e) {
- errorMessage = t("wao.ui.form.Contact.error.missingDataReliability");
-
- } catch (MismatchContactSecondaryObserverCompanyException e) {
- String companyName = e.getCompany().getName();
- String observerLogin = e.getObserver().getLogin();
- errorMessage = t("wao.ui.form.Contact.error.mismatchCompanyForObserver", observerLogin, companyName);
-
- } catch (MissingContactObservedDataControlException e) {
- errorMessage = t("wao.ui.form.Contact.error.missingObservedDataControl");
-
- } catch (ContactWithObservedDataControlToCorrectionAskedException e) {
- errorMessage = t("wao.ui.form.Contact.error.observedDataControlToCorrectionAsked");
-
- } catch (MissingContactStateMotifException e) {
- errorMessage = t("wao.ui.form.Contact.error.missingContactStateMotif");
-
- } catch (MissingContactDataInputDateException e) {
- errorMessage = t("wao.ui.form.Contact.error.missingDataInputDate");
-
- } catch (MissingContactMainObserverException e) {
- errorMessage = t("wao.ui.form.Contact.error.missingMainObserver");
-
- } catch (MissingContactCommentAdminException e) {
- String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability());
- errorMessage = t("wao.ui.form.Contact.error.missingCommentAdmin", dataReliability);
-
- } catch (ContactObservationEndDateAfterTodayException e) {
- errorMessage = t("wao.ui.form.Contact.error.observationEndDateAfterToday");
-
- } catch (MissingContactObservationBeginDateException e) {
- String state = WaoUtils.l(getLocale(), e.getContact().getContactState());
- errorMessage = t("wao.ui.form.Contact.error.missingObservationBeginDate", state);
-
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error(e);
- }
- errorMessage = t("wao.ui.contacts.validation.failure", e.getMessage());
- }
-
- if (isSuccessful()) {
-
- try {
- service.save(updateContactCommand, true);
- } catch (ContactNotUpdatableException e) {
- throw new WaoTechnicalException("should never occur", e);
- }
- if (validationState == null) {
- successMessage = t("wao.ui.contacts.validation.to.unvalidate.state.success");
- } else if (validationState) {
- successMessage = t("wao.ui.contacts.validation.to.accept.state.success");
- } else {
- successMessage = t("wao.ui.contacts.validation.to.reject.state.success");
- }
- }
-
- return SUCCESS;
- }
-
- public boolean isAcceptable(Contact contact) {
- boolean acceptable;
- if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
- acceptable = contact.isAcceptableByCompany();
- } else if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
- acceptable = contact.isAcceptableByProgram();
- } else {
- throw new IllegalStateException();
- }
- return acceptable;
- }
-
- public boolean isRefusable(Contact contact) {
- boolean refuseable;
- if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
- refuseable = contact.isRefusableByCompany();
- } else if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
- refuseable = contact.isRefusableByProgram();
- } else {
- throw new IllegalStateException();
- }
- return refuseable;
- }
-
- public boolean isUnacceptable(Contact contact) {
- boolean unacceptable;
- if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationCompany()) {
- unacceptable = contact.isUnacceptableByCompany();
- } else if (session.getAuthenticatedWaoUser().isAuthorizedToChangeValidationProgram()) {
- unacceptable = contact.isUnacceptableByProgram();
- } else {
- throw new IllegalStateException();
- }
- return unacceptable;
- }
-
- public Boolean getValidationProgram() {
- return updateContactCommand.getContact().getValidationProgram();
- }
-
- public Boolean getValidationCompany() {
- return updateContactCommand.getContact().getValidationCompany();
- }
-
-}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/ContactsAction-conversion.properties (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/ContactsAction-conversion.properties)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/ContactsAction-conversion.properties (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/ContactsAction-conversion.properties 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1 @@
+filter=org.nuiton.web.struts2.converters.JsonConverter
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/ContactsAction-conversion.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/ContactsAction-conversion.properties 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/ContactsAction-conversion.properties 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1 +0,0 @@
-filter=org.nuiton.web.struts2.converters.JsonConverter
Modified: branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_en_GB.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-20 17:38:35 UTC (rev 2078)
@@ -290,7 +290,9 @@
wao.ui.form.Contact.error.mismatchCompanyForObserver=Observers must belong to the company attached to the sample row
wao.ui.form.Contact.error.missingComment=The comment is mandatory
wao.ui.form.Contact.error.missingCommentAdmin=The admin comment is mandatory
+wao.ui.form.Contact.error.missingContactMammalsInfo=
wao.ui.form.Contact.error.missingContactStateMotif=The contact state motif must be provided
+wao.ui.form.Contact.error.missingContactTerrestrialLocation=
wao.ui.form.Contact.error.missingDataInputDate=The data input date must be provided
wao.ui.form.Contact.error.missingDataReliability=The data reliability must be provided
wao.ui.form.Contact.error.missingMainObserver=The main observer must be provided
Modified: branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-20 17:38:35 UTC (rev 2078)
@@ -290,7 +290,9 @@
wao.ui.form.Contact.error.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s
wao.ui.form.Contact.error.missingComment=Il faut préciser un commentaire pour l'état '%s'
wao.ui.form.Contact.error.missingCommentAdmin=Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s'
+wao.ui.form.Contact.error.missingContactMammalsInfo=
wao.ui.form.Contact.error.missingContactStateMotif=Il faut préciser un motif de refus
+wao.ui.form.Contact.error.missingContactTerrestrialLocation=
wao.ui.form.Contact.error.missingDataInputDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution
wao.ui.form.Contact.error.missingDataReliability=Il faut préciser la qualité de la donnée avant de valider
wao.ui.form.Contact.error.missingMainObserver=Il faut au moins un observateur référant
Copied: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,593 @@
+<%--
+ #%L
+ Wao :: Web
+ %%
+ Copyright (C) 2009 - 2014 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<html>
+
+<head>
+ <title>
+ <s:text name="wao.ui.page.Contacts.title"/>
+ </title>
+
+ <script>
+
+ $(document).ready(function () {
+
+ var contactsFilterMappings = [
+ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies">
+ {
+ filterName: 'sampleRowFilter.companyIds',
+ filterLabel: "<s:text name="wao.ui.entity.Company"/>",
+ filterValuesField: 'sampleRowsFilterValues.companies',
+ },
+ </s:if>
+ {
+ filterName: 'sampleRowFilter.sampleRowCodes',
+ filterLabel: "<s:text name="wao.ui.field.SampleRow.code"/>",
+ filterValuesField: 'sampleRowsFilterValues.sampleRowCodes',
+ },
+ {
+ filterName: 'sampleRowFilter.programNames',
+ filterLabel: "<s:text name="wao.ui.field.SampleRow.programName"/>",
+ filterValuesField: 'sampleRowsFilterValues.programNames',
+ },
+ {
+ filterName: 'sampleRowFilter.fishingZoneFacadeNames',
+ filterLabel: "<s:text name="wao.ui.field.FishingZone.facadeName"/>",
+ filterValuesField: 'sampleRowsFilterValues.fishingZoneFacadeNames',
+ },
+ {
+ filterName: 'sampleRowFilter.fishingZoneSectorNames',
+ filterLabel: "<s:text name="wao.ui.field.FishingZone.sectorName"/>",
+ filterValuesField: 'sampleRowsFilterValues.fishingZoneSectorNames',
+ },
+ {
+ filterName: 'sampleRowFilter.fishingGearDcfIds',
+ filterLabel: "<s:text name="wao.ui.entity.fishingGearDCF"/>",
+ filterValuesField: 'sampleRowsFilterValues.fishingGearDcfs',
+ },
+ {
+ filterName: 'sampleRowFilter.targetSpeciesDcfIds',
+ filterLabel: "<s:text name="wao.ui.entity.targetSpeciesDCF"/>",
+ filterValuesField: 'sampleRowsFilterValues.targetSpeciesDcfs',
+ },
+ <s:if test="authenticatedWaoUser.authorizedToFilterOnBoats">
+ {
+ filterName: 'boatFilter.boatIds',
+ filterLabel: "<s:text name="wao.ui.entity.Boat"/>",
+ filterValuesField: 'boatsFilterValues.boats',
+ minimumInputLength: 3
+ },
+ </s:if>
+ {
+ filterName: 'boatFilter.districtIds',
+ filterLabel: "<s:text name="wao.ui.field.Boat.district"/>",
+ filterValuesField: 'boatsFilterValues.districts'
+ },
+ {
+ filterName: 'observerIds',
+ filterLabel: "<s:text name="wao.ui.misc.observer"/>",
+ filterValuesField: 'observers'
+ },
+ {
+ filterName: 'contactStates',
+ filterLabel: "<s:text name="wao.ui.field.Contact.contactState"/>",
+ filterValuesField: 'contactStates'
+ },
+ {
+ filterName: 'companyAcceptations',
+ filterLabel: "<s:text name="wao.ui.field.Contact.validationCompany"/>",
+ filterValuesField: 'companyAcceptations'
+ },
+ {
+ filterName: 'programAcceptations',
+ filterLabel: "<s:text name="wao.ui.field.Contact.validationProgram"/>",
+ filterValuesField: 'programAcceptations'
+ },
+ {
+ filterName: 'observedDataControls',
+ filterLabel: "<s:text name="wao.ui.field.Contact.observedDataControl"/>",
+ filterValuesField: 'observedDataControls'
+ },
+ {
+ filterName: 'dataReliabilities',
+ filterLabel: "<s:text name="wao.ui.field.Contact.dataReliability"/>",
+ filterValuesField: 'dataReliabilities'
+ }
+ ];
+
+ filter = <s:property value="filter" escapeHtml="false"/>;
+
+ contactsFilterController2 = new FilterController2(contactsFilterMappings, filter, WAO.CONTACTS_FILTER_VALUES_JSON_URL, $('#contacts-filters-form fieldset.extra-filters'));
+ contactsFilterController2.init();
+
+ $('#switch-compact-full-view').click(function () {
+ $('#switch-compact-full-view').toggleClass('full-view').toggleClass('compact-view');
+ $('table.contacts-list').toggleClass('full-view').toggleClass('compact-view');
+ });
+
+ $('.validation-action').click(function(e) {
+ e.preventDefault();
+ var $action = $(this);
+ var url = $action.attr('href');
+ var successCallback = function (data) {
+ var successful = data['successful'];
+ if (successful) {
+ var success = data['successMessage'];
+ WAO.notifications.success(success);
+ var $tr = $('#contacts-list').find('tr[data-contactId="' + data.contactId + '"]');
+ $tr.removeClass('accepted-by-company refused-by-company accepted-by-program refused-by-program');
+ if (data.validationCompany) {
+ $tr.addClass('accepted-by-company');
+ } else if (data.validationCompany === false) {
+ $tr.addClass('refused-by-company');
+ }
+ if (data.validationProgram) {
+ $tr.addClass('accepted-by-program');
+ } else if (data.validationProgram === false) {
+ $tr.addClass('refused-by-program');
+ }
+ } else {
+ var error = data['errorMessage'];
+ WAO.notifications.error(error);
+ }
+ };
+ WAO.post(url, {}, successCallback);
+ });
+
+ // Do not expose any struts internal input fields
+ $('input[type="hidden"][id^="__"]').prop('disabled', true);
+ });
+
+ </script>
+
+</head>
+
+<content tag="mainClass">large</content>
+<content tag="contactsMenuItemClass">active</content>
+
+<s:form method="GET" id="contacts-filters-form" cssClass="filters-form">
+
+ <fieldset>
+
+ <s:textfield name="filter.periodFrom"
+ label="%{getText('wao.ui.form.periodFrom')}"
+ placeholder="%{getFilterPeriodFromPlaceholder()}"
+ cssClass="input-small"/>
+
+ <s:textfield name="filter.periodTo"
+ label="%{getText('wao.ui.form.period.to')}"
+ placeholder="%{getFilterPeriodToPlaceholder()}"
+ cssClass="input-small"/>
+
+ <div title="<s:text name="wao.ui.form.filterOnObservationBeginDate.tooltip"/>">
+ <s:checkbox name="filter.filterOnObservationBeginDate"
+ label="%{getText('wao.ui.form.filterOnObservationBeginDate')}"/>
+ </div>
+
+ </fieldset>
+
+ <fieldset class="extra-filters">
+
+ </fieldset>
+
+ <fieldset>
+
+ <s:checkbox name="filter.mammalsObservationOnly"
+ label="%{getText('wao.ui.misc.observations')}"/>
+
+ <s:checkbox name="filter.mammalsCaptureOnly"
+ label="%{getText('wao.ui.field.Contact.mammalsCapture')}"/>
+
+ <s:checkbox name="filter.commentDefinedOnly"
+ label="%{getText('wao.ui.field.Contact.comment')}"/>
+
+ <s:checkbox name="filter.commentCompanyDefinedOnly"
+ label="%{getText('wao.ui.field.Contact.commentCompany')}"/>
+
+ <s:checkbox name="filter.commentAdminDefinedOnly"
+ label="%{getText('wao.ui.field.Contact.commentAdmin')}"/>
+
+ </fieldset>
+
+ <fieldset>
+
+ <s:checkbox name="filter.sortedByBoardingDate"
+ label="%{getText('wao.ui.form.sortByTideBegin')}"/>
+
+ </fieldset>
+
+ <div class="form-actions">
+
+ <s:submit type="button" action="contacts!applyFilter" cssClass="btn btn-primary">
+ <i class="icon-filter"></i> <s:text name="wao.ui.action.filter"/>
+ </s:submit>
+
+ <s:submit type="button" action="contacts!resetFilter" cssClass="btn">
+ <i class="icon-trash"></i> <s:text name="wao.ui.action.reset"/>
+ </s:submit>
+
+ <s:if test="authenticatedWaoUser.authorizedToExportContacts">
+ <s:submit action="export-contacts" type="button" cssClass="btn">
+ <i class="icon-download"></i> <s:text name="wao.ui.action.csvExport"/>
+ </s:submit>
+ </s:if>
+
+ </div>
+
+</s:form>
+
+<h3>
+ <s:text name="wao.ui.contacts.title">
+ <s:param value="%{pagination.count}"/>
+ </s:text>
+</h3>
+
+<s:set name="pagination">
+ <%-- Pagination --%>
+ <div class="pagination">
+ <ul>
+ <s:url var="fullUrl" includeParams="get"/>
+ <s:set var="paginationUrl" value="%{getPaginationUrl(#fullUrl)}"/>
+ <s:if test="firstRangePage > 2">
+ <li>
+ <a href="${paginationUrl}0">1</a>
+ </li>
+ <li>
+ <a href="${paginationUrl}1">2</a>
+ </li>
+ <li>
+ <span>...</span>
+ </li>
+ </s:if>
+
+ <s:iterator var="currentPage" begin="firstRangePage" end="lastRangePage">
+ <li class="<s:if test="#currentPage - 1 == pagination.currentPage.pageNumber">active</s:if>">
+ <a href="${paginationUrl}${currentPage - 1}">
+ <s:property/>
+ </a>
+ </li>
+ </s:iterator>
+
+ <s:if test="lastRangePage < pagination.pageCount - 1">
+ <li>
+ <span>...</span>
+ </li>
+ <li>
+ <a href="${paginationUrl}${pagination.pageCount - 2}">
+ <s:property value="pagination.pageCount - 1"/>
+ </a>
+ </li>
+ <li>
+ <a href="${paginationUrl}${pagination.pageCount - 1}">
+ <s:property value="pagination.pageCount"/>
+ </a>
+ </li>
+ </s:if>
+ </ul>
+ </div>
+</s:set>
+
+<s:set var="fullView" value="%{fullView}"/>
+
+<div class="sticky-buttons">
+ <button type="button" id="switch-compact-full-view" class="btn <s:if test="fullView">full-view</s:if><s:else>compact-view</s:else>">
+ <span class="only-in-compact-view">
+ <i class="fa fa-expand"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToFullView" /></span>
+ </span>
+ <span class="only-in-full-view">
+ <i class="fa fa-compress"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToCompactView" /></span>
+ </span>
+ </button>
+</div>
+
+
+<s:property value="#pagination" escapeHtml="false"/>
+
+<table id="contacts-list" class="contacts-list large-table table-striped <s:if test="fullView">full-view</s:if><s:else>compact-view</s:else>">
+ <thead>
+ <tr>
+ <th><s:text name="wao.ui.field.Contact.creationDate"/></th>
+ <th><s:text name="wao.ui.contacts.boatName"/></th>
+ <th><s:text name="wao.ui.field.Contact.sampleRow"/></th>
+ <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.programName"/></th>
+ <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.professionCode"/></th>
+ <th class="only-in-full-view"><s:text name="wao.ui.contacts.Profession.libelle"/></th>
+ <th class="only-in-full-view"><s:text name="wao.ui.contacts.Profession.species"/></th>
+ <th class="only-in-full-view"><s:text name="wao.ui.contacts.FishingZone.facadeName"/></th>
+ <th class="only-in-full-view"><s:text name="wao.ui.contacts.FishingZone.sectorName"/></th>
+ <th class="only-in-full-view"><s:text name="wao.ui.contacts.division"/></th>
+ <s:if test="obsVente">
+ <th><s:text name="wao.ui.field.Contact.terrestrialLocation"/></th>
+ </s:if>
+ <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.company"/></th>
+ <th><s:text name="wao.ui.contacts.observers"/></th>
+ <th><s:text name="wao.ui.field.Contact.contactState"/> (<s:text name="wao.ui.field.Contact.contactStateMotif"/>)</th>
+ <th class="date-time"><s:text name="wao.ui.field.Contact.beginDate"/></th>
+ <th class="date-time"><s:text name="wao.ui.field.Contact.endDate"/></th>
+ <s:if test="obsMer">
+ <th class="date-time"><s:text name="wao.ui.field.Contact.observationTimeInDays"/></th>
+ </s:if>
+ <th class="date"><s:text name="wao.ui.field.Contact.dataInputDate"/></th>
+ <s:if test="obsMer">
+ <th><s:text name="wao.ui.field.Contact.observedDataControl"/></th>
+ <th class="date"><s:text name="wao.ui.field.Contact.restitution"/></th>
+ <th><s:text name="wao.ui.contacts.observations"/></th>
+ </s:if>
+ <s:if test="obsVente">
+ <th><s:text name="wao.ui.field.Contact.samplingStrategy"/></th>
+ <th><s:text name="wao.ui.field.Contact.completeSampling"/></th>
+ </s:if>
+ <s:if test="authenticatedWaoUser.authorizedToViewContactsComments">
+ <th><s:text name="wao.ui.field.Contact.comment"/></th>
+ <th><s:text name="wao.ui.field.Contact.commentCompany"/></th>
+ <th><s:text name="wao.ui.field.Contact.commentAdmin"/></th>
+ </s:if>
+ <s:if test="obsMer">
+ <th><s:text name="wao.ui.field.Contact.dataReliability"/></th>
+ </s:if>
+ <th><s:text name="wao.ui.contacts.validation"/></th>
+ <th><s:text name="wao.ui.actions"/></th>
+ </tr>
+ </thead>
+ <tbody>
+
+ <s:iterator value="contacts" var="contact">
+ <s:set name="trCssClasses">contact-row<s:if test="topiaId.equals(contactToHighlightId)"> highlight</s:if><s:if test="validationCompany==null"></s:if><s:elseif test="validationCompany"> accepted-by-company</s:elseif><s:else> refused-by-company</s:else><s:if test="validationProgram==null"></s:if><s:elseif test="validationProgram"> accepted-by-program</s:elseif><s:else> refused-by-program</s:else></s:set>
+ <tr class="<s:property value="#trCssClasses"/>" data-contactId="<s:property value="topiaId"/>">
+ <td>
+ <s:property value="creationDate"/>
+ </td>
+ <td>
+ <s:set name="boatTooltip">
+ <s:text name="wao.ui.boats.registrationCode"/> <s:property value="%{'' + boat.immatriculation}" escapeHtml="false"/>
+ <s:text name="wao.ui.boats.boatLength"/> <s:property value="boat.boatLength" escapeHtml="false"/> cm
+ <s:text name="wao.ui.boats.buildYear"/> <s:property value="%{'' + boat.buildYear}" escapeHtml="false"/>
+ <s:text name="wao.ui.boats.district"/> <s:property value="boat.district.districtName" escapeHtml="false"/> (<s:property value="boat.district.districtCode" escapeHtml="false"/>)
+ </s:set>
+ <span data-original-title="<s:property value="#boatTooltip"/>" data-toggle="tooltip" data-placement="right">
+ <s:property value="boat.name"/>
+ </span>
+ </td>
+ <td class="only-in-compact-view">
+ <s:set name="sampleRowTooltip">
+ <s:text name="wao.ui.field.SampleRow.programName"/> <s:property value="sampleRow.programName" escapeHtml="false"/>
+ <s:text name="wao.ui.field.SampleRow.professionCode"/> <s:property value="sampleRow.professionDescription" escapeHtml="false"/>
+ <s:text name="wao.ui.contacts.Profession.libelle"/> <s:property value="sampleRow.profession.libelle" escapeHtml="false"/>
+ <s:text name="wao.ui.contacts.Profession.species"/> <s:property value="sampleRow.profession.species" escapeHtml="false"/>
+ <s:text name="wao.ui.contacts.FishingZone.facadeName"/> <s:property value="sampleRow.facade" escapeHtml="false"/>
+ <s:text name="wao.ui.contacts.FishingZone.sectorName"/> <s:property value="sampleRow.sectors" escapeHtml="false"/>
+ <s:text name="wao.ui.contacts.division"/> <s:property value="%{getDivision(sampleRow)}" escapeHtml="false"/>
+ </s:set>
+ <span data-original-title="<s:property value="#sampleRowTooltip"/>" data-toggle="tooltip" data-placement="right">
+ <s:property value="sampleRow.code"/>
+ </span>
+ </td>
+ <td class="only-in-full-view">
+ <s:property value="sampleRow.code"/>
+ </td>
+ <td class="only-in-full-view">
+ <s:property value="sampleRow.programName"/>
+ </td>
+ <td class="only-in-full-view">
+ <s:iterator value="getDcf5CodesAndDescriptions(sampleRow)">
+ <abbr title="<s:property value="value"/>"><s:property value="key"/></abbr>
+ </s:iterator>
+ <s:property value="sampleRow.professionDescriptionWithoutDCF5" />
+ </td>
+ <td class="only-in-full-view">
+ <s:property value="sampleRow.profession.libelle"/>
+ </td>
+ <td class="only-in-full-view">
+ <s:property value="sampleRow.profession.species"/>
+ </td>
+ <td class="only-in-full-view">
+ <s:property value="sampleRow.facade"/>
+ </td>
+ <td class="only-in-full-view">
+ <s:property value="sampleRow.sectors"/>
+ </td>
+ <td class="only-in-full-view">
+ <s:property value="%{getDivision(sampleRow)}"/>
+ </td>
+ <s:if test="obsVente">
+ <td>
+ <s:property value="terrestrialLocation.description"/>
+ </td>
+ </s:if>
+ <td class="only-in-full-view">
+ <s:property value="sampleRow.company.name"/>
+ </td>
+ <td>
+ <ul>
+ <s:iterator value="allObservers">
+ <li><s:property value="fullName"/></li>
+ </s:iterator>
+ </ul>
+ </td>
+ <td>
+ <s:text name="%{contactState.i18nKey}"/>
+ <s:if test="contactStateMotif != null">
+ <s:property value="contactStateMotif.name"/>
+ </s:if>
+ </td>
+ <td class="date-time">
+ <s:if test="observationBeginDate != null">
+ <s:property value="observationBeginDate"/>
+ </s:if>
+ </td>
+ <td class="date-time">
+ <s:if test="observationEndDate != null">
+ <s:property value="observationEndDate"/>
+ </s:if>
+ </td>
+ <s:if test="obsMer">
+ <td>
+ <s:if test="observationTimeInDays != null">
+ <s:property value="observationTimeInDays"/>
+ </s:if>
+ </td>
+ </s:if>
+ <td class="date">
+ <s:if test="dataInputDate != null">
+ <s:property value="dataInputDate"/>
+ </s:if>
+ </td>
+ <s:if test="obsMer">
+ <td>
+ <s:if test="observedDataControl != null">
+ <s:text name="%{observedDataControl.i18nKey}"/>
+ </s:if>
+ </td>
+ <td class="date">
+ <s:if test="restitution != null">
+ <s:property value="restitution"/>
+ </s:if>
+ </td>
+ <td class="align-center">
+ <s:if test="mammalsObservation">
+ <i class="fa fa-eye"
+ title="<s:text name="wao.ui.field.Contact.mammalsObservation"/>"></i>
+ </s:if>
+ <s:if test="mammalsCapture">
+ <img src="<s:url value="/img/hook-22px.png"/>"
+ alt="<s:text name="wao.ui.field.Contact.mammalsCapture"/>"
+ title="<s:property value="mammalsInfo" escapeHtml="false"/>"/>
+ </s:if>
+ </td>
+ </s:if>
+ <s:if test="obsVente">
+ <td>
+ <s:if test="samplingStrategy != null">
+ <s:text name="%{samplingStrategy.i18nKey}"/>
+ </s:if>
+ </td>
+ <td>
+ <s:if test="completeSampling == null">
+ </s:if>
+ <s:elseif test="completeSampling">
+ <s:text name="wao.ui.misc.yes"/>
+ </s:elseif>
+ <s:else>
+ <s:text name="wao.ui.misc.no"/>
+ </s:else>
+ </td>
+ </s:if>
+ <s:if test="authenticatedWaoUser.authorizedToViewContactsComments">
+ <td class="align-center">
+ <s:if test=" ! comment.empty">
+ <i title="<s:property value="comment" escapeHtml="false"/>" class="fa fa-comment"></i>
+ </s:if>
+ </td>
+ <td class="align-center">
+ <s:if test=" ! commentCoordinator.empty">
+ <i title="<s:property value="commentCoordinator" escapeHtml="false"/>" class="fa fa-comment"></i>
+ </s:if>
+ </td>
+ <td class="align-center">
+ <s:if test=" ! commentAdmin.empty">
+ <i title="<s:property value="commentAdmin" escapeHtml="false"/>" class="fa fa-comment"></i>
+ </s:if>
+ </td>
+ </s:if>
+ <s:if test="obsMer">
+ <td>
+ <s:if test="isBoardingDone(#contact)">
+ <s:if test="validationCompany">
+ <s:text name="%{dataReliability.i18nKey}"/>
+ </s:if>
+ </s:if>
+ </td>
+ </s:if>
+ <td>
+ <span class="fa-stack fa-lg" title="<s:text name="wao.ui.misc.validated"/>">
+ <i class="fa fa-square-o fa-stack-2x"></i>
+ <i class="fa fa-check fa-stack-1x only-if-accepted-by-company"></i>
+ <i class="fa fa-times fa-stack-1x only-if-refused-by-company"></i>
+ </span>
+ <span class="fa-stack fa-lg" title="<s:text name="wao.ui.misc.validated"/>">
+ <i class="fa fa-square-o fa-stack-2x"></i>
+ <i class="fa fa-check fa-stack-1x only-if-accepted-by-program"></i>
+ <i class="fa fa-times fa-stack-1x only-if-refused-by-program"></i>
+ </span>
+ </td>
+ <td class="actions">
+ <div class="dropdown">
+ <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
+ <s:text name="wao.ui.actions"/>
+ <b class="caret"></b>
+ </a>
+ <ul class="dropdown-menu">
+ <li>
+ <s:if test="authenticatedWaoUser.admin">
+ <s:set name="focusAnchor">adminFocus</s:set>
+ </s:if>
+ <s:else>
+ <s:set name="focusAnchor">coordinatorOrObserverFocus</s:set>
+ </s:else>
+ <s:url action="edit-contact!input" id="editContactUrl" anchor='%{focusAnchor}'>
+ <s:param name="contactId" value="topiaId"/>
+ </s:url>
+ <s:a href="%{editContactUrl}">
+ <i class="icon-edit"></i> <s:text name="wao.ui.action.editOrDeleteContact"/>
+ </s:a>
+ </li>
+ <s:if test="authenticatedWaoUser.authorizedToChangeContactValidation">
+ <li>
+ <s:url action="validate-contact-json" id="acceptContactUrl" escapeAmp="false">
+ <s:param name="contactId" value="topiaId"/>
+ <s:param name="validationState">true</s:param>
+ </s:url>
+ <s:set name="disabled"><s:if test="%{ ! isAcceptable(#contact)}">disabled</s:if></s:set>
+ <s:a cssClass="validation-action" href="%{acceptContactUrl}">
+ <s:text name="wao.ui.action.acceptContact"/>
+ </s:a>
+ </li>
+ <li>
+ <s:url action="validate-contact-json" id="refuseContactUrl" escapeAmp="false">
+ <s:param name="contactId" value="topiaId"/>
+ <s:param name="validationState">false</s:param>
+ </s:url>
+ <s:a cssClass="validation-action" href="%{refuseContactUrl}">
+ <s:text name="wao.ui.action.refuseContact"/>
+ </s:a>
+ </li>
+ <li>
+ <s:url action="validate-contact-json" id="unvalidateContactUrl">
+ <s:param name="contactId" value="topiaId"/>
+ </s:url>
+ <s:a cssClass="validation-action" href="%{unvalidateContactUrl}">
+ <s:text name="wao.ui.action.unvalidateContact"/>
+ </s:a>
+ </li>
+ </s:if>
+ </ul>
+ </div>
+ </td>
+ </tr>
+ </s:iterator>
+ </todby>
+</table>
+
+<s:property value="#pagination" escapeHtml="false"/>
+
+</html>
Copied: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp 2014-06-20 17:38:35 UTC (rev 2078)
@@ -0,0 +1,366 @@
+<%--
+ #%L
+ Wao :: Web
+ %%
+ Copyright (C) 2009 - 2014 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<html>
+<head>
+ <title>
+ <s:if test="updateContactCommand.creation">
+ <s:text name="wao.ui.contact.creation"/>
+ </s:if>
+ <s:else>
+ <s:text name="wao.ui.contact.edition"/>
+ </s:else>
+ </title>
+ <script>
+
+ $(document).ready(function () {
+
+ <s:if test="contact.obsProgram.obsMer">
+ var $mammalsCaptureCheckbox = $('#mammalsCaptureCheckbox');
+ var $mammalsInfo = $('#mammalsInfo');
+
+ var showHideMammalsInfo = function () {
+ if ($mammalsCaptureCheckbox.prop('checked')) {
+ $mammalsInfo.show();
+ } else {
+ $mammalsInfo.hide();
+ }
+ };
+
+ $mammalsCaptureCheckbox.change(showHideMammalsInfo);
+ showHideMammalsInfo();
+
+ var $contactStateMotif = $('#contactStateMotif');
+ var $contactStateSelect = $('select[name="updateContactCommand.contact.contactState"]');
+
+ var showHideContactStateMotif = function () {
+ var contactState = $contactStateSelect.val();
+ if (contactState === 'CONTACT_REFUSED' || contactState === 'CONTACT_DEFINITELY_REFUSED') {
+ $contactStateMotif.show();
+ } else {
+ $contactStateMotif.hide();
+ }
+ };
+
+ $contactStateSelect.change(showHideContactStateMotif);
+ showHideContactStateMotif();
+
+ </s:if>
+
+ $('#delete-contact-link').click(function (e) {
+ if ( ! confirm("<s:text name="wao.ui.action.deleteContact.confirm"/>")) {
+ e.preventDefault();
+ }
+ })
+
+ });
+
+ </script>
+ <content tag="mainClass">form</content>
+</head>
+
+ <div class="form-wrapper">
+ <h1>
+ <s:if test="updateContactCommand.creation">
+ <s:text name="wao.ui.contact.creation"/>
+ </s:if>
+ <s:else>
+ <s:text name="wao.ui.contact.edition"/>
+ </s:else>
+ </h1>
+
+ <aside class="well">
+
+ <h2><s:text name="wao.ui.misc.information"/></h2>
+
+ <s:text name="wao.ui.form.Contact.contactCreatedOn">
+ <s:param value="%{formatDate(updateContactCommand.contact.creationDate)}"/>
+ </s:text>
+
+ <h3><s:text name="wao.ui.field.Contact.boat"/></h3>
+
+ <table class="table">
+ <tbody>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Boat.name"/>
+ </th>
+ <td>
+ <s:property value="updateContactCommand.contact.boat.name"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Boat.immatriculation"/>
+ </th>
+ <td>
+ <s:property value="updateContactCommand.contact.boat.immatriculation"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Boat.districtCode"/>
+ </th>
+ <td>
+ <s:property value="updateContactCommand.contact.boat.districtCode"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Boat.boatLength"/>
+ </th>
+ <td>
+ <s:property value="%{'' + updateContactCommand.contact.boat.boatLength}"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Boat.buildYear"/>
+ </th>
+ <td>
+ <s:property value="%{'' + updateContactCommand.contact.boat.buildYear}"/>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <h3><s:text name="wao.ui.field.Contact.sampleRow"/></h3>
+
+ <table class="table">
+ <tbody>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.SampleRow.profession"/>
+ </th>
+ <td>
+ <s:property value="updateContactCommand.contact.sampleRow.professionDescription"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.SampleRow.programName"/>
+ </th>
+ <td>
+ <s:property value="updateContactCommand.contact.sampleRow.programName"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.SampleRow.periodBegin"/>
+ </th>
+ <td>
+ <s:property value="%{formatMonth(updateContactCommand.contact.sampleRow.periodBegin)}"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.SampleRow.periodEnd"/>
+ </th>
+ <td>
+ <s:property value="%{formatMonth(updateContactCommand.contact.sampleRow.periodEnd)}"/>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </aside>
+
+ <s:form>
+
+ <s:set name="editObservationReport"
+ value="%{authenticatedWaoUser.isAuthorizedToEditObservationReport(updateContactCommand.contact)}"/>
+
+ <s:hidden name="contactId" value="%{contactId}"/>
+
+ <fieldset>
+ <legend><s:text name="wao.ui.misc.observers"/></legend>
+
+ <s:select name="updateContactCommand.mainObserverId"
+ value="%{updateContactCommand.mainObserverId}"
+ label="%{getText('wao.ui.field.Contact.mainObserver')}"
+ list="observers"
+ emptyOption="true"
+ disabled="%{!#editObservationReport}"
+ cssClass="input-large"
+ />
+
+ <s:select name="updateContactCommand.secondaryObserverIds"
+ value="%{updateContactCommand.secondaryObserverIds}"
+ label="%{getText('wao.ui.field.Contact.secondaryObservers')}"
+ list="observers"
+ multiple="true"
+ disabled="%{!#editObservationReport}"
+ cssClass="input-xlarge"
+ />
+
+ </fieldset>
+
+ <%--Do not remove the id (use by contacts page)--%>
+ <fieldset id="coordinatorOrObserverFocus">
+ <legend><s:text name="wao.ui.misc.observationReport"/></legend>
+
+ <s:textfield name="updateContactCommand.contact.observationBeginDate"
+ label="%{getText('wao.ui.field.Contact.beginDate')}"
+ placeholder="%{getDateTimePlaceholder()}"
+ disabled="%{!#editObservationReport}"/>
+
+ <s:textfield name="updateContactCommand.contact.observationEndDate"
+ label="%{getText('wao.ui.field.Contact.endDate')}"
+ placeholder="%{getDateTimePlaceholder()}"
+ disabled="%{!#editObservationReport}"/>
+
+ <s:select name="updateContactCommand.contact.contactState"
+ label="%{getText('wao.ui.field.Contact.contactState')}"
+ requiredLabel="true"
+ list="contactStates"
+ disabled="%{!#editObservationReport}"/>
+
+ <s:if test="updateContactCommand.contact.obsProgram.obsVente">
+
+ <s:select name="updateContactCommand.terrestrialLocationId"
+ value="%{updateContactCommand.terrestrialLocationId}"
+ label="%{getText('wao.ui.field.Contact.terrestrialLocation')}"
+ list="terrestrialLocations"
+ emptyOption="true"
+ disabled="%{!#editObservationReport}"
+ cssClass="input-xxlarge select2"
+ />
+
+ <s:select name="updateContactCommand.contact.samplingStrategy"
+ label="%{getText('wao.ui.field.Contact.samplingStrategy')}"
+ list="samplingStrategies"
+ emptyOption="true"
+ disabled="%{!#editObservationReport}"/>
+
+ <s:checkbox name="updateContactCommand.contact.completeSampling"
+ label="%{getText('wao.ui.field.Contact.completeSampling')}"
+ disabled="%{!#editObservationReport}"/>
+
+ </s:if>
+
+ <s:if test="updateContactCommand.contact.obsProgram.obsMer">
+
+ <div id="contactStateMotif">
+ <s:select name="updateContactCommand.contact.contactStateMotif"
+ value="%{updateContactCommand.contact.contactState.topiaId}"
+ label="%{getText('wao.ui.field.Contact.contactStateMotif')}"
+ list="contactStateMotives"
+ emptyOption="true"
+ disabled="%{!#editObservationReport}"/>
+ </div>
+
+ <s:checkbox name="updateContactCommand.contact.mammalsObservation"
+ label="%{getText('wao.ui.field.Contact.mammalsObservation')}"
+ disabled="%{!#editObservationReport}"/>
+
+ <s:checkbox name="updateContactCommand.contact.mammalsCapture"
+ id="mammalsCaptureCheckbox"
+ label="%{getText('wao.ui.field.Contact.mammalsCapture')}"
+ disabled="%{!#editObservationReport}"/>
+
+ <div id="mammalsInfo">
+ <s:textarea name="updateContactCommand.contact.mammalsInfo"
+ label="%{getText('wao.ui.field.Contact.mammalsInfo')}"
+ disabled="%{!#editObservationReport}"/>
+ <div class="alert">
+ <s:text name="wao.ui.page.ContactForm.mammalsInfo.disclaimer"/>
+ </div>
+ </div>
+
+ </s:if>
+
+ <s:textfield name="updateContactCommand.contact.dataInputDate"
+ label="%{getText('wao.ui.field.Contact.dataInputDate')}"
+ placeholder="%{getDatePlaceholder()}"
+ disabled="%{!#editObservationReport}"/>
+
+ <s:if test="updateContactCommand.contact.obsProgram.obsMer">
+
+ <s:select name="updateContactCommand.contact.observedDataControl"
+ label="%{getText('wao.ui.field.Contact.observedDataControl')}"
+ list="observedDataControls"
+ emptyOption="true"
+ disabled="%{!#editObservationReport || !authenticatedWaoUser.coordinator}"/>
+
+ <s:textfield name="updateContactCommand.contact.restitution"
+ label="%{getText('wao.ui.field.Contact.restitution')}"
+ placeholder="%{getDatePlaceholder()}"
+ disabled="%{!#editObservationReport}"/>
+
+ </s:if>
+
+ <s:textarea name="updateContactCommand.contact.comment"
+ label="%{getText('wao.ui.field.Contact.comment')}"
+ placeholder="%{getText('wao.ui.misc.noComment')}"
+ disabled="%{!#editObservationReport || !authenticatedWaoUser.observer}"/>
+
+ <s:textarea name="updateContactCommand.contact.commentCoordinator"
+ label="%{getText('wao.ui.field.Contact.commentCoordinator')}"
+ placeholder="%{getText('wao.ui.misc.noComment')}"
+ disabled="%{!#editObservationReport || !authenticatedWaoUser.coordinator}"/>
+
+ </fieldset>
+
+ <%--Do not remove the id (use by contacts page)--%>
+ <fieldset id="adminFocus">
+ <legend><s:text name="wao.ui.form.programEvaluation"/></legend>
+
+ <s:if test="authenticatedWaoUser.authorizedToDisplayContactDataReliability">
+ <s:select name="updateContactCommand.contact.dataReliability"
+ label="%{getText('wao.ui.field.Contact.dataReliability')}"
+ list="dataReliabilities"
+ emptyOption="true"
+ disabled="%{!authenticatedWaoUser.isAuthorizedToEditContactDataReliability(updateContactCommand.contact)}"/>
+ </s:if>
+
+ <s:textarea name="updateContactCommand.contact.commentAdmin"
+ label="%{getText('wao.ui.field.Contact.commentAdmin')}"
+ placeholder="%{getText('wao.ui.misc.noComment')}"
+ disabled="%{!authenticatedWaoUser.admin}"/>
+ </fieldset>
+
+ <div class="form-actions">
+ <s:url action="contacts" id="contactsUrl"/>
+ <s:a href="%{contactsUrl}" cssClass="btn">
+ <i class="icon-chevron-left"></i> <s:text name="wao.ui.action.cancel"/>
+ </s:a>
+ <s:if test="authenticatedWaoUser.isAuthorizedToEditContact(updateContactCommand.contact)">
+ <s:submit type="button" cssClass="btn">
+ <i class="icon-hdd"></i> <s:text name="wao.ui.action.save"/>
+ </s:submit>
+ </s:if>
+
+ <s:if test=" ! updateContactCommand.creation && authenticatedWaoUser.isAuthorizedToDeleteContact(updateContactCommand.contact)">
+ <s:url action="delete-contact" id="deleteContactUrl">
+ <s:param name="contactId" value="contactId"/>
+ </s:url>
+ <s:a href="%{deleteContactUrl}" cssClass="btn pull-right" id="delete-contact-link">
+ <i class="icon-trash"></i> <s:text name="wao.ui.action.deleteContact"/>
+ </s:a>
+ </s:if>
+ </div>
+
+ </s:form>
+ </div>
+</html>
+
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,552 +0,0 @@
-<%--
- #%L
- Wao :: Web
- %%
- Copyright (C) 2009 - 2014 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
-<%@taglib uri="/struts-tags" prefix="s" %>
-
-<html>
-
-<head>
- <title>
- <s:text name="wao.ui.page.Contacts.title"/>
- </title>
-
- <script>
-
- $(document).ready(function () {
-
- var contactsFilterMappings = [
- <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies">
- {
- filterName: 'sampleRowFilter.companyIds',
- filterLabel: "<s:text name="wao.ui.entity.Company"/>",
- filterValuesField: 'sampleRowsFilterValues.companies',
- },
- </s:if>
- {
- filterName: 'sampleRowFilter.sampleRowCodes',
- filterLabel: "<s:text name="wao.ui.field.SampleRow.code"/>",
- filterValuesField: 'sampleRowsFilterValues.sampleRowCodes',
- },
- {
- filterName: 'sampleRowFilter.programNames',
- filterLabel: "<s:text name="wao.ui.field.SampleRow.programName"/>",
- filterValuesField: 'sampleRowsFilterValues.programNames',
- },
- {
- filterName: 'sampleRowFilter.fishingZoneFacadeNames',
- filterLabel: "<s:text name="wao.ui.field.FishingZone.facadeName"/>",
- filterValuesField: 'sampleRowsFilterValues.fishingZoneFacadeNames',
- },
- {
- filterName: 'sampleRowFilter.fishingZoneSectorNames',
- filterLabel: "<s:text name="wao.ui.field.FishingZone.sectorName"/>",
- filterValuesField: 'sampleRowsFilterValues.fishingZoneSectorNames',
- },
- {
- filterName: 'sampleRowFilter.fishingGearDcfIds',
- filterLabel: "<s:text name="wao.ui.entity.fishingGearDCF"/>",
- filterValuesField: 'sampleRowsFilterValues.fishingGearDcfs',
- },
- {
- filterName: 'sampleRowFilter.targetSpeciesDcfIds',
- filterLabel: "<s:text name="wao.ui.entity.targetSpeciesDCF"/>",
- filterValuesField: 'sampleRowsFilterValues.targetSpeciesDcfs',
- },
- <s:if test="authenticatedWaoUser.authorizedToFilterOnBoats">
- {
- filterName: 'boatFilter.boatIds',
- filterLabel: "<s:text name="wao.ui.entity.Boat"/>",
- filterValuesField: 'boatsFilterValues.boats',
- minimumInputLength: 3
- },
- </s:if>
- {
- filterName: 'boatFilter.districtIds',
- filterLabel: "<s:text name="wao.ui.field.Boat.district"/>",
- filterValuesField: 'boatsFilterValues.districts'
- },
- {
- filterName: 'observerIds',
- filterLabel: "<s:text name="wao.ui.misc.observer"/>",
- filterValuesField: 'observers'
- },
- {
- filterName: 'contactStates',
- filterLabel: "<s:text name="wao.ui.field.Contact.contactState"/>",
- filterValuesField: 'contactStates'
- },
- {
- filterName: 'companyAcceptations',
- filterLabel: "<s:text name="wao.ui.field.Contact.validationCompany"/>",
- filterValuesField: 'companyAcceptations'
- },
- {
- filterName: 'programAcceptations',
- filterLabel: "<s:text name="wao.ui.field.Contact.validationProgram"/>",
- filterValuesField: 'programAcceptations'
- },
- {
- filterName: 'observedDataControls',
- filterLabel: "<s:text name="wao.ui.field.Contact.observedDataControl"/>",
- filterValuesField: 'observedDataControls'
- },
- {
- filterName: 'dataReliabilities',
- filterLabel: "<s:text name="wao.ui.field.Contact.dataReliability"/>",
- filterValuesField: 'dataReliabilities'
- }
- ];
-
- filter = <s:property value="filter" escapeHtml="false"/>;
-
- contactsFilterController2 = new FilterController2(contactsFilterMappings, filter, WAO.OBSMER_CONTACTS_FILTER_VALUES_JSON_URL, $('#contacts-filters-form fieldset.extra-filters'));
- contactsFilterController2.init();
-
- $('#switch-compact-full-view').click(function () {
- $('#switch-compact-full-view').toggleClass('full-view').toggleClass('compact-view');
- $('table.contacts-list').toggleClass('full-view').toggleClass('compact-view');
- });
-
- $('.validation-action').click(function(e) {
- e.preventDefault();
- var $action = $(this);
- var url = $action.attr('href');
- var successCallback = function (data) {
- var successful = data['successful'];
- if (successful) {
- var success = data['successMessage'];
- WAO.notifications.success(success);
- var $tr = $('#contacts-list').find('tr[data-contactId="' + data.contactId + '"]');
- $tr.removeClass('accepted-by-company refused-by-company accepted-by-program refused-by-program');
- if (data.validationCompany) {
- $tr.addClass('accepted-by-company');
- } else if (data.validationCompany === false) {
- $tr.addClass('refused-by-company');
- }
- if (data.validationProgram) {
- $tr.addClass('accepted-by-program');
- } else if (data.validationProgram === false) {
- $tr.addClass('refused-by-program');
- }
- } else {
- var error = data['errorMessage'];
- WAO.notifications.error(error);
- }
- };
- WAO.post(url, {}, successCallback);
- });
-
- // Do not expose any struts internal input fields
- $('input[type="hidden"][id^="__"]').prop('disabled', true);
- });
-
- </script>
-
-</head>
-
-<content tag="mainClass">large</content>
-<content tag="contactsMenuItemClass">active</content>
-
-<s:form method="GET" id="contacts-filters-form" cssClass="filters-form">
-
- <fieldset>
-
- <s:textfield name="filter.periodFrom"
- label="%{getText('wao.ui.form.periodFrom')}"
- placeholder="%{getFilterPeriodFromPlaceholder()}"
- cssClass="input-small"/>
-
- <s:textfield name="filter.periodTo"
- label="%{getText('wao.ui.form.period.to')}"
- placeholder="%{getFilterPeriodToPlaceholder()}"
- cssClass="input-small"/>
-
- <div title="<s:text name="wao.ui.form.filterOnObservationBeginDate.tooltip"/>">
- <s:checkbox name="filter.filterOnObservationBeginDate"
- label="%{getText('wao.ui.form.filterOnObservationBeginDate')}"/>
- </div>
-
- </fieldset>
-
- <fieldset class="extra-filters">
-
- </fieldset>
-
- <fieldset>
-
- <s:checkbox name="filter.mammalsObservationOnly"
- label="%{getText('wao.ui.misc.observations')}"/>
-
- <s:checkbox name="filter.mammalsCaptureOnly"
- label="%{getText('wao.ui.field.Contact.mammalsCapture')}"/>
-
- <s:checkbox name="filter.commentDefinedOnly"
- label="%{getText('wao.ui.field.Contact.comment')}"/>
-
- <s:checkbox name="filter.commentCompanyDefinedOnly"
- label="%{getText('wao.ui.field.Contact.commentCompany')}"/>
-
- <s:checkbox name="filter.commentAdminDefinedOnly"
- label="%{getText('wao.ui.field.Contact.commentAdmin')}"/>
-
- </fieldset>
-
- <fieldset>
-
- <s:checkbox name="filter.sortedByBoardingDate"
- label="%{getText('wao.ui.form.sortByTideBegin')}"/>
-
- </fieldset>
-
- <div class="form-actions">
-
- <s:submit type="button" action="contacts!applyFilter" cssClass="btn btn-primary">
- <i class="icon-filter"></i> <s:text name="wao.ui.action.filter"/>
- </s:submit>
-
- <s:submit type="button" action="contacts!resetFilter" cssClass="btn">
- <i class="icon-trash"></i> <s:text name="wao.ui.action.reset"/>
- </s:submit>
-
- <s:if test="authenticatedWaoUser.authorizedToExportContacts">
- <s:submit action="export-contacts" type="button" cssClass="btn">
- <i class="icon-download"></i> <s:text name="wao.ui.action.csvExport"/>
- </s:submit>
- </s:if>
-
- </div>
-
-</s:form>
-
-<h3>
- <s:text name="wao.ui.contacts.title">
- <s:param value="%{pagination.count}"/>
- </s:text>
-</h3>
-
-<s:set name="pagination">
- <%-- Pagination --%>
- <div class="pagination">
- <ul>
- <s:url var="fullUrl" includeParams="get"/>
- <s:set var="paginationUrl" value="%{getPaginationUrl(#fullUrl)}"/>
- <s:if test="firstRangePage > 2">
- <li>
- <a href="${paginationUrl}0">1</a>
- </li>
- <li>
- <a href="${paginationUrl}1">2</a>
- </li>
- <li>
- <span>...</span>
- </li>
- </s:if>
-
- <s:iterator var="currentPage" begin="firstRangePage" end="lastRangePage">
- <li class="<s:if test="#currentPage - 1 == pagination.currentPage.pageNumber">active</s:if>">
- <a href="${paginationUrl}${currentPage - 1}">
- <s:property/>
- </a>
- </li>
- </s:iterator>
-
- <s:if test="lastRangePage < pagination.pageCount - 1">
- <li>
- <span>...</span>
- </li>
- <li>
- <a href="${paginationUrl}${pagination.pageCount - 2}">
- <s:property value="pagination.pageCount - 1"/>
- </a>
- </li>
- <li>
- <a href="${paginationUrl}${pagination.pageCount - 1}">
- <s:property value="pagination.pageCount"/>
- </a>
- </li>
- </s:if>
- </ul>
- </div>
-</s:set>
-
-<s:set var="fullView" value="%{fullView}"/>
-
-<div class="sticky-buttons">
- <button type="button" id="switch-compact-full-view" class="btn <s:if test="fullView">full-view</s:if><s:else>compact-view</s:else>">
- <span class="only-in-compact-view">
- <i class="fa fa-expand"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToFullView" /></span>
- </span>
- <span class="only-in-full-view">
- <i class="fa fa-compress"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToCompactView" /></span>
- </span>
- </button>
-</div>
-
-
-<s:property value="#pagination" escapeHtml="false"/>
-
-<table id="contacts-list" class="contacts-list large-table table-striped <s:if test="fullView">full-view</s:if><s:else>compact-view</s:else>">
- <thead>
- <tr>
- <th><s:text name="wao.ui.field.Contact.creationDate"/></th>
- <th><s:text name="wao.ui.contacts.boatName"/></th>
- <th><s:text name="wao.ui.field.Contact.sampleRow"/></th>
- <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.programName"/></th>
- <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.professionCode"/></th>
- <th class="only-in-full-view"><s:text name="wao.ui.contacts.Profession.libelle"/></th>
- <th class="only-in-full-view"><s:text name="wao.ui.contacts.Profession.species"/></th>
- <th class="only-in-full-view"><s:text name="wao.ui.contacts.FishingZone.facadeName"/></th>
- <th class="only-in-full-view"><s:text name="wao.ui.contacts.FishingZone.sectorName"/></th>
- <th class="only-in-full-view"><s:text name="wao.ui.contacts.division"/></th>
- <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.company"/></th>
- <th><s:text name="wao.ui.contacts.observers"/></th>
- <th><s:text name="wao.ui.field.Contact.contactState"/> (<s:text name="wao.ui.field.Contact.contactStateMotif"/>)</th>
- <th class="date-time"><s:text name="wao.ui.field.Contact.beginDate"/></th>
- <th class="date-time"><s:text name="wao.ui.field.Contact.endDate"/></th>
- <th class="date-time"><s:text name="wao.ui.field.Contact.observationTimeInDays"/></th>
- <th class="date"><s:text name="wao.ui.field.Contact.dataInputDate"/></th>
- <th><s:text name="wao.ui.field.Contact.observedDataControl"/></th>
- <th class="date"><s:text name="wao.ui.field.Contact.restitution"/></th>
- <th><s:text name="wao.ui.contacts.observations"/></th>
- <s:if test="authenticatedWaoUser.authorizedToViewContactsComments">
- <th><s:text name="wao.ui.field.Contact.comment"/></th>
- <th><s:text name="wao.ui.field.Contact.commentCompany"/></th>
- <th><s:text name="wao.ui.field.Contact.commentAdmin"/></th>
- </s:if>
- <th><s:text name="wao.ui.field.Contact.dataReliability"/></th>
- <th><s:text name="wao.ui.contacts.validation"/></th>
- <th><s:text name="wao.ui.actions"/></th>
- </tr>
- </thead>
- <tbody>
-
- <s:iterator value="contacts" var="contact">
- <s:set name="trCssClasses">contact-row<s:if test="topiaId.equals(contactToHighlightId)"> highlight</s:if><s:if test="validationCompany==null"></s:if><s:elseif test="validationCompany"> accepted-by-company</s:elseif><s:else> refused-by-company</s:else><s:if test="validationProgram==null"></s:if><s:elseif test="validationProgram"> accepted-by-program</s:elseif><s:else> refused-by-program</s:else></s:set>
- <tr class="<s:property value="#trCssClasses"/>" data-contactId="<s:property value="topiaId"/>">
- <td>
- <s:property value="creationDate"/>
- </td>
- <td>
- <s:set name="boatTooltip">
- <s:text name="wao.ui.boats.registrationCode"/> <s:property value="%{'' + boat.immatriculation}" escapeHtml="false"/>
- <s:text name="wao.ui.boats.boatLength"/> <s:property value="boat.boatLength" escapeHtml="false"/> cm
- <s:text name="wao.ui.boats.buildYear"/> <s:property value="%{'' + boat.buildYear}" escapeHtml="false"/>
- <s:text name="wao.ui.boats.district"/> <s:property value="boat.district.districtName" escapeHtml="false"/> (<s:property value="boat.district.districtCode" escapeHtml="false"/>)
- </s:set>
- <span data-original-title="<s:property value="#boatTooltip"/>" data-toggle="tooltip" data-placement="right">
- <s:property value="boat.name"/>
- </span>
- </td>
- <td class="only-in-compact-view">
- <s:set name="sampleRowTooltip">
- <s:text name="wao.ui.field.SampleRow.programName"/> <s:property value="sampleRow.programName" escapeHtml="false"/>
- <s:text name="wao.ui.field.SampleRow.professionCode"/> <s:property value="sampleRow.professionDescription" escapeHtml="false"/>
- <s:text name="wao.ui.contacts.Profession.libelle"/> <s:property value="sampleRow.profession.libelle" escapeHtml="false"/>
- <s:text name="wao.ui.contacts.Profession.species"/> <s:property value="sampleRow.profession.species" escapeHtml="false"/>
- <s:text name="wao.ui.contacts.FishingZone.facadeName"/> <s:property value="sampleRow.facade" escapeHtml="false"/>
- <s:text name="wao.ui.contacts.FishingZone.sectorName"/> <s:property value="sampleRow.sectors" escapeHtml="false"/>
- <s:text name="wao.ui.contacts.division"/> <s:property value="%{getDivision(sampleRow)}" escapeHtml="false"/>
- </s:set>
- <span data-original-title="<s:property value="#sampleRowTooltip"/>" data-toggle="tooltip" data-placement="right">
- <s:property value="sampleRow.code"/>
- </span>
- </td>
- <td class="only-in-full-view">
- <s:property value="sampleRow.code"/>
- </td>
- <td class="only-in-full-view">
- <s:property value="sampleRow.programName"/>
- </td>
- <td class="only-in-full-view">
- <s:iterator value="getDcf5CodesAndDescriptions(sampleRow)">
- <abbr title="<s:property value="value"/>"><s:property value="key"/></abbr>
- </s:iterator>
- <s:property value="sampleRow.professionDescriptionWithoutDCF5" />
- </td>
- <td class="only-in-full-view">
- <s:property value="sampleRow.profession.libelle"/>
- </td>
- <td class="only-in-full-view">
- <s:property value="sampleRow.profession.species"/>
- </td>
- <td class="only-in-full-view">
- <s:property value="sampleRow.facade"/>
- </td>
- <td class="only-in-full-view">
- <s:property value="sampleRow.sectors"/>
- </td>
- <td class="only-in-full-view">
- <s:property value="%{getDivision(sampleRow)}"/>
- </td>
- <td class="only-in-full-view">
- <s:property value="sampleRow.company.name"/>
- </td>
- <td>
- <ul>
- <s:iterator value="allObservers">
- <li><s:property value="fullName"/></li>
- </s:iterator>
- </ul>
- </td>
- <td>
- <s:text name="%{contactState.i18nKey}"/>
- <s:if test="contactStateMotif != null">
- <s:property value="contactStateMotif.name"/>
- </s:if>
- </td>
- <td class="date-time">
- <s:if test="observationBeginDate != null">
- <s:property value="observationBeginDate"/>
- </s:if>
- </td>
- <td class="date-time">
- <s:if test="observationEndDate != null">
- <s:property value="observationEndDate"/>
- </s:if>
- </td>
- <td>
- <s:if test="observationTimeInDays != null">
- <s:property value="observationTimeInDays"/>
- </s:if>
- </td>
- <td class="date">
- <s:if test="dataInputDate != null">
- <s:property value="dataInputDate"/>
- </s:if>
- </td>
- <td>
- <s:if test="observedDataControl != null">
- <s:text name="%{observedDataControl.i18nKey}"/>
- </s:if>
- </td>
- <td class="date">
- <s:if test="restitution != null">
- <s:property value="restitution"/>
- </s:if>
- </td>
- <td class="align-center">
- <s:if test="mammalsObservation">
- <i class="fa fa-eye"
- title="<s:text name="wao.ui.field.Contact.mammalsObservation"/>"></i>
- </s:if>
- <s:if test="mammalsCapture">
- <img src="<s:url value="/img/hook-22px.png"/>"
- alt="<s:text name="wao.ui.field.Contact.mammalsCapture"/>"
- title="<s:property value="mammalsInfo" escapeHtml="false"/>"/>
- </s:if>
- </td>
- <s:if test="authenticatedWaoUser.authorizedToViewContactsComments">
- <td class="align-center">
- <s:if test=" ! comment.empty">
- <i title="<s:property value="comment" escapeHtml="false"/>" class="fa fa-comment"></i>
- </s:if>
- </td>
- <td class="align-center">
- <s:if test=" ! commentCoordinator.empty">
- <i title="<s:property value="commentCoordinator" escapeHtml="false"/>" class="fa fa-comment"></i>
- </s:if>
- </td>
- <td class="align-center">
- <s:if test=" ! commentAdmin.empty">
- <i title="<s:property value="commentAdmin" escapeHtml="false"/>" class="fa fa-comment"></i>
- </s:if>
- </td>
- </s:if>
- <td>
- <s:if test="isBoardingDone(#contact)">
- <s:if test="validationCompany">
- <s:text name="%{dataReliability.i18nKey}"/>
- </s:if>
- </s:if>
- </td>
- <td>
- <span class="fa-stack fa-lg" title="<s:text name="wao.ui.misc.validated"/>">
- <i class="fa fa-square-o fa-stack-2x"></i>
- <i class="fa fa-check fa-stack-1x only-if-accepted-by-company"></i>
- <i class="fa fa-times fa-stack-1x only-if-refused-by-company"></i>
- </span>
- <span class="fa-stack fa-lg" title="<s:text name="wao.ui.misc.validated"/>">
- <i class="fa fa-square-o fa-stack-2x"></i>
- <i class="fa fa-check fa-stack-1x only-if-accepted-by-program"></i>
- <i class="fa fa-times fa-stack-1x only-if-refused-by-program"></i>
- </span>
- </td>
- <td class="actions">
- <div class="dropdown">
- <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
- <s:text name="wao.ui.actions"/>
- <b class="caret"></b>
- </a>
- <ul class="dropdown-menu">
- <li>
- <s:if test="authenticatedWaoUser.admin">
- <s:set name="focusAnchor">adminFocus</s:set>
- </s:if>
- <s:else>
- <s:set name="focusAnchor">coordinatorOrObserverFocus</s:set>
- </s:else>
- <s:url action="edit-contact!input" id="editContactUrl" anchor='%{focusAnchor}'>
- <s:param name="contactId" value="topiaId"/>
- </s:url>
- <s:a href="%{editContactUrl}">
- <i class="icon-edit"></i> <s:text name="wao.ui.action.editOrDeleteContact"/>
- </s:a>
- </li>
- <s:if test="authenticatedWaoUser.authorizedToChangeContactValidation">
- <li>
- <s:url action="validate-contact-json" id="acceptContactUrl" escapeAmp="false">
- <s:param name="contactId" value="topiaId"/>
- <s:param name="validationState">true</s:param>
- </s:url>
- <s:set name="disabled"><s:if test="%{ ! isAcceptable(#contact)}">disabled</s:if></s:set>
- <s:a cssClass="validation-action" href="%{acceptContactUrl}">
- <s:text name="wao.ui.action.acceptContact"/>
- </s:a>
- </li>
- <li>
- <s:url action="validate-contact-json" id="refuseContactUrl" escapeAmp="false">
- <s:param name="contactId" value="topiaId"/>
- <s:param name="validationState">false</s:param>
- </s:url>
- <s:a cssClass="validation-action" href="%{refuseContactUrl}">
- <s:text name="wao.ui.action.refuseContact"/>
- </s:a>
- </li>
- <li>
- <s:url action="validate-contact-json" id="unvalidateContactUrl">
- <s:param name="contactId" value="topiaId"/>
- </s:url>
- <s:a cssClass="validation-action" href="%{unvalidateContactUrl}">
- <s:text name="wao.ui.action.unvalidateContact"/>
- </s:a>
- </li>
- </s:if>
- </ul>
- </div>
- </td>
- </tr>
- </s:iterator>
- </todby>
-</table>
-
-<s:property value="#pagination" escapeHtml="false"/>
-
-</html>
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp 2014-06-20 17:38:35 UTC (rev 2078)
@@ -1,332 +0,0 @@
-<%--
- #%L
- Wao :: Web
- %%
- Copyright (C) 2009 - 2014 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
-<%@taglib uri="/struts-tags" prefix="s" %>
-
-<html>
-<head>
- <title>
- <s:if test="updateContactCommand.creation">
- <s:text name="wao.ui.contact.creation"/>
- </s:if>
- <s:else>
- <s:text name="wao.ui.contact.edition"/>
- </s:else>
- </title>
- <script>
-
- $(document).ready(function () {
-
- var $mammalsCaptureCheckbox = $('#mammalsCaptureCheckbox');
- var $mammalsInfo = $('#mammalsInfo');
-
- var showHideMammalsInfo = function () {
- if ($mammalsCaptureCheckbox.prop('checked')) {
- $mammalsInfo.show();
- } else {
- $mammalsInfo.hide();
- }
- };
-
- $mammalsCaptureCheckbox.change(showHideMammalsInfo);
- showHideMammalsInfo();
-
- var $contactStateMotif = $('#contactStateMotif');
- var $contactStateSelect = $('select[name="updateContactCommand.contact.contactState"]');
-
- var showHideContactStateMotif = function () {
- var contactState = $contactStateSelect.val();
- if (contactState === 'CONTACT_REFUSED' || contactState === 'CONTACT_DEFINITELY_REFUSED') {
- $contactStateMotif.show();
- } else {
- $contactStateMotif.hide();
- }
- };
-
- $contactStateSelect.change(showHideContactStateMotif);
- showHideContactStateMotif();
-
- $('#delete-contact-link').click(function (e) {
- if ( ! confirm("<s:text name="wao.ui.action.deleteContact.confirm"/>")) {
- e.preventDefault();
- }
- })
-
- });
-
- </script>
- <content tag="mainClass">form</content>
-</head>
-
- <div class="form-wrapper">
- <h1>
- <s:if test="updateContactCommand.creation">
- <s:text name="wao.ui.contact.creation"/>
- </s:if>
- <s:else>
- <s:text name="wao.ui.contact.edition"/>
- </s:else>
- </h1>
-
- <aside class="well">
-
- <h2><s:text name="wao.ui.misc.information"/></h2>
-
- <s:text name="wao.ui.form.Contact.contactCreatedOn">
- <s:param value="%{formatDate(updateContactCommand.contact.creationDate)}"/>
- </s:text>
-
- <h3><s:text name="wao.ui.field.Contact.boat"/></h3>
-
- <table class="table">
- <tbody>
- <tr>
- <th>
- <s:text name="wao.ui.field.Boat.name"/>
- </th>
- <td>
- <s:property value="updateContactCommand.contact.boat.name"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.Boat.immatriculation"/>
- </th>
- <td>
- <s:property value="updateContactCommand.contact.boat.immatriculation"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.Boat.districtCode"/>
- </th>
- <td>
- <s:property value="updateContactCommand.contact.boat.districtCode"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.Boat.boatLength"/>
- </th>
- <td>
- <s:property value="%{'' + updateContactCommand.contact.boat.boatLength}"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.Boat.buildYear"/>
- </th>
- <td>
- <s:property value="%{'' + updateContactCommand.contact.boat.buildYear}"/>
- </td>
- </tr>
- </tbody>
- </table>
-
- <h3><s:text name="wao.ui.field.Contact.sampleRow"/></h3>
-
- <table class="table">
- <tbody>
- <tr>
- <th>
- <s:text name="wao.ui.field.SampleRow.profession"/>
- </th>
- <td>
- <s:property value="updateContactCommand.contact.sampleRow.professionDescription"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.SampleRow.programName"/>
- </th>
- <td>
- <s:property value="updateContactCommand.contact.sampleRow.programName"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.SampleRow.periodBegin"/>
- </th>
- <td>
- <s:property value="%{formatMonth(updateContactCommand.contact.sampleRow.periodBegin)}"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.SampleRow.periodEnd"/>
- </th>
- <td>
- <s:property value="%{formatMonth(updateContactCommand.contact.sampleRow.periodEnd)}"/>
- </td>
- </tr>
- </tbody>
- </table>
-
- </aside>
-
- <s:form>
-
- <s:set name="editObservationReport"
- value="%{authenticatedWaoUser.isAuthorizedToEditObservationReport(updateContactCommand.contact)}"/>
-
- <s:hidden name="contactId" value="%{contactId}"/>
-
- <fieldset>
- <legend><s:text name="wao.ui.misc.observers"/></legend>
-
- <s:select name="updateContactCommand.mainObserverId"
- value="%{updateContactCommand.mainObserverId}"
- label="%{getText('wao.ui.field.Contact.mainObserver')}"
- list="observers"
- emptyOption="true"
- disabled="%{!#editObservationReport}"
- cssClass="input-large"
- />
-
- <s:select name="updateContactCommand.secondaryObserverIds"
- value="%{updateContactCommand.secondaryObserverIds}"
- label="%{getText('wao.ui.field.Contact.secondaryObservers')}"
- list="observers"
- multiple="true"
- disabled="%{!#editObservationReport}"
- cssClass="input-xlarge"
- />
-
- </fieldset>
-
- <%--Do not remove the id (use by contacts page)--%>
- <fieldset id="coordinatorOrObserverFocus">
- <legend><s:text name="wao.ui.misc.observationReport"/></legend>
-
- <s:textfield name="updateContactCommand.contact.observationBeginDate"
- label="%{getText('wao.ui.field.Contact.beginDate')}"
- placeholder="%{getDateTimePlaceholder()}"
- disabled="%{!#editObservationReport}"/>
-
- <s:textfield name="updateContactCommand.contact.observationEndDate"
- label="%{getText('wao.ui.field.Contact.endDate')}"
- placeholder="%{getDateTimePlaceholder()}"
- disabled="%{!#editObservationReport}"/>
-
- <s:select name="updateContactCommand.contact.contactState"
- label="%{getText('wao.ui.field.Contact.contactState')}"
- requiredLabel="true"
- list="contactStates"
- disabled="%{!#editObservationReport}"/>
-
- <div id="contactStateMotif">
- <s:select name="updateContactCommand.contact.contactStateMotif"
- value="%{updateContactCommand.contact.contactState.topiaId}"
- label="%{getText('wao.ui.field.Contact.contactStateMotif')}"
- list="contactStateMotives"
- emptyOption="true"
- disabled="%{!#editObservationReport}"/>
- </div>
-
- <s:checkbox name="updateContactCommand.contact.mammalsObservation"
- label="%{getText('wao.ui.field.Contact.mammalsObservation')}"
- disabled="%{!#editObservationReport}"/>
-
- <s:checkbox name="updateContactCommand.contact.mammalsCapture"
- id="mammalsCaptureCheckbox"
- label="%{getText('wao.ui.field.Contact.mammalsCapture')}"
- disabled="%{!#editObservationReport}"/>
-
- <div id="mammalsInfo">
- <s:textarea name="updateContactCommand.contact.mammalsInfo"
- label="%{getText('wao.ui.field.Contact.mammalsInfo')}"
- disabled="%{!#editObservationReport}"/>
- <div class="alert">
- <s:text name="wao.ui.page.ContactForm.mammalsInfo.disclaimer"/>
- </div>
- </div>
-
- <s:textfield name="updateContactCommand.contact.dataInputDate"
- label="%{getText('wao.ui.field.Contact.dataInputDate')}"
- placeholder="%{getDatePlaceholder()}"
- disabled="%{!#editObservationReport}"/>
-
- <s:select name="updateContactCommand.contact.observedDataControl"
- label="%{getText('wao.ui.field.Contact.observedDataControl')}"
- list="observedDataControls"
- emptyOption="true"
- disabled="%{!#editObservationReport || !authenticatedWaoUser.coordinator}"/>
-
- <s:textfield name="updateContactCommand.contact.restitution"
- label="%{getText('wao.ui.field.Contact.restitution')}"
- placeholder="%{getDatePlaceholder()}"
- disabled="%{!#editObservationReport}"/>
-
- <s:textarea name="updateContactCommand.contact.comment"
- label="%{getText('wao.ui.field.Contact.comment')}"
- placeholder="%{getText('wao.ui.misc.noComment')}"
- disabled="%{!#editObservationReport || !authenticatedWaoUser.observer}"/>
-
- <s:textarea name="updateContactCommand.contact.commentCoordinator"
- label="%{getText('wao.ui.field.Contact.commentCoordinator')}"
- placeholder="%{getText('wao.ui.misc.noComment')}"
- disabled="%{!#editObservationReport || !authenticatedWaoUser.coordinator}"/>
-
- </fieldset>
-
- <%--Do not remove the id (use by contacts page)--%>
- <fieldset id="adminFocus">
- <legend><s:text name="wao.ui.form.programEvaluation"/></legend>
-
- <s:if test="authenticatedWaoUser.authorizedToDisplayContactDataReliability">
- <s:select name="updateContactCommand.contact.dataReliability"
- label="%{getText('wao.ui.field.Contact.dataReliability')}"
- list="dataReliabilities"
- emptyOption="true"
- disabled="%{!authenticatedWaoUser.isAuthorizedToEditContactDataReliability(updateContactCommand.contact)}"/>
- </s:if>
-
- <s:textarea name="updateContactCommand.contact.commentAdmin"
- label="%{getText('wao.ui.field.Contact.commentAdmin')}"
- placeholder="%{getText('wao.ui.misc.noComment')}"
- disabled="%{!authenticatedWaoUser.admin}"/>
- </fieldset>
-
- <div class="form-actions">
- <s:url action="contacts" id="contactsUrl"/>
- <s:a href="%{contactsUrl}" cssClass="btn">
- <i class="icon-chevron-left"></i> <s:text name="wao.ui.action.cancel"/>
- </s:a>
- <s:if test="authenticatedWaoUser.isAuthorizedToEditContact(updateContactCommand.contact)">
- <s:submit type="button" cssClass="btn">
- <i class="icon-hdd"></i> <s:text name="wao.ui.action.save"/>
- </s:submit>
- </s:if>
-
- <s:if test=" ! updateContactCommand.creation && authenticatedWaoUser.isAuthorizedToDeleteContact(updateContactCommand.contact)">
- <s:url action="delete-contact" id="deleteContactUrl">
- <s:param name="contactId" value="contactId"/>
- </s:url>
- <s:a href="%{deleteContactUrl}" cssClass="btn pull-right" id="delete-contact-link">
- <i class="icon-trash"></i> <s:text name="wao.ui.action.deleteContact"/>
- </s:a>
- </s:if>
- </div>
-
- </s:form>
- </div>
-</html>
-
Modified: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp 2014-06-20 17:38:35 UTC (rev 2078)
@@ -94,7 +94,7 @@
filter = <s:property value="filter" escapeHtml="false"/>;
- contactsFilterController2 = new FilterController2(contactsFilterMappings, filter, WAO.OBSMER_CONTACTS_FILTER_VALUES_JSON_URL, $('#synthesis-filters-form fieldset.extra-filters'));
+ contactsFilterController2 = new FilterController2(contactsFilterMappings, filter, WAO.CONTACTS_FILTER_VALUES_JSON_URL, $('#synthesis-filters-form fieldset.extra-filters'));
contactsFilterController2.init();
});
Modified: branches/wao-4.0-obsvente/wao-web/src/main/webapp/endpoints-js.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/endpoints-js.jsp 2014-06-20 15:20:22 UTC (rev 2077)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/endpoints-js.jsp 2014-06-20 17:38:35 UTC (rev 2078)
@@ -34,7 +34,7 @@
WAO.GET_BOAT_CONTACTS_COUNT_JSON_URL = '<s:url namespace="/" action="get-boat-contacts-count-json"/>';
WAO.SEARCH_BOAT_JSON_URL = '<s:url namespace="/" action="search-boat-json"/>';
- WAO.OBSMER_CONTACTS_FILTER_VALUES_JSON_URL = '<s:url namespace="/obsmer" action="contacts-filter-values-json"/>';
+ WAO.CONTACTS_FILTER_VALUES_JSON_URL = '<s:url namespace="/obsmer" action="contacts-filter-values-json"/>';
// fragments
WAO.BOAT_DETAILS_URL = '<s:url namespace="/" action="boat-details"/>';
1
0
20 Jun '14
Author: bleny
Date: 2014-06-20 17:20:22 +0200 (Fri, 20 Jun 2014)
New Revision: 2077
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2077
Log:
refs #4493 synthesis for obsvente in branch, not working
Added:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/Synthesis.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/SynthesisAction.java
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/Synthesis-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/SynthesisAction-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp
Removed:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSynthesis.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SynthesisAction.java
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/ObsMerSynthesis-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/SynthesisAction-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/synthesis.jsp
Modified:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java
branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/WaoInterceptor.java
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -29,7 +29,7 @@
import fr.ifremer.wao.services.service.BoatsFilterValues;
import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
-import fr.ifremer.wao.services.service.ObsMerSynthesis;
+import fr.ifremer.wao.services.service.Synthesis;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
import java.lang.reflect.Constructor;
@@ -133,7 +133,7 @@
}
@Override
- public Cache<ContactsFilter, ObsMerSynthesis> getSynthesesCache() {
+ public Cache<ContactsFilter, Synthesis> getSynthesesCache() {
return waoApplicationContext.getSynthesesCache();
}
}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -7,7 +7,7 @@
import fr.ifremer.wao.services.service.BoatsFilterValues;
import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
-import fr.ifremer.wao.services.service.ObsMerSynthesis;
+import fr.ifremer.wao.services.service.Synthesis;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
import java.util.Date;
@@ -39,6 +39,6 @@
Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> getBoatsFilterValuesCache();
- Cache<ContactsFilter, ObsMerSynthesis> getSynthesesCache();
+ Cache<ContactsFilter, Synthesis> getSynthesesCache();
}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -28,7 +28,7 @@
import fr.ifremer.wao.services.service.BoatsFilterValues;
import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
-import fr.ifremer.wao.services.service.ObsMerSynthesis;
+import fr.ifremer.wao.services.service.Synthesis;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
import java.util.Date;
@@ -60,5 +60,5 @@
Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> getBoatsFilterValuesCache();
- Cache<ContactsFilter,ObsMerSynthesis> getSynthesesCache();
+ Cache<ContactsFilter,Synthesis> getSynthesesCache();
}
Added: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -0,0 +1,65 @@
+package fr.ifremer.wao.services.service;
+
+import com.google.common.collect.ImmutableSet;
+import fr.ifremer.wao.ContactsFilter;
+import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+
+public class ContactsService extends WaoServiceSupport {
+
+ private static final Log log = LogFactory.getLog(ContactsService.class);
+
+ public ContactsFilter newContactFilter(AuthenticatedWaoUser authenticatedWaoUser) {
+
+ ContactsFilter newContactsFilter = new ContactsFilter();
+
+ newContactsFilter.getSampleRowFilter().setObsProgram(authenticatedWaoUser.getObsProgram());
+
+ // DO NOT REMOVE THIS
+ if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ String authenticatedWaoUserCompanyTopiaId = authenticatedWaoUser.getWaoUser().getCompany().getTopiaId();
+ newContactsFilter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId));
+ }
+
+ Calendar periodFromCalendar = Calendar.getInstance();
+ periodFromCalendar.setTime(serviceContext.getNow());
+
+ // in the firsts months of a new year go from now to 6 months before
+ // in the rest of the year, just start at the beginning of the current year
+ if (periodFromCalendar.get(Calendar.MONTH) < 3) {
+ periodFromCalendar.add(Calendar.MONTH, -6);
+ } else {
+ periodFromCalendar.set(Calendar.DAY_OF_YEAR, 1);
+ }
+
+ Date periodFrom = periodFromCalendar.getTime();
+ Date periodTo = DateUtils.addYears(periodFromCalendar.getTime(), 1);
+
+ newContactsFilter.setPeriodFrom(periodFrom);
+ newContactsFilter.setPeriodTo(periodTo);
+
+ if (authenticatedWaoUser.isProfessional()) {
+ // Pour le profesionnel, on restreint d'office à la liste des contacts portant sur les bateaux qu'il peut voir
+ Collection<String> canReadBoatsTopiaIds = authenticatedWaoUser.getWaoUser().getCanReadBoatsTopiaIds();
+ if (CollectionUtils.isEmpty(canReadBoatsTopiaIds)) {
+ if (log.isWarnEnabled()) {
+ log.warn("user " + authenticatedWaoUser.getWaoUser() + " is professional but can't read any boat");
+ }
+ } else {
+ newContactsFilter.getBoatFilter().setBoatIds(new HashSet<>(canReadBoatsTopiaIds));
+ }
+ }
+
+ return newContactsFilter;
+
+ }
+
+}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -49,11 +49,9 @@
import fr.ifremer.wao.services.service.mail.AddBoatToUserAllegroWalletEmail;
import fr.ifremer.wao.services.service.mail.EmailService;
import fr.ifremer.wao.services.service.mail.MammalsObservationEmail;
-import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.csv.AbstractImportErrorInfo;
@@ -73,7 +71,6 @@
import org.nuiton.util.pagination.PaginationResult;
import java.io.InputStream;
-import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -85,7 +82,7 @@
import static org.nuiton.i18n.I18n.l;
-public class ObsMerContactsService extends WaoServiceSupport {
+public class ObsMerContactsService extends ContactsService {
private static final Log log = LogFactory.getLog(ObsMerContactsService.class);
@@ -137,51 +134,6 @@
return result;
}
- public ContactsFilter newContactFilter(AuthenticatedWaoUser authenticatedWaoUser) {
-
- ContactsFilter newContactsFilter = new ContactsFilter();
-
- newContactsFilter.getSampleRowFilter().setObsProgram(authenticatedWaoUser.getObsProgram());
-
- // DO NOT REMOVE THIS
- if (authenticatedWaoUser.isCoordinatorOrObserver()) {
- String authenticatedWaoUserCompanyTopiaId = authenticatedWaoUser.getWaoUser().getCompany().getTopiaId();
- newContactsFilter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId));
- }
-
- Calendar periodFromCalendar = Calendar.getInstance();
- periodFromCalendar.setTime(serviceContext.getNow());
-
- // in the firsts months of a new year go from now to 6 months before
- // in the rest of the year, just start at the beginning of the current year
- if (periodFromCalendar.get(Calendar.MONTH) < 3) {
- periodFromCalendar.add(Calendar.MONTH, -6);
- } else {
- periodFromCalendar.set(Calendar.DAY_OF_YEAR, 1);
- }
-
- Date periodFrom = periodFromCalendar.getTime();
- Date periodTo = DateUtils.addYears(periodFromCalendar.getTime(), 1);
-
- newContactsFilter.setPeriodFrom(periodFrom);
- newContactsFilter.setPeriodTo(periodTo);
-
- if (authenticatedWaoUser.isProfessional()) {
- // Pour le profesionnel, on restreint d'office à la liste des contacts portant sur les bateaux qu'il peut voir
- Collection<String> canReadBoatsTopiaIds = authenticatedWaoUser.getWaoUser().getCanReadBoatsTopiaIds();
- if (CollectionUtils.isEmpty(canReadBoatsTopiaIds)) {
- if (log.isWarnEnabled()) {
- log.warn("user " + authenticatedWaoUser.getWaoUser() + " is professional but can't read any boat");
- }
- } else {
- newContactsFilter.getBoatFilter().setBoatIds(new HashSet<>(canReadBoatsTopiaIds));
- }
- }
-
- return newContactsFilter;
-
- }
-
public UpdateContactCommand newUpdateContactCommand(AuthenticatedWaoUser authenticatedWaoUser, Optional<String> optionalContactId) {
//FIXME Should we apply some security rules (can create, update, import) ?
Deleted: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSynthesis.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSynthesis.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSynthesis.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -1,133 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-import fr.ifremer.wao.entity.Boat;
-import org.jfree.chart.JFreeChart;
-
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-public class ObsMerSynthesis {
-
- protected JFreeChart expectedVsActualObservationsByMonthsChart;
-
- protected JFreeChart boardingBoatsChart;
-
- protected int maxBoardingValue;
-
- protected Boat maxBoardingBoat;
-
- protected int boardingsCount;
-
- protected int invalidBoardingsCount;
-
- protected int validBoardingsCount;
-
- protected Map<String, CompanySynthesis> companySyntheses = new HashMap<>();
-
- protected Set<String> sampleRowIds;
-
- public Map<String, CompanySynthesis> getCompanySyntheses() {
- return companySyntheses;
- }
-
- public JFreeChart getExpectedVsActualObservationsByMonthsChart() {
- return expectedVsActualObservationsByMonthsChart;
- }
-
- public void setExpectedVsActualObservationsByMonthsChart(JFreeChart expectedVsActualObservationsByMonthsChart) {
- this.expectedVsActualObservationsByMonthsChart = expectedVsActualObservationsByMonthsChart;
- }
-
- public JFreeChart getBoardingBoatsChart() {
- return boardingBoatsChart;
- }
-
- public void setBoardingBoatsChart(JFreeChart boardingBoatsChart) {
- this.boardingBoatsChart = boardingBoatsChart;
- }
-
- public int getMaxBoardingValue() {
- return maxBoardingValue;
- }
-
- public void setMaxBoardingValue(int maxBoardingValue) {
- this.maxBoardingValue = maxBoardingValue;
- }
-
- public Boat getMaxBoardingBoat() {
- return maxBoardingBoat;
- }
-
- public void setMaxBoardingBoat(Boat maxBoardingBoat) {
- this.maxBoardingBoat = maxBoardingBoat;
- }
-
- public int getBoardingsCount() {
- return boardingsCount;
- }
-
- public void setBoardingsCount(int boardingsCount) {
- this.boardingsCount = boardingsCount;
- }
-
- public int getInvalidBoardingsCount() {
- return invalidBoardingsCount;
- }
-
- public void setInvalidBoardingsCount(int invalidBoardingsCount) {
- this.invalidBoardingsCount = invalidBoardingsCount;
- }
-
- public int getValidBoardingsCount() {
- return validBoardingsCount;
- }
-
- public void setValidBoardingsCount(int validBoardingsCount) {
- this.validBoardingsCount = validBoardingsCount;
- }
-
- public Map<String, Double> getComplianceBoardingIndicator() {
- Map<String, Double> complianceBoardingIndicator = new TreeMap();
- for (CompanySynthesis companySynthesis : companySyntheses.values()) {
- complianceBoardingIndicator.put(
- companySynthesis.getCompanyName(),
- companySynthesis.getComplianceBoardingIndicator());
- }
- return complianceBoardingIndicator;
- }
-
- public void setSampleRowIds(Set<String> sampleRowIds) {
- this.sampleRowIds = sampleRowIds;
- }
-
- public Set<String> getSampleRowIds() {
- return sampleRowIds;
- }
-
- public CompanySynthesis getCompanySynthesis(String companyId) {
- CompanySynthesis companySynthesis = companySyntheses.get(companyId);
- if (companySynthesis == null) {
- companySynthesis = new CompanySynthesis();
- companySynthesis.setCompanyId(companyId);
- companySyntheses.put(companyId, companySynthesis);
- }
- return companySynthesis;
- }
-
- public Set<CompanySynthesis> getCompanySynthesesOrderedByName() {
- Map<String, CompanySynthesis> companySynthesesOrderedByName = new TreeMap();
- for (CompanySynthesis companySynthesis : companySyntheses.values()) {
- companySynthesesOrderedByName.put(
- companySynthesis.getCompanyName(),
- companySynthesis);
- }
- return new LinkedHashSet<>(companySynthesesOrderedByName.values());
- }
-
- public boolean isEmpty() {
- return companySyntheses.isEmpty();
- }
-}
Copied: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/Synthesis.java (from rev 2075, branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSynthesis.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/Synthesis.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/Synthesis.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -0,0 +1,133 @@
+package fr.ifremer.wao.services.service;
+
+import fr.ifremer.wao.entity.Boat;
+import org.jfree.chart.JFreeChart;
+
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+public class Synthesis {
+
+ protected JFreeChart expectedVsActualObservationsByMonthsChart;
+
+ protected JFreeChart boardingBoatsChart;
+
+ protected int maxBoardingValue;
+
+ protected Boat maxBoardingBoat;
+
+ protected int boardingsCount;
+
+ protected int invalidBoardingsCount;
+
+ protected int validBoardingsCount;
+
+ protected Map<String, CompanySynthesis> companySyntheses = new HashMap<>();
+
+ protected Set<String> sampleRowIds;
+
+ public Map<String, CompanySynthesis> getCompanySyntheses() {
+ return companySyntheses;
+ }
+
+ public JFreeChart getExpectedVsActualObservationsByMonthsChart() {
+ return expectedVsActualObservationsByMonthsChart;
+ }
+
+ public void setExpectedVsActualObservationsByMonthsChart(JFreeChart expectedVsActualObservationsByMonthsChart) {
+ this.expectedVsActualObservationsByMonthsChart = expectedVsActualObservationsByMonthsChart;
+ }
+
+ public JFreeChart getBoardingBoatsChart() {
+ return boardingBoatsChart;
+ }
+
+ public void setBoardingBoatsChart(JFreeChart boardingBoatsChart) {
+ this.boardingBoatsChart = boardingBoatsChart;
+ }
+
+ public int getMaxBoardingValue() {
+ return maxBoardingValue;
+ }
+
+ public void setMaxBoardingValue(int maxBoardingValue) {
+ this.maxBoardingValue = maxBoardingValue;
+ }
+
+ public Boat getMaxBoardingBoat() {
+ return maxBoardingBoat;
+ }
+
+ public void setMaxBoardingBoat(Boat maxBoardingBoat) {
+ this.maxBoardingBoat = maxBoardingBoat;
+ }
+
+ public int getBoardingsCount() {
+ return boardingsCount;
+ }
+
+ public void setBoardingsCount(int boardingsCount) {
+ this.boardingsCount = boardingsCount;
+ }
+
+ public int getInvalidBoardingsCount() {
+ return invalidBoardingsCount;
+ }
+
+ public void setInvalidBoardingsCount(int invalidBoardingsCount) {
+ this.invalidBoardingsCount = invalidBoardingsCount;
+ }
+
+ public int getValidBoardingsCount() {
+ return validBoardingsCount;
+ }
+
+ public void setValidBoardingsCount(int validBoardingsCount) {
+ this.validBoardingsCount = validBoardingsCount;
+ }
+
+ public Map<String, Double> getComplianceBoardingIndicator() {
+ Map<String, Double> complianceBoardingIndicator = new TreeMap();
+ for (CompanySynthesis companySynthesis : companySyntheses.values()) {
+ complianceBoardingIndicator.put(
+ companySynthesis.getCompanyName(),
+ companySynthesis.getComplianceBoardingIndicator());
+ }
+ return complianceBoardingIndicator;
+ }
+
+ public void setSampleRowIds(Set<String> sampleRowIds) {
+ this.sampleRowIds = sampleRowIds;
+ }
+
+ public Set<String> getSampleRowIds() {
+ return sampleRowIds;
+ }
+
+ public CompanySynthesis getCompanySynthesis(String companyId) {
+ CompanySynthesis companySynthesis = companySyntheses.get(companyId);
+ if (companySynthesis == null) {
+ companySynthesis = new CompanySynthesis();
+ companySynthesis.setCompanyId(companyId);
+ companySyntheses.put(companyId, companySynthesis);
+ }
+ return companySynthesis;
+ }
+
+ public Set<CompanySynthesis> getCompanySynthesesOrderedByName() {
+ Map<String, CompanySynthesis> companySynthesesOrderedByName = new TreeMap();
+ for (CompanySynthesis companySynthesis : companySyntheses.values()) {
+ companySynthesesOrderedByName.put(
+ companySynthesis.getCompanyName(),
+ companySynthesis);
+ }
+ return new LinkedHashSet<>(companySynthesesOrderedByName.values());
+ }
+
+ public boolean isEmpty() {
+ return companySyntheses.isEmpty();
+ }
+}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -46,55 +46,55 @@
public ContactsFilter newFilter(AuthenticatedWaoUser authenticatedWaoUser) {
- ObsMerContactsService obsMerContactsService = newService(ObsMerContactsService.class);
+ ContactsService contactsService = newService(ObsMerContactsService.class);
- ContactsFilter newFilter = obsMerContactsService.newContactFilter(authenticatedWaoUser);
+ ContactsFilter newFilter = contactsService.newContactFilter(authenticatedWaoUser);
return newFilter;
}
- public ObsMerSynthesis getObsMerSynthesis(ContactsFilter filter) {
+ public Synthesis getObsMerSynthesis(ContactsFilter filter) {
- Cache<ContactsFilter, ObsMerSynthesis> cache = serviceContext.getSynthesesCache();
+ Cache<ContactsFilter, Synthesis> cache = serviceContext.getSynthesesCache();
- ObsMerSynthesis obsMerSynthesis = cache.getIfPresent(filter);
+ Synthesis synthesis = cache.getIfPresent(filter);
- if (obsMerSynthesis == null) {
+ if (synthesis == null) {
- obsMerSynthesis = new ObsMerSynthesis();
+ synthesis = new Synthesis();
List<String> sampleRowsIds = getContactDao().getSampleRowsIds(filter);
- obsMerSynthesis.setSampleRowIds(new HashSet<>(sampleRowsIds));
+ synthesis.setSampleRowIds(new HashSet<>(sampleRowsIds));
- setExpectedVsActualObservationsByMonthsBarChartData(obsMerSynthesis, filter);
+ setExpectedVsActualObservationsByMonthsBarChartData(synthesis, filter);
- setBoardingBoatsData(obsMerSynthesis, filter);
+ setBoardingBoatsData(synthesis, filter);
- setComplianceBoardingIndicator(obsMerSynthesis, filter);
+ setComplianceBoardingIndicator(synthesis, filter);
- setContactStatesStatistics(obsMerSynthesis, filter);
+ setContactStatesStatistics(synthesis, filter);
- setDataInputDateReactivity(obsMerSynthesis, filter);
+ setDataInputDateReactivity(synthesis, filter);
- setDataReliability(obsMerSynthesis, filter);
+ setDataReliability(synthesis, filter);
- for (CompanySynthesis companySynthesis : obsMerSynthesis.getCompanySyntheses().values()) {
+ for (CompanySynthesis companySynthesis : synthesis.getCompanySyntheses().values()) {
String companyId = companySynthesis.getCompanyId();
Company company = getCompanyDao().findByTopiaId(companyId);
companySynthesis.setCompanyName(company.getName());
}
- cache.put(filter, obsMerSynthesis);
+ cache.put(filter, synthesis);
}
- return obsMerSynthesis;
+ return synthesis;
}
- protected void setDataReliability(ObsMerSynthesis obsMerSynthesis, ContactsFilter filter) {
+ protected void setDataReliability(Synthesis synthesis, ContactsFilter filter) {
ContactTopiaDao dao = getContactDao();
@@ -102,13 +102,13 @@
for (Map.Entry<String, Long> entry : reliableObservationsCount.entrySet()) {
String companyId = entry.getKey();
- CompanySynthesis companySynthesis = obsMerSynthesis.getCompanySynthesis(companyId);
+ CompanySynthesis companySynthesis = synthesis.getCompanySynthesis(companyId);
companySynthesis.setReliableObservationsCount(reliableObservationsCount.get(companyId));
}
}
- protected void setDataInputDateReactivity(ObsMerSynthesis obsMerSynthesis, ContactsFilter filter) {
+ protected void setDataInputDateReactivity(Synthesis synthesis, ContactsFilter filter) {
ContactTopiaDao dao = getContactDao();
@@ -119,7 +119,7 @@
contactsDoneObservationBeginDateAndDateInputDate.asMap().entrySet()) {
String companyId = entry.getKey();
- CompanySynthesis companySynthesis = obsMerSynthesis.getCompanySynthesis(companyId);
+ CompanySynthesis companySynthesis = synthesis.getCompanySynthesis(companyId);
Collection<Pair<Date, Date>> dates = entry.getValue();
@@ -138,7 +138,7 @@
}
- protected void setContactStatesStatistics(ObsMerSynthesis obsMerSynthesis, ContactsFilter filter) {
+ protected void setContactStatesStatistics(Synthesis synthesis, ContactsFilter filter) {
ContactTopiaDao dao = getContactDao();
@@ -148,21 +148,21 @@
for (Map.Entry<String, Map<ContactState, Long>> entry : contactStatesStatistics.entrySet()) {
String companyId = entry.getKey();
- CompanySynthesis companySynthesis = obsMerSynthesis.getCompanySynthesis(companyId);
+ CompanySynthesis companySynthesis = synthesis.getCompanySynthesis(companyId);
companySynthesis.setContactsStatesStatistics(entry.getValue());
companySynthesis.setContactsCount(contactsCountsByCompany.get(companyId));
}
}
- protected void setComplianceBoardingIndicator(ObsMerSynthesis obsMerSynthesis, ContactsFilter filter) {
+ protected void setComplianceBoardingIndicator(Synthesis synthesis, ContactsFilter filter) {
ContactTopiaDao dao = getContactDao();
Map<String, Double> complianceBoardingIndicator = dao.getComplianceBoardingIndicator(filter);
for (Map.Entry<String, Double> entry : complianceBoardingIndicator.entrySet()) {
- CompanySynthesis companySynthesis = obsMerSynthesis.getCompanySynthesis(entry.getKey());
+ CompanySynthesis companySynthesis = synthesis.getCompanySynthesis(entry.getKey());
companySynthesis.setComplianceBoardingIndicator(entry.getValue());
}
@@ -172,7 +172,7 @@
* Un graphique avec, pour chaque mois, deux barres qui représentent l'effort demandé
* vs l'effort réalisé.
*/
- protected void setExpectedVsActualObservationsByMonthsBarChartData(ObsMerSynthesis obsMerSynthesis, ContactsFilter filter) {
+ protected void setExpectedVsActualObservationsByMonthsBarChartData(Synthesis synthesis, ContactsFilter filter) {
Locale locale = serviceContext.getLocale();
@@ -227,7 +227,7 @@
JFreeChart expectedVsActualObservationsByMonthsChart =
new JFreeChart(I18n.l(locale, SynthesisId.GRAPH_SAMPLING.getI18nKey()), JFreeChart.DEFAULT_TITLE_FONT, plot, true);
- obsMerSynthesis.setExpectedVsActualObservationsByMonthsChart(expectedVsActualObservationsByMonthsChart);
+ synthesis.setExpectedVsActualObservationsByMonthsChart(expectedVsActualObservationsByMonthsChart);
}
@@ -242,7 +242,7 @@
* and for invalid boardings from 1 to {@code MAX_BOARDINGS}, the boat with
* the max boarding and its value.
*/
- protected void setBoardingBoatsData(ObsMerSynthesis obsMerSynthesis, ContactsFilter filter) {
+ protected void setBoardingBoatsData(Synthesis synthesis, ContactsFilter filter) {
Locale locale = serviceContext.getLocale();
@@ -319,11 +319,11 @@
}
}
- obsMerSynthesis.setMaxBoardingValue(maxBoardingCount);
- obsMerSynthesis.setMaxBoardingBoat(maxBoardingBoat);
- obsMerSynthesis.setBoardingsCount(boardingTotal);
- obsMerSynthesis.setInvalidBoardingsCount(invalidBoardingTotal);
- obsMerSynthesis.setValidBoardingsCount(boardingTotal - invalidBoardingTotal);
+ synthesis.setMaxBoardingValue(maxBoardingCount);
+ synthesis.setMaxBoardingBoat(maxBoardingBoat);
+ synthesis.setBoardingsCount(boardingTotal);
+ synthesis.setInvalidBoardingsCount(invalidBoardingTotal);
+ synthesis.setValidBoardingsCount(boardingTotal - invalidBoardingTotal);
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
@@ -350,7 +350,7 @@
JFreeChart boardingBoatsChart =
new JFreeChart(I18n.l(locale, SynthesisId.GRAPH_BOARDING.getI18nKey()), JFreeChart.DEFAULT_TITLE_FONT, plot, true);
- obsMerSynthesis.setBoardingBoatsChart(boardingBoatsChart);
+ synthesis.setBoardingBoatsChart(boardingBoatsChart);
}
}
Modified: branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -12,7 +12,7 @@
import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.InitWaoService;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
-import fr.ifremer.wao.services.service.ObsMerSynthesis;
+import fr.ifremer.wao.services.service.Synthesis;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.logging.Log;
@@ -52,7 +52,7 @@
protected Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache;
- protected Cache<ContactsFilter, ObsMerSynthesis> synthesisCache;
+ protected Cache<ContactsFilter, Synthesis> synthesisCache;
public FakeWaoApplicationContext(String context, boolean initWithReferential) {
this.context = context;
@@ -261,7 +261,7 @@
}
@Override
- public Cache<ContactsFilter, ObsMerSynthesis> getSynthesesCache() {
+ public Cache<ContactsFilter, Synthesis> getSynthesesCache() {
if (synthesisCache == null) {
synthesisCache = CacheBuilder.newBuilder().build();
}
Modified: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -9,7 +9,7 @@
import fr.ifremer.wao.services.service.BoatsFilterValues;
import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
-import fr.ifremer.wao.services.service.ObsMerSynthesis;
+import fr.ifremer.wao.services.service.Synthesis;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.logging.Log;
@@ -36,7 +36,7 @@
protected Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache;
- protected Cache<ContactsFilter, ObsMerSynthesis> synthesesCache;
+ protected Cache<ContactsFilter, Synthesis> synthesesCache;
protected Set<String> dirtySampleRowIds = new HashSet<>();
@@ -53,7 +53,7 @@
public CacheInvalidationTopiaEntityListener(
Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> samplingPlansCache,
Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache,
- Cache<ContactsFilter, ObsMerSynthesis> synthesesCache) {
+ Cache<ContactsFilter, Synthesis> synthesesCache) {
this.samplingPlansCache = samplingPlansCache;
this.boatsFilterValuesCache = boatsFilterValuesCache;
this.synthesesCache = synthesesCache;
@@ -130,7 +130,7 @@
}
samplingPlansCache.invalidateAll(samplingPlansCacheKeysToInvalidate);
Set<ContactsFilter> synthesesCacheKeysToInvalidate = new HashSet<>();
- for (Map.Entry<ContactsFilter, ObsMerSynthesis> entry : synthesesCache.asMap().entrySet()) {
+ for (Map.Entry<ContactsFilter, Synthesis> entry : synthesesCache.asMap().entrySet()) {
if (CollectionUtils.containsAny(entry.getValue().getSampleRowIds(), dirtySampleRowIds)) {
synthesesCacheKeysToInvalidate.add(entry.getKey());
}
Modified: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -36,7 +36,7 @@
import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.InitWaoService;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
-import fr.ifremer.wao.services.service.ObsMerSynthesis;
+import fr.ifremer.wao.services.service.Synthesis;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -71,7 +71,7 @@
protected Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache;
- protected Cache<ContactsFilter, ObsMerSynthesis> synthesesCache;
+ protected Cache<ContactsFilter, Synthesis> synthesesCache;
@Override
public WaoApplicationConfig getApplicationConfig() {
@@ -132,7 +132,7 @@
}
@Override
- public Cache<ContactsFilter, ObsMerSynthesis> getSynthesesCache() {
+ public Cache<ContactsFilter, Synthesis> getSynthesesCache() {
if (synthesesCache == null) {
synthesesCache = newCacheBuilder(100).expireAfterAccess(30, TimeUnit.DAYS).build();
}
Modified: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/WaoInterceptor.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/WaoInterceptor.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/WaoInterceptor.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -88,7 +88,7 @@
admin.getCompany().getTopiaId();
UserProfile userProfile = new UserProfileImpl();
userProfile.setUserRole(UserRole.ADMIN);
- userProfile.setObsProgram(ObsProgram.OBSMER);
+ userProfile.setObsProgram(ObsProgram.OBSVENTE);
userProfile.setCanWrite(true);
AuthenticatedWaoUser authenticatedWaoUser = new AuthenticatedWaoUser(admin, userProfile);
waoSession.setAuthenticatedWaoUser(authenticatedWaoUser);
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/SynthesisAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SynthesisAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/SynthesisAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/SynthesisAction.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -0,0 +1,67 @@
+package fr.ifremer.wao.web.action;
+
+import com.google.common.base.Objects;
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.ContactsFilter;
+import fr.ifremer.wao.services.service.Synthesis;
+import fr.ifremer.wao.services.service.SynthesisService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+
+public class SynthesisAction extends WaoJspActionSupport implements Preparable {
+
+ protected ContactsFilter filter;
+
+ protected SynthesisService service;
+
+ protected Synthesis synthesis;
+
+ public void setService(SynthesisService service) {
+ this.service = service;
+ }
+
+ public ContactsFilter getFilter() {
+ if (filter == null) {
+ prepare();
+ }
+ return filter;
+ }
+
+ @Override
+ public void prepare() {
+
+ if (filter == null) {
+ filter = service.newFilter(getAuthenticatedWaoUser());
+ }
+
+ }
+
+ @Override
+ public String execute() {
+
+ filter = Objects.firstNonNull(session.getSynthesisFilter(), filter);
+
+ return applyFilter();
+
+ }
+
+ public String resetFilter() {
+
+ filter = service.newFilter(getAuthenticatedWaoUser());
+
+ return applyFilter();
+
+ }
+
+ public String applyFilter() {
+
+ getSession().setSynthesisFilter(filter);
+
+ synthesis = service.getObsMerSynthesis(filter);
+
+ return SUCCESS;
+ }
+
+ public Synthesis getSynthesis() {
+ return synthesis;
+ }
+}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SynthesisAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SynthesisAction.java 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SynthesisAction.java 2014-06-20 15:20:22 UTC (rev 2077)
@@ -1,67 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-import com.google.common.base.Objects;
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.ContactsFilter;
-import fr.ifremer.wao.services.service.ObsMerSynthesis;
-import fr.ifremer.wao.services.service.SynthesisService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-
-public class SynthesisAction extends WaoJspActionSupport implements Preparable {
-
- protected ContactsFilter filter;
-
- protected SynthesisService service;
-
- protected ObsMerSynthesis synthesis;
-
- public void setService(SynthesisService service) {
- this.service = service;
- }
-
- public ContactsFilter getFilter() {
- if (filter == null) {
- prepare();
- }
- return filter;
- }
-
- @Override
- public void prepare() {
-
- if (filter == null) {
- filter = service.newFilter(getAuthenticatedWaoUser());
- }
-
- }
-
- @Override
- public String execute() {
-
- filter = Objects.firstNonNull(session.getSynthesisFilter(), filter);
-
- return applyFilter();
-
- }
-
- public String resetFilter() {
-
- filter = service.newFilter(getAuthenticatedWaoUser());
-
- return applyFilter();
-
- }
-
- public String applyFilter() {
-
- getSession().setSynthesisFilter(filter);
-
- synthesis = service.getObsMerSynthesis(filter);
-
- return SUCCESS;
- }
-
- public ObsMerSynthesis getSynthesis() {
- return synthesis;
- }
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/ObsMerSynthesis-conversion.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/ObsMerSynthesis-conversion.properties 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/ObsMerSynthesis-conversion.properties 2014-06-20 15:20:22 UTC (rev 2077)
@@ -1,2 +0,0 @@
-expectedVsActualObservationsByMonthsChart=fr.ifremer.wao.web.converter.JFreeChartToImgTagConverter
-boardingBoatsChart=fr.ifremer.wao.web.converter.JFreeChartToImgTagConverter
Copied: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/Synthesis-conversion.properties (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/ObsMerSynthesis-conversion.properties)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/Synthesis-conversion.properties (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/services/service/Synthesis-conversion.properties 2014-06-20 15:20:22 UTC (rev 2077)
@@ -0,0 +1,2 @@
+expectedVsActualObservationsByMonthsChart=fr.ifremer.wao.web.converter.JFreeChartToImgTagConverter
+boardingBoatsChart=fr.ifremer.wao.web.converter.JFreeChartToImgTagConverter
Copied: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/SynthesisAction-conversion.properties (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/SynthesisAction-conversion.properties)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/SynthesisAction-conversion.properties (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/SynthesisAction-conversion.properties 2014-06-20 15:20:22 UTC (rev 2077)
@@ -0,0 +1 @@
+filter=org.nuiton.web.struts2.converters.JsonConverter
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/SynthesisAction-conversion.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/SynthesisAction-conversion.properties 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/SynthesisAction-conversion.properties 2014-06-20 15:20:22 UTC (rev 2077)
@@ -1 +0,0 @@
-filter=org.nuiton.web.struts2.converters.JsonConverter
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/synthesis.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/synthesis.jsp 2014-06-20 13:56:00 UTC (rev 2076)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/synthesis.jsp 2014-06-20 15:20:22 UTC (rev 2077)
@@ -1,361 +0,0 @@
-<%--
- #%L
- Wao :: Web
- %%
- Copyright (C) 2009 - 2014 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
-<%@taglib uri="/struts-tags" prefix="s" %>
-
-<content tag="synthesisMenuItemClass">active</content>
-
-<html>
-
- <head>
- <title>
- <s:text name="wao.ui.page.Synthesis.title"/>
- </title>
-
- <script type="text/javascript">
-
- $(document).ready(function() {
-
- var contactsFilterMappings = [
- <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies">
- {
- filterName: 'sampleRowFilter.companyIds',
- filterLabel: "<s:text name="wao.ui.entity.Company"/>",
- filterValuesField: 'sampleRowsFilterValues.companies',
- },
- </s:if>
- {
- filterName: 'sampleRowFilter.sampleRowCodes',
- filterLabel: "<s:text name="wao.ui.field.SampleRow.code"/>",
- filterValuesField: 'sampleRowsFilterValues.sampleRowCodes',
- },
- {
- filterName: 'sampleRowFilter.programNames',
- filterLabel: "<s:text name="wao.ui.field.SampleRow.programName"/>",
- filterValuesField: 'sampleRowsFilterValues.programNames',
- },
- {
- filterName: 'sampleRowFilter.fishingZoneFacadeNames',
- filterLabel: "<s:text name="wao.ui.field.FishingZone.facadeName"/>",
- filterValuesField: 'sampleRowsFilterValues.fishingZoneFacadeNames',
- },
- {
- filterName: 'sampleRowFilter.fishingZoneSectorNames',
- filterLabel: "<s:text name="wao.ui.field.FishingZone.sectorName"/>",
- filterValuesField: 'sampleRowsFilterValues.fishingZoneSectorNames',
- },
- {
- filterName: 'sampleRowFilter.fishingGearDcfIds',
- filterLabel: "<s:text name="wao.ui.entity.fishingGearDCF"/>",
- filterValuesField: 'sampleRowsFilterValues.fishingGearDcfs',
- },
- {
- filterName: 'sampleRowFilter.targetSpeciesDcfIds',
- filterLabel: "<s:text name="wao.ui.entity.targetSpeciesDCF"/>",
- filterValuesField: 'sampleRowsFilterValues.targetSpeciesDcfs',
- },
- <s:if test="authenticatedWaoUser.authorizedToFilterOnBoats">
- {
- filterName: 'boatFilter.boatIds',
- filterLabel: "<s:text name="wao.ui.entity.Boat"/>",
- filterValuesField: 'boatsFilterValues.boats',
- minimumInputLength: 3
- },
- </s:if>
- {
- filterName: 'boatFilter.districtIds',
- filterLabel: "<s:text name="wao.ui.field.Boat.district"/>",
- filterValuesField: 'boatsFilterValues.districts'
- },
- {
- filterName: 'observerIds',
- filterLabel: "<s:text name="wao.ui.misc.observer"/>",
- filterValuesField: 'observers'
- }
- ];
-
- filter = <s:property value="filter" escapeHtml="false"/>;
-
- contactsFilterController2 = new FilterController2(contactsFilterMappings, filter, WAO.OBSMER_CONTACTS_FILTER_VALUES_JSON_URL, $('#synthesis-filters-form fieldset.extra-filters'));
- contactsFilterController2.init();
-
- });
-
- </script>
- </head>
-
- <content tag="mainClass">large syntheses</content>
-
- <s:form method="GET" id="synthesis-filters-form" cssClass="filters-form">
-
- <fieldset>
-
- <s:textfield name="filter.periodFrom"
- label="%{getText('wao.ui.form.periodFrom')}"
- placeholder="%{getFilterPeriodFromPlaceholder()}"
- cssClass="input-small"/>
-
- <s:textfield name="filter.periodTo"
- label="%{getText('wao.ui.form.period.to')}"
- placeholder="%{getFilterPeriodToPlaceholder()}"
- cssClass="input-small"/>
-
- <div title="<s:text name="wao.ui.form.filterOnObservationBeginDate.tooltip"/>">
- <s:checkbox name="filter.filterOnObservationBeginDate"
- label="%{getText('wao.ui.form.filterOnObservationBeginDate')}"/>
- </div>
-
- </fieldset>
-
- <fieldset class="extra-filters">
-
- </fieldset>
-
- <fieldset>
-
- <s:checkbox name="filter.mammalsObservationOnly"
- label="%{getText('wao.ui.misc.observations')}"/>
-
- <s:checkbox name="filter.mammalsCaptureOnly"
- label="%{getText('wao.ui.field.Contact.mammalsCapture')}"/>
-
- <s:checkbox name="filter.commentDefinedOnly"
- label="%{getText('wao.ui.field.Contact.comment')}"/>
-
- <s:checkbox name="filter.commentCompanyDefinedOnly"
- label="%{getText('wao.ui.field.Contact.commentCompany')}"/>
-
- <s:checkbox name="filter.commentAdminDefinedOnly"
- label="%{getText('wao.ui.field.Contact.commentAdmin')}"/>
-
- <s:checkbox name="filter.realVsEstimated"
- label="%{getText('wao.ui.form.realTides.description')}"/>
-
- </fieldset>
-
- <div class="form-actions">
-
- <s:submit type="button" action="synthesis!applyFilter" cssClass="btn btn-primary">
- <i class="icon-filter"></i> <s:text name="wao.ui.action.filter"/>
- </s:submit>
-
- <s:submit type="button" action="synthesis!resetFilter" cssClass="btn">
- <i class="icon-trash"></i> <s:text name="wao.ui.action.reset"/>
- </s:submit>
-
- </div>
-
- </s:form>
-
- <s:if test="synthesis.empty">
- <s:text name="wao.ui.synthesis.empty"/>
- </s:if>
- <s:else>
-
- <article>
- <h2>
- <s:text name="SynthesisId.GRAPH_SAMPLING"/>
- </h2>
-
- <s:property value="synthesis.expectedVsActualObservationsByMonthsChart" escapeHtml="false"/>
- </article>
-
- <article>
- <h2>
- <s:text name="SynthesisId.GRAPH_BOARDING"/>
- </h2>
-
- <s:property value="synthesis.boardingBoatsChart" escapeHtml="false"/>
-
- <p>
- <s:text name="wao.ui.synthesis.boarding.description"/>
- </p>
-
- <p>
- <s:text name="wao.ui.synthesis.boarding.mostUsedBoat">
- <s:param value="%{synthesis.maxBoardingValue}"/>
- <s:param value="%{synthesis.maxBoardingBoat.name}"/>
- <s:param value="%{synthesis.maxBoardingBoat.immatriculation}"/>
- </s:text>
- </p>
-
- <p>
- <s:text name="wao.ui.synthesis.boarding.boardingCount">
- <s:param value="%{synthesis.invalidBoardingsCount}"/>
- <s:param value="%{synthesis.boardingsCount}"/>
- <%--
- <s:param value="%{synthesis.validBoardingsCount}"/>
- --%>
- </s:text>
- </p>
-
- </article>
-
- <article>
- <h2>
- <s:text name="SynthesisId.IND_COMPLIANCE_BOARDING"/>
- </h2>
-
- <table class="table">
- <thead>
- <tr>
- <th>
- <s:text name="wao.ui.entity.Company"/>
- </th>
- <th>
- <s:text name="wao.ui.synthesis.complianceBoarding.description"/>
- </th>
- </tr>
- </thead>
- <tbody>
- <s:iterator value="synthesis.companySynthesesOrderedByName">
- <tr>
- <td>
- <s:property value="companyName"/>
- </td>
- <td>
- <s:property value="complianceBoardingIndicator * 100"/> %
- </td>
- </tr>
- </s:iterator>
- </tbody>
- </table>
-
- </article>
-
- <article>
- <h2>
- <s:text name="SynthesisId.IND_CONTACT_STATE"/>
- </h2>
-
- <table class="table">
- <thead>
- <tr>
- <th>
- <s:text name="wao.ui.entity.Company"/>
- </th>
- <s:iterator value="synthesis.companySynthesesOrderedByName.iterator.next().contactsStatesStatistics.keySet()" var="contactState">
- <th>
- <s:text name="%{#contactState.i18nKey}"/>
- </th>
- </s:iterator>
- <th>
- <s:text name="wao.ui.misc.total"/>
- </th>
- </tr>
- </thead>
- <tbody>
- <s:iterator value="synthesis.companySynthesesOrderedByName">
- <tr>
- <td>
- <s:property value="companyName"/>
- </td>
- <s:iterator value="contactsStatesStatistics">
- <td>
- <s:property value="value"/>
- <s:set name="percentage" value="%{value.doubleValue() / contactsCount * 100}" />
- (<s:property value="#percentage"/> %)
- </td>
- </s:iterator>
- <td>
- <s:property value="contactsCount"/>
- </td>
- </tr>
- </s:iterator>
- </tbody>
- </table>
-
- </article>
-
- <article>
- <h2>
- <s:text name="SynthesisId.IND_ALLEGRO_REACTIVITY"/>
- </h2>
-
- <table class="table">
- <thead>
- <tr>
- <th>
- <s:text name="wao.ui.entity.Company"/>
- </th>
- <th>
- <s:text name="wao.ui.synthesis.allegroReactivity.title"/>
- </th>
- </tr>
- </thead>
- <tbody>
- <s:iterator value="synthesis.companySynthesesOrderedByName">
- <tr>
- <td>
- <s:property value="companyName"/>
- </td>
- <td<s:if test="dataInputDateReactivityHigh"> class="lower-than-expected"</s:if>>
- <s:property value="dataInputDateReactivity"/>
- <s:text name="wao.ui.unit.days"/>
- </td>
- </tr>
- </s:iterator>
- </tbody>
- </table>
-
- <p>
- <s:text name="wao.ui.synthesis.allegroReactivity.description"/>
- </p>
-
- </article>
-
- <article>
-
- <h2>
- <s:text name="SynthesisId.IND_DATA_RELIABILITY"/>
- </h2>
-
- <table class="table">
- <thead>
- <tr>
- <th>
- <s:text name="wao.ui.entity.Company"/>
- </th>
- <th>
- <s:text name="wao.ui.synthesis.dataReliability.description"/>
- </th>
- </tr>
- </thead>
- <tbody>
- <s:iterator value="synthesis.companySynthesesOrderedByName">
- <tr>
- <td>
- <s:property value="companyName"/>
- </td>
- <td>
- <s:property value="dataReliabilityRatio * 100"/> %
- </td>
- </tr>
- </s:iterator>
- </tbody>
- </table>
-
- </article>
-
- </s:else>
-
-
-</html>
Copied: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/synthesis.jsp)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp 2014-06-20 15:20:22 UTC (rev 2077)
@@ -0,0 +1,369 @@
+<%--
+ #%L
+ Wao :: Web
+ %%
+ Copyright (C) 2009 - 2014 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<content tag="synthesisMenuItemClass">active</content>
+
+<html>
+
+ <head>
+ <title>
+ <s:text name="wao.ui.page.Synthesis.title"/>
+ </title>
+
+ <script type="text/javascript">
+
+ $(document).ready(function() {
+
+ var contactsFilterMappings = [
+ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies">
+ {
+ filterName: 'sampleRowFilter.companyIds',
+ filterLabel: "<s:text name="wao.ui.entity.Company"/>",
+ filterValuesField: 'sampleRowsFilterValues.companies',
+ },
+ </s:if>
+ {
+ filterName: 'sampleRowFilter.sampleRowCodes',
+ filterLabel: "<s:text name="wao.ui.field.SampleRow.code"/>",
+ filterValuesField: 'sampleRowsFilterValues.sampleRowCodes',
+ },
+ {
+ filterName: 'sampleRowFilter.programNames',
+ filterLabel: "<s:text name="wao.ui.field.SampleRow.programName"/>",
+ filterValuesField: 'sampleRowsFilterValues.programNames',
+ },
+ {
+ filterName: 'sampleRowFilter.fishingZoneFacadeNames',
+ filterLabel: "<s:text name="wao.ui.field.FishingZone.facadeName"/>",
+ filterValuesField: 'sampleRowsFilterValues.fishingZoneFacadeNames',
+ },
+ {
+ filterName: 'sampleRowFilter.fishingZoneSectorNames',
+ filterLabel: "<s:text name="wao.ui.field.FishingZone.sectorName"/>",
+ filterValuesField: 'sampleRowsFilterValues.fishingZoneSectorNames',
+ },
+ {
+ filterName: 'sampleRowFilter.fishingGearDcfIds',
+ filterLabel: "<s:text name="wao.ui.entity.fishingGearDCF"/>",
+ filterValuesField: 'sampleRowsFilterValues.fishingGearDcfs',
+ },
+ {
+ filterName: 'sampleRowFilter.targetSpeciesDcfIds',
+ filterLabel: "<s:text name="wao.ui.entity.targetSpeciesDCF"/>",
+ filterValuesField: 'sampleRowsFilterValues.targetSpeciesDcfs',
+ },
+ <s:if test="authenticatedWaoUser.authorizedToFilterOnBoats">
+ {
+ filterName: 'boatFilter.boatIds',
+ filterLabel: "<s:text name="wao.ui.entity.Boat"/>",
+ filterValuesField: 'boatsFilterValues.boats',
+ minimumInputLength: 3
+ },
+ </s:if>
+ {
+ filterName: 'boatFilter.districtIds',
+ filterLabel: "<s:text name="wao.ui.field.Boat.district"/>",
+ filterValuesField: 'boatsFilterValues.districts'
+ },
+ {
+ filterName: 'observerIds',
+ filterLabel: "<s:text name="wao.ui.misc.observer"/>",
+ filterValuesField: 'observers'
+ }
+ ];
+
+ filter = <s:property value="filter" escapeHtml="false"/>;
+
+ contactsFilterController2 = new FilterController2(contactsFilterMappings, filter, WAO.OBSMER_CONTACTS_FILTER_VALUES_JSON_URL, $('#synthesis-filters-form fieldset.extra-filters'));
+ contactsFilterController2.init();
+
+ });
+
+ </script>
+ </head>
+
+ <content tag="mainClass">large syntheses</content>
+
+ <s:form method="GET" id="synthesis-filters-form" cssClass="filters-form">
+
+ <fieldset>
+
+ <s:textfield name="filter.periodFrom"
+ label="%{getText('wao.ui.form.periodFrom')}"
+ placeholder="%{getFilterPeriodFromPlaceholder()}"
+ cssClass="input-small"/>
+
+ <s:textfield name="filter.periodTo"
+ label="%{getText('wao.ui.form.period.to')}"
+ placeholder="%{getFilterPeriodToPlaceholder()}"
+ cssClass="input-small"/>
+
+ <div title="<s:text name="wao.ui.form.filterOnObservationBeginDate.tooltip"/>">
+ <s:checkbox name="filter.filterOnObservationBeginDate"
+ label="%{getText('wao.ui.form.filterOnObservationBeginDate')}"/>
+ </div>
+
+ </fieldset>
+
+ <fieldset class="extra-filters">
+
+ </fieldset>
+
+ <fieldset>
+
+ <s:checkbox name="filter.mammalsObservationOnly"
+ label="%{getText('wao.ui.misc.observations')}"/>
+
+ <s:checkbox name="filter.mammalsCaptureOnly"
+ label="%{getText('wao.ui.field.Contact.mammalsCapture')}"/>
+
+ <s:checkbox name="filter.commentDefinedOnly"
+ label="%{getText('wao.ui.field.Contact.comment')}"/>
+
+ <s:checkbox name="filter.commentCompanyDefinedOnly"
+ label="%{getText('wao.ui.field.Contact.commentCompany')}"/>
+
+ <s:checkbox name="filter.commentAdminDefinedOnly"
+ label="%{getText('wao.ui.field.Contact.commentAdmin')}"/>
+
+ <s:checkbox name="filter.realVsEstimated"
+ label="%{getText('wao.ui.form.realTides.description')}"/>
+
+ </fieldset>
+
+ <div class="form-actions">
+
+ <s:submit type="button" action="synthesis!applyFilter" cssClass="btn btn-primary">
+ <i class="icon-filter"></i> <s:text name="wao.ui.action.filter"/>
+ </s:submit>
+
+ <s:submit type="button" action="synthesis!resetFilter" cssClass="btn">
+ <i class="icon-trash"></i> <s:text name="wao.ui.action.reset"/>
+ </s:submit>
+
+ </div>
+
+ </s:form>
+
+ <s:if test="synthesis.empty">
+ <s:text name="wao.ui.synthesis.empty"/>
+ </s:if>
+ <s:else>
+
+ <article>
+ <h2>
+ <s:text name="SynthesisId.GRAPH_SAMPLING"/>
+ </h2>
+
+ <s:property value="synthesis.expectedVsActualObservationsByMonthsChart" escapeHtml="false"/>
+ </article>
+
+ <article>
+ <h2>
+ <s:text name="SynthesisId.GRAPH_BOARDING"/>
+ </h2>
+
+ <s:property value="synthesis.boardingBoatsChart" escapeHtml="false"/>
+
+ <p>
+ <s:text name="wao.ui.synthesis.boarding.description"/>
+ </p>
+
+ <p>
+ <s:text name="wao.ui.synthesis.boarding.mostUsedBoat">
+ <s:param value="%{synthesis.maxBoardingValue}"/>
+ <s:param value="%{synthesis.maxBoardingBoat.name}"/>
+ <s:param value="%{synthesis.maxBoardingBoat.immatriculation}"/>
+ </s:text>
+ </p>
+
+ <p>
+ <s:text name="wao.ui.synthesis.boarding.boardingCount">
+ <s:param value="%{synthesis.invalidBoardingsCount}"/>
+ <s:param value="%{synthesis.boardingsCount}"/>
+ <%--
+ <s:param value="%{synthesis.validBoardingsCount}"/>
+ --%>
+ </s:text>
+ </p>
+
+ </article>
+
+ <s:if test="obsMer">
+
+ <article>
+ <h2>
+ <s:text name="SynthesisId.IND_COMPLIANCE_BOARDING"/>
+ </h2>
+
+ <table class="table">
+ <thead>
+ <tr>
+ <th>
+ <s:text name="wao.ui.entity.Company"/>
+ </th>
+ <th>
+ <s:text name="wao.ui.synthesis.complianceBoarding.description"/>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <s:iterator value="synthesis.companySynthesesOrderedByName">
+ <tr>
+ <td>
+ <s:property value="companyName"/>
+ </td>
+ <td>
+ <s:property value="complianceBoardingIndicator * 100"/> %
+ </td>
+ </tr>
+ </s:iterator>
+ </tbody>
+ </table>
+
+ </article>
+
+ </s:if>
+
+ <article>
+ <h2>
+ <s:text name="SynthesisId.IND_CONTACT_STATE"/>
+ </h2>
+
+ <table class="table">
+ <thead>
+ <tr>
+ <th>
+ <s:text name="wao.ui.entity.Company"/>
+ </th>
+ <s:iterator value="synthesis.companySynthesesOrderedByName.iterator.next().contactsStatesStatistics.keySet()" var="contactState">
+ <th>
+ <s:text name="%{#contactState.i18nKey}"/>
+ </th>
+ </s:iterator>
+ <th>
+ <s:text name="wao.ui.misc.total"/>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <s:iterator value="synthesis.companySynthesesOrderedByName">
+ <tr>
+ <td>
+ <s:property value="companyName"/>
+ </td>
+ <s:iterator value="contactsStatesStatistics">
+ <td>
+ <s:property value="value"/>
+ <s:set name="percentage" value="%{value.doubleValue() / contactsCount * 100}" />
+ (<s:property value="#percentage"/> %)
+ </td>
+ </s:iterator>
+ <td>
+ <s:property value="contactsCount"/>
+ </td>
+ </tr>
+ </s:iterator>
+ </tbody>
+ </table>
+
+ </article>
+
+ <article>
+ <h2>
+ <s:text name="SynthesisId.IND_ALLEGRO_REACTIVITY"/>
+ </h2>
+
+ <table class="table">
+ <thead>
+ <tr>
+ <th>
+ <s:text name="wao.ui.entity.Company"/>
+ </th>
+ <th>
+ <s:text name="wao.ui.synthesis.allegroReactivity.title"/>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <s:iterator value="synthesis.companySynthesesOrderedByName">
+ <tr>
+ <td>
+ <s:property value="companyName"/>
+ </td>
+ <td<s:if test="dataInputDateReactivityHigh"> class="lower-than-expected"</s:if>>
+ <s:property value="dataInputDateReactivity"/>
+ <s:text name="wao.ui.unit.days"/>
+ </td>
+ </tr>
+ </s:iterator>
+ </tbody>
+ </table>
+
+ <p>
+ <s:text name="wao.ui.synthesis.allegroReactivity.description"/>
+ </p>
+
+ </article>
+
+ <s:if test="obsMer">
+
+ <article>
+
+ <h2>
+ <s:text name="SynthesisId.IND_DATA_RELIABILITY"/>
+ </h2>
+
+ <table class="table">
+ <thead>
+ <tr>
+ <th>
+ <s:text name="wao.ui.entity.Company"/>
+ </th>
+ <th>
+ <s:text name="wao.ui.synthesis.dataReliability.description"/>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <s:iterator value="synthesis.companySynthesesOrderedByName">
+ <tr>
+ <td>
+ <s:property value="companyName"/>
+ </td>
+ <td>
+ <s:property value="dataReliabilityRatio * 100"/> %
+ </td>
+ </tr>
+ </s:iterator>
+ </tbody>
+ </table>
+
+ </article>
+
+ </s:if>
+
+ </s:else>
+
+
+</html>
1
0
20 Jun '14
Author: bleny
Date: 2014-06-20 15:56:00 +0200 (Fri, 20 Jun 2014)
New Revision: 2076
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2076
Log:
refs #4491 boats for obsvente in branch
Added:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsList.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java
branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsServiceTest.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatDetailsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatsFilterValuesJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/CancelBoatSelectionAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportBoatsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/GetBoatContactsCountJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/UpdateBoatElligibilityJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/UpdateBoatInfosJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/BoatsAction-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/GetBoatContactsCountJsonAction-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/boats.jsp
Removed:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsList.java
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java
branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatDetailsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CancelBoatSelectionAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportBoatsAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SearchBoatJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatInfosJsonAction.java
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/BoatsAction-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction-conversion.properties
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp
branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp
Modified:
branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
branches/wao-4.0-obsvente/wao-web/src/main/webapp/endpoints-js.jsp
Copied: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsList.java (from rev 2075, branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsList.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsList.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsList.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,58 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.Boat;
+import org.nuiton.util.pagination.PaginationResult;
+
+import java.io.Serializable;
+
+/**
+ * Created on 4/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class BoatsList implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected PaginationResult<Boat> boats;
+
+ protected BoatsFilterValues filterValues;
+
+ public PaginationResult<Boat> getBoats() {
+ return boats;
+ }
+
+ public void setBoats(PaginationResult<Boat> boats) {
+ this.boats = boats;
+ }
+
+ public BoatsFilterValues getFilterValues() {
+ return filterValues;
+ }
+
+ public void setFilterValues(BoatsFilterValues filterValues) {
+ this.filterValues = filterValues;
+ }
+}
Copied: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java (from rev 2075, branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,291 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.cache.Cache;
+import com.google.common.collect.ImmutableSet;
+import fr.ifremer.wao.BoatsFilter;
+import fr.ifremer.wao.ContactsFilter;
+import fr.ifremer.wao.WaoTechnicalException;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.BoatInfos;
+import fr.ifremer.wao.entity.BoatInfosImpl;
+import fr.ifremer.wao.entity.BoatInfosTopiaDao;
+import fr.ifremer.wao.entity.BoatTopiaDao;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ContactState;
+import fr.ifremer.wao.entity.ContactTopiaDao;
+import fr.ifremer.wao.entity.ElligibleBoat;
+import fr.ifremer.wao.entity.ElligibleBoatTopiaDao;
+import fr.ifremer.wao.entity.ObsProgram;
+import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import fr.ifremer.wao.services.service.csv.BoatImportExportModel;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.csv.Export;
+import org.nuiton.csv.ExportModel;
+import org.nuiton.util.pagination.PaginationParameter;
+import org.nuiton.util.pagination.PaginationResult;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ * Created on 4/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class BoatsService extends WaoServiceSupport {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(BoatsService.class);
+
+ public BoatsFilterValues getBoatsFilterValues(AuthenticatedWaoUser authenticatedWaoUser, BoatsFilter filter) {
+
+ Optional<String> optionalCompanyId = Optional.absent();
+ if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ optionalCompanyId = Optional.of(authenticatedWaoUser.getCompany().getTopiaId());
+ }
+
+ BoatsFilterValuesCacheKey boatsFilterValuesCacheKey =
+ new BoatsFilterValuesCacheKey(
+ serviceContext.getLocale(),
+ authenticatedWaoUser.getObsProgram(),
+ optionalCompanyId);
+
+ Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> cache =
+ serviceContext.getBoatsFilterValuesCache();
+
+ BoatsFilterValues boatsFilterValues = cache.getIfPresent(boatsFilterValuesCacheKey);
+
+ if (boatsFilterValues == null) {
+
+ BoatTopiaDao dao = getBoatDao();
+
+ List<Boat> boats = dao.findAll(filter);
+
+ boatsFilterValues = new BoatsFilterValues(serviceContext.getLocale(), authenticatedWaoUser.getObsProgram(), optionalCompanyId);
+
+ for (Boat boat : boats) {
+ boatsFilterValues.addBoat(boat);
+ }
+
+ cache.put(boatsFilterValuesCacheKey, boatsFilterValues);
+
+ }
+
+ return boatsFilterValues;
+ }
+
+ public BoatsList getBoatsList(AuthenticatedWaoUser authenticatedWaoUser,
+ BoatsFilter filter,
+ PaginationParameter pager) {
+
+ BoatTopiaDao dao = getBoatDao();
+
+ PaginationResult<Boat> boats = dao.find(filter, pager);
+
+ BoatsFilterValues boatsFilterValues = getBoatsFilterValues(authenticatedWaoUser, filter);
+
+ BoatsList boatsList = new BoatsList();
+ boatsList.setBoats(boats);
+ boatsList.setFilterValues(boatsFilterValues);
+ return boatsList;
+ }
+
+ public PaginationParameter newBoatsPaginationParameter(int pageNumber, int pageSize) {
+ PaginationParameter result = PaginationParameter.of(pageNumber, pageSize, Boat.PROPERTY_NAME, false);
+ return result;
+ }
+
+ public BoatsFilter newBoatsFilter(AuthenticatedWaoUser authenticatedWaoUser) {
+
+ BoatsFilter boatsFilter = new BoatsFilter();
+
+ if (authenticatedWaoUser.isProfessional()) {
+ // Pour le profesionnel, on restreint d'office à la liste des bateaux qu'il peut voir
+ Collection<String> canReadBoatsTopiaIds = authenticatedWaoUser.getWaoUser().getCanReadBoatsTopiaIds();
+ if (CollectionUtils.isEmpty(canReadBoatsTopiaIds)) {
+ if (log.isWarnEnabled()) {
+ log.warn("user " + authenticatedWaoUser.getWaoUser() + " is professional but can't read any boat");
+ }
+ } else {
+ boatsFilter.setBoatIds(new HashSet<>(canReadBoatsTopiaIds));
+ }
+ }
+
+ return boatsFilter;
+
+ }
+
+ public InputStream exportBoats(BoatsFilter filter) {
+
+ BoatTopiaDao dao = getBoatDao();
+
+ List<Boat> sampleRows = dao.findAll(filter);
+
+ ExportModel<Boat> exportModel =
+ new BoatImportExportModel(getLocale());
+
+ Export<Boat> export = Export.newExport(exportModel, sampleRows);
+
+ try {
+
+ String csvContent = export.toString(Charsets.UTF_8);
+
+ InputStream csvInputStream = IOUtils.toInputStream(csvContent, Charsets.UTF_8);
+
+ return csvInputStream;
+
+ } catch (Exception e) {
+ throw new WaoTechnicalException(e);
+ }
+ }
+
+ public BoatDetails getBoatDetails(ObsProgram obsProgram, String boatId, String companyId) {
+
+ BoatInfos boatInfos = getBoatInfos(boatId, companyId);
+
+ Contact mostRecentContact = getContactDao().findMostRecentContactOrNull(obsProgram, boatId, companyId);
+
+ ContactsFilter filter = new ContactsFilter();
+ filter.getSampleRowFilter().setObsProgram(obsProgram);
+ filter.getBoatFilter().setBoatIds(ImmutableSet.of(boatId));
+ filter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(companyId));
+ long contactsCount = getContactDao().forFilter(filter, false).count();
+
+ Date now = serviceContext.getNow();
+
+ BoatDetails boatDetails = new BoatDetails(now, obsProgram, boatInfos, mostRecentContact, contactsCount);
+
+ return boatDetails;
+
+ }
+
+ public BoatInfos getBoatInfos(String boatId, String companyId) {
+
+ BoatInfosTopiaDao dao = getBoatInfosDao();
+
+ Optional<BoatInfos> optionalBoatInfos =
+ dao.newQueryBuilder()
+ .addTopiaIdEquals(BoatInfos.PROPERTY_BOAT, boatId)
+ .addTopiaIdEquals(BoatInfos.PROPERTY_COMPANY, companyId)
+ .tryFindUnique();
+
+ BoatInfos boatInfos;
+ if (optionalBoatInfos.isPresent()) {
+ boatInfos = optionalBoatInfos.get();
+ } else {
+ Boat boat = getBoatDao().findByTopiaId(boatId);
+ Company company = getCompanyDao().findByTopiaId(companyId);
+ boatInfos = new BoatInfosImpl();
+ boatInfos.setBoat(boat);
+ boatInfos.setCompany(company);
+ }
+
+ return boatInfos;
+
+ }
+
+ public void saveBoatInfos(BoatInfos boatInfos) {
+
+ BoatInfosTopiaDao dao = getBoatInfosDao();
+
+ if (boatInfos.isPersisted()) {
+ dao.update(boatInfos);
+ } else {
+ dao.create(boatInfos);
+ }
+
+ commit();
+
+ }
+
+ public BoatContactsCounts getBoatContactsCounts(AuthenticatedWaoUser authenticatedWaoUser, String boatId, String companyId, Date since) {
+
+ ContactsFilter filter = new ContactsFilter();
+
+ filter.getSampleRowFilter().setObsProgram(authenticatedWaoUser.getObsProgram());
+ filter.setPeriodFrom(since);
+ filter.getBoatFilter().setBoatIds(ImmutableSet.of(boatId));
+ filter.setFilterOnObservationBeginDate(false);
+
+ ContactTopiaDao dao = getContactDao();
+
+ long contactsCount = dao.forFilter(filter, false).count();
+
+ filter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(companyId));
+ long contactsCompanyCount = dao.forFilter(filter, false).count();
+
+ filter.setContactStates(ImmutableSet.of(ContactState.OBSERVATION_DONE));
+ long observationsCompanyCount = dao.forFilter(filter, false).count();
+
+ filter.getSampleRowFilter().setCompanyIds(null);
+ long observationsCount = dao.forFilter(filter, false).count();
+
+ Preconditions.checkState(contactsCompanyCount <= contactsCount);
+ Preconditions.checkState(observationsCount <= contactsCount);
+
+ Preconditions.checkState(observationsCompanyCount <= contactsCompanyCount);
+ Preconditions.checkState(observationsCompanyCount <= observationsCount);
+
+ return new BoatContactsCounts(contactsCount, observationsCount, contactsCompanyCount, observationsCompanyCount);
+
+ }
+
+ public Collection<Boat> getBoats(BoatsFilter boatsFilter, int pageSize) {
+
+ PaginationParameter pager = newBoatsPaginationParameter(0, pageSize);
+
+ PaginationResult<Boat> boats = getBoatDao().find(boatsFilter, pager);
+
+ return boats.getElements();
+
+ }
+
+ public void changeBoatElligibility(AuthenticatedWaoUser authenticatedWaoUser, String boatId, String sampleRowId, boolean active) {
+
+ ElligibleBoatTopiaDao dao = getElligibleBoatDao();
+
+ ElligibleBoat elligibleBoat = dao.forBoatIdAndSampleRowId(boatId, sampleRowId).findUnique();
+
+ if (authenticatedWaoUser.isAdmin()) {
+ elligibleBoat.setGlobalActive(active);
+ } else if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ elligibleBoat.setCompanyActive(active);
+ } else {
+ throw new IllegalStateException(authenticatedWaoUser.getWaoUser().toString());
+ }
+
+ commit();
+ }
+}
Deleted: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsList.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsList.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsList.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,60 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.entity.Boat;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.nuiton.util.pagination.PaginationResult;
-
-/**
- * Created on 4/1/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ObsMerBoatsList implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected PaginationResult<Boat> boats;
-
- protected BoatsFilterValues filterValues;
-
- public PaginationResult<Boat> getBoats() {
- return boats;
- }
-
- public void setBoats(PaginationResult<Boat> boats) {
- this.boats = boats;
- }
-
- public BoatsFilterValues getFilterValues() {
- return filterValues;
- }
-
- public void setFilterValues(BoatsFilterValues filterValues) {
- this.filterValues = filterValues;
- }
-}
Deleted: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,291 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.cache.Cache;
-import com.google.common.collect.ImmutableSet;
-import fr.ifremer.wao.BoatsFilter;
-import fr.ifremer.wao.ContactsFilter;
-import fr.ifremer.wao.WaoTechnicalException;
-import fr.ifremer.wao.entity.Boat;
-import fr.ifremer.wao.entity.BoatInfos;
-import fr.ifremer.wao.entity.BoatInfosImpl;
-import fr.ifremer.wao.entity.BoatInfosTopiaDao;
-import fr.ifremer.wao.entity.BoatTopiaDao;
-import fr.ifremer.wao.entity.Company;
-import fr.ifremer.wao.entity.Contact;
-import fr.ifremer.wao.entity.ContactState;
-import fr.ifremer.wao.entity.ContactTopiaDao;
-import fr.ifremer.wao.entity.ElligibleBoat;
-import fr.ifremer.wao.entity.ElligibleBoatTopiaDao;
-import fr.ifremer.wao.entity.ObsProgram;
-import fr.ifremer.wao.services.AuthenticatedWaoUser;
-import fr.ifremer.wao.services.service.csv.BoatImportExportModel;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.csv.Export;
-import org.nuiton.csv.ExportModel;
-import org.nuiton.util.pagination.PaginationParameter;
-import org.nuiton.util.pagination.PaginationResult;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-
-/**
- * Created on 4/1/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ObsMerBoatsService extends WaoServiceSupport {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ObsMerBoatsService.class);
-
- public BoatsFilterValues getBoatsFilterValues(AuthenticatedWaoUser authenticatedWaoUser, BoatsFilter filter) {
-
- Optional<String> optionalCompanyId = Optional.absent();
- if (authenticatedWaoUser.isCoordinatorOrObserver()) {
- optionalCompanyId = Optional.of(authenticatedWaoUser.getCompany().getTopiaId());
- }
-
- BoatsFilterValuesCacheKey boatsFilterValuesCacheKey =
- new BoatsFilterValuesCacheKey(
- serviceContext.getLocale(),
- authenticatedWaoUser.getObsProgram(),
- optionalCompanyId);
-
- Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> cache =
- serviceContext.getBoatsFilterValuesCache();
-
- BoatsFilterValues boatsFilterValues = cache.getIfPresent(boatsFilterValuesCacheKey);
-
- if (boatsFilterValues == null) {
-
- BoatTopiaDao dao = getBoatDao();
-
- List<Boat> boats = dao.findAll(filter);
-
- boatsFilterValues = new BoatsFilterValues(serviceContext.getLocale(), authenticatedWaoUser.getObsProgram(), optionalCompanyId);
-
- for (Boat boat : boats) {
- boatsFilterValues.addBoat(boat);
- }
-
- cache.put(boatsFilterValuesCacheKey, boatsFilterValues);
-
- }
-
- return boatsFilterValues;
- }
-
- public ObsMerBoatsList getBoatsList(AuthenticatedWaoUser authenticatedWaoUser,
- BoatsFilter filter,
- PaginationParameter pager) {
-
- BoatTopiaDao dao = getBoatDao();
-
- PaginationResult<Boat> boats = dao.find(filter, pager);
-
- BoatsFilterValues boatsFilterValues = getBoatsFilterValues(authenticatedWaoUser, filter);
-
- ObsMerBoatsList obsMerBoatsList = new ObsMerBoatsList();
- obsMerBoatsList.setBoats(boats);
- obsMerBoatsList.setFilterValues(boatsFilterValues);
- return obsMerBoatsList;
- }
-
- public PaginationParameter newBoatsPaginationParameter(int pageNumber, int pageSize) {
- PaginationParameter result = PaginationParameter.of(pageNumber, pageSize, Boat.PROPERTY_NAME, false);
- return result;
- }
-
- public BoatsFilter newBoatsFilter(AuthenticatedWaoUser authenticatedWaoUser) {
-
- BoatsFilter boatsFilter = new BoatsFilter();
-
- if (authenticatedWaoUser.isProfessional()) {
- // Pour le profesionnel, on restreint d'office à la liste des bateaux qu'il peut voir
- Collection<String> canReadBoatsTopiaIds = authenticatedWaoUser.getWaoUser().getCanReadBoatsTopiaIds();
- if (CollectionUtils.isEmpty(canReadBoatsTopiaIds)) {
- if (log.isWarnEnabled()) {
- log.warn("user " + authenticatedWaoUser.getWaoUser() + " is professional but can't read any boat");
- }
- } else {
- boatsFilter.setBoatIds(new HashSet<>(canReadBoatsTopiaIds));
- }
- }
-
- return boatsFilter;
-
- }
-
- public InputStream exportBoats(BoatsFilter filter) {
-
- BoatTopiaDao dao = getBoatDao();
-
- List<Boat> sampleRows = dao.findAll(filter);
-
- ExportModel<Boat> exportModel =
- new BoatImportExportModel(getLocale());
-
- Export<Boat> export = Export.newExport(exportModel, sampleRows);
-
- try {
-
- String csvContent = export.toString(Charsets.UTF_8);
-
- InputStream csvInputStream = IOUtils.toInputStream(csvContent, Charsets.UTF_8);
-
- return csvInputStream;
-
- } catch (Exception e) {
- throw new WaoTechnicalException(e);
- }
- }
-
- public BoatDetails getBoatDetails(ObsProgram obsProgram, String boatId, String companyId) {
-
- BoatInfos boatInfos = getBoatInfos(boatId, companyId);
-
- Contact mostRecentContact = getContactDao().findMostRecentContactOrNull(obsProgram, boatId, companyId);
-
- ContactsFilter filter = new ContactsFilter();
- filter.getSampleRowFilter().setObsProgram(obsProgram);
- filter.getBoatFilter().setBoatIds(ImmutableSet.of(boatId));
- filter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(companyId));
- long contactsCount = getContactDao().forFilter(filter, false).count();
-
- Date now = serviceContext.getNow();
-
- BoatDetails boatDetails = new BoatDetails(now, obsProgram, boatInfos, mostRecentContact, contactsCount);
-
- return boatDetails;
-
- }
-
- public BoatInfos getBoatInfos(String boatId, String companyId) {
-
- BoatInfosTopiaDao dao = getBoatInfosDao();
-
- Optional<BoatInfos> optionalBoatInfos =
- dao.newQueryBuilder()
- .addTopiaIdEquals(BoatInfos.PROPERTY_BOAT, boatId)
- .addTopiaIdEquals(BoatInfos.PROPERTY_COMPANY, companyId)
- .tryFindUnique();
-
- BoatInfos boatInfos;
- if (optionalBoatInfos.isPresent()) {
- boatInfos = optionalBoatInfos.get();
- } else {
- Boat boat = getBoatDao().findByTopiaId(boatId);
- Company company = getCompanyDao().findByTopiaId(companyId);
- boatInfos = new BoatInfosImpl();
- boatInfos.setBoat(boat);
- boatInfos.setCompany(company);
- }
-
- return boatInfos;
-
- }
-
- public void saveBoatInfos(BoatInfos boatInfos) {
-
- BoatInfosTopiaDao dao = getBoatInfosDao();
-
- if (boatInfos.isPersisted()) {
- dao.update(boatInfos);
- } else {
- dao.create(boatInfos);
- }
-
- commit();
-
- }
-
- public BoatContactsCounts getBoatContactsCounts(AuthenticatedWaoUser authenticatedWaoUser, String boatId, String companyId, Date since) {
-
- ContactsFilter filter = new ContactsFilter();
-
- filter.getSampleRowFilter().setObsProgram(authenticatedWaoUser.getObsProgram());
- filter.setPeriodFrom(since);
- filter.getBoatFilter().setBoatIds(ImmutableSet.of(boatId));
- filter.setFilterOnObservationBeginDate(false);
-
- ContactTopiaDao dao = getContactDao();
-
- long contactsCount = dao.forFilter(filter, false).count();
-
- filter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(companyId));
- long contactsCompanyCount = dao.forFilter(filter, false).count();
-
- filter.setContactStates(ImmutableSet.of(ContactState.OBSERVATION_DONE));
- long observationsCompanyCount = dao.forFilter(filter, false).count();
-
- filter.getSampleRowFilter().setCompanyIds(null);
- long observationsCount = dao.forFilter(filter, false).count();
-
- Preconditions.checkState(contactsCompanyCount <= contactsCount);
- Preconditions.checkState(observationsCount <= contactsCount);
-
- Preconditions.checkState(observationsCompanyCount <= contactsCompanyCount);
- Preconditions.checkState(observationsCompanyCount <= observationsCount);
-
- return new BoatContactsCounts(contactsCount, observationsCount, contactsCompanyCount, observationsCompanyCount);
-
- }
-
- public Collection<Boat> getBoats(BoatsFilter boatsFilter, int pageSize) {
-
- PaginationParameter pager = newBoatsPaginationParameter(0, pageSize);
-
- PaginationResult<Boat> boats = getBoatDao().find(boatsFilter, pager);
-
- return boats.getElements();
-
- }
-
- public void changeBoatElligibility(AuthenticatedWaoUser authenticatedWaoUser, String boatId, String sampleRowId, boolean active) {
-
- ElligibleBoatTopiaDao dao = getElligibleBoatDao();
-
- ElligibleBoat elligibleBoat = dao.forBoatIdAndSampleRowId(boatId, sampleRowId).findUnique();
-
- if (authenticatedWaoUser.isAdmin()) {
- elligibleBoat.setGlobalActive(active);
- } else if (authenticatedWaoUser.isCoordinatorOrObserver()) {
- elligibleBoat.setCompanyActive(active);
- } else {
- throw new IllegalStateException(authenticatedWaoUser.getWaoUser().toString());
- }
-
- commit();
- }
-}
Modified: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -71,7 +71,6 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -82,7 +81,6 @@
import org.nuiton.csv.ImportRuntimeException;
import org.nuiton.topia.persistence.TopiaEntities;
import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.util.DateUtil;
import java.io.InputStream;
import java.text.ParseException;
@@ -95,7 +93,7 @@
import java.util.Map;
import java.util.Set;
-public class ObsMerSamplingPlanService extends WaoServiceSupport {
+public class ObsMerSamplingPlanService extends SamplingPlanService {
private static final Log log = LogFactory.getLog(ObsMerSamplingPlanService.class);
@@ -360,14 +358,6 @@
}
- public SampleRow getSampleRow(String sampleRowId) {
-
- SampleRow sampleRow = getSampleRowDao().findByTopiaId(sampleRowId);
-
- return sampleRow;
-
- }
-
public void commentSampleRow(AuthenticatedWaoUser authenticatedWaoUser, String sampleRowId, String comment) {
SampleRow sampleRow = getSampleRow(sampleRowId);
@@ -383,14 +373,6 @@
}
- public List<SampleRow> getSamplingPlanRows(SampleRowsFilter sampleRowsFilter) {
-
- SampleRowTopiaDao dao = getSampleRowDao();
-
- return dao.findAll(sampleRowsFilter);
-
- }
-
public ObsMerSamplingPlan getSamplingPlan(
AuthenticatedWaoUser authenticatedWaoUser,
SampleRowsFilter sampleRowsFilter) {
@@ -459,53 +441,6 @@
}
- public SampleRowsFilter newSampleRowsFilter(AuthenticatedWaoUser authenticatedWaoUser) {
-
- // all users can see only rows for the program they are logged for
- SampleRowsFilter newFilter = new SampleRowsFilter();
- newFilter.setObsProgram(authenticatedWaoUser.getObsProgram());
-
- // We don't want to see all rows but the ones important for today
- Date fromDate = serviceContext.getNow();
- Date toDate = fromDate;
-
- // Dans ObsMer et ObsVente, le plan est mensualisé
- fromDate = DateUtils.truncate(fromDate, Calendar.MONTH);
-
- // la période initiale doit toujours aller d'avril à mars (contractuel).
- // on prend la période dans laquelle on se trouve actuellement
-
- // si on est avant le premier avril de l'année courante
- boolean beforePeriodChangeInCurrentYear = DateUtil.getMonth(fromDate) < 3;
-
- if (beforePeriodChangeInCurrentYear) {
- // on prend la période qui a commencé l'année dernière et qui finit
- // cette année
- fromDate = DateUtils.setMonths(fromDate, 3);
- fromDate = DateUtils.addYears(fromDate, -1);
- } else {
- // on prend la période qui commence cette année et se termine
- // l'année prochaine
- fromDate = DateUtils.setMonths(fromDate, 3);
- }
-
- // on a fromDate sur le premier avril de la bonne année, on va
- // jusqu'au mois de mars suivant
- toDate = DateUtils.addMonths(fromDate, 11);
-
- newFilter.setPeriodFrom(fromDate);
- newFilter.setPeriodTo(toDate);
-
- // Very very important to do that at beginning
- // Evo #2227 : Guest user has no default company filter
- if (authenticatedWaoUser.isCoordinatorOrObserver()) {
- newFilter.setCompanyIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId()));
- }
-
- return newFilter;
-
- }
-
public void importSamplingPlan(AuthenticatedWaoUser authenticatedWaoUser, InputStream csv) throws ImportErrorException {
ImportModel<SampleRow> samplingPlanImportModel =
@@ -794,21 +729,4 @@
}
- public List<SampleRow> getUnfinishedSampleRows(AuthenticatedWaoUser authenticatedWaoUser, String companyId) {
-
- SampleRowsFilter sampleRowsFilter = newSampleRowsFilter(authenticatedWaoUser);
-
- sampleRowsFilter.setCompanyIds(ImmutableSet.of(companyId));
-
- Date now = getNow();
- sampleRowsFilter.setPeriodFrom(now);
- // sampleRowsFilter.setPeriodTo(DateUtils.addYears(now, 1));
-
- sampleRowsFilter.setOrderByArguments(ImmutableSet.of(SampleRow.PROPERTY_CODE));
-
- List<SampleRow> unfinishedSampleRows = getSamplingPlanRows(sampleRowsFilter);
-
- return unfinishedSampleRows;
-
- }
}
Added: branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,96 @@
+package fr.ifremer.wao.services.service;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import fr.ifremer.wao.SampleRowsFilter;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.SampleRowTopiaDao;
+import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.DateUtil;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+public class SamplingPlanService extends WaoServiceSupport {
+
+ private static final Log log = LogFactory.getLog(SamplingPlanService.class);
+
+ public SampleRow getSampleRow(String sampleRowId) {
+
+ SampleRow sampleRow = getSampleRowDao().findByTopiaId(sampleRowId);
+
+ return sampleRow;
+
+ }
+
+ public SampleRowsFilter newSampleRowsFilter(AuthenticatedWaoUser authenticatedWaoUser) {
+
+ // all users can see only rows for the program they are logged for
+ SampleRowsFilter newFilter = new SampleRowsFilter();
+ newFilter.setObsProgram(authenticatedWaoUser.getObsProgram());
+
+ // We don't want to see all rows but the ones important for today
+ Date fromDate = serviceContext.getNow();
+ Date toDate = fromDate;
+
+ // Dans ObsMer et ObsVente, le plan est mensualisé
+ fromDate = DateUtils.truncate(fromDate, Calendar.MONTH);
+
+ // la période initiale doit toujours aller d'avril à mars (contractuel).
+ // on prend la période dans laquelle on se trouve actuellement
+
+ // si on est avant le premier avril de l'année courante
+ boolean beforePeriodChangeInCurrentYear = DateUtil.getMonth(fromDate) < 3;
+
+ if (beforePeriodChangeInCurrentYear) {
+ // on prend la période qui a commencé l'année dernière et qui finit
+ // cette année
+ fromDate = DateUtils.setMonths(fromDate, 3);
+ fromDate = DateUtils.addYears(fromDate, -1);
+ } else {
+ // on prend la période qui commence cette année et se termine
+ // l'année prochaine
+ fromDate = DateUtils.setMonths(fromDate, 3);
+ }
+
+ // on a fromDate sur le premier avril de la bonne année, on va
+ // jusqu'au mois de mars suivant
+ toDate = DateUtils.addMonths(fromDate, 11);
+
+ newFilter.setPeriodFrom(fromDate);
+ newFilter.setPeriodTo(toDate);
+
+ // Very very important to do that at beginning
+ // Evo #2227 : Guest user has no default company filter
+ if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ newFilter.setCompanyIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId()));
+ }
+
+ return newFilter;
+
+ }
+
+ public List<SampleRow> getUnfinishedSampleRows(AuthenticatedWaoUser authenticatedWaoUser, String companyId) {
+
+ SampleRowsFilter sampleRowsFilter = newSampleRowsFilter(authenticatedWaoUser);
+
+ sampleRowsFilter.setCompanyIds(ImmutableSet.of(companyId));
+
+ Date now = getNow();
+ sampleRowsFilter.setPeriodFrom(now);
+ // sampleRowsFilter.setPeriodTo(DateUtils.addYears(now, 1));
+
+ sampleRowsFilter.setOrderByArguments(ImmutableSet.of(SampleRow.PROPERTY_CODE));
+
+ SampleRowTopiaDao dao = getSampleRowDao();
+
+ List<SampleRow> unfinishedSampleRows = dao.findAll(sampleRowsFilter);
+
+ return unfinishedSampleRows;
+
+ }
+}
Copied: branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsServiceTest.java (from rev 2075, branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsServiceTest.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsServiceTest.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,73 @@
+package fr.ifremer.wao.services.service;
+
+/*
+ * #%L
+ * Wao :: Services
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.BoatsFilter;
+import fr.ifremer.wao.services.AbstractWaoServiceTest;
+import fr.ifremer.wao.services.ObsMerFixtures;
+import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.util.pagination.PaginationParameter;
+
+/**
+ * Created on 4/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class BoatsServiceTest extends AbstractWaoServiceTest {
+
+ protected BoatsService service;
+
+ protected ObsMerFixtures fixtures;
+
+ @Before
+ public void setUp() {
+ service = newService(BoatsService.class);
+ fixtures = new ObsMerFixtures(newServiceContext());
+ }
+
+ protected boolean isDatabaseWithReferential() {
+ return true;
+ }
+
+ @Test
+ public void testGetBoatsFilterValues() {
+
+ BoatsFilter filter = service.newBoatsFilter(fixtures.admin());
+
+ BoatsFilterValues boatsFilterValues = service.getBoatsFilterValues(fixtures.admin(), filter);
+
+ }
+
+ @Test
+ public void testGetBoatsList() {
+
+ BoatsFilter filter = service.newBoatsFilter(fixtures.admin());
+
+ PaginationParameter pager = service.newBoatsPaginationParameter(0, 50);
+
+ BoatsList boatsList = service.getBoatsList(fixtures.admin(), filter, pager);
+
+ }
+
+}
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java
===================================================================
--- branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerBoatsServiceTest.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,74 +0,0 @@
-package fr.ifremer.wao.services.service;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.BoatsFilter;
-import fr.ifremer.wao.services.AbstractWaoServiceTest;
-import fr.ifremer.wao.services.ObsMerFixtures;
-import org.junit.Before;
-import org.junit.Test;
-import org.nuiton.topia.persistence.pager.TopiaPagerBean;
-import org.nuiton.util.pagination.PaginationParameter;
-
-/**
- * Created on 4/1/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ObsMerBoatsServiceTest extends AbstractWaoServiceTest {
-
- protected ObsMerBoatsService service;
-
- protected ObsMerFixtures fixtures;
-
- @Before
- public void setUp() {
- service = newService(ObsMerBoatsService.class);
- fixtures = new ObsMerFixtures(newServiceContext());
- }
-
- protected boolean isDatabaseWithReferential() {
- return true;
- }
-
- @Test
- public void testGetBoatsFilterValues() {
-
- BoatsFilter filter = service.newBoatsFilter(fixtures.admin());
-
- BoatsFilterValues boatsFilterValues = service.getBoatsFilterValues(fixtures.admin(), filter);
-
- }
-
- @Test
- public void testGetBoatsList() {
-
- BoatsFilter filter = service.newBoatsFilter(fixtures.admin());
-
- PaginationParameter pager = service.newBoatsPaginationParameter(0, 50);
-
- ObsMerBoatsList boatsList = service.getBoatsList(fixtures.admin(), filter, pager);
-
- }
-
-}
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatDetailsAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatDetailsAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatDetailsAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatDetailsAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,98 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.services.service.BoatDetails;
+import fr.ifremer.wao.services.service.BoatsService;
+import fr.ifremer.wao.services.service.SamplingPlanService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+
+import java.util.List;
+
+public class BoatDetailsAction extends WaoJspActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient BoatsService service;
+
+ protected transient SamplingPlanService samplingPlanService;
+
+ protected String companyId;
+
+ protected String boatId;
+
+ protected BoatDetails boatDetails;
+
+ protected SampleRow startBoatSelectionForSampleRow;
+
+ private List<SampleRow> sampleRowsToSetElligible;
+
+ public void setService(BoatsService service) {
+ this.service = service;
+ }
+
+ public void setSamplingPlanService(SamplingPlanService samplingPlanService) {
+ this.samplingPlanService = samplingPlanService;
+ }
+
+ public void setCompanyId(String companyId) {
+ this.companyId = companyId;
+ }
+
+ public void setBoatId(String boatId) {
+ this.boatId = boatId;
+ }
+
+ @Override
+ public String execute() {
+
+ Preconditions.checkState(getAuthenticatedWaoUser().isAuthorizedToViewBoatDetails(companyId));
+
+ boatDetails = service.getBoatDetails(getObsProgram(), boatId, companyId);
+
+ String startBoatSelectionForSampleRowId = session.getStartBoatSelectionForSampleRowId();
+
+ if (startBoatSelectionForSampleRowId != null) {
+ startBoatSelectionForSampleRow = samplingPlanService.getSampleRow(startBoatSelectionForSampleRowId);
+ }
+
+ // TODO brendan 14/04/14 really useful ?
+ sampleRowsToSetElligible = samplingPlanService.getUnfinishedSampleRows(getAuthenticatedWaoUser(), companyId);
+
+ return SUCCESS;
+
+ }
+
+ public BoatDetails getBoatDetails() {
+ return boatDetails;
+ }
+
+ public SampleRow getStartBoatSelectionForSampleRow() {
+ return startBoatSelectionForSampleRow;
+ }
+
+ public List<SampleRow> getSampleRowsToSetElligible() {
+ return sampleRowsToSetElligible;
+ }
+}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatsAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatsAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatsAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,192 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Objects;
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.BoatsFilter;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.services.service.BoatsFilterValues;
+import fr.ifremer.wao.services.service.BoatsList;
+import fr.ifremer.wao.services.service.BoatsService;
+import fr.ifremer.wao.services.service.SamplingPlanService;
+import fr.ifremer.wao.services.service.administration.CompaniesService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.pagination.PaginationParameter;
+import org.nuiton.util.pagination.PaginationResult;
+
+import java.util.List;
+
+/**
+ * Created on 4/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class BoatsAction extends WaoJspActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log = LogFactory.getLog(BoatsAction.class);
+
+ protected transient BoatsService service;
+
+ protected transient CompaniesService companiesService;
+
+ protected transient SamplingPlanService samplingPlanService;
+
+ protected int pageNumber; // 1-based page number
+
+ protected long firstRangePage;
+
+ protected long lastRangePage;
+
+ /**
+ * Boats filter.
+ */
+ protected BoatsFilter filter;
+
+ /**
+ * List of boats according to the input pager and filter.
+ */
+ protected BoatsList boatList;
+
+ protected String startBoatSelectionForSampleRowId;
+
+ protected SampleRow startBoatSelectionForSampleRow;
+
+ public void setService(BoatsService service) {
+ this.service = service;
+ }
+
+ public BoatsFilter getFilter() {
+ if (filter == null) {
+ prepare();
+ }
+ return filter;
+ }
+
+ public List<Boat> getBoats() {
+ return boatList.getBoats().getElements();
+ }
+
+ public BoatsFilterValues getFilterValues() {
+ return boatList.getFilterValues();
+ }
+
+ public PaginationResult<Boat> getPagination() {
+ return boatList.getBoats();
+ }
+
+ public void setStartBoatSelectionForSampleRowId(String startBoatSelectionForSampleRowId) {
+ this.startBoatSelectionForSampleRowId = startBoatSelectionForSampleRowId;
+ }
+
+ public void setSamplingPlanService(SamplingPlanService samplingPlanService) {
+ this.samplingPlanService = samplingPlanService;
+ }
+
+ public void setCompaniesService(CompaniesService companiesService) {
+ this.companiesService = companiesService;
+ }
+
+ public void setPageNumber(int pageNumber) {
+ this.pageNumber = pageNumber;
+ }
+
+ @Override
+ public void prepare() {
+
+ if (filter == null) {
+ filter = service.newBoatsFilter(getAuthenticatedWaoUser());
+ }
+
+ if (StringUtils.isNotBlank(startBoatSelectionForSampleRowId)) {
+
+ session.setStartBoatSelectionForSampleRowId(startBoatSelectionForSampleRowId);
+
+ if (log.isInfoEnabled()) {
+ log.info("user " + getAuthenticatedWaoUser().getWaoUser() + " is starting to select a boat for sample row " + startBoatSelectionForSampleRow);
+ }
+
+ }
+
+ if (session.getStartBoatSelectionForSampleRowId() != null) {
+
+ startBoatSelectionForSampleRow = samplingPlanService.getSampleRow(session.getStartBoatSelectionForSampleRowId());
+
+ }
+
+ }
+
+ @Override
+ public String execute() {
+
+ filter = Objects.firstNonNull(session.getBoatsFilter(), filter);
+
+ return applyFilter();
+
+ }
+
+ public String resetFilter() {
+
+ filter = service.newBoatsFilter(getAuthenticatedWaoUser());
+
+ return applyFilter();
+
+ }
+
+ public String applyFilter() {
+
+ getSession().setBoatsFilter(filter);
+
+ PaginationParameter pager = service.newBoatsPaginationParameter(pageNumber, 25);
+ boatList = service.getBoatsList(getAuthenticatedWaoUser(), filter, pager);
+
+ firstRangePage = getPaginationFirstPage(boatList.getBoats(), 10);
+ lastRangePage = getPaginationLastPage(boatList.getBoats(), 10, firstRangePage);
+
+ return SUCCESS;
+
+ }
+
+ public SampleRow getStartBoatSelectionForSampleRow() {
+ return startBoatSelectionForSampleRow;
+ }
+
+ public List<Company> getAllCompanies() {
+ return companiesService.getAllCompanies();
+ }
+
+ public long getFirstRangePage() {
+ return firstRangePage;
+ }
+
+ public long getLastRangePage() {
+ return lastRangePage;
+ }
+}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatsFilterValuesJsonAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatsFilterValuesJsonAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/BoatsFilterValuesJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,90 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.BoatsFilter;
+import fr.ifremer.wao.services.service.BoatsFilterValues;
+import fr.ifremer.wao.services.service.BoatsService;
+import fr.ifremer.wao.web.WaoJsonActionSupport;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Created on 4/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class BoatsFilterValuesJsonAction extends WaoJsonActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient BoatsService service;
+
+ protected BoatsFilter filter;
+
+ protected BoatsFilterValues filterValues;
+
+ protected String filterValuesField;
+
+ public void setService(BoatsService service) {
+ this.service = service;
+ }
+
+ public void setFilterValuesField(String filterValuesField) {
+ this.filterValuesField = filterValuesField;
+ }
+
+ public BoatsFilter getFilter() {
+ if (filter == null) {
+ prepare();
+ }
+ return filter;
+ }
+
+ @Override
+ public void prepare() {
+
+ filter = service.newBoatsFilter(session.getAuthenticatedWaoUser());
+ }
+
+ @Override
+ public String execute() {
+
+ filterValues = service.getBoatsFilterValues(session.getAuthenticatedWaoUser(), filter);
+
+ if (StringUtils.isNotBlank(filterValuesField)) {
+
+ // le client ne demande qu'un seul champ, on peut éviter de retourner l'objet complet
+
+ filterValues = filterValues.getCopyWithSingleProperty(filterValuesField);
+
+ }
+
+ return SUCCESS;
+ }
+
+ public BoatsFilterValues getFilterValues() {
+ return filterValues;
+ }
+
+}
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/CancelBoatSelectionAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CancelBoatSelectionAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/CancelBoatSelectionAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/CancelBoatSelectionAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,22 @@
+package fr.ifremer.wao.web.action;
+
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+
+
+@Results({
+ @Result(name="success", type="redirectAction", params = { "actionName", "boats" })
+})
+public class CancelBoatSelectionAction extends WaoJspActionSupport {
+
+ @Override
+ public String execute() {
+
+ session.setStartBoatSelectionForSampleRowId(null);
+
+ return SUCCESS;
+
+ }
+
+}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportBoatsAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportBoatsAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportBoatsAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportBoatsAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,77 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.BoatsFilter;
+import fr.ifremer.wao.services.service.BoatsService;
+
+import java.io.InputStream;
+import java.util.Date;
+
+/**
+ * Created on 4/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 4.0
+ */
+public class ExportBoatsAction extends AbstractDownloadCsvAction implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient BoatsService service;
+
+ protected BoatsFilter filter;
+
+ public void setService(BoatsService service) {
+ this.service = service;
+ }
+
+ public BoatsFilter getFilter() {
+ if (filter == null) {
+ prepare();
+ }
+ return filter;
+ }
+
+ @Override
+ public void prepare() {
+
+ filter = service.newBoatsFilter(getAuthenticatedWaoUser());
+
+ }
+
+ @Override
+ public String getFileName() {
+
+ return "boats_" + getObsProgram().name() + "_" + dateFormat.format(new Date()) + ".csv";
+
+ }
+
+ @Override
+ public InputStream getInputStream() {
+
+ return service.exportBoats(filter);
+
+ }
+
+}
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/GetBoatContactsCountJsonAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/GetBoatContactsCountJsonAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/GetBoatContactsCountJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,50 @@
+package fr.ifremer.wao.web.action;
+
+import fr.ifremer.wao.services.service.BoatContactsCounts;
+import fr.ifremer.wao.services.service.BoatsService;
+import fr.ifremer.wao.web.WaoJsonActionSupport;
+
+import java.util.Date;
+
+public class GetBoatContactsCountJsonAction extends WaoJsonActionSupport {
+
+ protected Date since;
+
+ protected BoatsService service;
+
+ protected String boatId;
+
+ protected String companyId;
+
+ protected BoatContactsCounts boatContactsCounts;
+
+ public void setSince(Date since) {
+ this.since = since;
+ }
+
+ public void setService(BoatsService service) {
+ this.service = service;
+ }
+
+ public void setBoatId(String boatId) {
+ this.boatId = boatId;
+ }
+
+ public void setCompanyId(String companyId) {
+ this.companyId = companyId;
+ }
+
+ @Override
+ public String execute() {
+
+ boatContactsCounts = service.getBoatContactsCounts(session.getAuthenticatedWaoUser(), boatId, companyId, since);
+
+ return SUCCESS;
+
+ }
+
+ public BoatContactsCounts getBoatContactsCounts() {
+ return boatContactsCounts;
+ }
+
+}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/UpdateBoatElligibilityJsonAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/UpdateBoatElligibilityJsonAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/UpdateBoatElligibilityJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,39 @@
+package fr.ifremer.wao.web.action;
+
+import fr.ifremer.wao.services.service.BoatsService;
+import fr.ifremer.wao.web.WaoJsonActionSupport;
+
+public class UpdateBoatElligibilityJsonAction extends WaoJsonActionSupport {
+
+ protected BoatsService service;
+
+ protected String boatId;
+
+ protected String sampleRowId;
+
+ protected boolean active;
+
+ public void setService(BoatsService service) {
+ this.service = service;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public void setBoatId(String boatId) {
+ this.boatId = boatId;
+ }
+
+ public void setSampleRowId(String sampleRowId) {
+ this.sampleRowId = sampleRowId;
+ }
+
+ @Override
+ public String execute() {
+
+ service.changeBoatElligibility(session.getAuthenticatedWaoUser(), boatId, sampleRowId, active);
+
+ return SUCCESS;
+ }
+}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/UpdateBoatInfosJsonAction.java (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatInfosJsonAction.java)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/UpdateBoatInfosJsonAction.java (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/UpdateBoatInfosJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,59 @@
+package fr.ifremer.wao.web.action;
+
+import com.google.common.base.Preconditions;
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.entity.BoatInfos;
+import fr.ifremer.wao.services.service.BoatsService;
+import fr.ifremer.wao.web.WaoJsonActionSupport;
+
+public class UpdateBoatInfosJsonAction extends WaoJsonActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient BoatsService service;
+
+ protected String companyId;
+
+ protected String boatId;
+
+ protected BoatInfos boatInfos;
+
+ public void setService(BoatsService service) {
+ this.service = service;
+ }
+
+ public void setCompanyId(String companyId) {
+ this.companyId = companyId;
+ }
+
+ public void setBoatId(String boatId) {
+ this.boatId = boatId;
+ }
+
+ @Override
+ public void prepare() {
+
+ Preconditions.checkState(session.getAuthenticatedWaoUser().isAuthorizedToViewBoatDetails(companyId));
+
+ boatInfos = service.getBoatInfos(boatId, companyId);
+
+ }
+
+ public BoatInfos getBoatInfos() {
+ return boatInfos;
+ }
+
+ public void setBoatInfos(BoatInfos boatInfos) {
+ this.boatInfos = boatInfos;
+ }
+
+ @Override
+ public String execute() {
+
+ service.saveBoatInfos(boatInfos);
+
+ return SUCCESS;
+
+ }
+
+}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatDetailsAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatDetailsAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatDetailsAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,98 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.wao.entity.SampleRow;
-import fr.ifremer.wao.services.service.BoatDetails;
-import fr.ifremer.wao.services.service.ObsMerBoatsService;
-import fr.ifremer.wao.services.service.ObsMerSamplingPlanService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-
-import java.util.List;
-
-public class BoatDetailsAction extends WaoJspActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- protected transient ObsMerBoatsService service;
-
- protected transient ObsMerSamplingPlanService obsMerSamplingPlanService;
-
- protected String companyId;
-
- protected String boatId;
-
- protected BoatDetails boatDetails;
-
- protected SampleRow startBoatSelectionForSampleRow;
-
- private List<SampleRow> sampleRowsToSetElligible;
-
- public void setService(ObsMerBoatsService service) {
- this.service = service;
- }
-
- public void setObsMerSamplingPlanService(ObsMerSamplingPlanService obsMerSamplingPlanService) {
- this.obsMerSamplingPlanService = obsMerSamplingPlanService;
- }
-
- public void setCompanyId(String companyId) {
- this.companyId = companyId;
- }
-
- public void setBoatId(String boatId) {
- this.boatId = boatId;
- }
-
- @Override
- public String execute() {
-
- Preconditions.checkState(getAuthenticatedWaoUser().isAuthorizedToViewBoatDetails(companyId));
-
- boatDetails = service.getBoatDetails(getObsProgram(), boatId, companyId);
-
- String startBoatSelectionForSampleRowId = session.getStartBoatSelectionForSampleRowId();
-
- if (startBoatSelectionForSampleRowId != null) {
- startBoatSelectionForSampleRow = obsMerSamplingPlanService.getSampleRow(startBoatSelectionForSampleRowId);
- }
-
- // TODO brendan 14/04/14 really useful ?
- sampleRowsToSetElligible = obsMerSamplingPlanService.getUnfinishedSampleRows(getAuthenticatedWaoUser(), companyId);
-
- return SUCCESS;
-
- }
-
- public BoatDetails getBoatDetails() {
- return boatDetails;
- }
-
- public SampleRow getStartBoatSelectionForSampleRow() {
- return startBoatSelectionForSampleRow;
- }
-
- public List<SampleRow> getSampleRowsToSetElligible() {
- return sampleRowsToSetElligible;
- }
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,192 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.base.Objects;
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.BoatsFilter;
-import fr.ifremer.wao.entity.Boat;
-import fr.ifremer.wao.entity.Company;
-import fr.ifremer.wao.entity.SampleRow;
-import fr.ifremer.wao.services.service.BoatsFilterValues;
-import fr.ifremer.wao.services.service.ObsMerBoatsList;
-import fr.ifremer.wao.services.service.ObsMerBoatsService;
-import fr.ifremer.wao.services.service.ObsMerSamplingPlanService;
-import fr.ifremer.wao.services.service.administration.CompaniesService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.pagination.PaginationParameter;
-import org.nuiton.util.pagination.PaginationResult;
-
-import java.util.List;
-
-/**
- * Created on 4/1/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class BoatsAction extends WaoJspActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- private static final Log log = LogFactory.getLog(BoatsAction.class);
-
- protected transient ObsMerBoatsService service;
-
- protected transient CompaniesService companiesService;
-
- protected transient ObsMerSamplingPlanService obsMerSamplingPlanService;
-
- protected int pageNumber; // 1-based page number
-
- protected long firstRangePage;
-
- protected long lastRangePage;
-
- /**
- * Boats filter.
- */
- protected BoatsFilter filter;
-
- /**
- * List of boats according to the input pager and filter.
- */
- protected ObsMerBoatsList boatList;
-
- protected String startBoatSelectionForSampleRowId;
-
- protected SampleRow startBoatSelectionForSampleRow;
-
- public void setService(ObsMerBoatsService service) {
- this.service = service;
- }
-
- public BoatsFilter getFilter() {
- if (filter == null) {
- prepare();
- }
- return filter;
- }
-
- public List<Boat> getBoats() {
- return boatList.getBoats().getElements();
- }
-
- public BoatsFilterValues getFilterValues() {
- return boatList.getFilterValues();
- }
-
- public PaginationResult<Boat> getPagination() {
- return boatList.getBoats();
- }
-
- public void setStartBoatSelectionForSampleRowId(String startBoatSelectionForSampleRowId) {
- this.startBoatSelectionForSampleRowId = startBoatSelectionForSampleRowId;
- }
-
- public void setObsMerSamplingPlanService(ObsMerSamplingPlanService obsMerSamplingPlanService) {
- this.obsMerSamplingPlanService = obsMerSamplingPlanService;
- }
-
- public void setCompaniesService(CompaniesService companiesService) {
- this.companiesService = companiesService;
- }
-
- public void setPageNumber(int pageNumber) {
- this.pageNumber = pageNumber;
- }
-
- @Override
- public void prepare() {
-
- if (filter == null) {
- filter = service.newBoatsFilter(getAuthenticatedWaoUser());
- }
-
- if (StringUtils.isNotBlank(startBoatSelectionForSampleRowId)) {
-
- session.setStartBoatSelectionForSampleRowId(startBoatSelectionForSampleRowId);
-
- if (log.isInfoEnabled()) {
- log.info("user " + getAuthenticatedWaoUser().getWaoUser() + " is starting to select a boat for sample row " + startBoatSelectionForSampleRow);
- }
-
- }
-
- if (session.getStartBoatSelectionForSampleRowId() != null) {
-
- startBoatSelectionForSampleRow = obsMerSamplingPlanService.getSampleRow(session.getStartBoatSelectionForSampleRowId());
-
- }
-
- }
-
- @Override
- public String execute() {
-
- filter = Objects.firstNonNull(session.getBoatsFilter(), filter);
-
- return applyFilter();
-
- }
-
- public String resetFilter() {
-
- filter = service.newBoatsFilter(getAuthenticatedWaoUser());
-
- return applyFilter();
-
- }
-
- public String applyFilter() {
-
- getSession().setBoatsFilter(filter);
-
- PaginationParameter pager = service.newBoatsPaginationParameter(pageNumber, 25);
- boatList = service.getBoatsList(getAuthenticatedWaoUser(), filter, pager);
-
- firstRangePage = getPaginationFirstPage(boatList.getBoats(), 10);
- lastRangePage = getPaginationLastPage(boatList.getBoats(), 10, firstRangePage);
-
- return SUCCESS;
-
- }
-
- public SampleRow getStartBoatSelectionForSampleRow() {
- return startBoatSelectionForSampleRow;
- }
-
- public List<Company> getAllCompanies() {
- return companiesService.getAllCompanies();
- }
-
- public long getFirstRangePage() {
- return firstRangePage;
- }
-
- public long getLastRangePage() {
- return lastRangePage;
- }
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsFilterValuesJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,90 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.BoatsFilter;
-import fr.ifremer.wao.services.service.BoatsFilterValues;
-import fr.ifremer.wao.services.service.ObsMerBoatsService;
-import fr.ifremer.wao.web.WaoJsonActionSupport;
-import org.apache.commons.lang3.StringUtils;
-
-/**
- * Created on 4/1/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class BoatsFilterValuesJsonAction extends WaoJsonActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- protected transient ObsMerBoatsService service;
-
- protected BoatsFilter filter;
-
- protected BoatsFilterValues filterValues;
-
- protected String filterValuesField;
-
- public void setService(ObsMerBoatsService service) {
- this.service = service;
- }
-
- public void setFilterValuesField(String filterValuesField) {
- this.filterValuesField = filterValuesField;
- }
-
- public BoatsFilter getFilter() {
- if (filter == null) {
- prepare();
- }
- return filter;
- }
-
- @Override
- public void prepare() {
-
- filter = service.newBoatsFilter(session.getAuthenticatedWaoUser());
- }
-
- @Override
- public String execute() {
-
- filterValues = service.getBoatsFilterValues(session.getAuthenticatedWaoUser(), filter);
-
- if (StringUtils.isNotBlank(filterValuesField)) {
-
- // le client ne demande qu'un seul champ, on peut éviter de retourner l'objet complet
-
- filterValues = filterValues.getCopyWithSingleProperty(filterValuesField);
-
- }
-
- return SUCCESS;
- }
-
- public BoatsFilterValues getFilterValues() {
- return filterValues;
- }
-
-}
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CancelBoatSelectionAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CancelBoatSelectionAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/CancelBoatSelectionAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,22 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-import fr.ifremer.wao.web.WaoJspActionSupport;
-import org.apache.struts2.convention.annotation.Result;
-import org.apache.struts2.convention.annotation.Results;
-
-
-@Results({
- @Result(name="success", type="redirectAction", params = { "actionName", "boats" })
-})
-public class CancelBoatSelectionAction extends WaoJspActionSupport {
-
- @Override
- public String execute() {
-
- session.setStartBoatSelectionForSampleRowId(null);
-
- return SUCCESS;
-
- }
-
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportBoatsAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportBoatsAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportBoatsAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,78 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.BoatsFilter;
-import fr.ifremer.wao.services.service.ObsMerBoatsService;
-import fr.ifremer.wao.web.action.AbstractDownloadCsvAction;
-
-import java.io.InputStream;
-import java.util.Date;
-
-/**
- * Created on 4/1/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 4.0
- */
-public class ExportBoatsAction extends AbstractDownloadCsvAction implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- protected transient ObsMerBoatsService service;
-
- protected BoatsFilter filter;
-
- public void setService(ObsMerBoatsService service) {
- this.service = service;
- }
-
- public BoatsFilter getFilter() {
- if (filter == null) {
- prepare();
- }
- return filter;
- }
-
- @Override
- public void prepare() {
-
- filter = service.newBoatsFilter(getAuthenticatedWaoUser());
-
- }
-
- @Override
- public String getFileName() {
-
- return "boats_" + getObsProgram().name() + "_" + dateFormat.format(new Date()) + ".csv";
-
- }
-
- @Override
- public InputStream getInputStream() {
-
- return service.exportBoats(filter);
-
- }
-
-}
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,50 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-import fr.ifremer.wao.services.service.BoatContactsCounts;
-import fr.ifremer.wao.services.service.ObsMerBoatsService;
-import fr.ifremer.wao.web.WaoJsonActionSupport;
-
-import java.util.Date;
-
-public class GetBoatContactsCountJsonAction extends WaoJsonActionSupport {
-
- protected Date since;
-
- protected ObsMerBoatsService service;
-
- protected String boatId;
-
- protected String companyId;
-
- protected BoatContactsCounts boatContactsCounts;
-
- public void setSince(Date since) {
- this.since = since;
- }
-
- public void setService(ObsMerBoatsService service) {
- this.service = service;
- }
-
- public void setBoatId(String boatId) {
- this.boatId = boatId;
- }
-
- public void setCompanyId(String companyId) {
- this.companyId = companyId;
- }
-
- @Override
- public String execute() {
-
- boatContactsCounts = service.getBoatContactsCounts(session.getAuthenticatedWaoUser(), boatId, companyId, since);
-
- return SUCCESS;
-
- }
-
- public BoatContactsCounts getBoatContactsCounts() {
- return boatContactsCounts;
- }
-
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SearchBoatJsonAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SearchBoatJsonAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SearchBoatJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,71 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.BoatsFilter;
-import fr.ifremer.wao.entity.Boat;
-import fr.ifremer.wao.services.service.FilterOption;
-import fr.ifremer.wao.services.service.ObsMerBoatsService;
-import fr.ifremer.wao.web.WaoJsonActionSupport;
-
-import java.util.Collection;
-
-public class SearchBoatJsonAction extends WaoJsonActionSupport implements Preparable {
-
- protected static final Function<Boat, FilterOption> BOAT_TO_FILTER_OPTION_FUNCTION = new Function<Boat, FilterOption>() {
-
- @Override
- public FilterOption apply(Boat boat) {
- String value = boat.getTopiaId();
- String label = boat.getImmatriculation() + " " + boat.getName();
- return FilterOption.forValueAndLabel(value, label);
- }
- };
-
- protected ObsMerBoatsService service;
-
- protected BoatsFilter filter;
-
- protected int pageSize;
-
- protected Collection<FilterOption> boatFilterOptions;
-
- public void setService(ObsMerBoatsService service) {
- this.service = service;
- }
-
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
-
- public BoatsFilter getFilter() {
- if (filter == null) {
- prepare();
- }
- return filter;
- }
-
- @Override
- public void prepare() {
-
- filter = service.newBoatsFilter(session.getAuthenticatedWaoUser());
-
- }
-
- @Override
- public String execute() {
-
- Collection<Boat> boats = service.getBoats(filter, pageSize);
-
- boatFilterOptions = Collections2.transform(boats, BOAT_TO_FILTER_OPTION_FUNCTION);
-
- return SUCCESS;
-
- }
-
- public Collection<FilterOption> getBoatFilterOptions() {
- return boatFilterOptions;
- }
-
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,39 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-import fr.ifremer.wao.services.service.ObsMerBoatsService;
-import fr.ifremer.wao.web.WaoJsonActionSupport;
-
-public class UpdateBoatElligibilityJsonAction extends WaoJsonActionSupport {
-
- protected ObsMerBoatsService service;
-
- protected String boatId;
-
- protected String sampleRowId;
-
- protected boolean active;
-
- public void setService(ObsMerBoatsService service) {
- this.service = service;
- }
-
- public void setActive(boolean active) {
- this.active = active;
- }
-
- public void setBoatId(String boatId) {
- this.boatId = boatId;
- }
-
- public void setSampleRowId(String sampleRowId) {
- this.sampleRowId = sampleRowId;
- }
-
- @Override
- public String execute() {
-
- service.changeBoatElligibility(session.getAuthenticatedWaoUser(), boatId, sampleRowId, active);
-
- return SUCCESS;
- }
-}
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatInfosJsonAction.java
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatInfosJsonAction.java 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatInfosJsonAction.java 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,59 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-import com.google.common.base.Preconditions;
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.entity.BoatInfos;
-import fr.ifremer.wao.services.service.ObsMerBoatsService;
-import fr.ifremer.wao.web.WaoJsonActionSupport;
-
-public class UpdateBoatInfosJsonAction extends WaoJsonActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- protected transient ObsMerBoatsService service;
-
- protected String companyId;
-
- protected String boatId;
-
- protected BoatInfos boatInfos;
-
- public void setService(ObsMerBoatsService service) {
- this.service = service;
- }
-
- public void setCompanyId(String companyId) {
- this.companyId = companyId;
- }
-
- public void setBoatId(String boatId) {
- this.boatId = boatId;
- }
-
- @Override
- public void prepare() {
-
- Preconditions.checkState(session.getAuthenticatedWaoUser().isAuthorizedToViewBoatDetails(companyId));
-
- boatInfos = service.getBoatInfos(boatId, companyId);
-
- }
-
- public BoatInfos getBoatInfos() {
- return boatInfos;
- }
-
- public void setBoatInfos(BoatInfos boatInfos) {
- this.boatInfos = boatInfos;
- }
-
- @Override
- public String execute() {
-
- service.saveBoatInfos(boatInfos);
-
- return SUCCESS;
-
- }
-
-}
Copied: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/BoatsAction-conversion.properties (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/BoatsAction-conversion.properties)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/BoatsAction-conversion.properties (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/BoatsAction-conversion.properties 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1 @@
+filter=org.nuiton.web.struts2.converters.JsonConverter
Copied: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/GetBoatContactsCountJsonAction-conversion.properties (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction-conversion.properties)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/GetBoatContactsCountJsonAction-conversion.properties (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/GetBoatContactsCountJsonAction-conversion.properties 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1 @@
+since=fr.ifremer.wao.web.converter.DateConverter
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/BoatsAction-conversion.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/BoatsAction-conversion.properties 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/BoatsAction-conversion.properties 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1 +0,0 @@
-filter=org.nuiton.web.struts2.converters.JsonConverter
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction-conversion.properties
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction-conversion.properties 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/resources/fr/ifremer/wao/web/action/obsmer/GetBoatContactsCountJsonAction-conversion.properties 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1 +0,0 @@
-since=fr.ifremer.wao.web.converter.DateConverter
Copied: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,402 @@
+<%--
+ #%L
+ Wao :: Web
+ %%
+ Copyright (C) 2009 - 2014 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<script>
+ $(document).ready(function () {
+
+ // le formulaire concernant l'interlocuteur
+
+ var $boatInfosForm = $('#boat-infos-form');
+ var $saveBoatInfosButton = $('#save-boat-infos');
+ var $unlockBoatInfosFormButton = $('#unlock-boat-infos-form');
+
+ $saveBoatInfosButton.click(function () {
+ $boatInfosForm.find('input, textarea').attr('readonly', 'readonly');
+ $saveBoatInfosButton.attr('disabled', 'disabled');
+ $unlockBoatInfosFormButton.removeAttr('disabled');
+ var data = WAO.toData($boatInfosForm);
+ var successCallback = function () {
+ WAO.notifications.success('<s:text name="wao.ui.form.BoatInfos.success"/>');
+ }
+ WAO.post(WAO.UPDATE_BOAT_INFOS_JSON_URL, data, successCallback);
+ });
+
+ $unlockBoatInfosFormButton.click(function () {
+ $boatInfosForm.find('input[readonly], button, textarea').removeAttr('readonly').removeAttr('disabled');
+ $unlockBoatInfosFormButton.attr('disabled', 'disabled');
+ });
+
+
+ // le calcul des sollicitations
+
+ var $boatContactsCountForm = $('#boat-contacts-count-form');
+ var $boatContactsCountsTable = $('#boat-contacts-counts-table');
+
+ $boatContactsCountsTable.hide();
+
+ var getBoatContactsCount = function () {
+ var data = WAO.toData($boatContactsCountForm);
+ var since = data.since;
+ var successCallback = function (data) {
+ var tr = '<tr>'
+ + ' <td>'
+ + since
+ + ' </td>'
+ + ' <td>'
+ + data.boatContactsCounts.contactsCompanyCount
+ + ' (' + data.boatContactsCounts.observationsCompanyCount + ')'
+ + ' </td>'
+ + ' <td>'
+ + data.boatContactsCounts.contactsCount
+ + ' (' + data.boatContactsCounts.observationsCount + ')'
+ + ' </td>'
+ + '</tr>';
+ $boatContactsCountsTable.find('tbody').append(tr);
+ $boatContactsCountsTable.show();
+ };
+ WAO.get(WAO.GET_BOAT_CONTACTS_COUNT_JSON_URL, data, successCallback);
+ }
+
+ $('#get-boat-contacts-count').click(getBoatContactsCount);
+ $boatContactsCountForm.enterKey(getBoatContactsCount);
+
+ // création d'un contact depuis une ligne éligible
+
+ var $createContactFromBoatButton = $('#createContactFromBoatButton');
+ var $sampleRowIdInput = $('input[name="sampleRowId"]');
+ var expiredSampleRowIds = <s:property value="boatDetails.expiredSampleRowIds" escapeHtml="false"/>
+ $sampleRowIdInput.change(function () {
+ $createContactFromBoatButton.removeAttr('disabled');
+ });
+ $createContactFromBoatButton.click(function (e) {
+ var selectedSampleRowIsExpired = $.inArray($('input[name="sampleRowId"]:checked').val(), expiredSampleRowIds);
+ var confirmMessage = "<s:text name="wao.ui.contacts.createFromBoat.warn"/>";
+ if (selectedSampleRowIsExpired && ! confirm(confirmMessage)) {
+ e.preventDefault();
+ }
+ });
+
+ // suppresssion d'une éligibilité
+ $('.remove-boat-eligibility').click(function (e) {
+ e.preventDefault();
+ if (confirm("<s:text name="wao.ui.removeBoatEligibility.confirm"/>")) {
+ var url = $(this).attr('href');
+ var $toRemove = $(this).parents('.elligible-sample-row')
+ var successCallback = function (data) {
+ $toRemove.remove();
+ };
+ WAO.post(url, {}, successCallback);
+ }
+ });
+
+ });
+</script>
+
+<h2>
+ <s:text name="wao.ui.boatinfo.contacts">
+ <s:param value="boatDetails.boatInfos.boat.name"/>
+ </s:text>
+</h2>
+
+<h3>
+ <s:text name="wao.ui.boats.contacts.existing"/>
+</h3>
+
+<s:if test="boatDetails.contactsCount > 0">
+
+ <h4>
+ <s:text name="wao.ui.contact.lastContact"/>
+ </h4>
+
+ <table class="table">
+ <tbody>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Contact.creationDate"/>
+ </th>
+ <td>
+ <s:property value="boatDetails.mostRecentContact.creationDate"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Contact.mainObserver"/>
+ </th>
+ <td>
+ <s:property value="boatDetails.mostRecentContact.mainObserver.fullName"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Contact.contactState"/>
+ </th>
+ <td>
+ <s:property value="%{getText(boatDetails.mostRecentContact.contactState)}"/>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Contact.sampleRow"/>
+ </th>
+ <td>
+ <s:property value="boatDetails.mostRecentContact.sampleRow.code"/>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <s:url action="contacts" id="viewAssociatedContactsForBoatUrl">
+ <s:param name="filter.boatFilter.registrationCode" value="boatDetails.boatInfos.boat.immatriculation"/>
+ <s:param name="filter.sampleRowFilter.companyIds" value="boatDetails.boatInfos.company.topiaId"/>
+ <s:param name="filter.periodFrom"/>
+ <s:param name="filter.periodTo"/>
+ </s:url>
+ <s:a href="%{viewAssociatedContactsForBoatUrl}">
+ <s:text name="wao.ui.action.viewAssociatedContactsForBoat">
+ <s:param value="boatDetails.contactsCount"/>
+ </s:text>
+ </s:a>
+
+</s:if>
+<s:else>
+ <s:text name="wao.ui.boats.contacts.none"/>
+</s:else>
+
+<h3>
+ <s:text name="wao.ui.contact.creation"/>
+</h3>
+
+<s:if test="boatDetails.boatInfos.boat.active">
+ <s:if test="startBoatSelectionForSampleRow == null">
+ <s:if test="boatDetails.elligibleForSampleRows.empty">
+ <s:text name="wao.ui.tip.boatDetails.elligibleForSampleRowsEmpty" />
+ </s:if>
+ <s:else>
+ <s:text name="wao.ui.boats.associatedLine"/>
+ <s:if test="boatDetails.newContactCreatable && authenticatedWaoUser.authorizedToCreateContact">
+ <s:form action="create-contact">
+
+ <s:hidden name="boatId" value="%{boatDetails.boatInfos.boat.topiaId}"/>
+
+ <div class="control-group">
+ <div class="controls">
+ <s:iterator value="boatDetails.elligibleForSampleRows" status="status">
+ <div class="elligible-sample-row">
+ <s:set name="radioId">radio-<s:property value="#status.index"/></s:set>
+ <input type="radio" name="sampleRowId" id="<s:property value="#radioId"/>" value="<s:property value="topiaId"/>"/>
+ <%--
+ <label for="<s:property value="%{#radioId}"/>" class="radio">
+ <s:property value="code"/>
+ </label>
+ --%>
+ <s:property value="code"/>
+ <s:url action="update-boat-elligibility-json" id="updateBoatElligibilityUrl">
+ <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/>
+ <s:param name="sampleRowId" value="topiaId"/>
+ <s:param name="active" value="false"/>
+ </s:url>
+ <s:a href="%{updateBoatElligibilityUrl}" cssClass="btn btn-link remove-boat-eligibility">
+ <i class="icon-remove"></i>
+ </s:a>
+ </div>
+ </s:iterator>
+ </div>
+ </div>
+
+
+ <s:submit id="createContactFromBoatButton" type="button" cssClass="btn btn-success" disabled="true">
+ <i class="icon-plus"></i>
+ <s:text name="wao.ui.contacts.createFromBoat"/>
+ </s:submit>
+ </s:form>
+ </s:if>
+ <s:else>
+ <ul>
+ <s:iterator value="boatDetails.elligibleForSampleRows">
+ <li class="elligible-sample-row">
+ <s:property value="code"/>
+ <s:url action="update-boat-elligibility-json" id="updateBoatElligibilityUrl">
+ <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/>
+ <s:param name="sampleRowId" value="topiaId"/>
+ <s:param name="active" value="false"/>
+ </s:url>
+ <s:a href="%{updateBoatElligibilityUrl}" cssClass="btn btn-link remove-boat-eligibility">
+ <i class="icon-remove"></i>
+ </s:a>
+ </li>
+ </s:iterator>
+ </ul>
+ </s:else>
+ </s:else>
+ <s:if test="authenticatedWaoUser.authorizedToCreateContact">
+ <div class="alert alert-info">
+ <s:text name="wao.ui.tip.useBoatSelectionForSampleRow"/>
+ </div>
+ </s:if>
+ </s:if>
+ <s:else>
+ <s:if test="boatDetails.newContactCreatable">
+ <s:if test="boatDetails.newContactCreatable && authenticatedWaoUser.authorizedToCreateContact">
+ <s:url action="create-contact" id="createContactUrl">
+ <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/>
+ <s:param name="sampleRowId" value="startBoatSelectionForSampleRow.topiaId"/>
+ </s:url>
+ <s:a href="%{createContactUrl}" cssClass="btn btn-success">
+ <i class="icon-plus"></i>
+ <s:text name="wao.ui.contacts.createFromBoatAndSelectedSampleRow">
+ <s:param value="startBoatSelectionForSampleRow.code"/>
+ <s:param value="startBoatSelectionForSampleRow.professionDescription"/>
+ </s:text>
+ </s:a>
+ </s:if>
+ </s:if>
+ <s:else>
+ <div class="alert">
+ <s:text name="wao.ui.tip.contactAlreadyExists"/>
+ </div>
+ </s:else>
+ </s:else>
+
+</s:if>
+<s:else>
+ <div class="alert">
+ <s:text name="wao.ui.tip.inactiveBoat"/>
+ </div>
+</s:else>
+
+<h3>
+ <s:text name="wao.ui.boatDetails.boatContactsCounts.title"/>
+</h3>
+
+<table id="boat-contacts-counts-table" class="table no-border-top">
+ <thead>
+ <tr>
+ <td>
+ <s:text name="wao.ui.boatDetails.boatContactsCounts.since"/>
+ </td>
+ <td>
+ <s:text name="wao.ui.boatDetails.boatContactsCounts.contactsCompanyCount"/>
+ </td>
+ <td>
+ <s:text name="wao.ui.boatDetails.boatContactsCounts.contactsCount"/>
+ </td>
+ </thead>
+ <tbody>
+ </tbody>
+</table>
+
+<s:form id="boat-contacts-count-form">
+
+ <s:hidden name="boatId" value="%{boatDetails.boatInfos.boat.topiaId}" />
+ <s:hidden name="companyId" value="%{boatDetails.boatInfos.company.topiaId}" />
+
+ <div class="input-prepend input-append">
+
+ <span class="add-on">
+ <s:text name="wao.ui.boatDetails.boatContactsCounts.since"/>
+ </span>
+
+ <input name="since" type="text" value="<s:property value="%{oneYearAgoDatePlaceHolder}"/>"/>
+
+ <button type="button" id="get-boat-contacts-count" class="btn">
+ <i class="icon-plus"></i> <s:text name="wao.ui.boatDetails.boatContactsCounts.compute" />
+ </button>
+ </div>
+</s:form>
+
+<h2>
+ <s:text name="wao.ui.boatinfo.title">
+ <s:param value="boatDetails.boatInfos.boat.name"/>
+ </s:text>
+</h2>
+
+<h3>
+ <s:text name="wao.ui.boats.info"/>
+</h3>
+
+<table class="table">
+ <tbody>
+ <tr>
+ <th class="no-border-top">
+ <s:text name="wao.ui.field.Boat.shipOwner"/>
+ </th>
+ <td class="no-border-top">
+ <s:url action="boats" id="shipOwnerBoatsUrl">
+ <s:param name="filter.shipOwnerIds" value="boatDetails.boatInfos.boat.shipOwner.topiaId"/>
+ </s:url>
+ <s:set name="shipOwnerBoatsTitle">
+ <s:text name="wao.ui.action.viewShipOwnerBoats"/>
+ </s:set>
+ <s:a href="%{shipOwnerBoatsUrl}" title="%{shipOwnerBoatsTitle}">
+ <s:property value="boatDetails.boatInfos.boat.shipOwner.firstName"/>
+ <s:property value="boatDetails.boatInfos.boat.shipOwner.lastName"/>
+ </s:a>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <s:text name="wao.ui.field.Boat.boatGroup"/>
+ </th>
+ <td>
+ <s:if test="boatDetails.boatInfos.boat.boatGroup == null">
+ <s:text name="wao.ui.misc.N/A"/>
+ </s:if>
+ <s:else>
+ <s:property value="boatDetails.boatInfos.boat.boatGroup.description"/>
+ </s:else>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3>
+ <s:text name="wao.ui.boats.interlocutor"/>
+</h3>
+
+<s:form id="boat-infos-form" cssClass="form-horizontal">
+
+ <s:hidden name="boatId" value="%{boatDetails.boatInfos.boat.topiaId}" />
+ <s:hidden name="companyId" value="%{boatDetails.boatInfos.company.topiaId}" />
+
+ <s:textfield name="boatInfos.contactFirstName" value="%{boatDetails.boatInfos.contactFirstName}" label="%{getText('wao.ui.field.BoatInfos.contactFirstName')}" readonly="true" cssClass="input-large" />
+ <s:textfield name="boatInfos.contactLastName" value="%{boatDetails.boatInfos.contactLastName}" label="%{getText('wao.ui.field.BoatInfos.contactLastName')}" readonly="true" cssClass="input-large" />
+ <s:textfield type="email" name="boatInfos.contactEmail" value="%{boatDetails.boatInfos.contactEmail}" label="%{getText('wao.ui.field.BoatInfos.contactEmail')}" readonly="true" cssClass="input-large" />
+ <s:textfield type="tel" name="boatInfos.contactPhoneNumber" value="%{boatDetails.boatInfos.contactPhoneNumber}" label="%{getText('wao.ui.field.BoatInfos.contactPhoneNumber')}" readonly="true" cssClass="input-large" />
+ <s:textfield type="number" name="boatInfos.dup" value="%{boatDetails.boatInfos.dup}" label="%{getText('wao.ui.field.BoatInfos.dup')}" readonly="true" cssClass="input-small" />
+ <s:textfield name="boatInfos.contactAddress1" value="%{boatDetails.boatInfos.contactAddress1}" label="%{getText('wao.ui.field.BoatInfos.contactAddress1')}" readonly="true" cssClass="input-xxlarge" />
+ <s:textfield name="boatInfos.contactAddress2" value="%{boatDetails.boatInfos.contactAddress2}" label="%{getText('wao.ui.field.BoatInfos.contactAddress2')}" readonly="true" cssClass="input-xxlarge" />
+ <s:textfield name="boatInfos.contactPostalCode" value="%{boatDetails.boatInfos.contactPostalCode}" label="%{getText('wao.ui.field.BoatInfos.contactPostalCode')}" readonly="true" cssClass="input-small" />
+ <s:textfield name="boatInfos.contactCity" value="%{boatDetails.boatInfos.contactCity}" label="%{getText('wao.ui.field.BoatInfos.contactCity')}" readonly="true" cssClass="input-large" />
+ <s:textarea name="boatInfos.comment" value="%{boatDetails.boatInfos.comment}" label="%{getText('wao.ui.field.BoatInfos.comment')}" readonly="true" cssClass="input-xxlarge" />
+
+ <div class="form-actions">
+ <button type="button" id="unlock-boat-infos-form" class="btn">
+ <i class="icon-edit"></i> <s:text name="wao.ui.action.edit" />
+ </button>
+
+ <button type="button" id="save-boat-infos" class="btn" disabled="disabled">
+ <i class="icon-hdd"></i> <s:text name="wao.ui.action.save" />
+ </button>
+ </div>
+
+</s:form>
\ No newline at end of file
Copied: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/boats.jsp (from rev 2075, branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp)
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/boats.jsp (rev 0)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/boats.jsp 2014-06-20 13:56:00 UTC (rev 2076)
@@ -0,0 +1,308 @@
+<%--
+ #%L
+ Wao :: Web
+ %%
+ Copyright (C) 2009 - 2014 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<html>
+
+<head>
+ <title>
+ <s:text name="wao.ui.page.Boats.title"/>
+ </title>
+
+ <script>
+
+ $(document).ready(function () {
+
+ var boatFilterMappings = [
+
+ <s:if test="authenticatedWaoUser.authorizedToFilterOnBoats">
+ {
+ filterName: 'boatIds',
+ filterLabel: "<s:text name="wao.ui.entity.Boat"/>",
+ filterValuesField: 'boats',
+ minimumInputLength: 3
+ },
+ </s:if>
+ {
+ filterName: 'elligibleForSampleRowsFilter.fishingZoneFacadeNames',
+ filterLabel: "<s:text name="wao.ui.field.FishingZone.facadeName"/>",
+ filterValuesField: 'elligibleForSampleRowsFilterValues.fishingZoneFacadeNames'
+ },
+ {
+ filterName: 'elligibleForSampleRowsFilter.fishingZoneSectorNames',
+ filterLabel: "<s:text name="wao.ui.field.FishingZone.sectorName"/>",
+ filterValuesField: 'elligibleForSampleRowsFilterValues.fishingZoneSectorNames'
+ },
+ {
+ filterName: 'elligibleForSampleRowsFilter.sampleRowCodes',
+ filterLabel: "<s:text name="wao.ui.field.SampleRow.code"/>",
+ filterValuesField: 'elligibleForSampleRowsFilterValues.sampleRowCodes'
+ },
+ {
+ filterName: 'districtIds',
+ filterLabel: "<s:text name="wao.ui.field.Boat.district"/>",
+ filterValuesField: 'districts'
+ },
+ {
+ filterName: 'shipOwnerIds',
+ filterLabel: "<s:text name="wao.ui.field.Boat.shipOwner"/>",
+ filterValuesField: 'shipOwners',
+ minimumInputLength: 3
+ },
+ {
+ filterName: 'portOfRegistryIds',
+ filterLabel: "<s:text name="wao.ui.field.Boat.portOfRegistry"/>",
+ filterValuesField: 'portsOfRegistry'
+ }
+ ];
+
+ filter = <s:property value="filter" escapeHtml="false"/>;
+
+ boatsFilterController2 = new FilterController2(boatFilterMappings, filter, WAO.BOATS_FILTER_VALUES_JSON_URL, $('#boats-filters-form fieldset.extra-filters'));
+ boatsFilterController2.init();
+
+// var $boatsFiltersForm = $('#boats-filters-form');
+// var boatsFilterController = new FilterController(WAO.BOATS_FILTER_VALUES_JSON_URL, $boatsFiltersForm);
+// boatsFilterController.init();
+
+ var $boatDetails = $('#boat-details');
+ var $companyId = $('#companyId');
+
+ var showBoatDetails = function (boatId) {
+ var companyId = $companyId.val();
+ var successCallback = function (data) {
+ $boatDetails.html(data);
+ $('tr.boat-row').removeClass('highlight');
+ $('tr[data-boat-id="' + boatId + '"]').addClass('highlight');
+ $boatDetails.effect('highlight', 'slow');
+ };
+ var data = {
+ fragment: true,
+ boatId: boatId,
+ companyId: companyId
+ };
+ WAO.get(WAO.BOAT_DETAILS_URL, data, successCallback);
+ }
+ $('a.boat-details-action').click(function (e) {
+ e.preventDefault();
+ var boatId = $(this).parents('tr.boat-row').attr('data-boat-id');
+ showBoatDetails(boatId);
+ });
+ $companyId.change(function () {
+ var boatId = $('tr.boat-row.highlight').attr('data-boat-id');
+ if (boatId) {
+ showBoatDetails(boatId);
+ }
+ });
+
+ });
+
+ </script>
+
+</head>
+
+<content tag="mainClass">large</content>
+<content tag="boatsMenuItemClass">active</content>
+
+<s:if test="startBoatSelectionForSampleRow != null">
+ <div class="alert alert-info">
+ <s:text name="wao.ui.tip.boatSelectionForSampleRowStarted">
+ <s:param value="startBoatSelectionForSampleRow.code"/>
+ <s:param value="startBoatSelectionForSampleRow.professionDescription"/>
+ </s:text>
+ <s:url action="cancel-boat-selection" id="cancelBoatSelectionUrl"/>
+ <s:a href="%{cancelBoatSelectionUrl}" cssClass="btn btn-link">
+ <s:text name="wao.ui.action.cancel"/>
+ </s:a>
+ </div>
+</s:if>
+
+<div id="boats-filters-list-details-layout">
+
+ <div>
+ <s:form method="GET" id="boats-filters-form" cssClass="filters-form">
+
+ <fieldset class="extra-filters">
+
+ </fieldset>
+
+ <div class="form-actions">
+
+ <s:submit type="button" action="boats!applyFilter" cssClass="btn btn-primary">
+ <i class="icon-filter"></i> <s:text name="wao.ui.action.filter"/>
+ </s:submit>
+
+ <s:submit type="button" action="boats!resetFilter" cssClass="btn">
+ <i class="icon-trash"></i> <s:text name="wao.ui.action.reset"/>
+ </s:submit>
+
+ <s:submit action="export-boats" type="button" cssClass="btn">
+ <i class="icon-download"></i> <s:text name="wao.ui.action.csvExport"/>
+ </s:submit>
+
+ </div>
+
+ </s:form>
+
+ </div>
+
+ <div>
+ <div class="arrow-right"></div>
+ <h2>
+ <s:text name="wao.ui.boats.title">
+ <s:param value="%{pagination.count}"/>
+ </s:text>
+ </h2>
+
+ <s:if test="authenticatedWaoUser.authorizedToViewBoatDetailsForAllCompanies">
+ <s:select id="companyId"
+ name="companyId"
+ label="Vous devez sélectionner la société pour laquelle vous souhaitez consulter les informations"
+ list="allCompanies"
+ listKey="%{topiaId}"
+ listValue="%{name}"
+ value="%{authenticatedWaoUser.waoUser.company.topiaId}"
+ cssClass="input-xxlarge" />
+ </s:if>
+ <s:else>
+ <s:hidden id="companyId" name="companyId" value="%{authenticatedWaoUser.waoUser.company.topiaId}"/>
+ </s:else>
+
+ <table id="boats-list" class="table-condensed table-striped table-hover">
+ <thead>
+ <tr>
+ <th>
+ <s:text name="wao.ui.boats.registrationCode"/>
+ </th>
+ <th>
+ <s:text name="wao.ui.boats.boatName"/>
+ </th>
+ <th>
+ <s:text name="wao.ui.boats.boatLength"/> (cm)
+ </th>
+ <th>
+ <s:text name="wao.ui.boats.buildYear"/>
+ </th>
+ <th>
+ <s:text name="wao.ui.boats.district"/>
+ </th>
+ <th>
+ <span data-original-title="<s:text name="wao.ui.boats.portOfRegistry.description"/>" data-toggle="tooltip" data-placement="bottom">
+ <s:text name="wao.ui.boats.portOfRegistry"/>
+ </span>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <s:iterator value="boats" var="boat">
+ <tr data-boat-id="<s:property value="topiaId"/>" class="boat-row">
+ <td>
+ <s:if test="authenticatedWaoUser.authorizedToViewBoatDetails">
+ <s:url action="boat-details" id="boatDetailsUrl">
+ <s:param name="companyId" value="authenticatedWaoUser.waoUser.company.topiaId" />
+ <s:param name="boatId" value="topiaId" />
+ </s:url>
+ <s:a href="%{boatDetailsUrl}" cssClass="boat-details-action">
+ <s:property value="%{'' + immatriculation}"/>
+ </s:a>
+ </s:if>
+ <s:else>
+ <s:property value="%{'' + immatriculation}"/>
+ </s:else>
+ </td>
+ <td<s:if test="!active"> class="inactive"</s:if>>
+ <s:property value="name"/>
+ </td>
+ <td><s:property value="boatLength"/></td>
+ <td><s:property value="%{'' + buildYear}"/></td>
+ <td><s:property value="district.districtCode"/></td>
+ <td>
+ <s:if test="portOfRegistry != null">
+ <span data-original-title="<s:property value="portOfRegistry.description"/>" data-toggle="tooltip" data-placement="bottom">
+ <s:property value="portOfRegistry.portCode"/>
+ </span>
+ </s:if>
+ </td>
+ </tr>
+ </s:iterator>
+ </todby>
+ </table>
+
+ <%-- Pagination --%>
+ <div class="pagination">
+ <ul>
+ <s:url var="fullUrl" includeParams="get"/>
+ <s:set var="paginationUrl" value="%{getPaginationUrl(#fullUrl)}"/>
+ <s:if test="firstRangePage > 2">
+ <li>
+ <a href="${paginationUrl}0">1</a>
+ </li>
+ <li>
+ <a href="${paginationUrl}1">2</a>
+ </li>
+ <li>
+ <span>...</span>
+ </li>
+ </s:if>
+
+ <s:iterator var="currentPage" begin="firstRangePage" end="lastRangePage">
+ <li class="<s:if test="#currentPage - 1 == pagination.currentPage.pageNumber">active</s:if>">
+ <a href="${paginationUrl}${currentPage - 1}">
+ <s:property/>
+ </a>
+ </li>
+ </s:iterator>
+
+ <s:if test="lastRangePage < pagination.pageCount - 1">
+ <li>
+ <span>...</span>
+ </li>
+ <li>
+ <a href="${paginationUrl}${pagination.pageCount - 2}">
+ <s:property value="pagination.pageCount - 1"/>
+ </a>
+ </li>
+ <li>
+ <a href="${paginationUrl}${pagination.pageCount - 1}">
+ <s:property value="pagination.pageCount"/>
+ </a>
+ </li>
+ </s:if>
+ </ul>
+ </div>
+ </div>
+
+ <s:if test="authenticatedWaoUser.authorizedToViewBoatDetails">
+
+ <div>
+ <div class="arrow-right"></div>
+ <div id="boat-details">
+ <div class="alert alert-info">
+ <s:text name="wao.ui.tip.youMustChooseBoat" />
+ </div>
+ </div>
+ </div>
+ </s:if>
+
+</div>
+
+</html>
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,402 +0,0 @@
-<%--
- #%L
- Wao :: Web
- %%
- Copyright (C) 2009 - 2014 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
-<%@taglib uri="/struts-tags" prefix="s" %>
-
-<script>
- $(document).ready(function () {
-
- // le formulaire concernant l'interlocuteur
-
- var $boatInfosForm = $('#boat-infos-form');
- var $saveBoatInfosButton = $('#save-boat-infos');
- var $unlockBoatInfosFormButton = $('#unlock-boat-infos-form');
-
- $saveBoatInfosButton.click(function () {
- $boatInfosForm.find('input, textarea').attr('readonly', 'readonly');
- $saveBoatInfosButton.attr('disabled', 'disabled');
- $unlockBoatInfosFormButton.removeAttr('disabled');
- var data = WAO.toData($boatInfosForm);
- var successCallback = function () {
- WAO.notifications.success('<s:text name="wao.ui.form.BoatInfos.success"/>');
- }
- WAO.post(WAO.OBSMER_UPDATE_BOAT_INFOS_JSON_URL, data, successCallback);
- });
-
- $unlockBoatInfosFormButton.click(function () {
- $boatInfosForm.find('input[readonly], button, textarea').removeAttr('readonly').removeAttr('disabled');
- $unlockBoatInfosFormButton.attr('disabled', 'disabled');
- });
-
-
- // le calcul des sollicitations
-
- var $boatContactsCountForm = $('#boat-contacts-count-form');
- var $boatContactsCountsTable = $('#boat-contacts-counts-table');
-
- $boatContactsCountsTable.hide();
-
- var getBoatContactsCount = function () {
- var data = WAO.toData($boatContactsCountForm);
- var since = data.since;
- var successCallback = function (data) {
- var tr = '<tr>'
- + ' <td>'
- + since
- + ' </td>'
- + ' <td>'
- + data.boatContactsCounts.contactsCompanyCount
- + ' (' + data.boatContactsCounts.observationsCompanyCount + ')'
- + ' </td>'
- + ' <td>'
- + data.boatContactsCounts.contactsCount
- + ' (' + data.boatContactsCounts.observationsCount + ')'
- + ' </td>'
- + '</tr>';
- $boatContactsCountsTable.find('tbody').append(tr);
- $boatContactsCountsTable.show();
- };
- WAO.get(WAO.OBSMER_GET_BOAT_CONTACTS_COUNT_JSON_URL, data, successCallback);
- }
-
- $('#get-boat-contacts-count').click(getBoatContactsCount);
- $boatContactsCountForm.enterKey(getBoatContactsCount);
-
- // création d'un contact depuis une ligne éligible
-
- var $createContactFromBoatButton = $('#createContactFromBoatButton');
- var $sampleRowIdInput = $('input[name="sampleRowId"]');
- var expiredSampleRowIds = <s:property value="boatDetails.expiredSampleRowIds" escapeHtml="false"/>
- $sampleRowIdInput.change(function () {
- $createContactFromBoatButton.removeAttr('disabled');
- });
- $createContactFromBoatButton.click(function (e) {
- var selectedSampleRowIsExpired = $.inArray($('input[name="sampleRowId"]:checked').val(), expiredSampleRowIds);
- var confirmMessage = "<s:text name="wao.ui.contacts.createFromBoat.warn"/>";
- if (selectedSampleRowIsExpired && ! confirm(confirmMessage)) {
- e.preventDefault();
- }
- });
-
- // suppresssion d'une éligibilité
- $('.remove-boat-eligibility').click(function (e) {
- e.preventDefault();
- if (confirm("<s:text name="wao.ui.removeBoatEligibility.confirm"/>")) {
- var url = $(this).attr('href');
- var $toRemove = $(this).parents('.elligible-sample-row')
- var successCallback = function (data) {
- $toRemove.remove();
- };
- WAO.post(url, {}, successCallback);
- }
- });
-
- });
-</script>
-
-<h2>
- <s:text name="wao.ui.boatinfo.contacts">
- <s:param value="boatDetails.boatInfos.boat.name"/>
- </s:text>
-</h2>
-
-<h3>
- <s:text name="wao.ui.boats.contacts.existing"/>
-</h3>
-
-<s:if test="boatDetails.contactsCount > 0">
-
- <h4>
- <s:text name="wao.ui.contact.lastContact"/>
- </h4>
-
- <table class="table">
- <tbody>
- <tr>
- <th>
- <s:text name="wao.ui.field.Contact.creationDate"/>
- </th>
- <td>
- <s:property value="boatDetails.mostRecentContact.creationDate"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.Contact.mainObserver"/>
- </th>
- <td>
- <s:property value="boatDetails.mostRecentContact.mainObserver.fullName"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.Contact.contactState"/>
- </th>
- <td>
- <s:property value="%{getText(boatDetails.mostRecentContact.contactState)}"/>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.Contact.sampleRow"/>
- </th>
- <td>
- <s:property value="boatDetails.mostRecentContact.sampleRow.code"/>
- </td>
- </tr>
- </tbody>
- </table>
-
- <s:url action="contacts" id="viewAssociatedContactsForBoatUrl">
- <s:param name="filter.boatFilter.registrationCode" value="boatDetails.boatInfos.boat.immatriculation"/>
- <s:param name="filter.sampleRowFilter.companyIds" value="boatDetails.boatInfos.company.topiaId"/>
- <s:param name="filter.periodFrom"/>
- <s:param name="filter.periodTo"/>
- </s:url>
- <s:a href="%{viewAssociatedContactsForBoatUrl}">
- <s:text name="wao.ui.action.viewAssociatedContactsForBoat">
- <s:param value="boatDetails.contactsCount"/>
- </s:text>
- </s:a>
-
-</s:if>
-<s:else>
- <s:text name="wao.ui.boats.contacts.none"/>
-</s:else>
-
-<h3>
- <s:text name="wao.ui.contact.creation"/>
-</h3>
-
-<s:if test="boatDetails.boatInfos.boat.active">
- <s:if test="startBoatSelectionForSampleRow == null">
- <s:if test="boatDetails.elligibleForSampleRows.empty">
- <s:text name="wao.ui.tip.boatDetails.elligibleForSampleRowsEmpty" />
- </s:if>
- <s:else>
- <s:text name="wao.ui.boats.associatedLine"/>
- <s:if test="boatDetails.newContactCreatable && authenticatedWaoUser.authorizedToCreateContact">
- <s:form action="create-contact">
-
- <s:hidden name="boatId" value="%{boatDetails.boatInfos.boat.topiaId}"/>
-
- <div class="control-group">
- <div class="controls">
- <s:iterator value="boatDetails.elligibleForSampleRows" status="status">
- <div class="elligible-sample-row">
- <s:set name="radioId">radio-<s:property value="#status.index"/></s:set>
- <input type="radio" name="sampleRowId" id="<s:property value="#radioId"/>" value="<s:property value="topiaId"/>"/>
- <%--
- <label for="<s:property value="%{#radioId}"/>" class="radio">
- <s:property value="code"/>
- </label>
- --%>
- <s:property value="code"/>
- <s:url action="update-boat-elligibility-json" id="updateBoatElligibilityUrl">
- <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/>
- <s:param name="sampleRowId" value="topiaId"/>
- <s:param name="active" value="false"/>
- </s:url>
- <s:a href="%{updateBoatElligibilityUrl}" cssClass="btn btn-link remove-boat-eligibility">
- <i class="icon-remove"></i>
- </s:a>
- </div>
- </s:iterator>
- </div>
- </div>
-
-
- <s:submit id="createContactFromBoatButton" type="button" cssClass="btn btn-success" disabled="true">
- <i class="icon-plus"></i>
- <s:text name="wao.ui.contacts.createFromBoat"/>
- </s:submit>
- </s:form>
- </s:if>
- <s:else>
- <ul>
- <s:iterator value="boatDetails.elligibleForSampleRows">
- <li class="elligible-sample-row">
- <s:property value="code"/>
- <s:url action="update-boat-elligibility-json" id="updateBoatElligibilityUrl">
- <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/>
- <s:param name="sampleRowId" value="topiaId"/>
- <s:param name="active" value="false"/>
- </s:url>
- <s:a href="%{updateBoatElligibilityUrl}" cssClass="btn btn-link remove-boat-eligibility">
- <i class="icon-remove"></i>
- </s:a>
- </li>
- </s:iterator>
- </ul>
- </s:else>
- </s:else>
- <s:if test="authenticatedWaoUser.authorizedToCreateContact">
- <div class="alert alert-info">
- <s:text name="wao.ui.tip.useBoatSelectionForSampleRow"/>
- </div>
- </s:if>
- </s:if>
- <s:else>
- <s:if test="boatDetails.newContactCreatable">
- <s:if test="boatDetails.newContactCreatable && authenticatedWaoUser.authorizedToCreateContact">
- <s:url action="create-contact" id="createContactUrl">
- <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/>
- <s:param name="sampleRowId" value="startBoatSelectionForSampleRow.topiaId"/>
- </s:url>
- <s:a href="%{createContactUrl}" cssClass="btn btn-success">
- <i class="icon-plus"></i>
- <s:text name="wao.ui.contacts.createFromBoatAndSelectedSampleRow">
- <s:param value="startBoatSelectionForSampleRow.code"/>
- <s:param value="startBoatSelectionForSampleRow.professionDescription"/>
- </s:text>
- </s:a>
- </s:if>
- </s:if>
- <s:else>
- <div class="alert">
- <s:text name="wao.ui.tip.contactAlreadyExists"/>
- </div>
- </s:else>
- </s:else>
-
-</s:if>
-<s:else>
- <div class="alert">
- <s:text name="wao.ui.tip.inactiveBoat"/>
- </div>
-</s:else>
-
-<h3>
- <s:text name="wao.ui.boatDetails.boatContactsCounts.title"/>
-</h3>
-
-<table id="boat-contacts-counts-table" class="table no-border-top">
- <thead>
- <tr>
- <td>
- <s:text name="wao.ui.boatDetails.boatContactsCounts.since"/>
- </td>
- <td>
- <s:text name="wao.ui.boatDetails.boatContactsCounts.contactsCompanyCount"/>
- </td>
- <td>
- <s:text name="wao.ui.boatDetails.boatContactsCounts.contactsCount"/>
- </td>
- </thead>
- <tbody>
- </tbody>
-</table>
-
-<s:form id="boat-contacts-count-form">
-
- <s:hidden name="boatId" value="%{boatDetails.boatInfos.boat.topiaId}" />
- <s:hidden name="companyId" value="%{boatDetails.boatInfos.company.topiaId}" />
-
- <div class="input-prepend input-append">
-
- <span class="add-on">
- <s:text name="wao.ui.boatDetails.boatContactsCounts.since"/>
- </span>
-
- <input name="since" type="text" value="<s:property value="%{oneYearAgoDatePlaceHolder}"/>"/>
-
- <button type="button" id="get-boat-contacts-count" class="btn">
- <i class="icon-plus"></i> <s:text name="wao.ui.boatDetails.boatContactsCounts.compute" />
- </button>
- </div>
-</s:form>
-
-<h2>
- <s:text name="wao.ui.boatinfo.title">
- <s:param value="boatDetails.boatInfos.boat.name"/>
- </s:text>
-</h2>
-
-<h3>
- <s:text name="wao.ui.boats.info"/>
-</h3>
-
-<table class="table">
- <tbody>
- <tr>
- <th class="no-border-top">
- <s:text name="wao.ui.field.Boat.shipOwner"/>
- </th>
- <td class="no-border-top">
- <s:url action="boats" id="shipOwnerBoatsUrl">
- <s:param name="filter.shipOwnerIds" value="boatDetails.boatInfos.boat.shipOwner.topiaId"/>
- </s:url>
- <s:set name="shipOwnerBoatsTitle">
- <s:text name="wao.ui.action.viewShipOwnerBoats"/>
- </s:set>
- <s:a href="%{shipOwnerBoatsUrl}" title="%{shipOwnerBoatsTitle}">
- <s:property value="boatDetails.boatInfos.boat.shipOwner.firstName"/>
- <s:property value="boatDetails.boatInfos.boat.shipOwner.lastName"/>
- </s:a>
- </td>
- </tr>
- <tr>
- <th>
- <s:text name="wao.ui.field.Boat.boatGroup"/>
- </th>
- <td>
- <s:if test="boatDetails.boatInfos.boat.boatGroup == null">
- <s:text name="wao.ui.misc.N/A"/>
- </s:if>
- <s:else>
- <s:property value="boatDetails.boatInfos.boat.boatGroup.description"/>
- </s:else>
- </td>
- </tr>
- </tbody>
-</table>
-
-<h3>
- <s:text name="wao.ui.boats.interlocutor"/>
-</h3>
-
-<s:form id="boat-infos-form" cssClass="form-horizontal">
-
- <s:hidden name="boatId" value="%{boatDetails.boatInfos.boat.topiaId}" />
- <s:hidden name="companyId" value="%{boatDetails.boatInfos.company.topiaId}" />
-
- <s:textfield name="boatInfos.contactFirstName" value="%{boatDetails.boatInfos.contactFirstName}" label="%{getText('wao.ui.field.BoatInfos.contactFirstName')}" readonly="true" cssClass="input-large" />
- <s:textfield name="boatInfos.contactLastName" value="%{boatDetails.boatInfos.contactLastName}" label="%{getText('wao.ui.field.BoatInfos.contactLastName')}" readonly="true" cssClass="input-large" />
- <s:textfield type="email" name="boatInfos.contactEmail" value="%{boatDetails.boatInfos.contactEmail}" label="%{getText('wao.ui.field.BoatInfos.contactEmail')}" readonly="true" cssClass="input-large" />
- <s:textfield type="tel" name="boatInfos.contactPhoneNumber" value="%{boatDetails.boatInfos.contactPhoneNumber}" label="%{getText('wao.ui.field.BoatInfos.contactPhoneNumber')}" readonly="true" cssClass="input-large" />
- <s:textfield type="number" name="boatInfos.dup" value="%{boatDetails.boatInfos.dup}" label="%{getText('wao.ui.field.BoatInfos.dup')}" readonly="true" cssClass="input-small" />
- <s:textfield name="boatInfos.contactAddress1" value="%{boatDetails.boatInfos.contactAddress1}" label="%{getText('wao.ui.field.BoatInfos.contactAddress1')}" readonly="true" cssClass="input-xxlarge" />
- <s:textfield name="boatInfos.contactAddress2" value="%{boatDetails.boatInfos.contactAddress2}" label="%{getText('wao.ui.field.BoatInfos.contactAddress2')}" readonly="true" cssClass="input-xxlarge" />
- <s:textfield name="boatInfos.contactPostalCode" value="%{boatDetails.boatInfos.contactPostalCode}" label="%{getText('wao.ui.field.BoatInfos.contactPostalCode')}" readonly="true" cssClass="input-small" />
- <s:textfield name="boatInfos.contactCity" value="%{boatDetails.boatInfos.contactCity}" label="%{getText('wao.ui.field.BoatInfos.contactCity')}" readonly="true" cssClass="input-large" />
- <s:textarea name="boatInfos.comment" value="%{boatDetails.boatInfos.comment}" label="%{getText('wao.ui.field.BoatInfos.comment')}" readonly="true" cssClass="input-xxlarge" />
-
- <div class="form-actions">
- <button type="button" id="unlock-boat-infos-form" class="btn">
- <i class="icon-edit"></i> <s:text name="wao.ui.action.edit" />
- </button>
-
- <button type="button" id="save-boat-infos" class="btn" disabled="disabled">
- <i class="icon-hdd"></i> <s:text name="wao.ui.action.save" />
- </button>
- </div>
-
-</s:form>
\ No newline at end of file
Deleted: branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp 2014-06-20 13:56:00 UTC (rev 2076)
@@ -1,308 +0,0 @@
-<%--
- #%L
- Wao :: Web
- %%
- Copyright (C) 2009 - 2014 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
-<%@taglib uri="/struts-tags" prefix="s" %>
-
-<html>
-
-<head>
- <title>
- <s:text name="wao.ui.page.Boats.title"/>
- </title>
-
- <script>
-
- $(document).ready(function () {
-
- var boatFilterMappings = [
-
- <s:if test="authenticatedWaoUser.authorizedToFilterOnBoats">
- {
- filterName: 'boatIds',
- filterLabel: "<s:text name="wao.ui.entity.Boat"/>",
- filterValuesField: 'boats',
- minimumInputLength: 3
- },
- </s:if>
- {
- filterName: 'elligibleForSampleRowsFilter.fishingZoneFacadeNames',
- filterLabel: "<s:text name="wao.ui.field.FishingZone.facadeName"/>",
- filterValuesField: 'elligibleForSampleRowsFilterValues.fishingZoneFacadeNames'
- },
- {
- filterName: 'elligibleForSampleRowsFilter.fishingZoneSectorNames',
- filterLabel: "<s:text name="wao.ui.field.FishingZone.sectorName"/>",
- filterValuesField: 'elligibleForSampleRowsFilterValues.fishingZoneSectorNames'
- },
- {
- filterName: 'elligibleForSampleRowsFilter.sampleRowCodes',
- filterLabel: "<s:text name="wao.ui.field.SampleRow.code"/>",
- filterValuesField: 'elligibleForSampleRowsFilterValues.sampleRowCodes'
- },
- {
- filterName: 'districtIds',
- filterLabel: "<s:text name="wao.ui.field.Boat.district"/>",
- filterValuesField: 'districts'
- },
- {
- filterName: 'shipOwnerIds',
- filterLabel: "<s:text name="wao.ui.field.Boat.shipOwner"/>",
- filterValuesField: 'shipOwners',
- minimumInputLength: 3
- },
- {
- filterName: 'portOfRegistryIds',
- filterLabel: "<s:text name="wao.ui.field.Boat.portOfRegistry"/>",
- filterValuesField: 'portsOfRegistry'
- }
- ];
-
- filter = <s:property value="filter" escapeHtml="false"/>;
-
- boatsFilterController2 = new FilterController2(boatFilterMappings, filter, WAO.OBSMER_BOATS_FILTER_VALUES_JSON_URL, $('#boats-filters-form fieldset.extra-filters'));
- boatsFilterController2.init();
-
-// var $boatsFiltersForm = $('#boats-filters-form');
-// var boatsFilterController = new FilterController(WAO.OBSMER_BOATS_FILTER_VALUES_JSON_URL, $boatsFiltersForm);
-// boatsFilterController.init();
-
- var $boatDetails = $('#boat-details');
- var $companyId = $('#companyId');
-
- var showBoatDetails = function (boatId) {
- var companyId = $companyId.val();
- var successCallback = function (data) {
- $boatDetails.html(data);
- $('tr.boat-row').removeClass('highlight');
- $('tr[data-boat-id="' + boatId + '"]').addClass('highlight');
- $boatDetails.effect('highlight', 'slow');
- };
- var data = {
- fragment: true,
- boatId: boatId,
- companyId: companyId
- };
- WAO.get(WAO.OBSMER_BOAT_DETAILS_URL, data, successCallback);
- }
- $('a.boat-details-action').click(function (e) {
- e.preventDefault();
- var boatId = $(this).parents('tr.boat-row').attr('data-boat-id');
- showBoatDetails(boatId);
- });
- $companyId.change(function () {
- var boatId = $('tr.boat-row.highlight').attr('data-boat-id');
- if (boatId) {
- showBoatDetails(boatId);
- }
- });
-
- });
-
- </script>
-
-</head>
-
-<content tag="mainClass">large</content>
-<content tag="boatsMenuItemClass">active</content>
-
-<s:if test="startBoatSelectionForSampleRow != null">
- <div class="alert alert-info">
- <s:text name="wao.ui.tip.boatSelectionForSampleRowStarted">
- <s:param value="startBoatSelectionForSampleRow.code"/>
- <s:param value="startBoatSelectionForSampleRow.professionDescription"/>
- </s:text>
- <s:url action="cancel-boat-selection" id="cancelBoatSelectionUrl"/>
- <s:a href="%{cancelBoatSelectionUrl}" cssClass="btn btn-link">
- <s:text name="wao.ui.action.cancel"/>
- </s:a>
- </div>
-</s:if>
-
-<div id="boats-filters-list-details-layout">
-
- <div>
- <s:form method="GET" id="boats-filters-form" cssClass="filters-form">
-
- <fieldset class="extra-filters">
-
- </fieldset>
-
- <div class="form-actions">
-
- <s:submit type="button" action="boats!applyFilter" cssClass="btn btn-primary">
- <i class="icon-filter"></i> <s:text name="wao.ui.action.filter"/>
- </s:submit>
-
- <s:submit type="button" action="boats!resetFilter" cssClass="btn">
- <i class="icon-trash"></i> <s:text name="wao.ui.action.reset"/>
- </s:submit>
-
- <s:submit action="export-boats" type="button" cssClass="btn">
- <i class="icon-download"></i> <s:text name="wao.ui.action.csvExport"/>
- </s:submit>
-
- </div>
-
- </s:form>
-
- </div>
-
- <div>
- <div class="arrow-right"></div>
- <h2>
- <s:text name="wao.ui.boats.title">
- <s:param value="%{pagination.count}"/>
- </s:text>
- </h2>
-
- <s:if test="authenticatedWaoUser.authorizedToViewBoatDetailsForAllCompanies">
- <s:select id="companyId"
- name="companyId"
- label="Vous devez sélectionner la société pour laquelle vous souhaitez consulter les informations"
- list="allCompanies"
- listKey="%{topiaId}"
- listValue="%{name}"
- value="%{authenticatedWaoUser.waoUser.company.topiaId}"
- cssClass="input-xxlarge" />
- </s:if>
- <s:else>
- <s:hidden id="companyId" name="companyId" value="%{authenticatedWaoUser.waoUser.company.topiaId}"/>
- </s:else>
-
- <table id="boats-list" class="table-condensed table-striped table-hover">
- <thead>
- <tr>
- <th>
- <s:text name="wao.ui.boats.registrationCode"/>
- </th>
- <th>
- <s:text name="wao.ui.boats.boatName"/>
- </th>
- <th>
- <s:text name="wao.ui.boats.boatLength"/> (cm)
- </th>
- <th>
- <s:text name="wao.ui.boats.buildYear"/>
- </th>
- <th>
- <s:text name="wao.ui.boats.district"/>
- </th>
- <th>
- <span data-original-title="<s:text name="wao.ui.boats.portOfRegistry.description"/>" data-toggle="tooltip" data-placement="bottom">
- <s:text name="wao.ui.boats.portOfRegistry"/>
- </span>
- </th>
- </tr>
- </thead>
- <tbody>
- <s:iterator value="boats" var="boat">
- <tr data-boat-id="<s:property value="topiaId"/>" class="boat-row">
- <td>
- <s:if test="authenticatedWaoUser.authorizedToViewBoatDetails">
- <s:url action="boat-details" id="boatDetailsUrl">
- <s:param name="companyId" value="authenticatedWaoUser.waoUser.company.topiaId" />
- <s:param name="boatId" value="topiaId" />
- </s:url>
- <s:a href="%{boatDetailsUrl}" cssClass="boat-details-action">
- <s:property value="%{'' + immatriculation}"/>
- </s:a>
- </s:if>
- <s:else>
- <s:property value="%{'' + immatriculation}"/>
- </s:else>
- </td>
- <td<s:if test="!active"> class="inactive"</s:if>>
- <s:property value="name"/>
- </td>
- <td><s:property value="boatLength"/></td>
- <td><s:property value="%{'' + buildYear}"/></td>
- <td><s:property value="district.districtCode"/></td>
- <td>
- <s:if test="portOfRegistry != null">
- <span data-original-title="<s:property value="portOfRegistry.description"/>" data-toggle="tooltip" data-placement="bottom">
- <s:property value="portOfRegistry.portCode"/>
- </span>
- </s:if>
- </td>
- </tr>
- </s:iterator>
- </todby>
- </table>
-
- <%-- Pagination --%>
- <div class="pagination">
- <ul>
- <s:url var="fullUrl" includeParams="get"/>
- <s:set var="paginationUrl" value="%{getPaginationUrl(#fullUrl)}"/>
- <s:if test="firstRangePage > 2">
- <li>
- <a href="${paginationUrl}0">1</a>
- </li>
- <li>
- <a href="${paginationUrl}1">2</a>
- </li>
- <li>
- <span>...</span>
- </li>
- </s:if>
-
- <s:iterator var="currentPage" begin="firstRangePage" end="lastRangePage">
- <li class="<s:if test="#currentPage - 1 == pagination.currentPage.pageNumber">active</s:if>">
- <a href="${paginationUrl}${currentPage - 1}">
- <s:property/>
- </a>
- </li>
- </s:iterator>
-
- <s:if test="lastRangePage < pagination.pageCount - 1">
- <li>
- <span>...</span>
- </li>
- <li>
- <a href="${paginationUrl}${pagination.pageCount - 2}">
- <s:property value="pagination.pageCount - 1"/>
- </a>
- </li>
- <li>
- <a href="${paginationUrl}${pagination.pageCount - 1}">
- <s:property value="pagination.pageCount"/>
- </a>
- </li>
- </s:if>
- </ul>
- </div>
- </div>
-
- <s:if test="authenticatedWaoUser.authorizedToViewBoatDetails">
-
- <div>
- <div class="arrow-right"></div>
- <div id="boat-details">
- <div class="alert alert-info">
- <s:text name="wao.ui.tip.youMustChooseBoat" />
- </div>
- </div>
- </div>
- </s:if>
-
-</div>
-
-</html>
Modified: branches/wao-4.0-obsvente/wao-web/src/main/webapp/endpoints-js.jsp
===================================================================
--- branches/wao-4.0-obsvente/wao-web/src/main/webapp/endpoints-js.jsp 2014-06-20 13:09:06 UTC (rev 2075)
+++ branches/wao-4.0-obsvente/wao-web/src/main/webapp/endpoints-js.jsp 2014-06-20 13:56:00 UTC (rev 2076)
@@ -29,15 +29,15 @@
// json
WAO.OBSMER_SAMPLE_ROWS_FILTER_VALUES_JSON_URL = '<s:url namespace="/obsmer" action="sample-rows-filter-values-json"/>';
- WAO.OBSMER_UPDATE_BOAT_INFOS_JSON_URL = '<s:url namespace="/obsmer" action="update-boat-infos-json"/>';
- WAO.OBSMER_BOATS_FILTER_VALUES_JSON_URL = '<s:url namespace="/obsmer" action="boats-filter-values-json"/>';
- WAO.OBSMER_GET_BOAT_CONTACTS_COUNT_JSON_URL = '<s:url namespace="/obsmer" action="get-boat-contacts-count-json"/>';
- WAO.OBSMER_SEARCH_BOAT_JSON_URL = '<s:url namespace="/obsmer" action="search-boat-json"/>';
+ WAO.UPDATE_BOAT_INFOS_JSON_URL = '<s:url namespace="/" action="update-boat-infos-json"/>';
+ WAO.BOATS_FILTER_VALUES_JSON_URL = '<s:url namespace="/" action="boats-filter-values-json"/>';
+ WAO.GET_BOAT_CONTACTS_COUNT_JSON_URL = '<s:url namespace="/" action="get-boat-contacts-count-json"/>';
+ WAO.SEARCH_BOAT_JSON_URL = '<s:url namespace="/" action="search-boat-json"/>';
WAO.OBSMER_CONTACTS_FILTER_VALUES_JSON_URL = '<s:url namespace="/obsmer" action="contacts-filter-values-json"/>';
// fragments
- WAO.OBSMER_BOAT_DETAILS_URL = '<s:url namespace="/obsmer" action="boat-details"/>';
+ WAO.BOAT_DETAILS_URL = '<s:url namespace="/" action="boat-details"/>';
});
1
0
Author: bleny
Date: 2014-06-20 15:09:06 +0200 (Fri, 20 Jun 2014)
New Revision: 2075
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2075
Log:
create branch for obsvente
Added:
branches/wao-4.0-obsvente/
1
0
Author: bleny
Date: 2014-06-19 18:16:42 +0200 (Thu, 19 Jun 2014)
New Revision: 2074
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2074
Log:
fix used undeclared dependency
Modified:
trunk/pom.xml
trunk/wao-services/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-06-19 15:50:28 UTC (rev 2073)
+++ trunk/pom.xml 2014-06-19 16:16:42 UTC (rev 2074)
@@ -113,6 +113,7 @@
<commonsCodecVersion>1.9</commonsCodecVersion>
<ehCacheVersion>2.6.9</ehCacheVersion>
<jFreeChartVersion>1.0.13</jFreeChartVersion>
+ <jFreeChartCommonVersion>1.0.16</jFreeChartCommonVersion>
<nuitonWebVersion>1.16</nuitonWebVersion>
<nuitonI18nVersion>3.1</nuitonI18nVersion>
@@ -378,6 +379,12 @@
<version>${jFreeChartVersion}</version>
</dependency>
+ <dependency>
+ <groupId>jfree</groupId>
+ <artifactId>jcommon</artifactId>
+ <version>${jFreeChartCommonVersion}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
Modified: trunk/wao-services/pom.xml
===================================================================
--- trunk/wao-services/pom.xml 2014-06-19 15:50:28 UTC (rev 2073)
+++ trunk/wao-services/pom.xml 2014-06-19 16:16:42 UTC (rev 2074)
@@ -97,6 +97,11 @@
</dependency>
<dependency>
+ <groupId>jfree</groupId>
+ <artifactId>jcommon</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
1
0
r2073 - trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer
by bleny@users.forge.codelutin.com 19 Jun '14
by bleny@users.forge.codelutin.com 19 Jun '14
19 Jun '14
Author: bleny
Date: 2014-06-19 17:50:28 +0200 (Thu, 19 Jun 2014)
New Revision: 2073
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2073
Log:
fixes #5282
Modified:
trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp
Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp 2014-06-19 15:45:23 UTC (rev 2072)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-contact-input.jsp 2014-06-19 15:50:28 UTC (rev 2073)
@@ -192,9 +192,6 @@
<fieldset>
<legend><s:text name="wao.ui.misc.observers"/></legend>
- <s:set name="editObservers"
- value="%{authenticatedWaoUser.isAuthorizedToEditContactObservers(updateContactCommand.contact)}"/>
-
<s:select name="updateContactCommand.mainObserverId"
value="%{updateContactCommand.mainObserverId}"
label="%{getText('wao.ui.field.Contact.mainObserver')}"
1
0
r2072 - trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer
by bleny@users.forge.codelutin.com 19 Jun '14
by bleny@users.forge.codelutin.com 19 Jun '14
19 Jun '14
Author: bleny
Date: 2014-06-19 17:45:23 +0200 (Thu, 19 Jun 2014)
New Revision: 2072
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2072
Log:
fixes #5283
Modified:
trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp
Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-06-19 14:33:56 UTC (rev 2071)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-06-19 15:45:23 UTC (rev 2072)
@@ -101,7 +101,7 @@
e.preventDefault();
if (confirm("<s:text name="wao.ui.removeBoatEligibility.confirm"/>")) {
var url = $(this).attr('href');
- var $toRemove = $(this).parents('li, div')
+ var $toRemove = $(this).parents('.elligible-sample-row')
var successCallback = function (data) {
$toRemove.remove();
};
@@ -201,7 +201,7 @@
<div class="control-group">
<div class="controls">
<s:iterator value="boatDetails.elligibleForSampleRows" status="status">
- <div>
+ <div class="elligible-sample-row">
<s:set name="radioId">radio-<s:property value="#status.index"/></s:set>
<input type="radio" name="sampleRowId" id="<s:property value="#radioId"/>" value="<s:property value="topiaId"/>"/>
<%--
@@ -233,7 +233,7 @@
<s:else>
<ul>
<s:iterator value="boatDetails.elligibleForSampleRows">
- <li>
+ <li class="elligible-sample-row">
<s:property value="code"/>
<s:url action="update-boat-elligibility-json" id="updateBoatElligibilityUrl">
<s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/>
1
0
r2071 - in trunk/wao-web/src/main: java/fr/ifremer/wao/web/action java/fr/ifremer/wao/web/action/obsmer webapp/WEB-INF/content webapp/WEB-INF/content/obsmer
by bleny@users.forge.codelutin.com 19 Jun '14
by bleny@users.forge.codelutin.com 19 Jun '14
19 Jun '14
Author: bleny
Date: 2014-06-19 16:33:56 +0200 (Thu, 19 Jun 2014)
New Revision: 2071
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2071
Log:
refs #4552 news page for obsvente
Added:
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/DeleteNewsAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/EditNewsAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/NewsAction.java
trunk/wao-web/src/main/webapp/WEB-INF/content/edit-news-input.jsp
trunk/wao-web/src/main/webapp/WEB-INF/content/news.jsp
Removed:
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteNewsAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditNewsAction.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/NewsAction.java
trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-news-input.jsp
trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/news.jsp
Copied: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/DeleteNewsAction.java (from rev 2060, trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteNewsAction.java)
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/DeleteNewsAction.java (rev 0)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/DeleteNewsAction.java 2014-06-19 14:33:56 UTC (rev 2071)
@@ -0,0 +1,59 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.services.service.administration.NewsService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+
+@Results({
+ @Result(name="success", type="redirectAction", params = { "actionName", "news" })
+})
+public class DeleteNewsAction extends WaoJspActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient NewsService service;
+
+ protected String newsId;
+
+ public void setService(NewsService service) {
+ this.service = service;
+ }
+
+ public void setNewsId(String newsId) {
+ this.newsId = newsId;
+ }
+
+ @Override
+ public String execute() {
+
+ service.delete(newsId);
+
+ addActionMessage("Suppression effectuée");
+
+ return SUCCESS;
+
+ }
+
+}
Copied: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/EditNewsAction.java (from rev 2060, trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditNewsAction.java)
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/EditNewsAction.java (rev 0)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/EditNewsAction.java 2014-06-19 14:33:56 UTC (rev 2071)
@@ -0,0 +1,93 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.wao.entity.News;
+import fr.ifremer.wao.services.service.administration.NewsService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+import org.jsoup.Jsoup;
+import org.jsoup.safety.Whitelist;
+
+@Results({
+ @Result(name="success", type="redirectAction", params = { "actionName", "news" })
+})
+public class EditNewsAction extends WaoJspActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected static final Whitelist WHITE_LIST = Whitelist.basicWithImages().addTags("h1", "h2", "h3");
+
+ protected transient NewsService service;
+
+ protected String newsId;
+
+ protected News news;
+
+ public void setService(NewsService service) {
+ this.service = service;
+ }
+
+ public void setNewsId(String newsId) {
+ this.newsId = newsId;
+ }
+
+ public void setNews(News news) {
+ this.news = news;
+ }
+
+ @Override
+ public void prepare() {
+ if (StringUtils.isEmpty(newsId)) {
+ news = service.newNews(getAuthenticatedWaoUser());
+ } else {
+ news = service.getNews(newsId);
+ }
+ }
+
+ @Override
+ public String execute() {
+
+ //filtrage de news
+ String clean = Jsoup.clean(news.getContent(), WHITE_LIST);
+ news.setContent(clean);
+
+ service.save(news);
+
+ addActionMessage(t("wao.ui.action.createNews.success"));
+
+ return SUCCESS;
+
+ }
+
+ public String getNewsId() {
+ return newsId;
+ }
+
+ public News getNews() {
+ return news;
+ }
+
+}
Copied: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/NewsAction.java (from rev 2060, trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/NewsAction.java)
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/NewsAction.java (rev 0)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/NewsAction.java 2014-06-19 14:33:56 UTC (rev 2071)
@@ -0,0 +1,55 @@
+package fr.ifremer.wao.web.action;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.wao.entity.News;
+import fr.ifremer.wao.services.service.administration.NewsService;
+import fr.ifremer.wao.web.WaoJspActionSupport;
+
+import java.util.List;
+
+public class NewsAction extends WaoJspActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ protected transient NewsService service;
+
+ protected List<News> recentNews;
+
+ public void setService(NewsService service) {
+ this.service = service;
+ }
+
+ @Override
+ public String execute() {
+
+ recentNews = service.getRecentNews(getAuthenticatedWaoUser(), 15);
+
+ return SUCCESS;
+
+ }
+
+ public List<News> getRecentNews() {
+ return recentNews;
+ }
+
+}
Deleted: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteNewsAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteNewsAction.java 2014-06-19 13:47:26 UTC (rev 2070)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/DeleteNewsAction.java 2014-06-19 14:33:56 UTC (rev 2071)
@@ -1,59 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.services.service.administration.NewsService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-import org.apache.struts2.convention.annotation.Result;
-import org.apache.struts2.convention.annotation.Results;
-
-@Results({
- @Result(name="success", type="redirectAction", params = { "actionName", "news" })
-})
-public class DeleteNewsAction extends WaoJspActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- protected transient NewsService service;
-
- protected String newsId;
-
- public void setService(NewsService service) {
- this.service = service;
- }
-
- public void setNewsId(String newsId) {
- this.newsId = newsId;
- }
-
- @Override
- public String execute() {
-
- service.delete(newsId);
-
- addActionMessage("Suppression effectuée");
-
- return SUCCESS;
-
- }
-
-}
Deleted: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditNewsAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditNewsAction.java 2014-06-19 13:47:26 UTC (rev 2070)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditNewsAction.java 2014-06-19 14:33:56 UTC (rev 2071)
@@ -1,93 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.wao.entity.News;
-import fr.ifremer.wao.services.service.administration.NewsService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.struts2.convention.annotation.Result;
-import org.apache.struts2.convention.annotation.Results;
-import org.jsoup.Jsoup;
-import org.jsoup.safety.Whitelist;
-
-@Results({
- @Result(name="success", type="redirectAction", params = { "actionName", "news" })
-})
-public class EditNewsAction extends WaoJspActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- protected static final Whitelist WHITE_LIST = Whitelist.basicWithImages().addTags("h1", "h2", "h3");
-
- protected transient NewsService service;
-
- protected String newsId;
-
- protected News news;
-
- public void setService(NewsService service) {
- this.service = service;
- }
-
- public void setNewsId(String newsId) {
- this.newsId = newsId;
- }
-
- public void setNews(News news) {
- this.news = news;
- }
-
- @Override
- public void prepare() {
- if (StringUtils.isEmpty(newsId)) {
- news = service.newNews(getAuthenticatedWaoUser());
- } else {
- news = service.getNews(newsId);
- }
- }
-
- @Override
- public String execute() {
-
- //filtrage de news
- String clean = Jsoup.clean(news.getContent(), WHITE_LIST);
- news.setContent(clean);
-
- service.save(news);
-
- addActionMessage(t("wao.ui.action.createNews.success"));
-
- return SUCCESS;
-
- }
-
- public String getNewsId() {
- return newsId;
- }
-
- public News getNews() {
- return news;
- }
-
-}
Deleted: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/NewsAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/NewsAction.java 2014-06-19 13:47:26 UTC (rev 2070)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/NewsAction.java 2014-06-19 14:33:56 UTC (rev 2071)
@@ -1,55 +0,0 @@
-package fr.ifremer.wao.web.action.obsmer;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import fr.ifremer.wao.entity.News;
-import fr.ifremer.wao.services.service.administration.NewsService;
-import fr.ifremer.wao.web.WaoJspActionSupport;
-
-import java.util.List;
-
-public class NewsAction extends WaoJspActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- protected transient NewsService service;
-
- protected List<News> recentNews;
-
- public void setService(NewsService service) {
- this.service = service;
- }
-
- @Override
- public String execute() {
-
- recentNews = service.getRecentNews(getAuthenticatedWaoUser(), 15);
-
- return SUCCESS;
-
- }
-
- public List<News> getRecentNews() {
- return recentNews;
- }
-
-}
Copied: trunk/wao-web/src/main/webapp/WEB-INF/content/edit-news-input.jsp (from rev 2060, trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-news-input.jsp)
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/edit-news-input.jsp (rev 0)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/edit-news-input.jsp 2014-06-19 14:33:56 UTC (rev 2071)
@@ -0,0 +1,69 @@
+<%--
+ #%L
+ Wao :: Web
+ %%
+ Copyright (C) 2009 - 2014 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="<s:url value='/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5.css' />" />
+ <script src="<s:url value='/wysihtml5-0.3.0/wysihtml5.js'/>"></script>
+ <script src="<s:url value='/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5.js' />"></script>
+ <s:if test="!getText('wao.ui.wysihtml5.lang').equals('en')">
+ <script src="<s:url value='/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5.%{getText("wao.ui.wysihtml5.lang")}.js' />"></script>
+ </s:if>
+ <script>
+ $(document).ready(function () {
+ $("#editor").wysihtml5({
+ locale: "<s:property value="%{getText('wao.ui.wysihtml5.lang')}"/>",
+ stylesheets: ["<s:url value='/bootstrap-wysihtml5-0.0.2/wysiwyg-color.css' />"]
+ });
+ });
+ </script>
+ <content tag="mainClass">form</content>
+
+ </head>
+
+ <s:form onsubmit="save();">
+
+ <s:hidden name="newsId" value="%{newsId}" />
+
+ <s:textfield name="news.title" label="%{getText('wao.ui.news.title')}" cssClass="input-xxlarge" />
+
+ <s:textarea label="%{getText('wao.ui.news.content')}"
+ name="news.content"
+ id="editor"
+ rows="8"/>
+
+ <div class="form-actions">
+ <s:url action="news" id="newsUrl" />
+ <s:a href="%{newsUrl}" cssClass="btn">
+ <i class="icon-chevron-left"></i> <s:text name="wao.ui.action.cancel" />
+ </s:a>
+
+ <s:submit type="button" cssClass="btn">
+ <i class="icon-hdd"></i> <s:text name="wao.ui.action.save" />
+ </s:submit>
+ </div>
+
+ </s:form>
+
+</html>
+
Copied: trunk/wao-web/src/main/webapp/WEB-INF/content/news.jsp (from rev 2060, trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/news.jsp)
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/news.jsp (rev 0)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/news.jsp 2014-06-19 14:33:56 UTC (rev 2071)
@@ -0,0 +1,88 @@
+<%--
+ #%L
+ Wao :: Web
+ %%
+ Copyright (C) 2009 - 2014 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<content tag="newsMenuItemClass">active</content>
+
+<html>
+
+ <head>
+
+ </head>
+
+ <content tag="mainClass">home</content>
+
+ <s:if test="authenticatedWaoUser.authorizedToCreateNews">
+ <content tag="administrationMenuOtherOptions">
+ <li>
+ <s:url action="edit-news!input" id="createNewsUrl"/>
+ <s:a href="%{createNewsUrl}">
+ <i class="fa fa-plus-square"></i> <s:text name="wao.ui.action.createNews"/>
+ </s:a>
+ </li>
+ </content>
+ </s:if>
+
+ <div class="buttons-area">
+ </div>
+
+ <s:iterator value="recentNews" var="aRecentNews">
+
+ <div class="news">
+ <h2>
+ <s:property value="title" />
+ </h2>
+
+ <s:property value="content" escapeHtml="false" />
+
+ <p class="publication">
+ <s:if test="fromAdmin">
+ <s:text name="wao.ui.publishedByProgram" />
+ </s:if>
+ <s:else>
+ <s:text name="wao.ui.publishedByYourCompany" />
+ </s:else>
+ <s:text name="wao.ui.misc.onDate" />
+ <s:property value="topiaCreateDate" />
+
+ <s:if test="authenticatedWaoUser.isAuthorizedToEditOrDeleteNews(#aRecentNews)">
+
+ <s:url action="delete-news" id="deleteNewsUrl">
+ <s:param name="newsId" value="topiaId" />
+ </s:url>
+ <s:a href="%{deleteNewsUrl}" cssClass="btn-link" title="%{getText('wao.ui.action.delete')}" >
+ <i class="fa fa-trash-o"></i>
+ </s:a>
+
+ <s:url action="edit-news!input" id="editNewsUrl">
+ <s:param name="newsId" value="topiaId" />
+ </s:url>
+ <s:a href="%{editNewsUrl}" cssClass="btn-link btn-link-edit" title="%{getText('wao.ui.action.edit')}">
+ <i class="fa fa-edit"></i>
+ </s:a>
+ </s:if>
+ </p>
+ </div>
+
+ </s:iterator>
+
+</html>
Deleted: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-news-input.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-news-input.jsp 2014-06-19 13:47:26 UTC (rev 2070)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/edit-news-input.jsp 2014-06-19 14:33:56 UTC (rev 2071)
@@ -1,69 +0,0 @@
-<%--
- #%L
- Wao :: Web
- %%
- Copyright (C) 2009 - 2014 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
-<%@taglib uri="/struts-tags" prefix="s" %>
-
-<html>
- <head>
- <link rel="stylesheet" type="text/css" href="<s:url value='/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5.css' />" />
- <script src="<s:url value='/wysihtml5-0.3.0/wysihtml5.js'/>"></script>
- <script src="<s:url value='/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5.js' />"></script>
- <s:if test="!getText('wao.ui.wysihtml5.lang').equals('en')">
- <script src="<s:url value='/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5.%{getText("wao.ui.wysihtml5.lang")}.js' />"></script>
- </s:if>
- <script>
- $(document).ready(function () {
- $("#editor").wysihtml5({
- locale: "<s:property value="%{getText('wao.ui.wysihtml5.lang')}"/>",
- stylesheets: ["<s:url value='/bootstrap-wysihtml5-0.0.2/wysiwyg-color.css' />"]
- });
- });
- </script>
- <content tag="mainClass">form</content>
-
- </head>
-
- <s:form onsubmit="save();">
-
- <s:hidden name="newsId" value="%{newsId}" />
-
- <s:textfield name="news.title" label="%{getText('wao.ui.news.title')}" cssClass="input-xxlarge" />
-
- <s:textarea label="%{getText('wao.ui.news.content')}"
- name="news.content"
- id="editor"
- rows="8"/>
-
- <div class="form-actions">
- <s:url action="news" id="newsUrl" />
- <s:a href="%{newsUrl}" cssClass="btn">
- <i class="icon-chevron-left"></i> <s:text name="wao.ui.action.cancel" />
- </s:a>
-
- <s:submit type="button" cssClass="btn">
- <i class="icon-hdd"></i> <s:text name="wao.ui.action.save" />
- </s:submit>
- </div>
-
- </s:form>
-
-</html>
-
Deleted: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/news.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/news.jsp 2014-06-19 13:47:26 UTC (rev 2070)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/news.jsp 2014-06-19 14:33:56 UTC (rev 2071)
@@ -1,88 +0,0 @@
-<%--
- #%L
- Wao :: Web
- %%
- Copyright (C) 2009 - 2014 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
-<%@taglib uri="/struts-tags" prefix="s" %>
-
-<content tag="newsMenuItemClass">active</content>
-
-<html>
-
- <head>
-
- </head>
-
- <content tag="mainClass">home</content>
-
- <s:if test="authenticatedWaoUser.authorizedToCreateNews">
- <content tag="administrationMenuOtherOptions">
- <li>
- <s:url action="edit-news!input" id="createNewsUrl"/>
- <s:a href="%{createNewsUrl}">
- <i class="fa fa-plus-square"></i> <s:text name="wao.ui.action.createNews"/>
- </s:a>
- </li>
- </content>
- </s:if>
-
- <div class="buttons-area">
- </div>
-
- <s:iterator value="recentNews" var="aRecentNews">
-
- <div class="news">
- <h2>
- <s:property value="title" />
- </h2>
-
- <s:property value="content" escapeHtml="false" />
-
- <p class="publication">
- <s:if test="fromAdmin">
- <s:text name="wao.ui.publishedByProgram" />
- </s:if>
- <s:else>
- <s:text name="wao.ui.publishedByYourCompany" />
- </s:else>
- <s:text name="wao.ui.misc.onDate" />
- <s:property value="topiaCreateDate" />
-
- <s:if test="authenticatedWaoUser.isAuthorizedToEditOrDeleteNews(#aRecentNews)">
-
- <s:url action="delete-news" id="deleteNewsUrl">
- <s:param name="newsId" value="topiaId" />
- </s:url>
- <s:a href="%{deleteNewsUrl}" cssClass="btn-link" title="%{getText('wao.ui.action.delete')}" >
- <i class="fa fa-trash-o"></i>
- </s:a>
-
- <s:url action="edit-news!input" id="editNewsUrl">
- <s:param name="newsId" value="topiaId" />
- </s:url>
- <s:a href="%{editNewsUrl}" cssClass="btn-link btn-link-edit" title="%{getText('wao.ui.action.edit')}">
- <i class="fa fa-edit"></i>
- </s:a>
- </s:if>
- </p>
- </div>
-
- </s:iterator>
-
-</html>
1
0
19 Jun '14
Author: bleny
Date: 2014-06-19 15:47:26 +0200 (Thu, 19 Jun 2014)
New Revision: 2070
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2070
Log:
fixes #5278
Modified:
trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties
trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
Modified: trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties
===================================================================
--- trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-19 13:36:10 UTC (rev 2069)
+++ trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-19 13:47:26 UTC (rev 2070)
@@ -484,7 +484,7 @@
wao.ui.page.waoUsers.titleForCompany=Users for company %s
wao.ui.publishedByProgram=Pusblished by program
wao.ui.publishedByYourCompany=Published by company
-wao.ui.removeBoatEligibility.confirm=Êtes-vous sûr de vouloir rendre le navire inéligible pour cette ligne ?
+wao.ui.removeBoatEligibility.confirm=Are you sure you want to make this boat ineligible for sample row ?
wao.ui.sampleRow.creation=Creation of a sample row
wao.ui.sampleRow.edition=Edition of line %s
wao.ui.sampleRowLog.title=%s line historic
Modified: trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties
===================================================================
--- trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-19 13:36:10 UTC (rev 2069)
+++ trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-19 13:47:26 UTC (rev 2070)
@@ -484,7 +484,7 @@
wao.ui.page.waoUsers.titleForCompany=Utilisateurs de la société %s
wao.ui.publishedByProgram=Publiée par le programme
wao.ui.publishedByYourCompany=Publiée par la société
-wao.ui.removeBoatEligibility.confirm=Are you sure you want to make this boat ineligible for sample row ?
+wao.ui.removeBoatEligibility.confirm=Êtes-vous sûr de vouloir rendre le navire inéligible pour cette ligne ?
wao.ui.sampleRow.creation=Création d'une ligne du plan d'échantillonnage
wao.ui.sampleRow.edition=Modification de la ligne %s
wao.ui.sampleRowLog.title=Historique de la ligne %s
1
0