[Suiviobsmer-commits] r201 - in trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer: bean entity
Author: fdesbois Date: 2010-01-14 22:06:00 +0000 (Thu, 14 Jan 2010) New Revision: 201 Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java Log: Improve constraints on changing elligibleBoat by admin or by observer/user Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java 2010-01-14 19:14:05 UTC (rev 200) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java 2010-01-14 22:06:00 UTC (rev 201) @@ -45,7 +45,7 @@ public void removeElligibleBoat(String sampleRowCode) { ElligibleBoat elligible = elligibleBoats.get(sampleRowCode); // ElligibleBoat set by an admin - if (elligible.getCompanyActive() == null) { + if (elligible.getGlobalActive()) { elligible.setCompanyActive(Boolean.FALSE); } else { if (!deletedElligibleBoats.contains(elligible) && !StringUtils.isEmpty(elligible.getTopiaId())) { @@ -61,19 +61,19 @@ } @Override - public ElligibleBoat setNewElligibleBoat(SampleRow row) { - ElligibleBoat elligible = null; + public ElligibleBoat setNewElligibleBoat(SampleRow row) { if (row == null) { return null; } - if (!elligibleBoats.containsKey(row.getCode())) { + ElligibleBoat elligible = elligibleBoats.get(row.getCode()); + if (elligible == null) { elligible = new ElligibleBoatImpl(); - elligible.setCompanyActive(Boolean.TRUE); elligible.setBoat(boatInfos.getBoat()); elligible.setSampleRow(row); elligibleBoats.put(row.getCode(), elligible); removePreviouslyDeleted(row.getCode()); } + elligible.setCompanyActive(Boolean.TRUE); return elligible; } @@ -90,6 +90,7 @@ /** * Active only element wich is inactive. So element which is linked by admin in SamplingRowForm. * The Boolean CompanyActive is set to null : no specific modification for company. + * * @param sampleRowCode code of the element to reactivate */ @Override Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2010-01-14 19:14:05 UTC (rev 200) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2010-01-14 22:06:00 UTC (rev 201) @@ -29,6 +29,7 @@ import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; +import org.apache.commons.lang.BooleanUtils; import org.nuiton.util.PeriodDates; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -104,6 +105,7 @@ /** * Check from the list of ElligibleBoat linked with the SampleRow if the boats in argument corresponding. * The argument means new boats to linked with SampleRow, so an ElligibleBoat not contains in this list is removed. + * * @param boats a List of Boats to check with ElligibleBoats linked with the SampleRow. * @see fr.ifremer.suiviobsmer.impl.ServiceSamplingImpl#createUpdateSampleRow(fr.ifremer.suiviobsmer.entity.SampleRow, java.util.List) */ @@ -115,19 +117,25 @@ String elligibleBoatTopiaId = elligible.getBoat().getTopiaId(); boolean find = false; for (Boat boat : boats) { - if (elligibleBoatTopiaId.equals(boat.getTopiaId()) && elligible.getCompanyActive() == null) { + if (elligibleBoatTopiaId.equals(boat.getTopiaId())) { find = true; break; } } + // only if no company use this elligibleBoat if (!find) { - it.remove(); + if (BooleanUtils.isNotTrue(elligible.getCompanyActive())) { + it.remove(); + } else { + elligible.setGlobalActive(false); + } } } } /** * Used to get a list of boat's immatriculations linked with the sampleRow. + * * @return a simple String which contains immatriculations separate by a space */ @Override
participants (1)
-
fdesbois@users.labs.libre-entreprise.org