This is an automated email from the git hooks/post-receive script. New commit to branch feature/6805 in repository tutti. See http://git.codelutin.com/tutti.git commit 4bd9c93772190bfb5e289cc35510fd14e34c3901 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Mar 11 22:28:44 2015 +0100 correction des mises à jour de référentiels --- .../referential/GearPersistenceServiceImpl.java | 33 ++++++++++------- .../referential/PersonPersistenceServiceImpl.java | 11 ++++++ .../referential/VesselPersistenceServiceImpl.java | 41 +++++++++++++++++----- 3 files changed, 65 insertions(+), 20 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/GearPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/GearPersistenceServiceImpl.java index 91191b4..45b9aeb 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/GearPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/GearPersistenceServiceImpl.java @@ -30,6 +30,7 @@ import fr.ifremer.adagio.core.dao.referential.StatusCode; import fr.ifremer.adagio.core.dao.referential.gear.FishingGearExtendDao; import fr.ifremer.adagio.core.dao.referential.gear.GearClassification; import fr.ifremer.adagio.core.dao.referential.gear.GearClassificationId; +import fr.ifremer.adagio.core.dao.referential.gear.GearClassificationImpl; import fr.ifremer.tutti.persistence.entities.referential.Gear; import fr.ifremer.tutti.persistence.entities.referential.Gears; import org.hibernate.type.IntegerType; @@ -213,12 +214,7 @@ public class GearPersistenceServiceImpl extends ReferentialPersistenceServiceSup Preconditions.checkNotNull(source.getLabel()); Preconditions.checkNotNull(source.getName()); - Integer gearClassificationId; - if (source.isScientificGear()) { - gearClassificationId = GearClassificationId.SCIENTIFIC_CRUISE.getValue(); - } else { - gearClassificationId = GearClassificationId.FAO.getValue(); - } + Integer gearClassificationId = getGearClassificationId(source); Gear result; if (source.getId() != null) { @@ -246,12 +242,7 @@ public class GearPersistenceServiceImpl extends ReferentialPersistenceServiceSup Preconditions.checkNotNull(source.getName()); Preconditions.checkArgument(source.getId() == null || Gears.isTemporaryId(source.getIdAsInt())); - Integer gearClassificationId; - if (source.isScientificGear()) { - gearClassificationId = GearClassificationId.SCIENTIFIC_CRUISE.getValue(); - } else { - gearClassificationId = GearClassificationId.FAO.getValue(); - } + Integer gearClassificationId = getGearClassificationId(source); fr.ifremer.adagio.core.dao.referential.gear.Gear target = fishingGearDao.createAsTemporary(source.getLabel(), source.getName(), gearClassificationId); Gear result = Gears.newGear(); @@ -281,10 +272,28 @@ public class GearPersistenceServiceImpl extends ReferentialPersistenceServiceSup result.setName(source.getName()); result.setScientificGear(source.isScientificGear()); setStatus(status, result); + + fr.ifremer.adagio.core.dao.referential.gear.FishingGear toUpdate = fishingGearDao.load(source.getIdAsInt()); + toUpdate.setLabel(result.getLabel()); + toUpdate.setName(result.getName()); + Integer gearClassificationId = getGearClassificationId(source); + toUpdate.setGearClassification(load(GearClassificationImpl.class, gearClassificationId)); + fishingGearDao.update(toUpdate); + return result; } + private Integer getGearClassificationId(Gear source) { + Integer gearClassificationId; + if (source.isScientificGear()) { + gearClassificationId = GearClassificationId.SCIENTIFIC_CRUISE.getValue(); + } else { + gearClassificationId = GearClassificationId.FAO.getValue(); + } + return gearClassificationId; + } + protected Gear linkTemporaryGear(Gear source) { Preconditions.checkNotNull(source); diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/PersonPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/PersonPersistenceServiceImpl.java index 6e2081f..0c52656 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/PersonPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/PersonPersistenceServiceImpl.java @@ -30,6 +30,7 @@ import fr.ifremer.adagio.core.dao.administration.user.DepartmentId; import fr.ifremer.adagio.core.dao.administration.user.PersonExtendDao; import fr.ifremer.adagio.core.dao.administration.user.UserProfilId; import fr.ifremer.adagio.core.dao.referential.StatusCode; +import fr.ifremer.adagio.core.vo.administration.user.PersonVO; import fr.ifremer.tutti.persistence.entities.referential.Person; import fr.ifremer.tutti.persistence.entities.referential.Persons; import org.hibernate.type.IntegerType; @@ -252,6 +253,16 @@ public class PersonPersistenceServiceImpl extends ReferentialPersistenceServiceS result.setLastName(source.getLastName()); result.setFirstName(source.getFirstName()); setStatus(status, result); + + PersonVO toUpdate = new PersonVO(); + toUpdate.setId(source.getIdAsInt()); + toUpdate.setLastname(source.getLastName()); + toUpdate.setFirstname(source.getFirstName()); + toUpdate.setDepartmentId(DepartmentId.UNKNOWN_RECORDER_DEPARTMENT.getValue()); + toUpdate.setCreationDate(personDao.load(source.getIdAsInt()).getCreationDate()); + toUpdate.setStatusCode(status.getCode()); + personDao.save(toUpdate); + return result; } diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/VesselPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/VesselPersistenceServiceImpl.java index e77f8d8..fb6e7bc 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/VesselPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/VesselPersistenceServiceImpl.java @@ -217,12 +217,20 @@ public class VesselPersistenceServiceImpl extends ReferentialPersistenceServiceS @Override public List<Vessel> updateTemporaryVessels(List<Vessel> vessels) { + Integer countryLocationId = + locationDao.getLocationIdByLabelAndLocationLevel( + LocationLabel.FRANCE.getValue(), + new Integer[]{LocationLevelId.PAYS_ISO3.getValue()}); + if (countryLocationId == null) { + throw new DataIntegrityViolationException("Default country location not found, with label=" + LocationLabel.FRANCE.getValue()); + } + fr.ifremer.adagio.core.dao.referential.Status status = statusDao.load(StatusCode.TEMPORARY.getValue()); List<Vessel> result = Lists.newArrayList(); for (Vessel source : vessels) { - Vessel updated = updateTemporaryVessel(source, status); + Vessel updated = updateTemporaryVessel(source, countryLocationId, status); result.add(updated); } return Collections.unmodifiableList(result); @@ -330,12 +338,7 @@ public class VesselPersistenceServiceImpl extends ReferentialPersistenceServiceS Preconditions.checkNotNull(source.getInternationalRegistrationCode()); Preconditions.checkArgument(StringUtils.isBlank(source.getId()) || Vessels.isTemporaryId(source.getId())); - Integer vesselTypeId; - if (source.isScientificVessel()) { - vesselTypeId = VesselTypeId.SCIENTIFIC_RESEARCH_VESSEL.getValue(); - } else { - vesselTypeId = VesselTypeId.FISHING_VESSEL.getValue(); - } + Integer vesselTypeId = getVesselTypeId(source); fr.ifremer.adagio.core.dao.data.vessel.Vessel target = vesselExtendDao.createAsTemporary( @@ -357,7 +360,7 @@ public class VesselPersistenceServiceImpl extends ReferentialPersistenceServiceS } - protected Vessel updateTemporaryVessel(Vessel source, Status status) { + protected Vessel updateTemporaryVessel(Vessel source, Integer countryLocationId, Status status) { Preconditions.checkNotNull(source); Preconditions.checkNotNull(source.getId()); @@ -372,10 +375,32 @@ public class VesselPersistenceServiceImpl extends ReferentialPersistenceServiceS result.setInternationalRegistrationCode(source.getInternationalRegistrationCode()); result.setScientificVessel(source.isScientificVessel()); setStatus(status, result); + + Integer vesselTypeId = getVesselTypeId(source); + + vesselExtendDao.updateTemporaryVessel( + source.getId(), + source.getRegistrationCode(), + source.getInternationalRegistrationCode(), + countryLocationId, + source.getName(), + vesselTypeId, + false); + return result; } + private Integer getVesselTypeId(Vessel source) { + Integer vesselTypeId; + if (source.isScientificVessel()) { + vesselTypeId = VesselTypeId.SCIENTIFIC_RESEARCH_VESSEL.getValue(); + } else { + vesselTypeId = VesselTypeId.FISHING_VESSEL.getValue(); + } + return vesselTypeId; + } + protected Vessel linkTemporaryVessel(Vessel source) { Preconditions.checkNotNull(source); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.