Tutti-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
- 4058 discussions
r907 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: . content
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 16:27:16 +0200 (Wed, 01 May 2013)
New Revision: 907
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/907
Log:
fixes #2383: [TECH] - Mise ?\195?\160 jour de la base : ?\195?\169crasement des donn?\195?\169es si on force la mise ?\195?\160 jour
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-05-01 13:30:06 UTC (rev 906)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-05-01 14:27:16 UTC (rev 907)
@@ -146,10 +146,14 @@
dbInstalled = false;
dbUpdated = false;
} else {
- if (ApplicationUpdater.ZERO_VERSION.equals(info.oldVersion)) {
+ if (context.isDbExist()) {
+
+ // when db exists always an update
+ dbUpdated = true;
+ } else {
+
+ // when no db, then always install
dbInstalled = true;
- } else {
- dbUpdated = true;
}
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-05-01 13:30:06 UTC (rev 906)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-05-01 14:27:16 UTC (rev 907)
@@ -267,8 +267,7 @@
case DB: {
UpdateDbAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateDbAction.class);
action = logicAction;
- ApplicationInfo info = versions.get(appType);
- if (ApplicationUpdater.ZERO_VERSION.equals(info.oldVersion)) {
+ if (!getContext().isDbExist()) {
// install db
action.setActionDescription(
1
0
r906 - in trunk/tutti-persistence/src: main/java/fr/ifremer/tutti/persistence main/java/fr/ifremer/tutti/persistence/service main/java/fr/ifremer/tutti/persistence/service/batch main/resources/i18n test/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:30:06 +0200 (Wed, 01 May 2013)
New Revision: 906
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/906
Log:
refs #2221: Rendre les donn?\195?\169es CGFS compatible avec Tutti (am?\195?\169lioration validation arbre + api)
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -25,7 +25,6 @@
*/
import com.google.common.collect.Maps;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.adagio.core.service.technical.CacheService;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
@@ -579,12 +578,7 @@
@Override
public CatchBatch getCatchBatchFromFishingOperation(String id) throws InvalidBatchModelException {
- try {
- return catchBatchService.getCatchBatchFromFishingOperation(id);
- } catch (CatchBatchValidationException e) {
- throw new InvalidBatchModelException(
- "L'arbre d'échantillonage n'est pas compatible avec celui de Tutti.", e);
- }
+ return catchBatchService.getCatchBatchFromFishingOperation(id);
}
@Override
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -29,7 +29,6 @@
import fr.ifremer.adagio.core.dao.administration.programStrategy.Program;
import fr.ifremer.adagio.core.dao.administration.user.DepartmentImpl;
import fr.ifremer.adagio.core.dao.administration.user.PersonImpl;
-import fr.ifremer.adagio.core.dao.data.operation.FishingOperationDao;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationImpl;
import fr.ifremer.adagio.core.dao.data.sample.Sample;
import fr.ifremer.adagio.core.dao.data.sample.SampleDao;
@@ -79,9 +78,6 @@
@Autowired
protected SampleMeasurementPersistenceHelper sampleMeasurementPersistenceHelper;
- @Resource(name = "fishingOperationDao")
- protected FishingOperationDao fishingOperationDao;
-
@Resource(name = "sampleDao")
protected SampleDao sampleDao;
@@ -326,5 +322,4 @@
}
}
-
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -97,7 +97,7 @@
"allAttachment",
"objectId", IntegerType.INSTANCE, objectId,
"objectTypeCode", StringType.INSTANCE, objectType.getFieldValue()
- );
+ );
List<Attachment> result = Lists.newArrayList();
while (list.hasNext()) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -29,7 +29,6 @@
import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
@@ -43,14 +42,12 @@
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@@ -82,9 +79,6 @@
@Autowired
protected AttachmentPersistenceService attachmentPersistenceService;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
@@ -96,46 +90,43 @@
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- Preconditions.checkNotNull(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- Collection<Batch> catchBatchChils = catchBatch.getChildBatchs();
-
// Vrac / Benthos
- SortingBatch vracBenthosBatch = catchBatchDao.getSortingBatch(
- catchBatchChils,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ SortingBatch vracBenthosBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Vrac > Benthos > Alive Itemized",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
);
BatchContainer<BenthosBatch> result = new BatchContainer<BenthosBatch>();
- result.setId(vracBenthosBatch.getId());
+ if (vracBenthosBatch != null) {
+ result.setId(vracBenthosBatch.getId());
- for (Batch batch : vracBenthosBatch.getChildBatchs()) {
- SortingBatch source = (SortingBatch) batch;
- ReferenceTaxon referenceTaxon = source.getReferenceTaxon();
- Preconditions.checkNotNull(referenceTaxon, "Can't have a rootBenthosBatch with a null taxon, but was for " + batch.getId());
- Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId());
+ for (Batch batch : vracBenthosBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch;
+ ReferenceTaxon referenceTaxon = source.getReferenceTaxon();
+ Preconditions.checkNotNull(referenceTaxon, "Can't have a rootBenthosBatch with a null taxon, but was for " + batch.getId());
+ Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId());
- BenthosBatch target = TuttiBeanFactory.newBenthosBatch();
- target.setSpecies(species);
- entityToBenthosBatch(source, target);
- result.addChildren(target);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Benthos > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
+ BenthosBatch target = TuttiBeanFactory.newBenthosBatch();
+ target.setSpecies(species);
+ entityToBenthosBatch(source, target);
+ result.addChildren(target);
+ if (log.isInfoEnabled()) {
+ log.info("Loaded CatchBatch Vrac > Benthos > Alive Itemized > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId());
+ }
}
}
// Hors-Vrac / Benthos
- SortingBatch horsVracBenthosBatch = catchBatchDao.getSortingBatch(
- catchBatchChils,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS
+ SortingBatch horsVracBenthosBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Hors Vrac > Benthos",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS
);
if (horsVracBenthosBatch != null) {
for (Batch batch : horsVracBenthosBatch.getChildBatchs()) {
@@ -150,7 +141,7 @@
entityToBenthosBatch(source, target);
result.addChildren(target);
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > Benthos > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
+ log.info("Loaded CatchBatch Hors Vrac > Benthos > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId());
}
}
}
@@ -167,20 +158,11 @@
Preconditions.checkNotNull(bean.getFishingOperation());
Preconditions.checkNotNull(bean.getFishingOperation().getId());
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- // Load full batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(bean.getFishingOperation().getId(), false);
SortingBatch batch = SortingBatch.Factory.newInstance();
benthosBatchToEntity(bean, batch, parentBatchId, catchBatch);
- batch = catchBatchDao.createSortingBatch(batch, catchBatch);
+ bean = batchHelper.createSortingBatch(bean, catchBatch, batch);
- bean.setId(batch.getId());
-
- getCurrentSession().flush();
-
return bean;
}
@@ -189,23 +171,16 @@
Preconditions.checkNotNull(bean);
Preconditions.checkNotNull(bean.getId());
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
- Preconditions.checkNotNull(catchBatchId);
+ Integer batchId = bean.getIdAsInt();
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(batchId);
+ SortingBatch batch = batchHelper.getSortingBatchById(catchBatch, batchId);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, bean.getIdAsInt());
String parentBatchId = null;
if (bean.getParentBatch() != null) {
parentBatchId = bean.getParentBatch().getId();
}
benthosBatchToEntity(bean, batch, parentBatchId, catchBatch);
- catchBatchDao.updateSortingBatch(batch, catchBatch);
- getCurrentSession().flush();
+ batchHelper.updateSortingBatch(batch, catchBatch);
return bean;
}
@@ -214,37 +189,22 @@
public void deleteBenthosBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer batchId = Integer.valueOf(id);
- catchBatchDao.removeWithChildren(batchId);
+ batchHelper.removeWithChildren(batchId);
attachmentPersistenceService.deleteAllAttachment(
AttachementObjectTypeEnum.BATCH,
batchId);
-
- getCurrentSession().flush();
}
@Override
public void deleteBenthosSubBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
Integer benthosBatchId = Integer.valueOf(id);
- // get catch batch
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(benthosBatchId);
-
- Preconditions.checkNotNull(
- catchBatchId,
- "Could not find catchBatch for benthosBatch: " + benthosBatchId);
-
- CatchBatch catchBatch =
- catchBatchDao.loadFullTree(catchBatchId);
-
- // get species batch
- SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(benthosBatchId);
+ SortingBatch sortingBatch = batchHelper.getSortingBatchById(
catchBatch, benthosBatchId);
// get his children
@@ -260,7 +220,7 @@
if (log.isInfoEnabled()) {
log.info("Delete child [" + childBatchId + "] of species batch: " + id);
}
- catchBatchDao.removeWithChildren(childBatchId);
+ batchHelper.removeWithChildren(childBatchId);
// delete his attachment (if any)
attachmentPersistenceService.deleteAllAttachment(
@@ -268,8 +228,6 @@
childBatchId);
}
}
-
- getCurrentSession().flush();
}
@Override
@@ -279,7 +237,7 @@
Preconditions.checkNotNull(species);
Preconditions.checkNotNull(species.getReferenceTaxonId());
- catchBatchDao.setSortingBatchReferenceTaxon(batchId, species.getReferenceTaxonId());
+ batchHelper.setSortingBatchReferenceTaxon(batchId, species.getReferenceTaxonId());
}
//------------------------------------------------------------------------//
@@ -318,18 +276,15 @@
}
}
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer sortingBatchId = Integer.valueOf(benthosBatchId);
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(sortingBatchId);
if (catchBatch == null) {
return frequencies;
}
// Retrieve parent
- SortingBatch parentBatch = catchBatchDao.getSortingBatchById(catchBatch, sortingBatchId);
+ SortingBatch parentBatch = batchHelper.getSortingBatchById(catchBatch, sortingBatchId);
// Remember child ids, to remove unchanged item (see at bottom in this method)
List<Integer> notUpdatedChildIds = Lists.newArrayList();
@@ -352,13 +307,12 @@
benthosBatchFrequencyToEntity(source, target, parentBatch, rankOrder);
// Create the targeted batch, then update the source id
- catchBatchDao.createSortingBatch(target, catchBatch);
- source.setId(target.getId());
+ batchHelper.createSortingBatch(source, catchBatch, target);
}
// Existing batch
else {
- target = catchBatchDao.getSortingBatchById(catchBatch, source.getIdAsInt());
+ target = batchHelper.getSortingBatchById(catchBatch, source.getIdAsInt());
// Fill the sorting batch from the source
benthosBatchFrequencyToEntity(source, target, parentBatch, rankOrder);
@@ -372,17 +326,15 @@
// If some batchs need to be update, do it
if (batchsToUpdate.size() > 0) {
- catchBatchDao.updateSortingBatch(batchsToUpdate, catchBatch);
+ batchHelper.updateSortingBatch(batchsToUpdate, catchBatch);
}
if (notUpdatedChildIds.size() > 0) {
for (Integer batchId : notUpdatedChildIds) {
- catchBatchDao.removeWithChildren(batchId, catchBatch);
+ batchHelper.removeWithChildren(batchId, catchBatch);
}
}
- getCurrentSession().flush();
-
return Collections.unmodifiableList(frequencies);
}
@@ -416,7 +368,7 @@
if (source.getSortingMeasurements().size() == 1) {
sm = source.getSortingMeasurements().iterator().next();
} else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
- sm = catchBatchDao.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
+ sm = batchHelper.getInheritedSortingMeasurement(source);
}
if (sm != null) {
SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(sm.getPmfm().getId());
@@ -488,8 +440,6 @@
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -537,12 +487,14 @@
if (source.getWeight() == null && source.getSampleCategoryWeight() == null) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getSampleCategoryWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
} else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -555,20 +507,21 @@
samplingRatioText = samplingRatioText.replaceAll(",", ".");
target.setSamplingRatioText(samplingRatioText);
target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
- if ((source.getSampleCategoryType() == null || source.getSampleCategoryValue() == null)) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
+ if (source.getSampleCategoryType() != null && source.getSampleCategoryValue() != null) {
Integer pmfmId = source.getSampleCategoryType().getFieldValue();
// Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, recorderDepartmentId,
- source.getSampleCategoryType(), source.getSampleCategoryValue());
+ SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(
+ target,
+ source.getSampleCategoryType(),
+ source.getSampleCategoryValue());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
}
@@ -616,9 +569,6 @@
Preconditions.checkNotNull(source.getBatch());
Preconditions.checkNotNull(source.getBatch().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
-
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -645,21 +595,17 @@
target.setRankOrder(rankOrder);
// Weight or SampleCategoryWeight
- if (source.getWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
+ if (source.getWeight() != null) {
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
- if ((source.getLengthStepCaracteristic() == null || source.getLengthStep() == null)) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
+ if ((source.getLengthStepCaracteristic() != null && source.getLengthStep() != null)) {
Integer pmfmId = source.getLengthStepCaracteristic().getIdAsInt();
- SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, recorderDepartmentId, pmfmId,
+ SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, pmfmId,
source.getLengthStep());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
@@ -705,26 +651,5 @@
alphanumericalValue,
qualitativeValueId);
target.setSampleCategoryValue(categoryValue);
-// if (numericalvalue != null) {
-// target.setSampleCategoryValue(numericalvalue);
-// return;
-// }
-// if (alphanumericalValue != null) {
-// target.setSampleCategoryValue(alphanumericalValue);
-// return;
-// }
-//
-// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
-// if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
-// return;
-// }
-// CaracteristicQualitativeValue value = null;
-// for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
-// if (qualitativeValueId.equals(qv.getIdAsInt())) {
-// value = qv;
-// break;
-// }
-// }
-// target.setSampleCategoryValue(value);
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceService.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -24,8 +24,6 @@
* #L%
*/
-
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import org.springframework.transaction.annotation.Transactional;
@@ -42,9 +40,8 @@
*
* @param fishingOperationId id of the fihsing operation
* @return found catchBatch
- * @throws CatchBatchValidationException
*/
- CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException;
+ CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId);
/**
* Create the given CatchBatch and return it.
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -26,15 +26,10 @@
import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import fr.ifremer.adagio.core.dao.data.batch.Batch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
+import fr.ifremer.adagio.core.dao.data.batch.CatchBatchImpl;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
-import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationImpl;
import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus;
@@ -52,7 +47,6 @@
import javax.annotation.Resource;
import java.util.Collection;
-import java.util.Map;
import java.util.Set;
@Service("batchPersistenceService")
@@ -69,40 +63,20 @@
@Autowired
protected AttachmentPersistenceService attachmentPersistenceService;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
- @Resource(name = "scientificCruiseCatchBatchValidator")
- protected CatchBatchValidator catchBatchValidator;
-
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
- @Override
- public void init() {
- super.init();
- catchBatchDao.registerCatchBatchValidator(catchBatchValidator);
- }
-
- @Override
- public void close() {
- catchBatchDao.unregisterCatchBatchValidator(catchBatchValidator);
- super.close();
- }
-
//------------------------------------------------------------------------//
//-- CatchBatch methods --//
//------------------------------------------------------------------------//
@Override
- public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException {
+ public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- Preconditions.checkNotNull(catchBatchId);
-
// whenever want to repair anything from Tutti
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch source = catchBatchDao.loadFullTree(catchBatchId, true, false);
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch source =
+ batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, true);
CatchBatch result = new CatchBatchBean();
result.setId(source.getId());
@@ -113,176 +87,126 @@
}
// Vrac
- SortingBatch vracBatch = catchBatchDao.getSortingBatch(
- source.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch vracBatch = batchHelper.getSortingBatch(
+ source,
+ "Vrac",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_VRAC_ID);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac: " + vracBatch.getId());
- }
+
result.setCatchTotalSortedCarousselWeight(vracBatch.getWeight());
result.setCatchTotalSortedTremisWeight(vracBatch.getWeightBeforeSampling());
{
// Vrac > Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(
- vracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch(
+ vracBatch,
+ "Vrac > Species",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Species: " + speciesBatch.getId());
- }
+ if (vracSpeciesBatch != null) {
- result.setSpeciesTotalSortedWeight(speciesBatch.getWeight());
+ result.setSpeciesTotalSortedWeight(vracSpeciesBatch.getWeight());
- {
// Vrac > Species > Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch inertBatch = batchHelper.getSortingBatch(
+ vracSpeciesBatch,
+ "Vrac > Species > Inert",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
-
if (inertBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Species > Inert: " + inertBatch.getId());
- }
result.setSpeciesTotalInertWeight(inertBatch.getWeight());
}
// Vrac > Species > Alive not itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch(
+ vracSpeciesBatch,
+ "Vrac > Species > Alive not itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
if (livingNotItemizedBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Species > Alive not itemized: " + livingNotItemizedBatch.getId());
- }
result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
}
}
// Vrac > Benthos
- SortingBatch benthosBatch = catchBatchDao.getSortingBatch(
- vracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch vracBenthosBatch = batchHelper.getSortingBatch(
+ vracBatch,
+ "Vrac > Benthos",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Benthos: " + benthosBatch.getId());
- }
+ if (vracBenthosBatch != null) {
+ result.setBenthosTotalSortedWeight(vracBenthosBatch.getWeight());
- result.setBenthosTotalSortedWeight(benthosBatch.getWeight());
-
- {
// Vrac > Benthos > Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch inertBatch = batchHelper.getSortingBatch(
+ vracBenthosBatch,
+ "Vrac > Benthos > Inert",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
if (inertBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Benthos > Inert: " + inertBatch.getId());
- }
result.setBenthosTotalInertWeight(inertBatch.getWeight());
}
// Vrac > Benthos > Alive no itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch(
+ vracBenthosBatch,
+ "Vrac > Benthos > Alive not itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
if (livingNotItemizedBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Benthos > Alive not itemized: " + livingNotItemizedBatch.getId());
- }
result.setBenthosTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight());
}
}
-
- // TODO : Plancton...
}
// Hors Vrac
- SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(
- source.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch horsVracBatch = batchHelper.getSortingBatch(
+ source,
+ "Hors Vrac",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_HORS_VRAC_ID);
+
if (horsVracBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac: " + horsVracBatch.getId());
- }
- {
- // Hors Vrac > Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (speciesBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > Species: " + speciesBatch.getId());
- }
- }
+ // Hors Vrac > Species
+ batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Species",
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- // Hors Vrac > Benthos
- SortingBatch benthosBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ // Hors Vrac > Benthos
+ batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Benthos",
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ // Hors Vrac > MarineLitter
+ SortingBatch marineLitterBatch = batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > MarineLitter",
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
- if (benthosBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > Benthos: " + benthosBatch.getId());
- }
- }
-
- // Hors Vrac > MarineLitter
- SortingBatch marineLitterBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
-
-
- if (marineLitterBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > MarineLitter: " + marineLitterBatch.getId());
- }
-
- result.setMarineLitterTotalWeight(marineLitterBatch.getWeight());
- }
-
- // TODO : Plancton...
+ if (marineLitterBatch != null) {
+ result.setMarineLitterTotalWeight(marineLitterBatch.getWeight());
}
}
// Non trié
- SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(
- source.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch unsortedBatch = batchHelper.getSortingBatch(
+ source,
+ "Unsorted",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_UNSORTED_ID);
if (unsortedBatch != null) {
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Unsorted: " + unsortedBatch.getId());
- }
result.setCatchTotalRejectedWeight(unsortedBatch.getWeight());
}
@@ -298,8 +222,7 @@
fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = fr.ifremer.adagio.core.dao.data.batch.CatchBatch.Factory.newInstance();
catchBatchToEntity(bean, catchBatch);
- catchBatch = catchBatchDao.create(catchBatch);
- bean.setId(catchBatch.getId());
+ bean = batchHelper.createCatchBatch(bean, catchBatch);
// Link to fishing operation
getCurrentSession().flush();
@@ -324,13 +247,13 @@
getCurrentSession().enableFetchProfile("batch-with-childs");
getCurrentSession().setFlushMode(FlushMode.COMMIT);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.load(bean.getIdAsInt());
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = load(CatchBatchImpl.class, bean.getIdAsInt());
if (catchBatch == null) {
throw new DataRetrievalFailureException("Could not retrieve catch batch with id=" + bean.getId());
}
catchBatchToEntity(bean, catchBatch);
- catchBatchDao.update(catchBatch);
+ batchHelper.update(catchBatch);
getCurrentSession().flush();
return bean;
@@ -346,7 +269,6 @@
Preconditions.checkNotNull(source.getFishingOperation().getId());
// Retrieve recorder department
- Integer recorderDepartmentId = getRecorderDepartmentId();
// First initialization (when created)
Integer fishingOperationId = source.getFishingOperation().getIdAsInt();
@@ -364,11 +286,11 @@
}
// Total Weight
- if (source.getCatchTotalWeight() == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true);
+ if (source.getCatchTotalWeight() != null) {
+
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getCatchTotalWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -377,487 +299,110 @@
quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
}
- Map<Integer, SortingBatch> catchBatchChilds = getChildsMap(
- target, enumeration.PMFM_ID_SORTED_UNSORTED);
-
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// Vrac
- // -----------------------------------------------------------------------------
- {
- SortingBatch batch = catchBatchChilds.get(enumeration.QUALITATIVE_VRAC_ID);
- if (batch == null) {
- batch = SortingBatch.Factory.newInstance();
- target.getChildBatchs().add(batch);
- }
+ // ---------------------------------------------------------------------
+ SortingBatch vracBatch = batchHelper.getOrCreateVracBatch(
+ target,
+ source.getCatchTotalSortedCarousselWeight(),
+ source.getCatchTotalSortedTremisWeight());
- beanToEntitySortingBatch(target,
- target,
- batch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTED_UNSORTED,
- enumeration.QUALITATIVE_VRAC_ID,
- source.getCatchTotalSortedCarousselWeight(),
- source.getCatchTotalSortedTremisWeight());
- batch.setRankOrder((short) 1);
+ // ---------------------------------------------------------------------
+ // Vrac / Species
+ // ---------------------------------------------------------------------
- {
- if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Sets.<Batch>newHashSet());
- }
+ SortingBatch speciesBatch = batchHelper.getOrCreateSpeciesVracRootBatch(
+ target,
+ vracBatch,
+ source.getSpeciesTotalSortedWeight());
- Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
+ // ---------------------------------------------------------------------
+ // Vrac / Species / Alive not itemized
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateSpeciesVracAliveNotItemizeRootBatch(
+ target,
+ speciesBatch,
+ source.getSpeciesTotalLivingNotItemizedWeight());
- // -----------------------------------------------------------------------------
- // Vrac / Species
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
+ // Vrac / Species / Inert (not alive)
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateSpeciesVracInertRootBatch(
+ target,
+ speciesBatch,
+ source.getSpeciesTotalInertWeight());
- SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ // ---------------------------------------------------------------------
+ // Vrac / Species / Alive itemized
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateSpeciesVracAliveItemizeRootBatch(
+ target,
+ speciesBatch);
- if (speciesBatch == null) {
- speciesBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(speciesBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- speciesBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- source.getSpeciesTotalSortedWeight(),
- null);
- speciesBatch.setRankOrder((short) 1);
+ // ---------------------------------------------------------------------
+ // Vrac > Benthos
+ // ---------------------------------------------------------------------
+ SortingBatch benthosBatch = batchHelper.getOrCreateBenthosVracRootBatch(
+ target,
+ vracBatch,
+ source.getBenthosTotalSortedWeight());
- {
- if (speciesBatch.getChildBatchs() == null) {
- speciesBatch.setChildBatchs(Sets.<Batch>newHashSet());
- }
+ // ---------------------------------------------------------------------
+ // Vrac / Benthos / Alive not itemized
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateBenthosVracAliveNotItemizeRootBatch(
+ target,
+ benthosBatch,
+ source.getBenthosTotalLivingNotItemizedWeight());
- Map<Integer, SortingBatch> speciesBatchChilds = getChildsMap(speciesBatch, enumeration.PMFM_ID_SORTING_TYPE_2);
+ // ---------------------------------------------------------------------
+ // Vrac / Benthos / Inert (not alive)
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateBenthosVracInertRootBatch(
+ target,
+ benthosBatch,
+ source.getBenthosTotalInertWeight());
- // -----------------------------------------------------------------------------
- // Vrac / Species / Alive not itemized
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
+ // Vrac / Benthos / Alive itemized
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateBenthosVracAliveItemizeRootBatch(
+ target,
+ benthosBatch);
- SortingBatch aliveNotItemizedBatch = speciesBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
- if (aliveNotItemizedBatch == null) {
- aliveNotItemizedBatch = SortingBatch.Factory.newInstance();
- speciesBatch.getChildBatchs().add(aliveNotItemizedBatch);
- }
-
- beanToEntitySortingBatch(target,
- speciesBatch,
- aliveNotItemizedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED,
- source.getSpeciesTotalLivingNotItemizedWeight(),
- null);
- aliveNotItemizedBatch.setRankOrder((short) 1);
-
- // -----------------------------------------------------------------------------
- // Vrac / Species / Inert (not alive)
- // -----------------------------------------------------------------------------
-
- SortingBatch inertBatch = speciesBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
- if (inertBatch == null) {
- inertBatch = SortingBatch.Factory.newInstance();
- speciesBatch.getChildBatchs().add(inertBatch);
- }
-
- beanToEntitySortingBatch(target,
- speciesBatch,
- inertBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT,
- source.getSpeciesTotalInertWeight(),
- null);
- inertBatch.setRankOrder((short) 2);
-
- // -----------------------------------------------------------------------------
- // Vrac / Species / Alive itemized
- // -----------------------------------------------------------------------------
-
- SortingBatch aliveItemizedBatch = speciesBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
- if (aliveItemizedBatch == null) {
- aliveItemizedBatch = SortingBatch.Factory.newInstance();
- speciesBatch.getChildBatchs().add(aliveItemizedBatch);
- }
-
- beanToEntitySortingBatch(target,
- speciesBatch,
- aliveItemizedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED,
- null,
- null);
- aliveItemizedBatch.setRankOrder((short) 3);
- }
-
- // -----------------------------------------------------------------------------
- // Vrac > Benthos
- // -----------------------------------------------------------------------------
-
- SortingBatch benthosBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
-
- if (benthosBatch == null) {
- benthosBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(benthosBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- benthosBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
- source.getBenthosTotalSortedWeight(),
- null);
- benthosBatch.setRankOrder((short) 2);
-
- {
-
- if (benthosBatch.getChildBatchs() == null) {
- benthosBatch.setChildBatchs(Sets.<Batch>newHashSet());
- }
-
- Map<Integer, SortingBatch> benthosBatchChilds = getChildsMap(benthosBatch, enumeration.PMFM_ID_SORTING_TYPE_2);
-
- // -----------------------------------------------------------------------------
- // Vrac / Benthos / Alive not itemized
- // -----------------------------------------------------------------------------
-
- SortingBatch aliveNotItemizedBatch = benthosBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
- if (aliveNotItemizedBatch == null) {
- aliveNotItemizedBatch = SortingBatch.Factory.newInstance();
- benthosBatch.getChildBatchs().add(aliveNotItemizedBatch);
- }
-
- beanToEntitySortingBatch(target,
- benthosBatch,
- aliveNotItemizedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED,
- source.getBenthosTotalLivingNotItemizedWeight(),
- null);
- aliveNotItemizedBatch.setRankOrder((short) 1);
-
- // -----------------------------------------------------------------------------
- // Vrac / Benthos / Inert (not alive)
- // -----------------------------------------------------------------------------
-
- SortingBatch inertBatch = benthosBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
- if (inertBatch == null) {
- inertBatch = SortingBatch.Factory.newInstance();
- benthosBatch.getChildBatchs().add(inertBatch);
- }
-
- beanToEntitySortingBatch(target,
- benthosBatch,
- inertBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT,
- source.getBenthosTotalInertWeight(),
- null);
- inertBatch.setRankOrder((short) 2);
-
- // -----------------------------------------------------------------------------
- // Vrac / Benthos / Alive itemized
- // -----------------------------------------------------------------------------
-
- SortingBatch aliveItemizedBatch = benthosBatchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
- if (aliveItemizedBatch == null) {
- aliveItemizedBatch = SortingBatch.Factory.newInstance();
- benthosBatch.getChildBatchs().add(aliveItemizedBatch);
- }
-
- beanToEntitySortingBatch(target,
- benthosBatch,
- aliveItemizedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE_2,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED,
- null,
- null);
- aliveItemizedBatch.setRankOrder((short) 3);
- }
-
- // TODO plancton
- }
- }
-
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// Hors Vrac
- // -----------------------------------------------------------------------------
- {
- SortingBatch batch = catchBatchChilds.get(enumeration.QUALITATIVE_HORS_VRAC_ID);
- if (batch == null) {
- batch = SortingBatch.Factory.newInstance();
- target.getChildBatchs().add(batch);
- }
- beanToEntitySortingBatch(target,
- target,
- batch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTED_UNSORTED,
- enumeration.QUALITATIVE_HORS_VRAC_ID,
- null,
- null);
- batch.setRankOrder((short) 2);
+ // ---------------------------------------------------------------------
+ SortingBatch horsVracBatch = batchHelper.getOrCreateHorsVracBatch(target);
- {
- Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
- if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Sets.<Batch>newHashSet());
- }
- // -----------------------------------------------------------------------------
- // Hors Vrac > Species
- // -----------------------------------------------------------------------------
- {
- SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
- if (speciesBatch == null) {
- speciesBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(speciesBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- speciesBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- null,
- null);
- speciesBatch.setRankOrder((short) 1);
- }
+ // ---------------------------------------------------------------------
+ // Hors Vrac > Species
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateSpeciesHorsVracRootBatch(
+ target,
+ horsVracBatch);
- // -----------------------------------------------------------------------------
- // Hors Vrac > Benthos
- // -----------------------------------------------------------------------------
- {
- SortingBatch benthosBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
- if (benthosBatch == null) {
- benthosBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(benthosBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- benthosBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
- null,
- null);
- benthosBatch.setRankOrder((short) 2);
- }
+ // ---------------------------------------------------------------------
+ // Hors Vrac > Benthos
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateBenthosHorsVracRootBatch(
+ target,
+ horsVracBatch);
- // -----------------------------------------------------------------------------
- // Hors Vrac > MarineLitter
- // -----------------------------------------------------------------------------
- {
- SortingBatch marineLitterBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
- if (marineLitterBatch == null) {
- marineLitterBatch = SortingBatch.Factory.newInstance();
- batch.getChildBatchs().add(marineLitterBatch);
- }
- beanToEntitySortingBatch(target,
- batch,
- marineLitterBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER,
- source.getMarineLitterTotalWeight(),
- null);
- marineLitterBatch.setRankOrder((short) 3);
- }
+ // ---------------------------------------------------------------------
+ // Hors Vrac > MarineLitter
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateMarineLitterRootBatch(
+ target,
+ horsVracBatch,
+ source.getMarineLitterTotalWeight());
- // TODO : plancton
- }
-
- }
-
- // -----------------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// Unsorted (=rejected)
- // -----------------------------------------------------------------------------
- // Unsorted :
- SortingBatch unsortedBatch = catchBatchChilds.get(enumeration.QUALITATIVE_UNSORTED_ID);
- if (unsortedBatch == null) {
- unsortedBatch = SortingBatch.Factory.newInstance();
- target.getChildBatchs().add(unsortedBatch);
- }
- beanToEntitySortingBatch(target,
- target,
- unsortedBatch,
- recorderDepartmentId,
- enumeration.PMFM_ID_SORTED_UNSORTED,
- enumeration.QUALITATIVE_UNSORTED_ID,
- source.getCatchTotalRejectedWeight(),
- null);
- unsortedBatch.setRankOrder((short) 3);
- }
+ // ---------------------------------------------------------------------
+ batchHelper.getOrCreateRejectedBatch(
+ target, source.getCatchTotalRejectedWeight());
- protected Map<Integer, SortingBatch> getChildsMap(Batch parentBatch, Integer pmfmId) {
- Map<Integer, SortingBatch> batchByQualitativeValueId = Maps.newHashMap();
- if (parentBatch.getChildBatchs() == null) {
- return batchByQualitativeValueId;
- }
- for (Batch childBatch : parentBatch.getChildBatchs()) {
- SortingBatch childSortingBatch = (SortingBatch) childBatch;
- SortingMeasurement sm = catchBatchDao.getSortingMeasurement((SortingBatch) childBatch, pmfmId, null, false);
- if (sm != null && sm.getQualitativeValue() != null && sm.getQualitativeValue().getId() != null) {
- batchByQualitativeValueId.put(sm.getQualitativeValue().getId(), childSortingBatch);
- }
- }
- return batchByQualitativeValueId;
}
- protected void beanToEntitySortingBatch(
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
- Batch parentBatch,
- SortingBatch target,
- Integer recorderDepartmentId,
- Integer sortingPmfmId,
- Integer sortingQualitativeValueId,
- Float weight,
- Float weightBeforeSampling) {
-
- Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
- Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
-
- // Create lists to store all updates, then remove not updated items
- Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
- if (quantificationMeasurements != null) {
- notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
- }
- Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet();
- if (sortingMeasurements != null) {
- notChangedSortingMeasurements.addAll(sortingMeasurements);
- }
-
- // Some mandatory properties :
- QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
- target.setQualityFlag(qualityFlag);
- target.setRootBatch(rootBatch);
- target.setParentBatch(parentBatch);
- target.setExhaustiveInventory(true);
-
- // No taxon or taxon group
- target.setReferenceTaxon(null);
- target.setTaxonGroup(null);
-
- // Sorting measurement
- if (sortingPmfmId == null || sortingQualitativeValueId == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
- SortingMeasurement sm = batchHelper.setSortingMeasurement(target, recorderDepartmentId, sortingPmfmId, sortingQualitativeValueId);
- notChangedSortingMeasurements.remove(sm);
- }
-
- // Sampling Ratio
- if (weightBeforeSampling == null || weight == null) {
- target.setSamplingRatio(null);
- target.setSamplingRatioText(null);
- } else {
- String samplingRatioText = weight + "/" + weightBeforeSampling;
- samplingRatioText = samplingRatioText.replaceAll(",", ".");
- target.setSamplingRatioText(samplingRatioText);
- target.setSamplingRatio(weight / weightBeforeSampling);
- }
-
- // Weight
- if (weightBeforeSampling == null && weight == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else {
- Float batchReferenceWeight = weight;
- if (batchReferenceWeight == null) {
- batchReferenceWeight = weightBeforeSampling;
- }
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
- target,
- enumeration.PMFM_ID_WEIGHT_MEASURED,
- recorderDepartmentId,
- batchReferenceWeight,
- true);
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- }
-
- // Removed not changed measurements (in sorting and quantification measurement lists)
- if (quantificationMeasurements != null) {
- quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
- }
- if (sortingMeasurements != null) {
- sortingMeasurements.removeAll(notChangedSortingMeasurements);
- }
- }
-
-// protected void beanToEntityReferenceTaxonBatch(
-// fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
-// Batch parentBatch,
-// SortingBatch target,
-// Integer recorderDepartmentId,
-// Integer referenceTaxonId,
-// Float weight,
-// Float sampleWeight) {
-//
-// Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
-// Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
-//
-// // Create lists to store all updates, then remove not updated items
-// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
-// if (quantificationMeasurements != null) {
-// notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
-// }
-// Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet();
-// if (sortingMeasurements != null) {
-// notChangedSortingMeasurements.addAll(sortingMeasurements);
-// }
-//
-// // Some mandatory properties :
-// target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
-// target.setRootBatch(rootBatch);
-// target.setParentBatch(parentBatch);
-// target.setExhaustiveInventory(true);
-//
-// // Reference taxon
-// target.setReferenceTaxon(load(ReferenceTaxonImpl.class, referenceTaxonId));
-// target.setTaxonGroup(null);
-//
-// // Sampling Ratio
-// if ((sampleWeight == null || weight == null)) {
-// target.setSamplingRatio(null);
-// target.setSamplingRatioText(null);
-// } else {
-// String samplingRatioText = weight + "/" + sampleWeight;
-// samplingRatioText = samplingRatioText.replaceAll(",", ".");
-// target.setSamplingRatioText(samplingRatioText);
-// target.setSamplingRatio(weight / sampleWeight);
-// }
-//
-// // Weight
-// if ((sampleWeight == null && weight == null)) {
-// // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
-// } else {
-// Float batchReferenceWeight = weight;
-// if (batchReferenceWeight == null) {
-// batchReferenceWeight = sampleWeight;
-// }
-// QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
-// enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true);
-// notChangedQuantificationMeasurements.remove(quantificationMeasurement);
-// }
-//
-// // Removed not changed measurements (in sorting and quantification measurement lists)
-// if (quantificationMeasurements != null) {
-// quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
-// }
-// if (sortingMeasurements != null) {
-// sortingMeasurements.removeAll(notChangedSortingMeasurements);
-// }
-// }
-
- protected Integer getRecorderDepartmentId() {
- // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
- return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
- }
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -30,9 +30,7 @@
import fr.ifremer.adagio.core.dao.administration.user.DepartmentImpl;
import fr.ifremer.adagio.core.dao.administration.user.PersonImpl;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
-import fr.ifremer.adagio.core.dao.data.operation.FishingOperationDao;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationImpl;
import fr.ifremer.adagio.core.dao.data.sample.Sample;
import fr.ifremer.adagio.core.dao.data.sample.SampleDao;
@@ -83,12 +81,9 @@
@Autowired
protected SampleMeasurementPersistenceHelper sampleMeasurementPersistenceHelper;
- @Resource(name = "fishingOperationDao")
- protected FishingOperationDao fishingOperationDao;
+ @Resource(name = "batchPersistenceHelper")
+ protected BatchPersistenceHelper batchHelper;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
@Resource(name = "sampleDao")
protected SampleDao sampleDao;
@@ -323,20 +318,17 @@
}
protected SortingBatch getBatch(Integer operationId) {
+ Preconditions.checkNotNull(operationId);
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(operationId);
- Preconditions.checkNotNull(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(operationId.toString(), false);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
// Vrac / Species
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(
- catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Vrac > Species > Alive Itemized",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
);
Preconditions.checkNotNull(vracSpeciesBatch);
return vracSpeciesBatch;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -28,13 +28,11 @@
import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue;
-import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
@@ -45,9 +43,7 @@
import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -72,9 +68,6 @@
@Autowired
protected AttachmentPersistenceService attachmentPersistenceService;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
@@ -103,32 +96,29 @@
public BatchContainer<MarineLitterBatch> getRootMarineLitterBatch(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- Preconditions.checkNotNull(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
// Get marine litter root batch
- SortingBatch vracMarineLitterBatch = getMarineLitterParentBatch(catchBatch);
+ SortingBatch sortingBatch = getMarineLitterParentBatch(catchBatch);
BatchContainer<MarineLitterBatch> result = new BatchContainer<MarineLitterBatch>();
- result.setId(vracMarineLitterBatch.getId());
+ if (sortingBatch != null) {
+ result.setId(sortingBatch.getId());
- for (Batch batch1 : vracMarineLitterBatch.getChildBatchs()) {
- SortingBatch source = (SortingBatch) batch1;
+ for (Batch batch1 : sortingBatch.getChildBatchs()) {
+ SortingBatch source = (SortingBatch) batch1;
- MarineLitterBatch target = TuttiBeanFactory.newMarineLitterBatch();
- entityToMarineLitterBatch(source, target);
- result.addChildren(target);
+ MarineLitterBatch target = TuttiBeanFactory.newMarineLitterBatch();
+ entityToMarineLitterBatch(source, target);
+ result.addChildren(target);
- if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch MarineLetter > " +
- target.getMarineLitterCategory().getName() + " / " +
- target.getMarineLitterSizeCategory().getName() + " : " +
- target.getId());
+ if (log.isInfoEnabled()) {
+ log.info("Loaded CatchBatch Hors Vrac > MarineLetter > " +
+ target.getMarineLitterCategory().getName() + " / " +
+ target.getMarineLitterSizeCategory().getName() + ": " +
+ target.getId());
+ }
}
}
@@ -144,22 +134,12 @@
Preconditions.checkNotNull(bean.getMarineLitterCategory());
Preconditions.checkNotNull(bean.getMarineLitterSizeCategory());
Preconditions.checkNotNull(bean.getNumber());
-// Preconditions.checkNotNull(bean.getWeight());
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- // Load full batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(bean.getFishingOperation().getId(), false);
SortingBatch batch = SortingBatch.Factory.newInstance();
marineLitterBatchToEntity(bean, batch, catchBatch);
- batch = catchBatchDao.createSortingBatch(batch, catchBatch);
+ bean = batchHelper.createSortingBatch(bean, catchBatch, batch);
- bean.setId(batch.getId());
-
- getCurrentSession().flush();
-
return bean;
}
@@ -167,20 +147,11 @@
public MarineLitterBatch saveMarineLitterBatch(MarineLitterBatch bean) {
Preconditions.checkNotNull(bean);
Preconditions.checkNotNull(bean.getId());
-
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
- Preconditions.checkNotNull(catchBatchId);
-
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, bean.getIdAsInt());
+ Integer batchId = bean.getIdAsInt();
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(batchId);
+ SortingBatch batch = batchHelper.getSortingBatchById(catchBatch, batchId);
marineLitterBatchToEntity(bean, batch, catchBatch);
- catchBatchDao.updateSortingBatch(batch, catchBatch);
- getCurrentSession().flush();
+ batchHelper.updateSortingBatch(batch, catchBatch);
return bean;
}
@@ -189,16 +160,11 @@
public void deleteMarineLitterBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer batchId = Integer.valueOf(id);
- catchBatchDao.removeWithChildren(batchId);
+ batchHelper.removeWithChildren(batchId);
attachmentPersistenceService.deleteAllAttachment(
- AttachementObjectTypeEnum.BATCH,
- batchId);
-
- getCurrentSession().flush();
+ AttachementObjectTypeEnum.BATCH, batchId);
}
public MarineLitterBatch entityToMarineLitterBatch(SortingBatch source,
@@ -241,9 +207,6 @@
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
-
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -277,41 +240,33 @@
target.setSubgroupCount(1f);
// Weight
- if (source.getWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
+ if (source.getWeight() != null) {
+
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
target,
- enumeration.PMFM_ID_WEIGHT_MEASURED,
- recorderDepartmentId,
- source.getWeight(),
- true);
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// MarineLitterCategory
- if (source.getMarineLitterCategory() == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else {
- SortingMeasurement measurement = catchBatchDao.getSortingMeasurement(
+ if (source.getMarineLitterCategory() != null) {
+
+ SortingMeasurement measurement = batchHelper.setSortingMeasurement(
target,
marineLitterCategory,
- recorderDepartmentId,
- true);
- measurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterCategory().getIdAsInt()));
+ source.getMarineLitterCategory().getIdAsInt()
+ );
notChangedSortingMeasurements.remove(measurement);
}
// MarineLitterSizeCategory
- if (source.getMarineLitterSizeCategory() == null) {
- // Nothing to do : will be removed later, using notChangedQuantificationMeasurements
- } else {
- SortingMeasurement measurement = catchBatchDao.getSortingMeasurement(
+ if (source.getMarineLitterSizeCategory() != null) {
+
+ SortingMeasurement measurement = batchHelper.setSortingMeasurement(
target,
marineLitterSizeCategory,
- recorderDepartmentId,
- true);
- measurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterSizeCategory().getIdAsInt()));
+ source.getMarineLitterSizeCategory().getIdAsInt()
+ );
notChangedSortingMeasurements.remove(measurement);
}
@@ -345,28 +300,31 @@
Preconditions.checkNotNull(target);
- // Load existing parent and root
SortingBatch parentBatch = getMarineLitterParentBatch(catchBatch);
- // Parent Batch
-
if (parentBatch == null) {
- throw new DataIntegrityViolationException(
- "Could not retrieve parent batch, for a given marineLitterBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a MarineLitterBatch.");
+
+ SortingBatch horsVracBatch = batchHelper.getOrCreateHorsVracBatch(
+ catchBatch
+ );
+
+ parentBatch = batchHelper.getOrCreateMarineLitterRootBatch(
+ catchBatch,
+ horsVracBatch,
+ null
+ );
}
- // Parent Batch
target.setParentBatch(parentBatch);
target.setRootBatch(catchBatch);
}
protected SortingBatch getMarineLitterParentBatch(CatchBatch catchBatch) {
- SortingBatch parentBatch = catchBatchDao.getSortingBatch(
- catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, // hors vrac
+ SortingBatch parentBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Hors Vrac > Marine Litter",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_HORS_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, // marine litter
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
return parentBatch;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -29,7 +29,6 @@
import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
-import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
@@ -49,7 +48,6 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.FlushMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@@ -81,9 +79,6 @@
@Autowired
protected ReferentialPersistenceService referentialService;
- @Resource(name = "catchBatchDao")
- protected CatchBatchExtendDao catchBatchDao;
-
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
@@ -95,20 +90,15 @@
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
- Preconditions.checkNotNull(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- Collection<Batch> catchBatchChilds = catchBatch.getChildBatchs();
// Vrac / Species
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(
- catchBatchChilds,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Vrac > Species > Alive Itemized",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
);
// container of speciesBatch is arbitraty put on vrac type (there is
@@ -128,15 +118,16 @@
result.addChildren(target);
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Vrac > Species > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
+ log.info("Loaded CatchBatch Vrac > Species > Alive Itemized > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId());
}
}
// Hors-Vrac / Species
- SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(
- catchBatchChilds,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ SortingBatch horsVracSpeciesBatch = batchHelper.getSortingBatch(
+ catchBatch,
+ "Hors Vrac > Species",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
+ enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
if (horsVracSpeciesBatch != null) {
for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) {
SortingBatch source = (SortingBatch) batch;
@@ -149,7 +140,7 @@
entityToSpeciesBatch(source, target);
result.addChildren(target);
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac > Species > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
+ log.info("Loaded CatchBatch Hors Vrac > Species > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId());
}
}
}
@@ -167,20 +158,11 @@
Preconditions.checkNotNull(bean.getFishingOperation());
Preconditions.checkNotNull(bean.getFishingOperation().getId());
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- // Load full batch tree
- Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(bean.getFishingOperation().getId(), false);
SortingBatch batch = SortingBatch.Factory.newInstance();
speciesBatchToEntity(bean, batch, parentBatchId, catchBatch);
- batch = catchBatchDao.createSortingBatch(batch, catchBatch);
+ bean = batchHelper.createSortingBatch(bean, catchBatch, batch);
- bean.setId(batch.getId());
-
- getCurrentSession().flush();
-
return bean;
}
@@ -189,23 +171,16 @@
Preconditions.checkNotNull(bean);
Preconditions.checkNotNull(bean.getId());
- // Load batch tree
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
- Preconditions.checkNotNull(catchBatchId);
+ Integer batchId = bean.getIdAsInt();
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
- Preconditions.checkNotNull(catchBatch);
-
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
- SortingBatch batch = catchBatchDao.getSortingBatchById(catchBatch, bean.getIdAsInt());
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(batchId);
+ SortingBatch batch = batchHelper.getSortingBatchById(catchBatch, batchId);
String parentBatchId = null;
if (bean.getParentBatch() != null) {
parentBatchId = bean.getParentBatch().getId();
}
speciesBatchToEntity(bean, batch, parentBatchId, catchBatch);
- catchBatchDao.updateSortingBatch(batch, catchBatch);
- getCurrentSession().flush();
+ batchHelper.updateSortingBatch(batch, catchBatch);
return bean;
}
@@ -214,38 +189,22 @@
public void deleteSpeciesBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer batchId = Integer.valueOf(id);
- catchBatchDao.removeWithChildren(batchId);
+ batchHelper.removeWithChildren(batchId);
attachmentPersistenceService.deleteAllAttachment(
AttachementObjectTypeEnum.BATCH,
batchId);
-
- getCurrentSession().flush();
}
@Override
public void deleteSpeciesSubBatch(String id) {
Preconditions.checkNotNull(id);
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer speciesBatchId = Integer.valueOf(id);
- // get catch batch
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(speciesBatchId);
-
- Preconditions.checkNotNull(
- catchBatchId,
- "Could not find catchBatch for speciesBatch: " + speciesBatchId);
-
- CatchBatch catchBatch =
- catchBatchDao.loadFullTree(catchBatchId);
-
- // get species batch
- SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(speciesBatchId);
+ SortingBatch sortingBatch = batchHelper.getSortingBatchById(
catchBatch, speciesBatchId);
// get his children
@@ -261,7 +220,7 @@
if (log.isInfoEnabled()) {
log.info("Delete child [" + childBatchId + "] of species batch: " + id);
}
- catchBatchDao.removeWithChildren(childBatchId);
+ batchHelper.removeWithChildren(childBatchId);
// delete his attachment (if any)
attachmentPersistenceService.deleteAllAttachment(
@@ -269,9 +228,6 @@
childBatchId);
}
}
-
-
- getCurrentSession().flush();
}
@Override
@@ -281,7 +237,7 @@
Preconditions.checkNotNull(species);
Preconditions.checkNotNull(species.getReferenceTaxonId());
- catchBatchDao.setSortingBatchReferenceTaxon(
+ batchHelper.setSortingBatchReferenceTaxon(
batchId,
species.getReferenceTaxonId());
}
@@ -295,7 +251,8 @@
String speciesBatchId) {
Preconditions.checkNotNull(speciesBatchId);
- List<SortingBatch> frequencyChilds = batchHelper.getFrequencies(speciesBatchId);
+ List<SortingBatch> frequencyChilds =
+ batchHelper.getFrequencies(speciesBatchId);
List<SpeciesBatchFrequency> results = Lists.newArrayList();
for (SortingBatch child : frequencyChilds) {
SpeciesBatchFrequency target =
@@ -331,18 +288,15 @@
}
}
- getCurrentSession().setFlushMode(FlushMode.COMMIT);
-
Integer sortingBatchId = Integer.valueOf(speciesBatchId);
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(sortingBatchId);
if (catchBatch == null) {
return notNullFrequencies;
}
// Retrieve parent
- SortingBatch parentBatch = catchBatchDao.getSortingBatchById(catchBatch, sortingBatchId);
+ SortingBatch parentBatch = batchHelper.getSortingBatchById(catchBatch, sortingBatchId);
// Remember child ids, to remove unchanged item (see at bottom in this method)
List<Integer> notUpdatedChildIds = Lists.newArrayList();
@@ -366,7 +320,7 @@
speciesBatchFrequencyToEntity(source, target, parentBatch, rankOrder);
// Create the targeted batch, then update the source id
- catchBatchDao.createSortingBatch(target, catchBatch);
+ batchHelper.createSortingBatch(source, catchBatch, target);
// push back id of created sortingBatch
source.setId(target.getId());
@@ -377,7 +331,7 @@
} else {
// Existing batch
- target = catchBatchDao.loadSortingBatch(source.getIdAsInt(), catchBatch);
+ target = batchHelper.loadSortingBatch(source.getIdAsInt(), catchBatch);
// Fill the sorting batch from the source
speciesBatchFrequencyToEntity(source, target, parentBatch, rankOrder);
@@ -397,7 +351,7 @@
if (batchsToUpdate.size() > 0) {
// update some batchs
- catchBatchDao.updateSortingBatch(batchsToUpdate, catchBatch);
+ batchHelper.updateSortingBatch(batchsToUpdate, catchBatch);
}
if (notUpdatedChildIds.size() > 0) {
@@ -408,12 +362,10 @@
if (log.isInfoEnabled()) {
log.info("Remove obsolete frequency sortingBatch: " + batchId);
}
- catchBatchDao.removeWithChildren(batchId, catchBatch);
+ batchHelper.removeWithChildren(batchId, catchBatch);
}
}
- getCurrentSession().flush();
-
return Collections.unmodifiableList(notNullFrequencies);
}
@@ -447,7 +399,7 @@
if (source.getSortingMeasurements().size() == 1) {
sm = source.getSortingMeasurements().iterator().next();
} else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
- sm = catchBatchDao.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
+ sm = batchHelper.getInheritedSortingMeasurement(source);
}
if (sm != null) {
SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(sm.getPmfm().getId());
@@ -514,15 +466,11 @@
protected void speciesBatchToEntity(SpeciesBatch source,
SortingBatch target,
String parentBatchId,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch
- ) {
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch ) {
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
-
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -570,12 +518,14 @@
if (source.getWeight() == null && source.getSampleCategoryWeight() == null) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
} else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getSampleCategoryWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
} else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -588,20 +538,21 @@
samplingRatioText = samplingRatioText.replaceAll(",", ".");
target.setSamplingRatioText(samplingRatioText);
target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
+ target,
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
- if ((source.getSampleCategoryType() == null || source.getSampleCategoryValue() == null)) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
+ if (source.getSampleCategoryType() != null && source.getSampleCategoryValue() != null) {
Integer pmfmId = source.getSampleCategoryType().getFieldValue();
// Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, recorderDepartmentId,
- source.getSampleCategoryType(), source.getSampleCategoryValue());
+ SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(
+ target,
+ source.getSampleCategoryType(),
+ source.getSampleCategoryValue());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
}
@@ -649,9 +600,6 @@
Preconditions.checkNotNull(source.getBatch());
Preconditions.checkNotNull(source.getBatch().getId());
- // Retrieve recorder department
- Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
-
Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
@@ -678,21 +626,17 @@
target.setRankOrder(rankOrder);
// Weight or SampleCategoryWeight
- if (source.getWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
+ if (source.getWeight() != null) {
+ QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
target,
- enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ source.getWeight());
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
- if ((source.getLengthStepCaracteristic() == null || source.getLengthStep() == null)) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else {
+ if ((source.getLengthStepCaracteristic() != null && source.getLengthStep() != null)) {
Integer pmfmId = source.getLengthStepCaracteristic().getIdAsInt();
- SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, recorderDepartmentId, pmfmId,
+ SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, pmfmId,
source.getLengthStep());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -26,12 +26,19 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
+import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
+import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
+import fr.ifremer.tutti.persistence.entities.TuttiEntity;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
@@ -39,6 +46,8 @@
import fr.ifremer.tutti.persistence.service.AbstractPersistenceService;
import fr.ifremer.tutti.persistence.service.MeasurementPersistenceHelper;
import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;
@@ -46,7 +55,9 @@
import javax.annotation.Resource;
import java.io.Serializable;
import java.text.MessageFormat;
+import java.util.Collection;
import java.util.List;
+import java.util.Set;
/**
* Helper around batches.
@@ -57,9 +68,9 @@
@Component("batchPersistenceHelper")
public class BatchPersistenceHelper extends AbstractPersistenceService {
-// /** Logger. */
-// private static final Log log =
-// LogFactory.getLog(BatchPersistenceHelper.class);
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(BatchPersistenceHelper.class);
public static final String BATCH_PMFM_ID = "pmfmId";
@@ -69,9 +80,76 @@
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
+ @Resource(name = "scientificCruiseCatchBatchValidator")
+ protected CatchBatchValidator catchBatchValidator;
+
@Autowired
protected MeasurementPersistenceHelper measurementPersistenceHelper;
+ @Override
+ public void init() {
+ super.init();
+ catchBatchDao.registerCatchBatchValidator(catchBatchValidator);
+ }
+
+ @Override
+ public void close() {
+ catchBatchDao.unregisterCatchBatchValidator(catchBatchValidator);
+ super.close();
+ }
+
+ public fr.ifremer.tutti.persistence.entities.data.CatchBatch createCatchBatch(fr.ifremer.tutti.persistence.entities.data.CatchBatch bean, CatchBatch catchBatch) {
+ catchBatch = catchBatchDao.create(catchBatch);
+ bean.setId(catchBatch.getId());
+ return bean;
+ }
+
+ public <D extends TuttiEntity> D createSortingBatch(D bean, CatchBatch catchBatch, SortingBatch batch) {
+ batch = catchBatchDao.createSortingBatch(batch, catchBatch);
+ bean.setId(batch.getId());
+ return bean;
+ }
+
+ public void removeWithChildren(Integer batchId) {
+ catchBatchDao.removeWithChildren(batchId);
+ }
+
+ public void removeWithChildren(Integer batchId, CatchBatch parentCatchBatch) {
+ catchBatchDao.removeWithChildren(batchId, parentCatchBatch);
+ }
+
+ public void updateSortingBatch(List<SortingBatch> sortingBatchs, CatchBatch parentCatchBatch) {
+ catchBatchDao.updateSortingBatch(sortingBatchs, parentCatchBatch);
+ }
+
+ public SortingBatch loadSortingBatch(Integer sortingBatchId, CatchBatch parentCatchBatch) {
+ return catchBatchDao.loadSortingBatch(sortingBatchId, parentCatchBatch);
+ }
+
+ public void update(CatchBatch catchBatch) {
+ catchBatchDao.update(catchBatch);
+ }
+
+ public void setSortingBatchReferenceTaxon(String batchId, Integer referenceTaxonId) {
+ catchBatchDao.setSortingBatchReferenceTaxon(batchId, referenceTaxonId);
+ }
+
+ public SortingBatch getSortingBatchById(CatchBatch catchBatch, Integer sortingBatchId) {
+ return catchBatchDao.getSortingBatchById(catchBatch, sortingBatchId);
+ }
+
+ public void updateSortingBatch(SortingBatch sortingBatch, CatchBatch parentCatchBatch) {
+ catchBatchDao.updateSortingBatch(sortingBatch, parentCatchBatch);
+ }
+
+ public SortingMeasurement getInheritedSortingMeasurement(SortingBatch sortingBatch) {
+ return catchBatchDao.getInheritedSortingMeasurement(sortingBatch, enumeration.PMFM_ID_SORTED_UNSORTED);
+ }
+
+ public QuantificationMeasurement setWeightMeasurementQuantificationMeasurement(Batch batch, Float weightValue) {
+ return catchBatchDao.setQuantificationMeasurement(batch, enumeration.PMFM_ID_WEIGHT_MEASURED, getRecorderDepartmentId(), weightValue, true);
+ }
+
public List<SortingBatch> getFrequencyChilds(SortingBatch sortingBatch) {
List<SortingBatch> result = Lists.newArrayList();
@@ -87,13 +165,7 @@
public List<SortingBatch> getFrequencies(String batchId) {
Preconditions.checkNotNull(batchId);
Integer sortingBatchId = Integer.valueOf(batchId);
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- Preconditions.checkNotNull(
- catchBatchId,
- "Could not find catchBatch for batch: " + batchId);
-
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
+ CatchBatch catchBatch = getRootCatchBatchByBatchId(sortingBatchId);
SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
catchBatch, sortingBatchId);
@@ -101,33 +173,45 @@
return frequencyChilds;
}
- /**
- * Check if the given {@code sortingBatch} is a frequency one.
- * <p/>
- * We test that:
- * <ul>
- * <li>batch has exactly one measurement</li>
- * <li>the measurement pmfm is not a sample category</li>
- * </ul>
- *
- * @param sortingBatch batch to check
- * @return {@code true} if given batch is a frequency batch,
- * {@code false} otherwise.
- */
- protected boolean isFrequencyBatch(SortingBatch sortingBatch) {
- boolean result = false;
- if (sortingBatch.getSortingMeasurements().size() == 1) {
- SortingMeasurement sm
- = sortingBatch.getSortingMeasurements().iterator().next();
- Pmfm pmfm = sm.getPmfm();
- SampleCategoryEnum sampleCategoryByPmfmId =
- enumeration.getSampleCategoryByPmfmId(pmfm.getId());
- result = sampleCategoryByPmfmId == null;
+ public fr.ifremer.adagio.core.dao.data.batch.CatchBatch getRootCatchBatchByFishingOperationId(String fishingOperationId, boolean validate) {
+ Preconditions.checkNotNull(fishingOperationId);
+ Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
+ Preconditions.checkNotNull(catchBatchId);
+
+ // whenever want to repair anything from Tutti
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch result;
+
+ if (validate) {
+
+ try {
+ result = catchBatchDao.loadFullTree(catchBatchId, true, false);
+ } catch (CatchBatchValidationException e) {
+ throw new InvalidBatchModelException(
+ "L'arbre d'échantillonage n'est pas compatible avec celui de Tutti.", e);
+ }
+ } else {
+ result = catchBatchDao.loadFullTree(catchBatchId);
}
+ Preconditions.checkNotNull(result);
return result;
}
+ public fr.ifremer.adagio.core.dao.data.batch.CatchBatch getRootCatchBatchByBatchId(Integer batchId) {
+ Preconditions.checkNotNull(batchId);
+
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(batchId);
+ Preconditions.checkNotNull(catchBatchId);
+
+ // whenever want to repair anything from Tutti
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch result;
+
+ result = catchBatchDao.loadFullTree(catchBatchId);
+
+ Preconditions.checkNotNull(result);
+ return result;
+ }
+
public void setBatchParents(SampleCategoryEnum sampleCategoryType,
Serializable sampleCategoryValue,
SortingBatch target,
@@ -158,17 +242,21 @@
if (enumeration.QUALITATIVE_VRAC_ID.equals(qualitativeValueId)) {
// vrac
- parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, // vrac
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // Species | Benthos
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
+ parentBatch = getSortingBatch(
+ catchBatch,
+ "Vrac > (Species | Benthos) > Alive Itemized",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, // vrac
+ enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // Species | Benthos
+ enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
);
} else if (enumeration.QUALITATIVE_HORS_VRAC_ID.equals(qualitativeValueId)) {
// hors-vrac
- parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, // hors vrac
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId // Species | Benthos
+ parentBatch = getSortingBatch(
+ catchBatch,
+ "Hors vrac > (Species|Benthos)",
+ enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, // hors vrac
+ enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId // Species | Benthos
);
} else {
@@ -201,37 +289,213 @@
return qualitativeValueId;
}
- public Integer getRecorderDepartmentId() {
- // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
- return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
+ public SortingBatch getSortingBatch(Batch source,
+ String debugMessage,
+ Integer... ids) {
+
+ return getSortingBatch(source.getChildBatchs(), debugMessage, ids);
}
-// public void setMeasurement(Measurement measurement,
-// Caracteristic caracteristic,
-// Serializable value) {
-// if (caracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
-// measurement.setAlphanumericalValue((String) value);
-// } else if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
-// measurement.setNumericalValue((Float) value);
-// } else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
-// Integer qvId;
-// if (value instanceof CaracteristicQualitativeValue) {
-// qvId = ((CaracteristicQualitativeValue) value).getIdAsInt();
-// } else if (value instanceof Integer) {
-// qvId = (Integer) value;
-// }
-// // TODO BL : not used ? => to remove
-// else {
-// qvId = Integer.valueOf(value.toString());
-// }
-// QualitativeValue qv = load(QualitativeValueImpl.class, qvId);
-// measurement.setQualitativeValue(qv);
-// }
-// }
+ public SortingBatch getSortingBatch(Collection<Batch> childs,
+ String debugMessage,
+ Integer... ids) {
+ int nbParams = ids.length / 2;
+
+ Object[] params = new Object[nbParams * 3];
+ for (int i = 0; i < nbParams; i++) {
+ Integer sortingPmfmId = ids[2 * i];
+ Integer sortingQualitativeValueId = ids[2 * i + 1];
+ params[3 * i] = BatchPersistenceHelper.BATCH_PMFM_ID;
+ params[3 * i + 1] = sortingPmfmId;
+ params[3 * i + 2] = sortingQualitativeValueId;
+ }
+ SortingBatch result = catchBatchDao.getSortingBatch(childs, params);
+ if (result != null && debugMessage != null && log.isInfoEnabled()) {
+ log.info("Loaded " + debugMessage + ": " + result.getId());
+ }
+ return result;
+ }
+
+ public SortingBatch getOrCreateVracBatch(CatchBatch batch,
+ Float weight,
+ Float weightBeforeSampling) {
+ return getOrCreate(
+ batch,
+ batch,
+ enumeration.PMFM_ID_SORTED_UNSORTED,
+ enumeration.QUALITATIVE_VRAC_ID,
+ weight,
+ weightBeforeSampling,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesVracRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ totalWeight,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesVracAliveNotItemizeRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED,
+ totalWeight,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesVracInertRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT,
+ totalWeight,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesVracAliveItemizeRootBatch(CatchBatch target,
+ SortingBatch batch) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED,
+ null,
+ (short) 3
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosVracRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ totalWeight,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosVracAliveNotItemizeRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED,
+ totalWeight,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosVracInertRootBatch(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT,
+ totalWeight,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosVracAliveItemizeRootBatch(CatchBatch target,
+ SortingBatch batch) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE_2,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED,
+ null,
+ (short) 3
+ );
+ }
+
+ public SortingBatch getOrCreateHorsVracBatch(CatchBatch batch) {
+ return getOrCreate(
+ batch,
+ batch,
+ enumeration.PMFM_ID_SORTED_UNSORTED,
+ enumeration.QUALITATIVE_HORS_VRAC_ID,
+ null,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateSpeciesHorsVracRootBatch(CatchBatch target,
+ SortingBatch batch) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ null,
+ (short) 1
+ );
+ }
+
+ public SortingBatch getOrCreateBenthosHorsVracRootBatch(CatchBatch target,
+ SortingBatch batch) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ null,
+ (short) 2
+ );
+ }
+
+ public SortingBatch getOrCreateMarineLitterRootBatch(CatchBatch target,
+ SortingBatch batch,
+ Float totalWeight) {
+ return getOrCreate(
+ target,
+ batch,
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER,
+ totalWeight,
+ (short) 3
+ );
+ }
+
+ public SortingBatch getOrCreateRejectedBatch(CatchBatch batch,
+ Float weight) {
+
+ return getOrCreate(
+ batch,
+ batch,
+ enumeration.PMFM_ID_SORTED_UNSORTED,
+ enumeration.QUALITATIVE_UNSORTED_ID,
+ weight,
+ (short) 3
+ );
+ }
+
public SortingMeasurement setSortingMeasurement(
SortingBatch sortingBatch,
- Integer recorderDepartmentId,
SampleCategoryEnum sampleCategory,
Serializable value) {
Preconditions.checkNotNull(sampleCategory);
@@ -241,14 +505,13 @@
Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
- sortingBatch, pmfmId, recorderDepartmentId, true);
+ sortingBatch, pmfmId, getRecorderDepartmentId(), true);
measurementPersistenceHelper.setMeasurement(sortingMeasurement, caracteristic, value);
return sortingMeasurement;
}
public SortingMeasurement setSortingMeasurement(
SortingBatch sortingBatch,
- Integer recorderDepartmentId,
Integer pmfmId,
Serializable value) {
Preconditions.checkNotNull(pmfmId);
@@ -256,7 +519,7 @@
Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
- sortingBatch, pmfmId, recorderDepartmentId, true);
+ sortingBatch, pmfmId, getRecorderDepartmentId(), true);
measurementPersistenceHelper.setMeasurement(sortingMeasurement,
caracteristic,
value);
@@ -289,4 +552,155 @@
return value;
}
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected Integer getRecorderDepartmentId() {
+ // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
+ return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
+ }
+
+ /**
+ * Check if the given {@code sortingBatch} is a frequency one.
+ * <p/>
+ * We test that:
+ * <ul>
+ * <li>batch has exactly one measurement</li>
+ * <li>the measurement pmfm is not a sample category</li>
+ * </ul>
+ *
+ * @param sortingBatch batch to check
+ * @return {@code true} if given batch is a frequency batch,
+ * {@code false} otherwise.
+ */
+ protected boolean isFrequencyBatch(SortingBatch sortingBatch) {
+ boolean result = false;
+ if (sortingBatch.getSortingMeasurements().size() == 1) {
+ SortingMeasurement sm
+ = sortingBatch.getSortingMeasurements().iterator().next();
+ Pmfm pmfm = sm.getPmfm();
+ SampleCategoryEnum sampleCategoryByPmfmId =
+ enumeration.getSampleCategoryByPmfmId(pmfm.getId());
+ result = sampleCategoryByPmfmId == null;
+
+ }
+ return result;
+ }
+
+ protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target,
+ Batch batch,
+ Integer pmfmId,
+ Integer pmfmValue,
+ Float totalWeight,
+ short rankOrder) {
+ return getOrCreate(
+ target,
+ batch,
+ pmfmId,
+ pmfmValue,
+ totalWeight,
+ null,
+ rankOrder
+ );
+ }
+
+ protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch,
+ Batch parentBatch,
+ Integer sortingPmfmId,
+ Integer sortingQualitativeValueId,
+ Float weight,
+ Float weightBeforeSampling,
+ short rankOrder) {
+ SortingBatch result = getSortingBatch(
+ parentBatch,
+ null,
+ sortingPmfmId,
+ sortingQualitativeValueId);
+ if (result == null) {
+
+ result = SortingBatch.Factory.newInstance();
+ if (parentBatch.getChildBatchs() == null) {
+ parentBatch.setChildBatchs(Sets.<Batch>newHashSet());
+ }
+ parentBatch.getChildBatchs().add(result);
+
+// Collection<QuantificationMeasurement> quantificationMeasurements = result.getQuantificationMeasurements();
+ Collection<SortingMeasurement> sortingMeasurements = result.getSortingMeasurements();
+
+ // Create lists to store all updates, then remove not updated items
+// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
+// if (quantificationMeasurements != null) {
+// notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
+// }
+ Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet();
+ if (sortingMeasurements != null) {
+ notChangedSortingMeasurements.addAll(sortingMeasurements);
+ }
+
+ // Some mandatory properties :
+ QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
+ result.setQualityFlag(qualityFlag);
+ result.setRootBatch(rootBatch);
+ result.setParentBatch(parentBatch);
+ result.setExhaustiveInventory(true);
+
+ // No taxon or taxon group
+ result.setReferenceTaxon(null);
+ result.setTaxonGroup(null);
+
+ result.setRankOrder(rankOrder);
+
+ // Sorting measurement
+ if (sortingPmfmId != null && sortingQualitativeValueId != null) {
+ SortingMeasurement sm = setSortingMeasurement(
+ result,
+ sortingPmfmId,
+ sortingQualitativeValueId);
+ notChangedSortingMeasurements.remove(sm);
+ }
+ // Removed not changed sorting measurements
+ if (sortingMeasurements != null) {
+ sortingMeasurements.removeAll(notChangedSortingMeasurements);
+ }
+
+ catchBatchDao.createSortingBatch(result, rootBatch);
+ }
+
+ Collection<QuantificationMeasurement> quantificationMeasurements = result.getQuantificationMeasurements();
+ Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
+ if (quantificationMeasurements != null) {
+ notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
+ }
+
+ // Sampling Ratio
+ if (weightBeforeSampling == null || weight == null) {
+ result.setSamplingRatio(null);
+ result.setSamplingRatioText(null);
+ } else {
+ String samplingRatioText = weight + "/" + weightBeforeSampling;
+ samplingRatioText = samplingRatioText.replaceAll(",", ".");
+ result.setSamplingRatioText(samplingRatioText);
+ result.setSamplingRatio(weight / weightBeforeSampling);
+ }
+
+ // Weight
+ if (weightBeforeSampling != null || weight != null) {
+ Float batchReferenceWeight = weight;
+ if (batchReferenceWeight == null) {
+ batchReferenceWeight = weightBeforeSampling;
+ }
+ QuantificationMeasurement quantificationMeasurement = setWeightMeasurementQuantificationMeasurement(
+ result,
+ batchReferenceWeight);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ }
+ // Removed not changed quantification measurements
+ if (quantificationMeasurements != null) {
+ quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
+ }
+
+ return result;
+ }
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -60,6 +60,9 @@
@Autowired
protected TuttiEnumerationFile enumeration;
+ @Autowired
+ protected BatchPersistenceHelper batchHelper;
+
@Override
public boolean isEnable(CatchBatch catchBatch) {
// Apply validation only on catch batch for fishingOperation
@@ -81,9 +84,9 @@
List<CatchBatchValidationError> errors) {
// Vrac
- SortingBatch vracBatch = catchBatchDao.getSortingBatch(
+ SortingBatch vracBatch = batchHelper.getSortingBatch(
batchs,
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ "Vrac",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_VRAC_ID);
@@ -95,18 +98,31 @@
addError(errors, n_("tutti.persistence.batch.validation.vracNotFound"));
} else {
// Vrac > Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(
- vracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch speciesBatch = batchHelper.getSortingBatch(
+ vracBatch,
+ "Vrac > Species",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+
+ // Vrac > Benthos
+ SortingBatch benthosBatch = batchHelper.getSortingBatch(
+ vracBatch,
+ "Vrac > Benthos",
+ enumeration.PMFM_ID_SORTING_TYPE,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+
if (speciesBatch == null) {
- addError(errors, n_("tutti.persistence.batch.validation.vracSpeciesNotFound"));
+
+ if (benthosBatch == null) {
+ addError(errors, n_("tutti.persistence.batch.validation.vracSpeciesNotFound"));
+ } else {
+ addWarning(errors, n_("tutti.persistence.batch.validation.vracSpeciesNotFound"));
+ }
} else {
// Vrac > Species > Alive not itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch(
+ speciesBatch,
+ "Vrac > Species > Alive not itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
if (livingNotItemizedBatch == null) {
@@ -114,9 +130,9 @@
}
// Vrac > Species > Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch inertBatch = batchHelper.getSortingBatch(
+ speciesBatch,
+ "Vrac > Species > Inert",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
if (inertBatch == null) {
@@ -124,9 +140,9 @@
}
// Vrac > Species > Alive itemized
- SortingBatch aliveItemizedBatch = catchBatchDao.getSortingBatch(
- speciesBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch aliveItemizedBatch = batchHelper.getSortingBatch(
+ speciesBatch,
+ "Vrac > Species > Alive itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
if (aliveItemizedBatch == null) {
@@ -136,20 +152,18 @@
// TODO verifier que les espèces en haut de grappe ont bien la catégorie voulue (sorted-unsorted)
}
- // Vrac > Benthos
- SortingBatch benthosBatch = catchBatchDao.getSortingBatch(
- vracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
if (benthosBatch == null) {
- addError(errors, n_("tutti.persistence.batch.validation.vracBenthosNotFound"));
+ if (speciesBatch == null) {
+ addError(errors, n_("tutti.persistence.batch.validation.vracBenthosNotFound"));
+ } else {
+ addWarning(errors, n_("tutti.persistence.batch.validation.vracBenthosNotFound"));
+ }
} else {
// Vrac > Benthos > Alive not itemized
- SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch(
+ benthosBatch,
+ "Vrac > Benthos > Alive not itemized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED);
if (livingNotItemizedBatch == null) {
@@ -157,9 +171,9 @@
}
// Vrac > Benthos > Inert
- SortingBatch inertBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch inertBatch = batchHelper.getSortingBatch(
+ benthosBatch,
+ "Vrac > Benthos > Inert",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT);
if (inertBatch == null) {
@@ -167,31 +181,30 @@
}
// Vrac > Benthos > Alive itermized
- SortingBatch aliveItemizedBatch = catchBatchDao.getSortingBatch(
- benthosBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch aliveItemizedBatch = batchHelper.getSortingBatch(
+ benthosBatch,
+ "Vrac > Benthos > Alive itermized",
enumeration.PMFM_ID_SORTING_TYPE_2,
enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
if (aliveItemizedBatch == null) {
addWarning(errors, n_("tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound"));
}
}
- // TODO : Plankton...
}
// Hors Vrac
- SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(
+ SortingBatch horsVracBatch = batchHelper.getSortingBatch(
batchs,
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ "Hors Vrac",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_HORS_VRAC_ID);
if (horsVracBatch == null) {
- addWarning(errors, n_("tutti.persistence.batch.validation.horsVracSpeciesNotFound"));
+ addWarning(errors, n_("tutti.persistence.batch.validation.horsVracNotFound"));
} else {
// Hors Vrac > Species
- SortingBatch speciesBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch speciesBatch = batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Species",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
if (speciesBatch == null) {
@@ -199,31 +212,30 @@
}
// Hors Vrac > Benthos
- SortingBatch benthosBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch benthosBatch = batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Benthos",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
if (benthosBatch == null) {
addWarning(errors, n_("tutti.persistence.batch.validation.horsVracBenthosNotFound"));
}
// Hors Vrac > Marine Litter
- SortingBatch marineLitterBatch = catchBatchDao.getSortingBatch(
- horsVracBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ SortingBatch marineLitterBatch = batchHelper.getSortingBatch(
+ horsVracBatch,
+ "Hors Vrac > Marine Litter",
enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
if (marineLitterBatch == null) {
addWarning(errors, n_("tutti.persistence.batch.validation.horsVracMarineLitterNotFound"));
}
- // TODO : Plankton...
}
// Unsorted
- SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(
+ SortingBatch unsortedBatch = batchHelper.getSortingBatch(
batchs,
- BatchPersistenceHelper.BATCH_PMFM_ID,
+ "Unsorted",
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_UNSORTED_ID);
if (unsortedBatch == null) {
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-05-01 13:30:06 UTC (rev 906)
@@ -18,6 +18,7 @@
tutti.persistence.attachment.deleteFile.error=
tutti.persistence.batch.validation.horsVracBenthosNotFound=
tutti.persistence.batch.validation.horsVracMarineLitterNotFound=
+tutti.persistence.batch.validation.horsVracNotFound=
tutti.persistence.batch.validation.horsVracSpeciesNotFound=
tutti.persistence.batch.validation.unsortedNotFound=
tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound=
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-05-01 13:30:06 UTC (rev 906)
@@ -18,6 +18,7 @@
tutti.persistence.attachment.deleteFile.error=Erreur lors de la suppression de la pièce jointe %s
tutti.persistence.batch.validation.horsVracBenthosNotFound=Lot 'Hors Vrac > Benthos' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracMarineLitterNotFound=Lot 'Hors Vrac > Macro-déchet' non trouvé, ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.horsVracNotFound=Lot 'Hors Vrac' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracSpeciesNotFound=Lot 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.unsortedNotFound=Lot 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound=Lot 'Vrac > Benthos > Vivant Trié' non trouvé, ou configuré avec d'autres critères de classement.
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceReadTest.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -24,8 +24,8 @@
* #L%
*/
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import org.junit.Before;
import org.junit.ClassRule;
@@ -68,7 +68,7 @@
assertNotNull(fishingOperation.getId());
}
- @Test(expected = CatchBatchValidationException.class)
+ @Test(expected = InvalidBatchModelException.class)
public void getCatchBatchFromFishingOperation() throws Exception {
//TODO-TC Change test when data will be Tutti-aware
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java 2013-05-01 13:21:10 UTC (rev 905)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceWriteTest.java 2013-05-01 13:30:06 UTC (rev 906)
@@ -24,8 +24,8 @@
* #L%
*/
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
@@ -188,7 +188,7 @@
CatchBatch reloadedCatchBatch = null;
try {
reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- } catch (CatchBatchValidationException e) {
+ } catch (InvalidBatchModelException e) {
Assert.fail(e.getMessage());
}
assertCatchBatch(createdCatchBatch, reloadedCatchBatch, true);
@@ -205,7 +205,7 @@
CatchBatch reloadedCatchBatch = null;
try {
reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- } catch (CatchBatchValidationException e) {
+ } catch (InvalidBatchModelException e) {
Assert.fail(e.getMessage());
}
assertCatchBatch(savedCatchBatch, reloadedCatchBatch, true);
1
0
r905 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:21:10 +0200 (Wed, 01 May 2013)
New Revision: 905
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/905
Log:
fixes #2389: [TECH] Ne pas supprimer le r?\195?\169pertoire des protocoles lors de l'action Exporter et fermer
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-05-01 13:18:36 UTC (rev 904)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-05-01 13:21:10 UTC (rev 905)
@@ -111,7 +111,6 @@
progressionModel.setMessage(_("tutti.exportDb.closeDb"));
-
TuttiActionHelper.runInternalAction(getHandler(), CloseDbAction.class);
PersistenceService persistenceService =
@@ -138,8 +137,8 @@
File attachmentDirectory = persistenceConfig.getDbAttachmentDirectory();
TuttiIOUtil.cleanDirectory(attachmentDirectory, _("tutti.io.directory.delete.error", attachmentDirectory));
- File protocolDirectory = persistenceConfig.getProtocolDirectory();
- TuttiIOUtil.cleanDirectory(protocolDirectory, _("tutti.io.directory.delete.error", protocolDirectory));
+// File protocolDirectory = persistenceConfig.getProtocolDirectory();
+// TuttiIOUtil.cleanDirectory(protocolDirectory, _("tutti.io.directory.delete.error", protocolDirectory));
getModel().setDbExist(false);
}
1
0
r904 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:18:36 +0200 (Wed, 01 May 2013)
New Revision: 904
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/904
Log:
refs #2383: [TECH] - Mise ?\195?\160 jour de la base : ?\195?\169crasement des donn?\195?\169es si on force la mise ?\195?\160 jour
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-05-01 13:17:24 UTC (rev 903)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-05-01 13:18:36 UTC (rev 904)
@@ -41,7 +41,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.Version;
import org.nuiton.util.updater.ApplicationInfo;
import org.nuiton.util.updater.ApplicationUpdater;
import org.nuiton.util.updater.ApplicationUpdaterCallback;
@@ -161,10 +160,10 @@
public void startUpdate(ApplicationInfo info) {
if (UpdateType.DB.name().toLowerCase().equals(info.name)) {
- if (Version.VZERO.toString().equals(info.oldVersion)) {
+ if (dbInstalled) {
progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.installation", info.newVersion));
- } else {
+ } else if (dbUpdated) {
progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.update", info.newVersion));
}
}
@@ -362,12 +361,12 @@
persistenceConfig.generateExternalDbFiles(true);
- if (ApplicationUpdater.ZERO_VERSION.equals(info.oldVersion)) {
+ if (dbInstalled) {
// first database, just copy it to correct directory
prepareFirstDatabase(info);
- } else {
+ } else if (dbUpdated) {
// launch a referential synchronize operation
synchronizetDatabase(info);
1
0
r903 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:17:24 +0200 (Wed, 01 May 2013)
New Revision: 903
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/903
Log:
refs #2369: [IMP/EXP] - L'export de base avec suppression ne fonctionne pas
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-05-01 13:16:06 UTC (rev 902)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-05-01 13:17:24 UTC (rev 903)
@@ -24,7 +24,6 @@
* #L%
*/
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
@@ -72,9 +71,9 @@
// clean db context
getContext().clearDbContext();
- TuttiIOUtil.deleteDirectory(
- getConfig().getServiceConfig().getPersistenceConfig().getCacheDirectory(),
- _("tutti.dbManager.action.closeDb.deleteCache.error"));
+// TuttiIOUtil.deleteDirectory(
+// getConfig().getServiceConfig().getPersistenceConfig().getCacheDirectory(),
+// _("tutti.dbManager.action.closeDb.deleteCache.error"));
}
@Override
1
0
r902 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence
by tchemit@users.forge.codelutin.com 01 May '13
by tchemit@users.forge.codelutin.com 01 May '13
01 May '13
Author: tchemit
Date: 2013-05-01 15:16:06 +0200 (Wed, 01 May 2013)
New Revision: 902
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/902
Log:
improve NoDbImpl implementation
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-04-30 20:56:38 UTC (rev 901)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-05-01 13:16:06 UTC (rev 902)
@@ -68,498 +68,498 @@
@Override
public void clearAllCaches() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllProgramZone() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllCountry() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllHarbour() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllFishingOperationStrata(String zoneId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllFishingOperationSubStrata(String zoneId, String strataId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiLocation> getAllFishingOperationLocation(String zoneId, String strataId, String subStrataId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Vessel> getAllScientificVessel() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Vessel> getAllFishingVessel() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> getAllSpecies() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> getAllReferentSpecies() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> getAllSpecies(TuttiProtocol protocol) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> getAllReferentSpecies(TuttiProtocol protocol) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer referenceTaxonId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Caracteristic> getAllCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Caracteristic> getAllNumericCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getSizeCategoryCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getSexCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getSortedUnsortedCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getMaturityCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getAgeCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getMarineLitterCategoryCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getMarineLitterSizeCategoryCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getVerticalOpeningCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getHorizontalOpeningWingCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getHorizontalOpeningDoorCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getDeadOrAliveCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getSampleIdCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getOtolitheIdCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getPmfmIdCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Caracteristic getWeightMeasuredCaracteristic() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public boolean isTemporary(TuttiReferentialEntity entity) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Gear> getAllScientificGear() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Gear> getAllFishingGear() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Person> getAllPerson() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Person getPerson(Integer personId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Gear getGear(Integer gearCode) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Vessel getVessel(String vesselCode) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Species> importTemporarySpecies(List<Species> species) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Vessel> importTemporaryVessel(List<Vessel> vessels) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Person> importTemporaryPerson(List<Person> persons) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Gear> importTemporaryGear(List<Gear> gears) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<ObjectType> getAllObjectType() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public ObjectType getObjectType(String objectTypeCode) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Program> getAllProgram() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Program getProgram(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Program createProgram(Program bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Program saveProgram(Program bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Cruise> getAllCruise(String programId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Cruise getCruise(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Cruise createCruise(Cruise bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Cruise saveCruise(Cruise bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<String> getAllProtocolNames() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<TuttiProtocol> getAllProtocol() {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public boolean isProtocolExist(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public TuttiProtocol getProtocol(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public TuttiProtocol createProtocol(TuttiProtocol bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public TuttiProtocol saveProtocol(TuttiProtocol bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteProtocol(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<FishingOperation> getAllFishingOperation(String cruiseId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public FishingOperation getFishingOperation(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public FishingOperation createFishingOperation(FishingOperation bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public FishingOperation saveFishingOperation(FishingOperation bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public CatchBatch getCatchBatchFromFishingOperation(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public CatchBatch createCatchBatch(CatchBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public CatchBatch saveCatchBatch(CatchBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public SpeciesBatch saveSpeciesBatch(SpeciesBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteSpeciesBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteSpeciesSubBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void changeSpeciesBatchSpecies(String batchId, Species species) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId, List<SpeciesBatchFrequency> frequencies) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BenthosBatch saveBenthosBatch(BenthosBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteBenthosBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteBenthosSubBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void changeBenthosBatchSpecies(String batchId, Species species) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<BenthosBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId, List<BenthosBatchFrequency> frequencies) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deletePlanktonBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public BatchContainer<MarineLitterBatch> getRootMarineLitterBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public MarineLitterBatch createMarineLitterBatch(MarineLitterBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public MarineLitterBatch saveMarineLitterBatch(MarineLitterBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteMarineLitterBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public AccidentalBatch createAccidentalBatch(AccidentalBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public AccidentalBatch saveAccidentalBatch(AccidentalBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteAccidentalBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType,
Integer objectId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public File getAttachmentFile(String attachmentId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Attachment createAttachment(Attachment attachment, File file) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public Attachment saveAttachment(Attachment attachment) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteAttachment(String attachmentId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
//------------------------------------------------------------------------//
@@ -568,22 +568,22 @@
@Override
public List<IndividualObservationBatch> getAllIndividualObservationBatch(String fishingOperationId) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public IndividualObservationBatch createIndividualObservationBatch(IndividualObservationBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public IndividualObservationBatch saveIndividualObservationBatch(IndividualObservationBatch bean) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
public void deleteIndividualObservationBatch(String id) {
- throw new RuntimeException("method not implemented");
+ throw notImplemented();
}
@Override
@@ -593,4 +593,8 @@
@Override
public void close() throws IOException {
}
+
+ protected RuntimeException notImplemented() {
+ return new RuntimeException("method not implemented");
+ }
}
1
0
r901 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches
by tchemit@users.forge.codelutin.com 30 Apr '13
by tchemit@users.forge.codelutin.com 30 Apr '13
30 Apr '13
Author: tchemit
Date: 2013-04-30 22:56:38 +0200 (Tue, 30 Apr 2013)
New Revision: 901
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/901
Log:
fixes #2388: Impossible de cr?\195?\169er des macro-d?\195?\169chets
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-04-30 15:59:25 UTC (rev 900)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-04-30 20:56:38 UTC (rev 901)
@@ -694,5 +694,6 @@
setCatchTotalComputedWeight(null);
removeAllAttachment(getAttachment());
getSpeciesUsed().clear();
+ getMarineLitterCategoriesUsed().clear();
}
}
1
0
r900 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: . accidental benthos individualobservation marinelitter species
by tchemit@users.forge.codelutin.com 30 Apr '13
by tchemit@users.forge.codelutin.com 30 Apr '13
30 Apr '13
Author: tchemit
Date: 2013-04-30 17:59:25 +0200 (Tue, 30 Apr 2013)
New Revision: 900
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/900
Log:
fixes #2387: [ERGO] Supprimer l'acc?\195?\168s aux pi?\195?\168ces-jointes sur les onglets esp?\195?\168ce - benthos - macro d?\195?\169ch?\195?\169t
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-04-30 15:59:25 UTC (rev 900)
@@ -60,18 +60,6 @@
rightDecoration: {catchesCaracteristicsTabToolBar};
}
-#speciesTabFishingOperationReminderLabel {
- rightDecoration: {speciesTabContent.getSpeciesBatchTabToolBar()};
-}
-
-#benthosTabFishingOperationReminderLabel {
- rightDecoration: {benthosTabContent.getBenthosBatchTabToolBar()};
-}
-
-#marineLitterTabFishingOperationReminderLabel {
- rightDecoration: {marineLitterTabContent.getMarineLitterBatchTabToolBar()};
-}
-
#catchTable {
border: {BorderFactory.createTitledBorder(_("tutti.editCatchBatch.legend.total"))};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-30 15:59:25 UTC (rev 900)
@@ -183,9 +183,6 @@
@Override
protected boolean onTabChanged(int currentIndex, int newIndex) {
ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI();
- ui.getSpeciesTabContent().getSpeciesBatchAttachmentsButton().onCloseUI();
- ui.getBenthosTabContent().getBenthosBatchAttachmentsButton().onCloseUI();
- ui.getMarineLitterTabContent().getMarineLitterBatchAttachmentsButton().onCloseUI();
ui.getComputeSpeciesBatchButton().setVisible(newIndex < 4);
return super.onTabChanged(currentIndex, newIndex);
}
@@ -194,9 +191,6 @@
public boolean onHideTab(int currentIndex, int newIndex) {
ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI();
- ui.getSpeciesTabContent().getSpeciesBatchAttachmentsButton().onCloseUI();
- ui.getBenthosTabContent().getBenthosBatchAttachmentsButton().onCloseUI();
- ui.getMarineLitterTabContent().getMarineLitterBatchAttachmentsButton().onCloseUI();
//FIXME 20130203 kmorin: cannot change tab if model is modified
// (I do not even know why it is set to modified and have no time
// before the demo)
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx 2013-04-30 15:59:25 UTC (rev 900)
@@ -29,7 +29,6 @@
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
jaxx.runtime.swing.editor.NumberEditor
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-04-30 15:59:25 UTC (rev 900)
@@ -46,16 +46,6 @@
_help: {"tutti.editBenthosBatch.help"};
}
-#benthosBatchTabToolBar {
- floatable: false;
- opaque: false;
- borderPainted: false;
-}
-
-#benthosBatchAttachmentsButton {
- enabled: {model.getObjectId() != null};
-}
-
#benthosTotalWeightLabel {
text: "tutti.editBenthosBatch.field.benthosTotalWeight";
toolTipText: "tutti.editBenthosBatch.field.benthosTotalWeight.tip";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-04-30 15:59:25 UTC (rev 900)
@@ -30,7 +30,6 @@
fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
org.jdesktop.swingx.JXTable
@@ -70,11 +69,6 @@
<TuttiHelpBroker id='broker'
constructorParams='"tutti.editBenthosBatch.help"'/>
- <JToolBar id='benthosBatchTabToolBar'>
- <ButtonAttachment id='benthosBatchAttachmentsButton'
- constructorParams='getHandler().getContext(), getModel()'/>
- </JToolBar>
-
<JPopupMenu id='tablePopup'>
<JMenuItem id='splitBenthosBatchMenu'
onActionPerformed='handler.splitBatch()'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-30 15:59:25 UTC (rev 900)
@@ -35,14 +35,11 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.ValidationService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
@@ -57,8 +54,6 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -221,26 +216,12 @@
}
rows = Lists.newArrayList();
- model.removeAllAttachment(model.getAttachment());
-
if (!TuttiEntities.isNew(bean)) {
// get all batch species root (says the one with only a species sample category)
BatchContainer<BenthosBatch> rootBenthosBatch =
persistenceService.getRootBenthosBatch(bean.getId());
- model.setRootBatchId(rootBenthosBatch.getIdAsInt());
-
- List<Attachment> attachments =
- persistenceService.getAllAttachments(
- model.getObjectType(),
- model.getObjectId());
- model.addAllAttachment(attachments);
-
- if (log.isInfoEnabled()) {
- log.info("species root batch id: " + model.getRootBatchId());
- }
-
List<BenthosBatch> catches = rootBenthosBatch.getChildren();
for (BenthosBatch aBatch : catches) {
@@ -288,9 +269,9 @@
boolean result = !validator.hasErrorMessagess();
if (result
- && ValidationService.VALIDATION_CONTEXT_VALIDATE.equals(
+ && ValidationService.VALIDATION_CONTEXT_VALIDATE.equals(
getContext().getValidationContext())
- && row.isBatchLeaf()) {
+ && row.isBatchLeaf()) {
List<BenthosBatchFrequency> frequencies =
BenthosFrequencyRowModel.toBeans(row.getFrequency(), batch);
result = TuttiProtocols.isBenthosBatchValid(getDataContext().getProtocol(),
@@ -695,7 +676,6 @@
if (log.isDebugEnabled()) {
log.debug("Closing: " + ui);
}
- ui.getBenthosBatchAttachmentsButton().onCloseUI();
}
//------------------------------------------------------------------------//
@@ -1118,7 +1098,7 @@
Float rowWeight = newRow.getFinestCategory().getNotNullWeight();
boolean subSample = rowWeight != null && childrenWeights != null
- && childrenWeights < rowWeight;
+ && childrenWeights < rowWeight;
for (BenthosBatchRowModel childRow : batchChilds) {
childRow.getFinestCategory().setSubSample(subSample);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-04-30 15:59:25 UTC (rev 900)
@@ -24,10 +24,7 @@
* #L%
*/
-import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
-import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
-import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
@@ -35,12 +32,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode;
import fr.ifremer.tutti.ui.swing.util.TabContentModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
-import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
-import java.util.Collection;
-import java.util.List;
-
import static org.nuiton.i18n.I18n.n_;
/**
@@ -48,7 +41,7 @@
* @since 0.1
*/
public class BenthosBatchUIModel extends AbstractTuttiBatchUIModel<BenthosBatchRowModel, BenthosBatchUIModel>
- implements AttachmentModelAware, TabContentModel {
+ implements TabContentModel {
private static final long serialVersionUID = 1L;
@@ -131,10 +124,6 @@
/** @since 1.0 */
protected int leafNumber;
- protected final List<Attachment> attachment = Lists.newArrayList();
-
- private Integer rootBatchId;
-
public BenthosBatchUIModel(EditCatchesUIModel catchesUIModel) {
super(catchesUIModel,
EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT,
@@ -150,8 +139,7 @@
return CollectionUtils.isEmpty(getRows())
&& getBenthosTotalSortedWeight() == null
&& getBenthosTotalInertWeight() == null
- && getBenthosTotalLivingNotItemizedWeight() == null
- && CollectionUtils.isEmpty(getAttachment());
+ && getBenthosTotalLivingNotItemizedWeight() == null;
}
@Override
@@ -357,57 +345,4 @@
firePropertyChange(PROPERTY_CREATE_MELAG_ENABLED, oldValue, createMelagEnabled);
}
- public void setRootBatchId(Integer rootBatchId) {
- Integer oldValue = getObjectId();
- this.rootBatchId = rootBatchId;
- firePropertyChange(PROPERTY_OBJECT_ID, oldValue, getObjectId());
- }
-
- public Integer getRootBatchId() {
- return rootBatchId;
- }
-
- //------------------------------------------------------------------------//
- //-- AttachmentModelAware --//
- //------------------------------------------------------------------------//
-
- @Override
- public AttachementObjectTypeEnum getObjectType() {
- return AttachementObjectTypeEnum.BATCH;
- }
-
- @Override
- public Integer getObjectId() {
- return rootBatchId;
- }
-
- @Override
- public List<Attachment> getAttachment() {
- return attachment;
- }
-
- @Override
- public void addAllAttachment(Collection<Attachment> attachments) {
- this.attachment.addAll(attachments);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void addAttachment(Attachment attachment) {
- this.attachment.add(attachment);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void removeAllAttachment(Collection<Attachment> attachments) {
- this.attachment.removeAll(attachments);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void removeAttachment(Attachment attachment) {
- this.attachment.remove(attachment);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUI.jaxx 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUI.jaxx 2013-04-30 15:59:25 UTC (rev 900)
@@ -29,7 +29,6 @@
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
jaxx.runtime.swing.editor.NumberEditor
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-04-30 15:59:25 UTC (rev 900)
@@ -36,16 +36,6 @@
_help: {"tutti.editMarineLitterBatch.help"};
}
-#marineLitterBatchTabToolBar {
- floatable: false;
- opaque: false;
- borderPainted: false;
-}
-
-#marineLitterBatchAttachmentsButton {
- enabled: {model.getObjectId() != null};
-}
-
#marineLitterTotalWeightLabel {
text: "tutti.editMarineLitterBatch.field.marineLitterTotalWeight";
toolTipText: "tutti.editMarineLitterBatch.field.marineLitterTotalWeight.tip";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx 2013-04-30 15:59:25 UTC (rev 900)
@@ -29,7 +29,6 @@
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
org.jdesktop.swingx.JXTable
@@ -68,11 +67,6 @@
<TuttiHelpBroker id='broker'
constructorParams='"tutti.editMarineLitterBatch.help"'/>
- <JToolBar id='marineLitterBatchTabToolBar'>
- <ButtonAttachment id='marineLitterBatchAttachmentsButton'
- constructorParams='getHandler().getContext(), getModel()'/>
- </JToolBar>
-
<JPopupMenu id='tablePopup'>
<JMenuItem id='removeMarineLitterBatchMenu'/>
</JPopupMenu>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-30 15:59:25 UTC (rev 900)
@@ -116,18 +116,6 @@
BatchContainer<MarineLitterBatch> batchContainer =
persistenceService.getRootMarineLitterBatch(bean.getId());
- model.setRootBatchId(batchContainer.getIdAsInt());
-
- List<Attachment> attachments =
- persistenceService.getAllAttachments(
- model.getObjectType(),
- model.getObjectId());
- model.addAllAttachment(attachments);
-
- if (log.isInfoEnabled()) {
- log.info("marineLitter root batch id: " + model.getRootBatchId());
- }
-
for (MarineLitterBatch aBatch : batchContainer.getChildren()) {
MarineLitterBatchRowModel entry = loadBatch(aBatch);
rows.add(entry);
@@ -389,7 +377,6 @@
if (log.isDebugEnabled()) {
log.debug("closing: " + ui);
}
- ui.getMarineLitterBatchAttachmentsButton().onCloseUI();
}
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-04-30 15:59:25 UTC (rev 900)
@@ -24,21 +24,14 @@
* #L%
*/
-import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
-import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
-import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.util.TabContentModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
-import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
-import java.util.Collection;
-import java.util.List;
-
import static org.nuiton.i18n.I18n.n_;
/**
@@ -46,14 +39,12 @@
* @since 0.2
*/
public class MarineLitterBatchUIModel extends AbstractTuttiBatchUIModel<MarineLitterBatchRowModel, MarineLitterBatchUIModel>
- implements AttachmentModelAware, TabContentModel {
+ implements TabContentModel {
private static final long serialVersionUID = 1L;
public static final String PROPERTY_REMOVE_BATCH_ENABLED = "removeBatchEnabled";
- protected final List<Attachment> attachment = Lists.newArrayList();
-
/**
* Can user remove a selected marineLitter batch?
*
@@ -61,8 +52,6 @@
*/
protected boolean removeBatchEnabled;
- private Integer rootBatchId;
-
public MarineLitterBatchUIModel(EditCatchesUIModel catchesUIModel) {
super(catchesUIModel,
EditCatchesUIModel.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT);
@@ -98,71 +87,17 @@
firePropertyChange(PROPERTY_REMOVE_BATCH_ENABLED, oldValue, removeBatchEnabled);
}
- public void setRootBatchId(Integer rootBatchId) {
- Integer oldValue = getObjectId();
- this.rootBatchId = rootBatchId;
- firePropertyChange(PROPERTY_OBJECT_ID, oldValue, getObjectId());
- }
-
- public Integer getRootBatchId() {
- return rootBatchId;
- }
-
public Multimap<CaracteristicQualitativeValue, CaracteristicQualitativeValue> getMarineLitterCategoriesUsed() {
return catchesUIModel.getMarineLitterCategoriesUsed();
}
//------------------------------------------------------------------------//
- //-- AttachmentModelAware --//
- //------------------------------------------------------------------------//
-
- @Override
- public AttachementObjectTypeEnum getObjectType() {
- return AttachementObjectTypeEnum.BATCH;
- }
-
- @Override
- public Integer getObjectId() {
- return rootBatchId;
- }
-
- @Override
- public List<Attachment> getAttachment() {
- return attachment;
- }
-
- @Override
- public void addAllAttachment(Collection<Attachment> attachments) {
- this.attachment.addAll(attachments);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void addAttachment(Attachment attachment) {
- this.attachment.add(attachment);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void removeAllAttachment(Collection<Attachment> attachments) {
- this.attachment.removeAll(attachments);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void removeAttachment(Attachment attachment) {
- this.attachment.remove(attachment);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- //------------------------------------------------------------------------//
//-- TabContentModel --//
//------------------------------------------------------------------------//
@Override
public boolean isEmpty() {
- boolean result = getMarineLitterTotalWeight() == null
- && CollectionUtils.isEmpty(getAttachment());
+ boolean result = getMarineLitterTotalWeight() == null;
if (result && CollectionUtils.isNotEmpty(getRows())) {
// check if every line is not valid
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-04-30 15:59:25 UTC (rev 900)
@@ -46,16 +46,6 @@
_help: {"tutti.editSpeciesBatch.help"};
}
-#speciesBatchTabToolBar {
- floatable: false;
- opaque: false;
- borderPainted: false;
-}
-
-#speciesBatchAttachmentsButton {
- enabled: {model.getObjectId() != null};
-}
-
#speciesTotalWeightLabel {
text: "tutti.editSpeciesBatch.field.speciesTotalWeight";
toolTipText: "tutti.editSpeciesBatch.field.speciesTotalWeight.tip";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-04-30 15:59:25 UTC (rev 900)
@@ -29,7 +29,6 @@
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
org.jdesktop.swingx.JXTable
@@ -69,11 +68,6 @@
<TuttiHelpBroker id='broker'
constructorParams='"tutti.editSpeciesBatch.help"'/>
- <JToolBar id='speciesBatchTabToolBar'>
- <ButtonAttachment id='speciesBatchAttachmentsButton'
- constructorParams='getHandler().getContext(), getModel()'/>
- </JToolBar>
-
<JPopupMenu id='tablePopup'>
<JMenuItem id='splitSpeciesBatchMenu'
onActionPerformed='handler.splitBatch()'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-30 15:59:25 UTC (rev 900)
@@ -35,14 +35,11 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.ValidationService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
@@ -71,7 +68,6 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -219,25 +215,12 @@
}
rows = Lists.newArrayList();
- model.removeAllAttachment(model.getAttachment());
-
if (!TuttiEntities.isNew(bean)) {
// get all batch species root (says the one with only a species sample category)
BatchContainer<SpeciesBatch> rootSpeciesBatch =
persistenceService.getRootSpeciesBatch(bean.getId());
- model.setRootBatchId(rootSpeciesBatch.getIdAsInt());
-
- List<Attachment> attachments =
- persistenceService.getAllAttachments(model.getObjectType(),
- model.getObjectId());
- model.addAllAttachment(attachments);
-
- if (log.isInfoEnabled()) {
- log.info("species root batch id: " + model.getRootBatchId());
- }
-
List<SpeciesBatch> catches = rootSpeciesBatch.getChildren();
for (SpeciesBatch aBatch : catches) {
@@ -285,9 +268,9 @@
boolean result = !validator.hasErrorMessagess();
if (result
- && ValidationService.VALIDATION_CONTEXT_VALIDATE.equals(
- getContext().getValidationContext())
- && row.isBatchLeaf()) {
+ && ValidationService.VALIDATION_CONTEXT_VALIDATE.equals(
+ getContext().getValidationContext())
+ && row.isBatchLeaf()) {
List<SpeciesBatchFrequency> frequencies =
SpeciesFrequencyRowModel.toBeans(row.getFrequency(), batch);
@@ -695,7 +678,6 @@
if (log.isDebugEnabled()) {
log.debug("Closing: " + ui);
}
- ui.getSpeciesBatchAttachmentsButton().onCloseUI();
}
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-04-30 15:41:24 UTC (rev 899)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-04-30 15:59:25 UTC (rev 900)
@@ -24,10 +24,7 @@
* #L%
*/
-import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
-import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
-import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
@@ -35,12 +32,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode;
import fr.ifremer.tutti.ui.swing.util.TabContentModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
-import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
-import java.util.Collection;
-import java.util.List;
-
import static org.nuiton.i18n.I18n.n_;
/**
@@ -48,7 +41,7 @@
* @since 0.1
*/
public class SpeciesBatchUIModel extends AbstractTuttiBatchUIModel<SpeciesBatchRowModel, SpeciesBatchUIModel>
- implements AttachmentModelAware, TabContentModel {
+ implements TabContentModel {
private static final long serialVersionUID = 1L;
@@ -131,10 +124,6 @@
/** @since 1.0 */
protected int leafNumber;
- protected final List<Attachment> attachment = Lists.newArrayList();
-
- private Integer rootBatchId;
-
public SpeciesBatchUIModel(EditCatchesUIModel catchesUIModel) {
super(catchesUIModel,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT,
@@ -338,60 +327,7 @@
firePropertyChange(PROPERTY_CREATE_MELAG_ENABLED, oldValue, createMelagEnabled);
}
- public void setRootBatchId(Integer rootBatchId) {
- Integer oldValue = getObjectId();
- this.rootBatchId = rootBatchId;
- firePropertyChange(PROPERTY_OBJECT_ID, oldValue, getObjectId());
- }
-
- public Integer getRootBatchId() {
- return rootBatchId;
- }
-
//------------------------------------------------------------------------//
- //-- AttachmentModelAware --//
- //------------------------------------------------------------------------//
-
- @Override
- public AttachementObjectTypeEnum getObjectType() {
- return AttachementObjectTypeEnum.BATCH;
- }
-
- @Override
- public Integer getObjectId() {
- return rootBatchId;
- }
-
- @Override
- public List<Attachment> getAttachment() {
- return attachment;
- }
-
- @Override
- public void addAllAttachment(Collection<Attachment> attachments) {
- this.attachment.addAll(attachments);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void addAttachment(Attachment attachment) {
- this.attachment.add(attachment);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void removeAllAttachment(Collection<Attachment> attachments) {
- this.attachment.removeAll(attachments);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- @Override
- public void removeAttachment(Attachment attachment) {
- this.attachment.remove(attachment);
- firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
- }
-
- //------------------------------------------------------------------------//
//-- TabContentModel --//
//------------------------------------------------------------------------//
@@ -400,8 +336,7 @@
return CollectionUtils.isEmpty(getRows())
&& getSpeciesTotalSortedWeight() == null
&& getSpeciesTotalInertWeight() == null
- && getSpeciesTotalLivingNotItemizedWeight() == null
- && CollectionUtils.isEmpty(getAttachment());
+ && getSpeciesTotalLivingNotItemizedWeight() == null;
}
@Override
1
0
r899 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service tutti-service/src/main/java/fr/ifremer/tutti/service tutti-service/src/main/resources/i18n
by tchemit@users.forge.codelutin.com 30 Apr '13
by tchemit@users.forge.codelutin.com 30 Apr '13
30 Apr '13
Author: tchemit
Date: 2013-04-30 17:41:24 +0200 (Tue, 30 Apr 2013)
New Revision: 899
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/899
Log:
add isTemporary method
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-04-30 14:31:18 UTC (rev 898)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-04-30 15:41:24 UTC (rev 899)
@@ -46,6 +46,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Species;
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 org.springframework.transaction.annotation.Transactional;
@@ -246,6 +247,8 @@
Caracteristic getWeightMeasuredCaracteristic();
+ boolean isTemporary(TuttiReferentialEntity entity);
+
List<Gear> getAllScientificGear();
List<Gear> getAllFishingGear();
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-04-30 14:31:18 UTC (rev 898)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-04-30 15:41:24 UTC (rev 899)
@@ -50,6 +50,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Species;
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.service.AccidentalBatchPersistenceService;
import fr.ifremer.tutti.persistence.service.AttachmentPersistenceService;
@@ -370,6 +371,11 @@
}
@Override
+ public boolean isTemporary(TuttiReferentialEntity entity) {
+ return referentialService.isTemporary(entity);
+ }
+
+ @Override
public List<Gear> getAllScientificGear() {
return referentialService.getAllScientificGear();
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-04-30 14:31:18 UTC (rev 898)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-04-30 15:41:24 UTC (rev 899)
@@ -46,6 +46,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Species;
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 java.io.File;
@@ -221,6 +222,11 @@
}
@Override
+ public boolean isTemporary(TuttiReferentialEntity entity) {
+ throw new RuntimeException("method not implemented");
+ }
+
+ @Override
public List<Gear> getAllScientificGear() {
throw new RuntimeException("method not implemented");
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-04-30 14:31:18 UTC (rev 898)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-04-30 15:41:24 UTC (rev 899)
@@ -33,6 +33,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Species;
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 org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@@ -238,6 +239,8 @@
Caracteristic getWeightMeasuredCaracteristic();
+ boolean isTemporary(TuttiReferentialEntity entity);
+
List<Gear> getAllScientificGear();
List<Gear> getAllFishingGear();
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-04-30 14:31:18 UTC (rev 898)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-04-30 15:41:24 UTC (rev 899)
@@ -636,6 +636,14 @@
}
@Override
+ public boolean isTemporary(TuttiReferentialEntity entity) {
+ Preconditions.checkNotNull(entity);
+ Preconditions.checkNotNull(entity.getStatus());
+ return enumeration.STATUS_TEMPORARY_CODE.equals(
+ entity.getStatus().getId());
+ }
+
+ @Override
public Caracteristic getCaracteristic(Integer pmfmId) {
Object[] source = queryUniqueWithStatus("pmfmById",
"pmfmId", IntegerType.INSTANCE, pmfmId,
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-04-30 14:31:18 UTC (rev 898)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-04-30 15:41:24 UTC (rev 899)
@@ -53,6 +53,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Species;
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.service.TuttiPersistenceServiceLocator;
import fr.ifremer.tutti.service.config.TuttiServiceConfig;
@@ -472,6 +473,11 @@
}
@Override
+ public boolean isTemporary(TuttiReferentialEntity entity) {
+ return driver.isTemporary(entity);
+ }
+
+ @Override
public Vessel getVessel(String vesselCode) {
return driver.getVessel(vesselCode);
}
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-04-30 14:31:18 UTC (rev 898)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-04-30 15:41:24 UTC (rev 899)
@@ -68,6 +68,8 @@
tutti.service.exportCruise.buildZip=
tutti.service.exportCruise.checkCruise=
tutti.service.exportCruise.exportCatches=
+tutti.service.exportCruise.exportIndividualObservations=
+tutti.service.exportCruise.exportMarineLitters=
tutti.service.exportCruise.exportOperations=
tutti.service.exportCruise.exportParameters=
tutti.service.exportCruise.exportSurvey=
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-04-30 14:31:18 UTC (rev 898)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-04-30 15:41:24 UTC (rev 899)
@@ -66,10 +66,10 @@
tutti.service.exportCruise.buildZip=Création de l'archive de l'export (fichier %s)
tutti.service.exportCruise.checkCruise=Vérification de la campagne %s
tutti.service.exportCruise.exportCatches=Export du fichier <strong>catch.csv</strong> pour la campagne %s
+tutti.service.exportCruise.exportIndividualObservations=Export du fichier <strong>individualObservation.csv</strong> pour la campagne %s
+tutti.service.exportCruise.exportMarineLitters=Export du fichier <strong>marineLitter.csv</strong> pour la campagne %s
tutti.service.exportCruise.exportOperations=Export du fichier <strong>operations.csv</strong> pour la campagne %s
tutti.service.exportCruise.exportParameters=Export du fichier <strong>parameters.csv</strong> pour la campagne %s
-tutti.service.exportCruise.exportMarineLitters=Export du fichier <strong>marineLitter.csv</strong> pour la campagne %s
-tutti.service.exportCruise.exportIndividualObservations=Export du fichier <strong>individualObservation.csv</strong> pour la campagne %s
tutti.service.exportCruise.exportSurvey=Export du fichier <strong>survey.csv</strong> pour la campagne %s
tutti.service.exportSumatra.error.species.null=L'espèce est nulle
tutti.service.exportSumatra.error.station.null=Le trait est nul
1
0
r898 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/db resources/i18n
by kmorin@users.forge.codelutin.com 30 Apr '13
by kmorin@users.forge.codelutin.com 30 Apr '13
30 Apr '13
Author: kmorin
Date: 2013-04-30 16:31:18 +0200 (Tue, 30 Apr 2013)
New Revision: 898
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/898
Log:
refs #2000 [TECH] Mettre en place les messages d'erreur m?\195?\169tier
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-04-30 14:28:59 UTC (rev 897)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-04-30 14:31:18 UTC (rev 898)
@@ -109,7 +109,7 @@
// close db
- progressionModel.setMessage("Fermeture de la base courante");
+ progressionModel.setMessage(_("tutti.exportDb.closeDb"));
TuttiActionHelper.runInternalAction(getHandler(), CloseDbAction.class);
@@ -120,14 +120,14 @@
// export db
progressionModel.increments(1);
- progressionModel.setMessage("Création de l'archive " + file);
+ progressionModel.setMessage(_("tutti.exportDb.createArchive", file));
persistenceService.exportDb(file);
// clean files
progressionModel.increments(1);
- progressionModel.setMessage("Suppression des fichiers dans Tutti");
+ progressionModel.setMessage(_("tutti.exportDb.deleteFiles"));
TuttiPersistenceConfig persistenceConfig =
getConfig().getServiceConfig().getPersistenceConfig();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java 2013-04-30 14:28:59 UTC (rev 897)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java 2013-04-30 14:31:18 UTC (rev 898)
@@ -105,7 +105,7 @@
// close db
- progressionModel.setMessage("Fermuture de la base courante");
+ progressionModel.setMessage(_("tutti.exportDb.closeDb"));
getContext().setDbLoaded(false);
getHandler().reloadPersistenceService();
@@ -113,14 +113,14 @@
// export
progressionModel.increments(1);
- progressionModel.setMessage("Création de l'archive " + file);
+ progressionModel.setMessage(_("tutti.exportDb.createArchive", file));
getContext().getPersistenceService().exportDb(file);
// reopen db
progressionModel.increments(1);
- progressionModel.setMessage("Réouverture de la base courante");
+ progressionModel.setMessage(_("tutti.exportDb.openDb"));
getContext().setDbLoaded(true);
getHandler().reloadPersistenceService();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-04-30 14:28:59 UTC (rev 897)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-04-30 14:31:18 UTC (rev 898)
@@ -100,7 +100,7 @@
// import db
- progressionModel.setMessage("Décompression de l'archive");
+ progressionModel.setMessage(_("tutti.importDb.unzipArchive"));
getContext().getPersistenceService().importDb(file);
getContext().setDbExist(true);
@@ -108,7 +108,7 @@
// open db
progressionModel.increments(1);
- progressionModel.setMessage("Ouverture de la base de données");
+ progressionModel.setMessage(_("tutti.importDb.openDb"));
TuttiActionHelper.runInternalAction(getHandler(), OpenDbAction.class);
}
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-04-30 14:28:59 UTC (rev 897)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-04-30 14:31:18 UTC (rev 898)
@@ -847,6 +847,10 @@
tutti.exportCruiseForSumatra.action.success=
tutti.exportCruiseForSumatra.choose.exportFile.default=
tutti.exportCruiseForSumatra.title.choose.exportFile=
+tutti.exportDb.closeDb=
+tutti.exportDb.createArchive=
+tutti.exportDb.deleteFiles=
+tutti.exportDb.openDb=
tutti.exportProgram.action.success=
tutti.exportProtocol.action.success=
tutti.fishingOperations.action.newFishingOperation.mnemonic=
@@ -891,6 +895,8 @@
tutti.help.mkDir.error=
tutti.i18n.deleteCache.error=
tutti.i18n.mkDir.error=
+tutti.importDb.openDb=
+tutti.importDb.unzipArchive=
tutti.importProtocol.action.success=
tutti.importPupitri.carrouselFile.extension=
tutti.importPupitri.carrouselFile.extension.description=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-30 14:28:59 UTC (rev 897)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-30 14:31:18 UTC (rev 898)
@@ -818,6 +818,10 @@
tutti.exportCruiseForSumatra.action.success=Les captures ont correctement été exporté dans le fichier %s
tutti.exportCruiseForSumatra.choose.exportFile.default=import_sumatra
tutti.exportCruiseForSumatra.title.choose.exportFile=Exporter les captures de la campagne
+tutti.exportDb.closeDb=Fermeture de la base courante
+tutti.exportDb.createArchive=Création de l'archive %s
+tutti.exportDb.deleteFiles=Suppression des fichiers dans Tutti
+tutti.exportDb.openDb=Réouverture de la base courante
tutti.exportProgram.action.success=La série de campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>.
tutti.exportProtocol.action.success=Protocole [%1s] exporté dans le fichier <strong>%2s</strong>.
tutti.fishingOperations.action.newFishingOperation.mnemonic=N
@@ -862,6 +866,8 @@
tutti.help.mkDir.error=Erreur à la création du dossier d'aide
tutti.i18n.deleteCache.error=Erreur à la suppression du cache de l'internationalisation
tutti.i18n.mkDir.error=Erreur à la création du dossier d'internationalisation
+tutti.importDb.openDb=Ouverture de la base de données
+tutti.importDb.unzipArchive=Décompression de l'archive
tutti.importProtocol.action.success=Protocole [%s] lu depuis le fichier.
tutti.importPupitri.carrouselFile.extension=car
tutti.importPupitri.carrouselFile.extension.description=Fichier du carrousel (.car)
1
0