This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 63f77bd948ec648e83fc5491ccb80b0ccaedbe7c Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 4 16:22:25 2014 +0100 refs #5997: [IMPORT] Améliorer la gestion des référentiels temporaires (ne pas utiliser un service spring pour du code non transactionnel... sinon gresse degradation des performances) --- .../persistence/entities/referential/Gears.java | 24 +++ .../persistence/entities/referential/Persons.java | 30 ++++ .../persistence/entities/referential/Speciess.java | 25 +++ .../referential/TuttiReferentialEntities.java | 22 +++ .../persistence/entities/referential/Vessels.java | 31 ++++ .../referential/GearPersistenceService.java | 10 -- .../referential/GearPersistenceServiceImpl.java | 9 +- .../referential/PersonPersistenceService.java | 10 -- .../referential/PersonPersistenceServiceImpl.java | 13 +- .../ReferentialPersistenceServiceSupport.java | 8 +- .../referential/SpeciesPersistenceService.java | 9 - .../referential/SpeciesPersistenceServiceImpl.java | 12 +- .../referential/VesselPersistenceService.java | 9 - .../referential/VesselPersistenceServiceImpl.java | 12 +- .../ifremer/tutti/service/PersistenceService.java | 71 +++----- .../referential/ReferentialExportService.java | 190 +++++++++++++-------- 16 files changed, 286 insertions(+), 199 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Gears.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Gears.java index 85d508b..4fd0d36 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Gears.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Gears.java @@ -25,6 +25,7 @@ package fr.ifremer.tutti.persistence.entities.referential; */ +import com.google.common.base.Preconditions; import com.google.common.base.Predicate; public class Gears extends AbstractGears { @@ -43,4 +44,27 @@ public class Gears extends AbstractGears { return input.isScientificGear(); } }; + + public static final Predicate<Gear> IS_TEMPORARY = new Predicate<Gear>() { + @Override + public boolean apply(Gear input) { + return isTemporary(input); + } + }; + + /** + * Is the given {@code gear} a temporary data ? + * + * @param gear gear to test + * @return {@code true} if the given {@code gear} is temporary + * @since 3.8 + */ + public static boolean isTemporary(Gear gear) { + + Preconditions.checkNotNull(gear); + Preconditions.checkNotNull(gear.getId()); + + return TuttiReferentialEntities.isStatusTemporary(gear) && gear.getIdAsInt() < 0; + + } } //Gears diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Persons.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Persons.java new file mode 100644 index 0000000..a8160da --- /dev/null +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Persons.java @@ -0,0 +1,30 @@ +package fr.ifremer.tutti.persistence.entities.referential; + +import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; + +public class Persons extends AbstractPersons { + + /** + * Is the given {@code person} a temporary data ? + * + * @param person person to test + * @return {@code true} if the given {@code person} is temporary + * @since 3.8 + */ + public static boolean isTemporary(Person person) { + + Preconditions.checkNotNull(person); + Preconditions.checkNotNull(person.getId()); + + return TuttiReferentialEntities.isStatusTemporary(person) && person.getIdAsInt() < 0; + + } + + public static final Predicate<Person> IS_TEMPORARY = new Predicate<Person>() { + @Override + public boolean apply(Person input) { + return Persons.isTemporary(input); + } + }; +} diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Speciess.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Speciess.java index d29899c..e378151 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Speciess.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Speciess.java @@ -25,6 +25,8 @@ package fr.ifremer.tutti.persistence.entities.referential; */ import com.google.common.base.Function; +import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; @@ -39,6 +41,29 @@ import java.util.Set; public class Speciess extends AbstractSpeciess { + public static final Predicate<Species> IS_TEMPORARY = new Predicate<Species>() { + @Override + public boolean apply(Species input) { + return isTemporary(input); + } + }; + + /** + * Is the given {@code species} a temporary data ? + * + * @param species species to test + * @return {@code true} if the given {@code species} is temporary + * @since 3.8 + */ + public static boolean isTemporary(Species species) { + + Preconditions.checkNotNull(species); + Preconditions.checkNotNull(species.getId()); + + return TuttiReferentialEntities.isStatusTemporary(species) && species.getIdAsInt() < 0; + + } + public static final Comparator<Species> SPECIES_BY_NAME_COMPARATOR = new Comparator<Species>() { public int compare(Species o1, Species o2) { diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/TuttiReferentialEntities.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/TuttiReferentialEntities.java new file mode 100644 index 0000000..d6cdd47 --- /dev/null +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/TuttiReferentialEntities.java @@ -0,0 +1,22 @@ +package fr.ifremer.tutti.persistence.entities.referential; + +import com.google.common.base.Preconditions; +import fr.ifremer.adagio.core.dao.referential.StatusCode; + +/** + * Created on 11/4/14. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 3.8 + */ +public class TuttiReferentialEntities { + + public static boolean isStatusTemporary(TuttiReferentialEntity entity) { + + Preconditions.checkNotNull(entity.getStatus()); + + return StatusCode.TEMPORARY.getValue().equals(entity.getStatus().getId()); + + } + +} diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Vessels.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Vessels.java new file mode 100644 index 0000000..dbe5b0d --- /dev/null +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Vessels.java @@ -0,0 +1,31 @@ +package fr.ifremer.tutti.persistence.entities.referential; + +import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; +import fr.ifremer.adagio.core.dao.technical.hibernate.TemporaryDataHelper; + +public class Vessels extends AbstractVessels { + + public static final Predicate<Vessel> IS_TEMPORARY = new Predicate<Vessel>() { + @Override + public boolean apply(Vessel input) { + return isTemporary(input); + } + }; + + /** + * Is the given {@code vessel} a temporary data ? + * + * @param vessel vessel to test + * @return {@code true} if the given {@code vessel} is temporary + * @since 3.8 + */ + public static boolean isTemporary(Vessel vessel) { + + Preconditions.checkNotNull(vessel); + Preconditions.checkNotNull(vessel.getId()); + + return TuttiReferentialEntities.isStatusTemporary(vessel) && vessel.getId().startsWith(TemporaryDataHelper.TEMPORARY_NAME_PREFIX); + + } +} diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/GearPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/GearPersistenceService.java index ac950d4..b1db9f0 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/GearPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/GearPersistenceService.java @@ -2,7 +2,6 @@ package fr.ifremer.tutti.persistence.service.referential; import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; import fr.ifremer.tutti.persistence.entities.referential.Gear; -import fr.ifremer.tutti.persistence.entities.referential.Person; import org.springframework.cache.annotation.CacheEvict; import org.springframework.transaction.annotation.Transactional; @@ -25,15 +24,6 @@ public interface GearPersistenceService extends TuttiPersistenceServiceImplement Gear getGear(Integer gearId); /** - * Is the given {@code gear} a temporary data ? - * - * @param gear gear to test - * @return {@code true} if the given {@code gear} is temporary - * @since 3.8 - */ - boolean isTemporaryGear(Gear gear); - - /** * Check if the temporary gear with the given {@code id} is used. * * @param id id of the gear to remove 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 7c43cdc..c5b9af0 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 @@ -74,11 +74,12 @@ public class GearPersistenceServiceImpl extends ReferentialPersistenceServiceSup } - @Override - public boolean isTemporaryGear(Gear entity) { - Preconditions.checkNotNull(entity.getId()); + protected boolean isTemporaryGear(Gear gear) { + + Preconditions.checkNotNull(gear); + Preconditions.checkNotNull(gear.getId()); - return isStatusTemporary(entity) && entity.getIdAsInt() < 0; + return isStatusTemporary(gear) && gear.getIdAsInt() < 0; } diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/PersonPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/PersonPersistenceService.java index ae844a0..863e748 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/PersonPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/PersonPersistenceService.java @@ -25,16 +25,6 @@ public interface PersonPersistenceService extends TuttiPersistenceServiceImpleme Person getPerson(Integer personId); /** - * Is the given {@code person} a temporary data ? - * - * @param person person to test - * @return {@code true} if the given {@code person} is temporary - * @since 3.8 - */ - boolean isTemporaryPerson(Person person); - - - /** * Check if the temporary person with the given {@code id} is used. * * @param id id of the person to check 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 d4d4886..a9ee7f9 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 @@ -66,15 +66,6 @@ public class PersonPersistenceServiceImpl extends ReferentialPersistenceServiceS } @Override - public boolean isTemporaryPerson(Person entity) { - - Preconditions.checkNotNull(entity.getId()); - - return isStatusTemporary(entity) && entity.getIdAsInt() < 0; - - } - - @Override public boolean isTemporaryPersonUsed(Integer id) { Long count = queryUniqueTyped("countManagerPersonInScientificCruise", "id", IntegerType.INSTANCE, id); boolean result = count > 0; @@ -117,8 +108,8 @@ public class PersonPersistenceServiceImpl extends ReferentialPersistenceServiceS Preconditions.checkNotNull(source); Preconditions.checkNotNull(target); - Preconditions.checkState(isTemporaryPerson(source)); - Preconditions.checkState(!isTemporaryPerson(target)); + Preconditions.checkState(Persons.isTemporary(source)); + Preconditions.checkState(!Persons.isTemporary(target)); Integer sourceId = source.getIdAsInt(); Integer targetId = target.getIdAsInt(); diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/ReferentialPersistenceServiceSupport.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/ReferentialPersistenceServiceSupport.java index 8d3193b..9228784 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/ReferentialPersistenceServiceSupport.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/ReferentialPersistenceServiceSupport.java @@ -3,7 +3,6 @@ package fr.ifremer.tutti.persistence.service.referential; import com.google.common.base.Preconditions; import fr.ifremer.adagio.core.dao.referential.StatusCode; import fr.ifremer.adagio.core.dao.referential.StatusDao; -import fr.ifremer.adagio.core.dao.technical.hibernate.TemporaryDataHelper; import fr.ifremer.adagio.core.service.technical.CacheService; import fr.ifremer.tutti.persistence.entities.referential.Status; import fr.ifremer.tutti.persistence.entities.referential.Statuss; @@ -27,12 +26,13 @@ public abstract class ReferentialPersistenceServiceSupport extends AbstractPersi @Resource(name = "cacheService") protected CacheService cacheService; - - public boolean isStatusTemporary(TuttiReferentialEntity entity) { - Preconditions.checkNotNull(entity); + + protected boolean isStatusTemporary(TuttiReferentialEntity entity) { + Preconditions.checkNotNull(entity.getStatus()); return StatusCode.TEMPORARY.getValue().equals(entity.getStatus().getId()); + } protected Iterator<Object[]> queryListWithStatus(String queryName, diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/SpeciesPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/SpeciesPersistenceService.java index e9325a0..d3663ca 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/SpeciesPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/SpeciesPersistenceService.java @@ -60,15 +60,6 @@ public interface SpeciesPersistenceService extends TuttiPersistenceServiceImplem Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer referenceTaxonId); /** - * Is the given {@code species} a temporary data ? - * - * @param species species to test - * @return {@code true} if the given {@code species} is temporary - * @since 3.8 - */ - boolean isTemporarySpecies(Species species); - - /** * Check if the temporary species with the given {@code id} is used. * * @param id id of the species to check diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/SpeciesPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/SpeciesPersistenceServiceImpl.java index 94dd51e..cf50b7f 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/SpeciesPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/SpeciesPersistenceServiceImpl.java @@ -130,14 +130,6 @@ public class SpeciesPersistenceServiceImpl extends ReferentialPersistenceService } @Override - public boolean isTemporarySpecies(Species entity) { - Preconditions.checkNotNull(entity.getId()); - - return isStatusTemporary(entity) && entity.getIdAsInt() < 0; - - } - - @Override public boolean isTemporarySpeciesUsed(Integer id) { Long count = queryUniqueTyped("countReferenceTaxonInSortingBatch", "id", IntegerType.INSTANCE, id); @@ -168,8 +160,8 @@ public class SpeciesPersistenceServiceImpl extends ReferentialPersistenceService Preconditions.checkNotNull(source); Preconditions.checkNotNull(target); - Preconditions.checkState(isTemporarySpecies(source)); - Preconditions.checkState(!isTemporarySpecies(target)); + Preconditions.checkState(Speciess.isTemporary(source)); + Preconditions.checkState(!Speciess.isTemporary(target)); Integer sourceId = source.getReferenceTaxonId(); Integer targetId = target.getReferenceTaxonId(); diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/VesselPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/VesselPersistenceService.java index b08de30..5f2b4db 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/VesselPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/VesselPersistenceService.java @@ -45,15 +45,6 @@ public interface VesselPersistenceService extends TuttiPersistenceServiceImpleme Vessel getVessel(String vesselCode); /** - * Is the given {@code vessel} a temporary data ? - * - * @param vessel vessel to test - * @return {@code true} if the given {@code vessel} is temporary - * @since 3.8 - */ - boolean isTemporaryVessel(Vessel vessel); - - /** * Check if the temporary vessel with the given {@code id} is used. * * @param code code of the vessel to remove 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 f7ef5ad..20ca8c6 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 @@ -116,14 +116,6 @@ public class VesselPersistenceServiceImpl extends ReferentialPersistenceServiceS } @Override - public boolean isTemporaryVessel(Vessel vessel) { - Preconditions.checkNotNull(vessel.getId()); - - return isStatusTemporary(vessel) && vessel.getId().startsWith(TemporaryDataHelper.TEMPORARY_NAME_PREFIX); - - } - - @Override public boolean isTemporaryVesselUsed(String code) { Long count = queryUniqueTyped("countVesselInCruise", "id", StringType.INSTANCE, code); @@ -201,8 +193,8 @@ public class VesselPersistenceServiceImpl extends ReferentialPersistenceServiceS Preconditions.checkNotNull(source); Preconditions.checkNotNull(target); - Preconditions.checkState(isTemporaryVessel(source)); - Preconditions.checkState(!isTemporaryVessel(target)); + Preconditions.checkState(Vessels.isTemporary(source)); + Preconditions.checkState(!Vessels.isTemporary(target)); String sourceId = source.getId(); String targetId = target.getId(); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java index 041494d..2d999f3 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java @@ -55,13 +55,16 @@ import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Gear; +import fr.ifremer.tutti.persistence.entities.referential.Gears; import fr.ifremer.tutti.persistence.entities.referential.ObjectType; import fr.ifremer.tutti.persistence.entities.referential.Person; +import fr.ifremer.tutti.persistence.entities.referential.Persons; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.persistence.entities.referential.Speciess; import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation; import fr.ifremer.tutti.persistence.entities.referential.TuttiReferentialEntity; import fr.ifremer.tutti.persistence.entities.referential.Vessel; +import fr.ifremer.tutti.persistence.entities.referential.Vessels; import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; @@ -107,34 +110,6 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer protected TuttiPersistence driver; - private final Predicate<Gear> isTemporaryGearPredicate = new Predicate<Gear>() { - @Override - public boolean apply(Gear input) { - return isTemporaryGear(input); - } - }; - - private final Predicate<Person> isTemporaryPersonPredicate = new Predicate<Person>() { - @Override - public boolean apply(Person input) { - return isTemporaryPerson(input); - } - }; - - private final Predicate<Species> isTemporarySpeciesPredicate = new Predicate<Species>() { - @Override - public boolean apply(Species input) { - return isTemporarySpecies(input); - } - }; - - private final Predicate<Vessel> isTemporaryVesselPredicate = new Predicate<Vessel>() { - @Override - public boolean apply(Vessel input) { - return isTemporaryVessel(input); - } - }; - @Override public void setServiceContext(TuttiServiceContext context) { super.setServiceContext(context); @@ -144,28 +119,28 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer public List<Gear> retainTemporaryGearList(List<Gear> targetList) { - List<Gear> sourceList = retainTemporaryList(isTemporaryGearPredicate, targetList); + List<Gear> sourceList = retainTemporaryList(Gears.IS_TEMPORARY, targetList); return sourceList; } public List<Person> retainTemporaryPersonList(List<Person> targetList) { - List<Person> sourceList = retainTemporaryList(isTemporaryPersonPredicate, targetList); + List<Person> sourceList = retainTemporaryList(Persons.IS_TEMPORARY, targetList); return sourceList; } public List<Species> retainTemporarySpeciesList(List<Species> targetList) { - List<Species> sourceList = retainTemporaryList(isTemporarySpeciesPredicate, targetList); + List<Species> sourceList = retainTemporaryList(Speciess.IS_TEMPORARY, targetList); return sourceList; } public List<Vessel> retainTemporaryVesselList(List<Vessel> targetList) { - List<Vessel> sourceList = retainTemporaryList(isTemporaryVesselPredicate, targetList); + List<Vessel> sourceList = retainTemporaryList(Vessels.IS_TEMPORARY, targetList); return sourceList; } @@ -1084,25 +1059,25 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer driver.deleteTemporaryVessels(codes, checkIfUsed); } - @Override - public boolean isTemporaryGear(Gear gear) { - return driver.isTemporaryGear(gear); - } +// @Override +// public boolean isTemporary(Gear gear) { +// return driver.isTemporary(gear); +// } - @Override - public boolean isTemporaryPerson(Person person) { - return driver.isTemporaryPerson(person); - } +// @Override +// public boolean isTemporary(Person person) { +// return driver.isTemporary(person); +// } - @Override - public boolean isTemporarySpecies(Species species) { - return driver.isTemporarySpecies(species); - } +// @Override +// public boolean isTemporary(Species species) { +// return driver.isTemporary(species); +// } - @Override - public boolean isTemporaryVessel(Vessel vessel) { - return driver.isTemporaryVessel(vessel); - } +// @Override +// public boolean isTemporary(Vessel vessel) { +// return driver.isTemporary(vessel); +// } @Override public boolean isTemporaryPersonUsed(Integer id) { diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialExportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialExportService.java index 22f82dc..be34c35 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialExportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialExportService.java @@ -38,6 +38,8 @@ import fr.ifremer.tutti.service.AbstractTuttiService; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.TuttiServiceContext; 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.jaxx.application.ApplicationTechnicalException; @@ -56,6 +58,9 @@ import static org.nuiton.i18n.I18n.t; */ public class ReferentialExportService extends AbstractTuttiService { + /** Logger. */ + private static final Log log = LogFactory.getLog(ReferentialExportService.class); + protected PersistenceService persistenceService; @Override @@ -66,10 +71,18 @@ public class ReferentialExportService extends AbstractTuttiService { public void exportExistingTemporarySpecies(File file) throws IOException { + if (log.isInfoEnabled()) { + log.info("Getting all species from database"); + } List<Species> targetList = Lists.newArrayList(persistenceService.getAllReferentSpecies()); + if (log.isInfoEnabled()) { + log.info("Got " + targetList.size() + " species"); + } List<Species> toExport = persistenceService.retainTemporarySpeciesList(targetList); - + if (log.isInfoEnabled()) { + log.info("Got " + toExport.size() + " temporary species"); + } exportTemporarySpecies(file, toExport); } @@ -78,20 +91,21 @@ public class ReferentialExportService extends AbstractTuttiService { List<Species> toExport = Lists.newArrayList(); - Species s; - - s = Speciess.newSpecies(); - s.setName("Temporary Species name 1"); - toExport.add(s); - - s = Speciess.newSpecies(); - s.setName("Temporary Species name 2"); - toExport.add(s); - - s = Speciess.newSpecies(); - s.setName("Temporary Species name 3"); - toExport.add(s); - + { + Species s = Speciess.newSpecies(); + s.setName("Temporary Species name 1"); + toExport.add(s); + } + { + Species s = Speciess.newSpecies(); + s.setName("Temporary Species name 2"); + toExport.add(s); + } + { + Species s = Speciess.newSpecies(); + s.setName("Temporary Species name 3"); + toExport.add(s); + } exportTemporarySpecies(file, toExport); } @@ -125,11 +139,19 @@ public class ReferentialExportService extends AbstractTuttiService { public void exportExistingTemporaryVessel(File file) throws IOException { + if (log.isInfoEnabled()) { + log.info("Getting all vessels from database"); + } List<Vessel> targetList = Lists.newArrayList(persistenceService.getAllFishingVessel()); targetList.addAll(persistenceService.getAllScientificVessel()); - + if (log.isInfoEnabled()) { + log.info("Got " + targetList.size() + " vessels"); + } List<Vessel> toExport = persistenceService.retainTemporaryVesselList(targetList); + if (log.isInfoEnabled()) { + log.info("Got " + toExport.size() + " temporary vessels"); + } exportTemporaryVessel(file, toExport); } @@ -138,36 +160,38 @@ public class ReferentialExportService extends AbstractTuttiService { List<Vessel> toExport = Lists.newArrayList(); - Vessel v; - - v = Vessels.newVessel(); - v.setRegistrationCode("RegCode1"); - v.setName("Temporary fishing vessel name 1"); - v.setInternationalRegistrationCode("International registration code F1"); - v.setScientificVessel(false); - toExport.add(v); - - v = Vessels.newVessel(); - v.setRegistrationCode("RegCode2"); - v.setName("Temporary fishing vessel name 2"); - v.setInternationalRegistrationCode("International registration code F2"); - v.setScientificVessel(false); - toExport.add(v); - - v = Vessels.newVessel(); - v.setRegistrationCode("RegCode3"); - v.setName("Temporary scientific vessel name 3"); - v.setInternationalRegistrationCode("International registration code S3"); - v.setScientificVessel(true); - toExport.add(v); - - v = Vessels.newVessel(); - v.setRegistrationCode("RegCode4"); - v.setName("Temporary scientific vessel name 4"); - v.setInternationalRegistrationCode("International registration code S4"); - v.setScientificVessel(true); - toExport.add(v); - + { + Vessel v = Vessels.newVessel(); + v.setRegistrationCode("RegCode1"); + v.setName("Temporary fishing vessel name 1"); + v.setInternationalRegistrationCode("International registration code F1"); + v.setScientificVessel(false); + toExport.add(v); + } + { + Vessel v = Vessels.newVessel(); + v.setRegistrationCode("RegCode2"); + v.setName("Temporary fishing vessel name 2"); + v.setInternationalRegistrationCode("International registration code F2"); + v.setScientificVessel(false); + toExport.add(v); + } + { + Vessel v = Vessels.newVessel(); + v.setRegistrationCode("RegCode3"); + v.setName("Temporary scientific vessel name 3"); + v.setInternationalRegistrationCode("International registration code S3"); + v.setScientificVessel(true); + toExport.add(v); + } + { + Vessel v = Vessels.newVessel(); + v.setRegistrationCode("RegCode4"); + v.setName("Temporary scientific vessel name 4"); + v.setInternationalRegistrationCode("International registration code S4"); + v.setScientificVessel(true); + toExport.add(v); + } exportTemporaryVessel(file, toExport); } @@ -200,10 +224,17 @@ public class ReferentialExportService extends AbstractTuttiService { public void exportExistingTemporaryPerson(File file) throws IOException { + if (log.isInfoEnabled()) { + log.info("Getting all persons from database"); + } List<Person> targetList = Lists.newArrayList(persistenceService.getAllPerson()); - + if (log.isInfoEnabled()) { + log.info("Got " + targetList.size() + " persons"); + } List<Person> toExport = persistenceService.retainTemporaryPersonList(targetList); - + if (log.isInfoEnabled()) { + log.info("Got " + toExport.size() + " temporary persons"); + } exportTemporaryPerson(file, toExport); } @@ -261,42 +292,53 @@ public class ReferentialExportService extends AbstractTuttiService { public void exportExistingTemporaryGear(File file) throws IOException { + if (log.isInfoEnabled()) { + log.info("Getting all gears from database"); + } + List<Gear> targetList = Lists.newArrayList(persistenceService.getAllFishingGear()); targetList.addAll(persistenceService.getAllScientificGear()); - + if (log.isInfoEnabled()) { + log.info("Got " + targetList.size() + " gears"); + } List<Gear> toExport = persistenceService.retainTemporaryGearList(targetList); - + if (log.isInfoEnabled()) { + log.info("Got " + toExport.size() + " temporary gears"); + } exportTemporaryGear(file, toExport); } public void exportTemporaryGearExample(File file) throws IOException { - List<Gear> toExport = Lists.newArrayList(); - - Gear g; - - g = Gears.newGear(); - g.setName("Gear fishing name 1"); - g.setLabel("Gear fishing label 1"); - toExport.add(g); - - g = Gears.newGear(); - g.setName("Gear fishing name 2"); - g.setLabel("Gear fishing label 2"); - toExport.add(g); - - g = Gears.newGear(); - g.setName("Gear scientific name 3"); - g.setLabel("Gear scientific label 3"); - g.setScientificGear(true); - toExport.add(g); - g = Gears.newGear(); - g.setName("Gear scientific name 4"); - g.setLabel("Gear scientific label 4"); - g.setScientificGear(true); - toExport.add(g); + List<Gear> toExport = Lists.newArrayList(); + { + Gear g = Gears.newGear(); + g.setName("Gear fishing name 1"); + g.setLabel("Gear fishing label 1"); + toExport.add(g); + } + { + Gear g = Gears.newGear(); + g.setName("Gear fishing name 2"); + g.setLabel("Gear fishing label 2"); + toExport.add(g); + } + { + Gear g = Gears.newGear(); + g.setName("Gear scientific name 3"); + g.setLabel("Gear scientific label 3"); + g.setScientificGear(true); + toExport.add(g); + } + { + Gear g = Gears.newGear(); + g.setName("Gear scientific name 4"); + g.setLabel("Gear scientific label 4"); + g.setScientificGear(true); + toExport.add(g); + } exportTemporaryGear(file, toExport); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.