r365 - in trunk/tutti-persistence/src/main: java/fr/ifremer/tutti/persistence/service resources
Author: blavenier Date: 2013-02-08 17:15:42 +0100 (Fri, 08 Feb 2013) New Revision: 365 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/365 Log: Fix : - change call of adagio-core->TaxonNameDao (new API for synonyms management) Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java trunk/tutti-persistence/src/main/resources/applicationContext-service-tutti.xml Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-08 10:29:38 UTC (rev 364) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-08 16:15:42 UTC (rev 365) @@ -28,6 +28,9 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ifremer.adagio.core.dao.referential.StatusDao; +import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxon; +import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxonDao; +import fr.ifremer.adagio.core.dao.referential.taxon.TaxonName; import fr.ifremer.adagio.core.dao.referential.taxon.TaxonNameExtendDao; import fr.ifremer.adagio.core.dao.referential.taxon.TaxonRefTaxVO; import fr.ifremer.tutti.persistence.entities.TuttiEntities; @@ -50,6 +53,7 @@ import org.hibernate.type.DateType; import org.hibernate.type.IntegerType; import org.hibernate.type.StringType; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @@ -78,6 +82,9 @@ @Resource(name = "statusDao") protected StatusDao statusDao; + + @Resource(name = "referenceTaxonDao") + protected ReferenceTaxonDao referenceTaxonDao; //------------------------------------------------------------------------// //-- ReferentialPersistenceService implentation --// @@ -213,7 +220,7 @@ } @Override - @Cacheable(value = "tuttiAllFishingVessel") + @Cacheable(value = "fishingVessels") public List<Vessel> getAllFishingVessel() { Iterator<Object[]> list = queryListWithStatus( "allVessels", @@ -363,9 +370,10 @@ } @Override + @Cacheable(value = "species") public List<Species> getAllSpecies() { - TaxonRefTaxVO[] sources = taxonNameDao.getAllTaxonRefTax(); + TaxonRefTaxVO[] sources = taxonNameDao.getAllTaxonNames(true); List<Species> result = Lists.newArrayList(); for (TaxonRefTaxVO source : sources) { @@ -376,8 +384,9 @@ } @Override + //TODO manage Cacheable(value = "species") public Species getSpecies(String speciesId) { - TaxonRefTaxVO source = taxonNameDao.getTaxonRefTax( + TaxonRefTaxVO source = taxonNameDao.getTaxonNameReferent( Integer.valueOf(speciesId)); Species target = loadSpecies(source); @@ -385,6 +394,7 @@ } @Override + @Cacheable(value = "pmfms") public List<Caracteristic> getAllCaracteristic() { Iterator<Object[]> sources = queryListWithStatus( "allPmfm", @@ -454,6 +464,7 @@ } @Override + //TODO manage Cacheable(value = "pmfms") public Caracteristic getCaracteristic(Integer pmfmId) { Object[] source = queryUniqueWithStatus("pmfmById", "pmfmId", IntegerType.INSTANCE, pmfmId, @@ -463,24 +474,34 @@ } @Override + @CacheEvict (value = "species") public List<Species> importTemporarySpecies(List<Species> species) { - //TODO - return null; + List<Species> result = Lists.newArrayList(); + for (Iterator iterator = species.iterator(); iterator.hasNext();) { + Species source = (Species) iterator.next(); + + source = importTemporarySpecies(source); + result.add(source); + } + return result; } @Override + @CacheEvict (value = "fishingVessels") public List<Vessel> importTemporaryVessel(List<Vessel> vessels) { //TODO return null; } @Override + @CacheEvict (value = "persons") public List<Person> importTemporaryPerson(List<Person> persons) { //TODO return null; } @Override + @CacheEvict (value = "gears") public List<Gear> importTemporaryGear(List<Gear> gears) { //TODO return null; @@ -489,6 +510,31 @@ //------------------------------------------------------------------------// //-- Internal methods --// //------------------------------------------------------------------------// + + protected Species importTemporarySpecies(Species source) { + Preconditions.checkNotNull(source); + Preconditions.checkNotNull(source.getName()); + + // Generate a new id for referenceTaxon + Integer referenceTaxonId = queryUniqueTyped( + "newReferenceTaxonTemporaryId"); + + ReferenceTaxon referenceTaxon = ReferenceTaxon.Factory.newInstance(); + referenceTaxon.setId(referenceTaxonId); + referenceTaxon.setName(source.getName()); + + referenceTaxon = referenceTaxonDao.create(referenceTaxon); +// source.setReferenceTaxonId() + + TaxonName taxonName = TaxonName.Factory.newInstance(); + taxonName.setIsTemporary(true); + taxonName.setIsReferent(true); + taxonName.setReferenceTaxon(referenceTaxon); + taxonName.setName(source.getName()); + + + return source; + } protected List<FishingOperationLocation> getFishingOperationLocations(Integer locationLevelId) { Iterator<Object[]> sources = queryListWithStatus( Modified: trunk/tutti-persistence/src/main/resources/applicationContext-service-tutti.xml =================================================================== --- trunk/tutti-persistence/src/main/resources/applicationContext-service-tutti.xml 2013-02-08 10:29:38 UTC (rev 364) +++ trunk/tutti-persistence/src/main/resources/applicationContext-service-tutti.xml 2013-02-08 16:15:42 UTC (rev 365) @@ -37,7 +37,11 @@ <bean id="tuttiEnumerationFile" init-method="init" class="fr.ifremer.tutti.persistence.service.TuttiEnumerationFile"/> - <!-- Specific caches for tutti (not defined in ehcache.xml) --> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <!-- Caches management for tutti (not defined in adagio-core/ehcache.xml) --> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + + <!-- Session caches : --> <bean id="tuttiAbstractCache" abstract="true" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager" ref="ehcache"/> <property name="maxElementsInMemory" value="5000"/> @@ -47,10 +51,14 @@ <property name="overflowToDisk" value="false"/> <property name="diskPersistent" value="false"/> <property name="diskExpiryThreadIntervalSeconds" value="300"/> - </bean> + </bean> + + <bean id="tuttiPmfmsCache" parent="tuttiAbstractEternalCache"> + <property name="cacheName" value="pmfms" /> + </bean> - <bean id="tuttiAllFishingVesselCache" parent="tuttiAbstractCache"> - <property name="cacheName" value="tuttiAllFishingVessel" /> + <!-- Eternal caches : --> + <bean id="tuttiAbstractEternalCache" abstract="true" parent="tuttiAbstractCache"> <property name="eternal" value="true"/> <property name="overflowToDisk" value="true"/> <property name="diskPersistent" value="true"/> @@ -59,6 +67,22 @@ <property name="timeToIdle" value="0"/> </bean> + <bean id="tuttiFishingVesselsCache" parent="tuttiAbstractEternalCache"> + <property name="cacheName" value="fishingVessels" /> + </bean> + + <bean id="tuttiSpeciesCache" parent="tuttiAbstractEternalCache"> + <property name="cacheName" value="species" /> + </bean> + + <bean id="tuttiGearsCache" parent="tuttiAbstractEternalCache"> + <property name="cacheName" value="gears" /> + </bean> + + <bean id="tuttiPersonsCache" parent="tuttiAbstractEternalCache"> + <property name="cacheName" value="persons" /> + </bean> + <!-- Example to use to create a new cache area : <bean id="tuttiOtherCache" parent="tuttiPersistenceDefaultCache"> </bean> -->
participants (1)
-
blavenier@users.forge.codelutin.com