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
r736 - trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 21:02:11 +0200 (Thu, 04 Apr 2013)
New Revision: 736
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/736
Log:
reformat + import + ...
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-04-04 19:01:21 UTC (rev 735)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-04-04 19:02:11 UTC (rev 736)
@@ -1,7 +1,36 @@
package fr.ifremer.tutti.service.catches;
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.TuttiBusinessException;
-import fr.ifremer.tutti.persistence.entities.data.*;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.AbstractTuttiService;
import fr.ifremer.tutti.service.PersistenceService;
@@ -10,7 +39,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.*;
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -33,8 +61,8 @@
}
public void computeCatchBatchWeights(CatchBatch catchBatch,
- BatchContainer<SpeciesBatch> rootSpeciesBatch,
- BatchContainer<SpeciesBatch> rootBenthosBatch) {
+ BatchContainer<SpeciesBatch> rootSpeciesBatch,
+ BatchContainer<SpeciesBatch> rootBenthosBatch) {
// Species
Float speciesTotalComputedSortedWeight = 0f;
@@ -165,11 +193,10 @@
+ totalSortedWeight)) {
throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentTotal"));
- } else {
- catchBatch.setCatchTotalRejectedComputedWeight(totalWeight
- - totalUnsortedWeight
- - totalSortedWeight);
}
+ catchBatch.setCatchTotalRejectedComputedWeight(totalWeight
+ - totalUnsortedWeight
+ - totalSortedWeight);
} else if (totalWeight == null) {
if (rejectedWeight == null) {
@@ -177,8 +204,8 @@
catchBatch.setCatchTotalRejectedComputedWeight(0f);
}
catchBatch.setCatchTotalComputedWeight(totalUnsortedWeight
- + totalSortedWeight
- + rejectedWeight);
+ + totalSortedWeight
+ + rejectedWeight);
} else if (!totalWeight.equals(totalUnsortedWeight + totalSortedWeight + rejectedWeight)) {
throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentTotal"));
@@ -193,8 +220,7 @@
if (rootSpeciesBatch != null) {
List<SpeciesBatch> roots = rootSpeciesBatch.getChildren();
- for (int i = 0; i < roots.size(); i++) {
- SpeciesBatch batch = roots.get(i);
+ for (SpeciesBatch batch : roots) {
computeSpeciesBatch(batch);
}
}
@@ -209,8 +235,7 @@
List<SpeciesBatch> roots = rootBenthosBatch.getChildren();
- for (int i = 0; i < roots.size(); i++) {
- SpeciesBatch batch = roots.get(i);
+ for (SpeciesBatch batch : roots) {
computeSpeciesBatch(batch);
}
@@ -300,7 +325,7 @@
result = frequencyWeight;
} else if (frequencyWeight != null
- && !frequencyWeight.equals(categoryWeight)) {
+ && !frequencyWeight.equals(categoryWeight)) {
// if the weight of the frequencies is different from the category
// weight, then set the weight of the sample
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r735 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 21:01:21 +0200 (Thu, 04 Apr 2013)
New Revision: 735
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/735
Log:
fixes #2248: [TECH] Pi?\195?\168ces-jointes non supprim?\195?\169es
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/AttachmentPersistenceService.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/CatchBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.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/PlanktonBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
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-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -24,10 +24,12 @@
* #L%
*/
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -43,6 +45,9 @@
private static final Log log =
LogFactory.getLog(AccidentalBatchPersistenceServiceImpl.class);
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Override
public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) {
List<AccidentalBatch> result = Lists.newArrayList();
@@ -68,5 +73,7 @@
@Override
public void deleteAccidentalBatch(String id) {
+ Preconditions.checkNotNull(id);
+ attachmentPersistenceService.deleteAllAttachment(Integer.valueOf(id));
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -85,4 +85,12 @@
@Transactional(readOnly = false)
void deleteAttachment(String attachmentId);
+ /**
+ * Deletes all attachments of the given object id.
+ *
+ * @param objectId id of the object
+ */
+ @Transactional(readOnly = false)
+ void deleteAllAttachment(Integer objectId);
+
}
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-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -236,12 +236,17 @@
Attachment target = TuttiBeanFactory.newAttachment();
loadAttachment(source, target);
- measurementFileDao.remove(id);
+ delete(target);
+
getCurrentSession().flush();
+ }
- File file = getFile(target);
- //TODO Hum we do not have a transaction manager for file :(
- TuttiIOUtil.deleteFile(file, "Could not delete attachement file " + file);
+ @Override
+ public void deleteAllAttachment(Integer objectId) {
+ List<Attachment> attachments = getAllAttachments(objectId);
+ for (Attachment attachment : attachments) {
+ delete(attachment);
+ }
}
//------------------------------------------------------------------------//
@@ -269,4 +274,13 @@
File result = new File(dbAttachmentDirectory, attachment.getPath());
return result;
}
+
+ protected void delete(Attachment target) {
+
+ measurementFileDao.remove(target.getObjectId());
+
+ File file = getFile(target);
+ TuttiIOUtil.deleteFile(file, "Could not delete attachement file " + file);
+
+ }
}
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-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -39,6 +39,7 @@
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;
@@ -61,9 +62,12 @@
private static final Log log =
LogFactory.getLog(BenthosBatchPersistenceServiceImpl.class);
- @Resource(name = "referentialPersistenceService")
+ @Autowired
protected ReferentialPersistenceService referentialService;
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
@@ -188,8 +192,11 @@
getCurrentSession().setFlushMode(FlushMode.COMMIT);
- catchBatchDao.removeWithChildren(Integer.valueOf(id));
+ Integer batchId = Integer.valueOf(id);
+ catchBatchDao.removeWithChildren(batchId);
+ attachmentPersistenceService.deleteAllAttachment(batchId);
+
getCurrentSession().flush();
}
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-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -46,6 +46,7 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.FlushMode;
import org.hibernate.type.IntegerType;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.stereotype.Service;
@@ -63,9 +64,12 @@
private static final Log log =
LogFactory.getLog(CatchBatchPersistenceServiceImpl.class);
- @Resource(name = "referentialPersistenceService")
+ @Autowired
protected ReferentialPersistenceService referentialService;
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceService.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceService.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -48,4 +48,7 @@
@Transactional(readOnly = false)
FishingOperation saveFishingOperation(FishingOperation bean);
+
+ @Transactional(readOnly = false)
+ void deleteFishingOperation(String id);
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -103,6 +103,9 @@
@Autowired
protected ReferentialPersistenceService referentialService;
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "scientificCruiseDao")
protected ScientificCruiseDao scientificCruiseDao;
@@ -391,6 +394,13 @@
return bean;
}
+ @Override
+ public void deleteFishingOperation(String id) {
+ Preconditions.checkNotNull(id);
+
+ attachmentPersistenceService.deleteAllAttachment(Integer.valueOf(id));
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
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-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -45,6 +45,7 @@
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;
@@ -64,9 +65,12 @@
private static final Log log =
LogFactory.getLog(MarineLitterBatchPersistenceServiceImpl.class);
- @Resource(name = "referentialPersistenceService")
+ @Autowired
protected ReferentialPersistenceService referentialService;
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
@@ -186,8 +190,11 @@
getCurrentSession().setFlushMode(FlushMode.COMMIT);
- catchBatchDao.removeWithChildren(Integer.valueOf(id));
+ Integer batchId = Integer.valueOf(id);
+ catchBatchDao.removeWithChildren(batchId);
+ attachmentPersistenceService.deleteAllAttachment(batchId);
+
getCurrentSession().flush();
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -24,10 +24,12 @@
* #L%
*/
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -43,6 +45,9 @@
private static final Log log =
LogFactory.getLog(PlanktonBatchPersistenceServiceImpl.class);
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Override
public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
List<PlanktonBatch> result = Lists.newArrayList();
@@ -69,5 +74,7 @@
@Override
public void deletePlanktonBatch(String id) {
+ Preconditions.checkNotNull(id);
+ attachmentPersistenceService.deleteAllAttachment(Integer.valueOf(id));
}
}
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-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -39,6 +39,7 @@
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;
@@ -61,6 +62,9 @@
private static final Log log =
LogFactory.getLog(SpeciesBatchPersistenceServiceImpl.class);
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
@@ -187,8 +191,11 @@
getCurrentSession().setFlushMode(FlushMode.COMMIT);
- catchBatchDao.removeWithChildren(Integer.valueOf(id));
+ Integer batchId = Integer.valueOf(id);
+ catchBatchDao.removeWithChildren(batchId);
+ attachmentPersistenceService.deleteAllAttachment(batchId);
+
getCurrentSession().flush();
}
1
0
r734 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/catches/benthos content/operation/catches/marinelitter content/operation/catches/species util/table
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 13:29:07 +0200 (Thu, 04 Apr 2013)
New Revision: 734
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/734
Log:
fixes #2244: [CAPTURES] Benthos - La cellule des commentaires et pi?\195?\168ces-jointes n'ont pas un fond vert si il y a des donn?\195?\169es dedans
refs #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets
continue ?\195?\160 r?\195?\169usiner les mod?\195?\168les d'ui (SpeciesBatch)
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/marinelitter/MarineLitterBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java
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/species/SpeciesBatchRowModel.java
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/util/table/AbstractTuttiTableUIHandler.java
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-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -66,6 +66,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -86,6 +87,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
+import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
@@ -354,6 +356,79 @@
recomputeBatchActionEnable();
}
+ @Override
+ protected void addHighlighters(JXTable table) {
+
+ super.addHighlighters(table);
+
+ Color toConfirmColor = getConfig().getColorRowToConfirm();
+
+ // paint the cell in orange if the row is to confirm
+ Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate() {
+
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
+ return row.isSpeciesToConfirm();
+ }
+
+ }, toConfirmColor);
+ table.addHighlighter(confirmHighlighter);
+
+ // highlight only the species column if the row is selected
+ Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ HighlightPredicate.IS_SELECTED,
+ new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.SPECIES)),
+ UIManager.getColor("Table[Enabled+Selected].textBackground"));
+
+ table.addHighlighter(selectedHighlighter);
+
+ // paint the cell in dark orange if the row is to confirm and the cell is not editable
+ Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate() {
+
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
+ return row.isSpeciesToConfirm() && !adapter.isEditable();
+ }
+
+ }, toConfirmColor.darker());
+ table.addHighlighter(confirmNotEditableHighlighter);
+
+ // paint in a special color for comment cell (with not null value)
+ Color cellWithValueColor = getConfig().getColorCellWithValue();
+
+ Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.COMMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ String value = (String) adapter.getValue();
+ return StringUtils.isNotBlank(value);
+ }
+ }), cellWithValueColor);
+ table.addHighlighter(commentHighlighter);
+
+ // paint in a special color for attachment cell (when some attachments)
+
+ Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.ATTACHMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ Collection attachments = (Collection) adapter.getValue();
+ return CollectionUtils.isNotEmpty(attachments);
+ }
+ }
+ ), cellWithValueColor);
+ table.addHighlighter(attachmentHighlighter);
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -559,48 +634,6 @@
ui.getBenthosBatchAttachmentsButton().onCloseUI();
}
- @Override
- protected void addHighlighters(JXTable table) {
-
- super.addHighlighters(table);
-
- Color toConfirmColor = getConfig().getColorRowToConfirm();
-
- // paint the cell in orange if the row is to confirm
- Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate() {
-
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.isSpeciesToConfirm();
- }
-
- }, toConfirmColor);
- table.addHighlighter(confirmHighlighter);
-
- // highlight only the species column if the row is selected
- Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- HighlightPredicate.IS_SELECTED,
- new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.SPECIES)),
- UIManager.getColor("Table[Enabled+Selected].textBackground"));
-
- table.addHighlighter(selectedHighlighter);
-
- // paint the cell in dark orange if the row is to confirm and the cell is not editable
- Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate() {
-
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.isSpeciesToConfirm() && !adapter.isEditable();
- }
-
- }, toConfirmColor.darker());
- table.addHighlighter(confirmNotEditableHighlighter);
-
- }
-
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -76,9 +76,11 @@
super(MarineLitterBatch.class, fromBeanBinder, toBeanBinder);
}
- public MarineLitterBatchRowModel(MarineLitterBatch aBatch) {
+ public MarineLitterBatchRowModel(MarineLitterBatch aBatch,
+ List<Attachment> attachments) {
this();
fromBean(aBatch);
+ this.attachment.addAll(attachments);
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -83,4 +83,19 @@
return result;
}
+ @Override
+ protected boolean isCellEditable(int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<MarineLitterBatchRowModel> propertyName) {
+ boolean cellEditable = super.isCellEditable(rowIndex,
+ columnIndex,
+ propertyName);
+ if (ATTACHMENT == propertyName) {
+
+ // only editable if row exists
+ MarineLitterBatchRowModel entry = getEntry(rowIndex);
+ cellEditable = entry.getObjectId() != null;
+ }
+ return cellEditable;
+ }
}
\ No newline at end of file
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-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -34,19 +34,29 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.Collection;
import java.util.List;
/**
@@ -108,8 +118,7 @@
}
for (MarineLitterBatch aBatch : batchContainer.getChildren()) {
- MarineLitterBatchRowModel entry =
- new MarineLitterBatchRowModel(aBatch);
+ MarineLitterBatchRowModel entry = loadBatch(aBatch);
rows.add(entry);
}
}
@@ -118,6 +127,19 @@
recomputeBatchActionEnable();
}
+ protected MarineLitterBatchRowModel loadBatch(MarineLitterBatch aBatch) {
+
+ Integer id = aBatch.getIdAsInt();
+
+ List<Attachment> attachments =
+ persistenceService.getAllAttachments(id);
+
+ MarineLitterBatchRowModel newRow =
+ new MarineLitterBatchRowModel(aBatch, attachments);
+
+ return newRow;
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiTableUIHandler methods --//
//------------------------------------------------------------------------//
@@ -210,6 +232,43 @@
recomputeBatchActionEnable();
}
+ @Override
+ protected void addHighlighters(JXTable table) {
+ super.addHighlighters(table);
+
+ // paint in a special color for comment cell (with not null value)
+ Color cellWithValueColor = getConfig().getColorCellWithValue();
+
+ Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(MarineLitterBatchTableModel.COMMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ String value = (String) adapter.getValue();
+ return StringUtils.isNotBlank(value);
+ }
+ }), cellWithValueColor);
+ table.addHighlighter(commentHighlighter);
+
+ // paint in a special color for attachment cell (when some attachments)
+
+ Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(MarineLitterBatchTableModel.ATTACHMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ Collection attachments = (Collection) adapter.getValue();
+ return CollectionUtils.isNotEmpty(attachments);
+ }
+ }
+ ), cellWithValueColor);
+ table.addHighlighter(attachmentHighlighter);
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -58,10 +58,6 @@
private static final long serialVersionUID = 1L;
- public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm";
-
- public static final String PROPERTY_SPECIES = "species";
-
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory";
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE = "sortedUnsortedCategoryValue";
@@ -102,18 +98,12 @@
public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight";
- public static final String PROPERTY_WEIGHT = "weight";
-
- public static final String PROPERTY_NUMBER = "number";
-
public static final String PROPERTY_FREQUENCY = "frequency";
public static final String PROPERTY_COMPUTED_NUMBER = "computedOrNotNumber";
public static final String PROPERTY_COMPUTED_WEIGHT = "computedOrNotWeight";
- public static final String PROPERTY_PARENT_BATCH = "parentBatch";
-
public static final String PROPERTY_CHILD_BATCH = "childBatch";
public static final String PROPERTY_BATCH_LEAF = "batchLeaf";
@@ -130,7 +120,7 @@
protected final SpeciesBatch editObject = TuttiBeanFactory.newSpeciesBatch();
/**
- * Sorted - Unsroted category (can not be null).
+ * Sorted - Unsorted category (can not be null).
*
* @since 0.2
*/
@@ -144,21 +134,21 @@
protected SampleCategory<CaracteristicQualitativeValue> sizeCategory;
/**
- * Sex (can be null).
+ * Sex category (can be null).
*
* @since 0.2
*/
protected SampleCategory<CaracteristicQualitativeValue> sexCategory;
/**
- * Maturity (can be null).
+ * Maturity category (can be null).
*
* @since 0.2
*/
protected SampleCategory<CaracteristicQualitativeValue> maturityCategory;
/**
- * Age (can be null).
+ * Age category (can be null).
*
* @since 0.2
*/
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-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -58,6 +58,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -74,6 +75,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
+import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
@@ -364,6 +366,79 @@
recomputeBatchActionEnable();
}
+ @Override
+ protected void addHighlighters(JXTable table) {
+
+ super.addHighlighters(table);
+
+ Color toConfirmColor = getConfig().getColorRowToConfirm();
+
+ // paint the cell in orange if the row is to confirm
+ Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate() {
+
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
+ return row.isSpeciesToConfirm();
+ }
+
+ }, toConfirmColor);
+ table.addHighlighter(confirmHighlighter);
+
+ // highlight only the species column if the row is selected
+ Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ HighlightPredicate.IS_SELECTED,
+ new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.SPECIES)),
+ UIManager.getColor("Table[Enabled+Selected].textBackground"));
+
+ table.addHighlighter(selectedHighlighter);
+
+ // paint the cell in dark orange if the row is to confirm and the cell is not editable
+ Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate() {
+
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
+ return row.isSpeciesToConfirm() && !adapter.isEditable();
+ }
+
+ }, toConfirmColor.darker());
+ table.addHighlighter(confirmNotEditableHighlighter);
+
+ // paint in a special color for comment cell (with not null value)
+ Color cellWithValueColor = getConfig().getColorCellWithValue();
+
+ Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ String value = (String) adapter.getValue();
+ return StringUtils.isNotBlank(value);
+ }
+ }), cellWithValueColor);
+ table.addHighlighter(commentHighlighter);
+
+ // paint in a special color for attachment cell (when some attachments)
+
+ Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ Collection attachments = (Collection) adapter.getValue();
+ return CollectionUtils.isNotEmpty(attachments);
+ }
+ }
+ ), cellWithValueColor);
+ table.addHighlighter(attachmentHighlighter);
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -578,48 +653,6 @@
ui.getSpeciesBatchAttachmentsButton().onCloseUI();
}
- @Override
- protected void addHighlighters(JXTable table) {
-
- super.addHighlighters(table);
-
- Color toConfirmColor = getConfig().getColorRowToConfirm();
-
- // paint the cell in orange if the row is to confirm
- Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate() {
-
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.isSpeciesToConfirm();
- }
-
- }, toConfirmColor);
- table.addHighlighter(confirmHighlighter);
-
- // highlight only the species column if the row is selected
- Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- HighlightPredicate.IS_SELECTED,
- new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.SPECIES)),
- UIManager.getColor("Table[Enabled+Selected].textBackground"));
-
- table.addHighlighter(selectedHighlighter);
-
- // paint the cell in dark orange if the row is to confirm and the cell is not editable
- Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate() {
-
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.isSpeciesToConfirm() && !adapter.isEditable();
- }
-
- }, toConfirmColor.darker());
- table.addHighlighter(confirmNotEditableHighlighter);
-
- }
-
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -297,43 +297,12 @@
}
protected void addHighlighters(JXTable table) {
+
// paint in a special color for read only cells
Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly());
table.addHighlighter(readOnlyHighlighter);
- // paint in a special color for comment cell (with not null value)
- Color cellWithValueColor = getConfig().getColorCellWithValue();
-
- Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT),
- // for not null value
- new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- String value = (String) adapter.getValue();
- return StringUtils.isNotBlank(value);
- }
- }), cellWithValueColor);
- table.addHighlighter(commentHighlighter);
-
- // paint in a special color for attachment cell (when some attachments)
-
- Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENT),
- // for not null value
- new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- Collection attachments = (Collection) adapter.getValue();
- return CollectionUtils.isNotEmpty(attachments);
- }
- }
- ), cellWithValueColor);
- table.addHighlighter(attachmentHighlighter);
-
// paint in a special color inValid rows
Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
@@ -351,110 +320,6 @@
table.addHighlighter(validHighlighter);
}
-// protected void addColumnToModel(TableColumnModel model,
-// TableCellEditor editor,
-// TableCellRenderer renderer,
-// ColumnIdentifier<R> identifier) {
-//
-// TableColumnExt col = new TableColumnExt(model.getColumnCount());
-// col.setCellEditor(editor);
-// col.setCellRenderer(renderer);
-// col.setHeaderValue(_(identifier.getHeaderI18nKey()));
-// col.setToolTipText(_(identifier.getHeaderTipI18nKey()));
-//
-// col.setIdentifier(identifier);
-// model.addColumn(col);
-// }
-
-// protected void addColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier) {
-//
-// addColumnToModel(model, null, null, identifier);
-// }
-//
-// protected void addFloatColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// String numberPattern) {
-//
-// NumberCellEditor<Float> editor =
-// JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
-// editor.getNumberEditor().setSelectAllTextOnError(true);
-// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
-// editor.getNumberEditor().setNumberPattern(numberPattern);
-//
-// addColumnToModel(model, editor, null, identifier);
-//
-// }
-
-// protected void addIntegerColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// String numberPattern) {
-//
-// NumberCellEditor<Integer> editor =
-// JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
-// editor.getNumberEditor().setSelectAllTextOnError(true);
-// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
-// editor.getNumberEditor().setNumberPattern(numberPattern);
-//
-// addColumnToModel(model, editor, null, identifier);
-// }
-
-// protected void addBooleanColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// JTable table) {
-//
-// addColumnToModel(model,
-// table.getDefaultEditor(Boolean.class),
-// table.getDefaultRenderer(Boolean.class),
-// identifier);
-// }
-
-// protected <B> void addComboDataColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// Decorator<B> decorator,
-// List<B> data) {
-// JComboBox comboBox = new JComboBox();
-// comboBox.setRenderer(newListCellRender(decorator));
-//
-// List<B> dataToList = Lists.newArrayList(data);
-//
-// // add a null value at first position
-// if (!dataToList.isEmpty() && dataToList.get(0) != null) {
-// dataToList.add(0, null);
-// }
-// SwingUtil.fillComboBox(comboBox, dataToList, null);
-//
-// ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
-// BeanUIUtil.decorate(comboBox, converter);
-// ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox);
-//
-// addColumnToModel(model,
-// editor,
-// newTableCellRender(decorator),
-// identifier);
-// }
-//
-// protected <O> TableCellRenderer newTableCellRender(Class<O> type) {
-//
-// return newTableCellRender(type, null);
-// }
-//
-// protected <O> TableCellRenderer newTableCellRender(Class<O> type, String name) {
-//
-// Decorator<O> decorator = getDecorator(type, name);
-//
-// TableCellRenderer result = newTableCellRender(decorator);
-// return result;
-// }
-//
-// protected <O> TableCellRenderer newTableCellRender(Decorator<O> decorator) {
-//
-// Preconditions.checkNotNull(decorator);
-//
-// DecoratorTableCellRenderer result = new DecoratorTableCellRenderer(decorator, true);
-// return result;
-// }
-
//------------------------------------------------------------------------//
//-- Internal methods (listener methods) --//
//------------------------------------------------------------------------//
1
0
r733 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 13:05:45 +0200 (Thu, 04 Apr 2013)
New Revision: 733
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/733
Log:
reformat code + remove fqn on classes
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/SpeciesBatchPersistenceServiceImpl.java
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-04-04 11:02:34 UTC (rev 732)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-04 11:05:45 UTC (rev 733)
@@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
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.tutti.persistence.entities.TuttiBeanFactory;
@@ -81,16 +82,17 @@
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
Collection<Batch> catchBatchChils = catchBatch.getChildBatchs();
// Vrac / Benthos
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatchChils,
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ SortingBatch vracSpeciesBatch = 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
);
BatchContainer<SpeciesBatch> result = new BatchContainer<SpeciesBatch>();
@@ -108,9 +110,11 @@
}
// Hors-Vrac / Benthos
- SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatchChils,
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ SortingBatch horsVracSpeciesBatch = 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
+ );
if (horsVracSpeciesBatch != null) {
for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) {
@@ -139,7 +143,7 @@
// Load full batch tree
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
SortingBatch batch = SortingBatch.Factory.newInstance();
benthosBatchToEntity(bean, batch, parentBatchId, catchBatch);
@@ -161,7 +165,7 @@
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
getCurrentSession().setFlushMode(FlushMode.COMMIT);
@@ -218,7 +222,7 @@
return results;
}
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(benthosBatchId));
@@ -253,7 +257,7 @@
Integer sortingBatchId = Integer.valueOf(benthosBatchId);
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
if (catchBatch == null) {
return frequencies;
@@ -325,7 +329,12 @@
protected void benthosBatchToEntity(SpeciesBatch source,
SortingBatch target,
String parentBatchId,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- batchHelper.speciesBatchToEntity(source, target, parentBatchId, catchBatch, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ CatchBatch catchBatch) {
+ batchHelper.speciesBatchToEntity(
+ source,
+ target,
+ parentBatchId,
+ catchBatch,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
}
}
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-04-04 11:02:34 UTC (rev 732)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-04 11:05:45 UTC (rev 733)
@@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
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.tutti.persistence.entities.TuttiBeanFactory;
@@ -78,16 +79,17 @@
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
Collection<Batch> catchBatchChilds = catchBatch.getChildBatchs();
// Vrac / Species
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatchChilds,
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
- );
+ 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
+ );
// container of speciesBatch is arbitraty put on vrac type (there is
// no common ancestor for all species batch).
@@ -107,9 +109,10 @@
}
// Hors-Vrac / Species
- SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatchChilds,
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_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);
if (horsVracSpeciesBatch != null) {
for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) {
@@ -139,7 +142,7 @@
// Load full batch tree
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
SortingBatch batch = SortingBatch.Factory.newInstance();
speciesBatchToEntity(bean, batch, parentBatchId, catchBatch);
@@ -161,7 +164,7 @@
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
getCurrentSession().setFlushMode(FlushMode.COMMIT);
@@ -222,7 +225,7 @@
catchBatchId,
"Could not find catchBatch for speciesBatch: " + speciesBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch =
+ CatchBatch catchBatch =
catchBatchDao.loadFullTree(catchBatchId);
SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
@@ -266,7 +269,7 @@
Integer sortingBatchId = Integer.valueOf(speciesBatchId);
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
if (catchBatch == null) {
return notNullFrequencies;
@@ -359,8 +362,13 @@
protected void speciesBatchToEntity(SpeciesBatch source,
SortingBatch target,
String parentBatchId,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- batchHelper.speciesBatchToEntity(source, target, parentBatchId, catchBatch, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ CatchBatch catchBatch) {
+ batchHelper.speciesBatchToEntity(
+ source,
+ target,
+ parentBatchId,
+ catchBatch,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
}
}
1
0
r732 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 13:02:34 +0200 (Thu, 04 Apr 2013)
New Revision: 732
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/732
Log:
refs #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
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-04-04 11:00:48 UTC (rev 731)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-04-04 11:02:34 UTC (rev 732)
@@ -207,7 +207,7 @@
// Should have 2 quantification measurements
- for (QuantificationMeasurement measurement : source.getQuantificationMeasurements()) {
+ for (SortingMeasurement measurement : source.getSortingMeasurements()) {
Integer pmfmId = measurement.getPmfm().getId();
if (marineLitterCategory.equals(pmfmId)) {
QualitativeValue qualitativeValue = measurement.getQualitativeValue();
@@ -266,7 +266,6 @@
// Force subgroup count to '1', as Allegro
target.setSubgroupCount(1f);
- //FIXME-TC Do we really need this ?
// Weight
if (source.getWeight() == null) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
@@ -284,26 +283,26 @@
if (source.getMarineLitterCategory() == null) {
// Nothing to do : will be removed later, using notChangedQuantificationMeasurements
} else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.getQuantificationMeasurement(
+ SortingMeasurement measurement = catchBatchDao.getSortingMeasurement(
target,
marineLitterCategory,
recorderDepartmentId,
true);
- quantificationMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterCategory().getIdAsInt()));
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ measurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterCategory().getIdAsInt()));
+ notChangedSortingMeasurements.remove(measurement);
}
// MarineLitterSizeCategory
if (source.getMarineLitterSizeCategory() == null) {
// Nothing to do : will be removed later, using notChangedQuantificationMeasurements
} else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.getQuantificationMeasurement(
+ SortingMeasurement measurement = catchBatchDao.getSortingMeasurement(
target,
marineLitterSizeCategory,
recorderDepartmentId,
true);
- quantificationMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterSizeCategory().getIdAsInt()));
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ measurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterSizeCategory().getIdAsInt()));
+ notChangedSortingMeasurements.remove(measurement);
}
// Sampling Ratio
@@ -313,9 +312,6 @@
// Individual count
target.setIndividualCount(source.getNumber());
- // Weight
- target.setWeight(source.getWeight());
-
// QualityFlag
QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
target.setQualityFlag(qualityFlag);
1
0
04 Apr '13
Author: tchemit
Date: 2013-04-04 13:00:48 +0200 (Thu, 04 Apr 2013)
New Revision: 731
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/731
Log:
fixes #2243: Mauvaise r?\195?\169cup?\195?\169ration des valeurs qualitatives d'un pmfm
Modified:
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-04-04 08:17:58 UTC (rev 730)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-04-04 11:00:48 UTC (rev 731)
@@ -423,7 +423,7 @@
<![CDATA[
SELECT
qv.id AS id,
- case when (qv.name = qv.description) then qv.name else concat(qv.name, ' - ', qv.description) end AS name,
+ case when (qv.description is null or qv.name = qv.description) then qv.name else concat(qv.name, ' - ', qv.description) end AS name,
qv.status AS status
FROM
PmfmImpl p JOIN p.qualitativeValues qv
1
0
r730 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 10:17:58 +0200 (Thu, 04 Apr 2013)
New Revision: 730
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/730
Log:
continue model imporvment
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 08:17:26 UTC (rev 729)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 08:17:58 UTC (rev 730)
@@ -123,14 +123,14 @@
public static final String PROPERTY_SAMPLE_CATEGORY = "sampleCategory";
/**
- * Species.
+ * Delegate edit object.
*
- * @since 0.3
+ * @since 1.3
*/
- protected Species species;
+ protected final SpeciesBatch editObject = TuttiBeanFactory.newSpeciesBatch();
/**
- * Is catch is vrac or horsVrac?.
+ * Sorted - Unsroted category (can not be null).
*
* @since 0.2
*/
@@ -167,7 +167,7 @@
/**
* Sample category of this batch.
* <p/>
- * This is one of the sample category befined above, used to know if the
+ * This is one of the sample category defined above, used to know if the
* table row which sample category affects this row exactly.
*
* @since 0.3
@@ -175,13 +175,6 @@
private SampleCategory<?> sampleCategory;
/**
- * Is the species need to be confirmed?.
- *
- * @since 0.2
- */
- protected boolean speciesToConfirm;
-
- /**
* Observed weight.
*
* @since 0.2
@@ -198,13 +191,6 @@
new TuttiComputedOrNotData<Integer>();
/**
- * Comment.
- *
- * @since 0.2
- */
- protected String comment;
-
- /**
* Attachments (should never be null).
*
* @since 0.2
@@ -219,14 +205,6 @@
protected List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
/**
- * Parent of this batch (can be null if batch is root).
- *
- * @see #isBatchRoot()
- * @since 0.3
- */
- protected SpeciesBatchRowModel parentBatch;
-
- /**
* List of child batches (can be null or empty if batch is a leaf).
*
* @see #isBatchLeaf()
@@ -274,6 +252,197 @@
}
//------------------------------------------------------------------------//
+ //-- SpeciesBatch --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public Species getSpecies() {
+ return editObject.getSpecies();
+ }
+
+ @Override
+ public void setSpecies(Species species) {
+ Object oldCategory = getSpecies();
+ editObject.setSpecies(species);
+ firePropertyChange(PROPERTY_SPECIES, oldCategory, species);
+ }
+
+ @Override
+ public String getComment() {
+ return editObject.getComment();
+ }
+
+ @Override
+ public void setComment(String comment) {
+ Object oldValue = getComment();
+ editObject.setComment(comment);
+ firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
+ }
+
+ @Override
+ public boolean isSpeciesToConfirm() {
+ return editObject.isSpeciesToConfirm();
+ }
+
+ @Override
+ public void setSpeciesToConfirm(boolean speciesToConfirm) {
+ Object oldValue = isSpeciesToConfirm();
+ editObject.setSpeciesToConfirm(speciesToConfirm);
+ firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
+ }
+
+ @Override
+ public Integer getComputedNumber() {
+ return computedOrNotNumber.getComputedData();
+ }
+
+ @Override
+ public void setComputedNumber(Integer computedNumber) {
+ computedOrNotNumber.setComputedData(computedNumber);
+ }
+
+ @Override
+ public Float getComputedWeight() {
+ return computedOrNotWeight.getComputedData();
+ }
+
+ @Override
+ public void setComputedWeight(Float computedWeight) {
+ computedOrNotWeight.setComputedData(computedWeight);
+ }
+
+ @Override
+ public FishingOperation getFishingOperation() {
+ return editObject.getFishingOperation();
+ }
+
+ @Override
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ editObject.setFishingOperation(fishingOperation);
+ }
+
+ @Override
+ public SpeciesBatchRowModel getParentBatch() {
+ return (SpeciesBatchRowModel) editObject.getParentBatch();
+ }
+
+ @Override
+ public void setParentBatch(SpeciesBatch parentBatch) {
+ Object oldValue = getParentBatch();
+ editObject.setParentBatch(parentBatch);
+ firePropertyChange(PROPERTY_PARENT_BATCH, oldValue, parentBatch);
+ firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot());
+ }
+
+ @Override
+ public Float getWeight() {
+ return computedOrNotWeight.getData();
+ }
+
+ @Override
+ public void setWeight(Float weight) {
+ this.computedOrNotWeight.setData(weight);
+ }
+
+ @Override
+ public SampleCategoryEnum getSampleCategoryType() {
+ return null;
+ }
+
+ @Override
+ public void setSampleCategoryType(SampleCategoryEnum sampleCategoryType) {
+ }
+
+ @Override
+ public Serializable getSampleCategoryValue() {
+ return null;
+ }
+
+ @Override
+ public void setSampleCategoryValue(Serializable sampleCategoryValue) {
+ }
+
+ @Override
+ public Float getSampleCategoryWeight() {
+ return null;
+ }
+
+ @Override
+ public void setSampleCategoryWeight(Float sampleCategoryWeight) {
+ }
+
+ @Override
+ public Integer getNumber() {
+ return computedOrNotNumber.getData();
+ }
+
+ @Override
+ public void setNumber(Integer number) {
+ computedOrNotNumber.setData(number);
+ }
+
+ @Override
+ public Float getSampleCategoryComputedWeight() {
+ return null;
+ }
+
+ @Override
+ public void setSampleCategoryComputedWeight(Float sampleCategoryComputedWeight) {
+ }
+
+ @Override
+ public SpeciesBatch getChildBatchs(int index) {
+ return null;
+ }
+
+ @Override
+ public boolean isChildBatchsEmpty() {
+ return false;
+ }
+
+ @Override
+ public int sizeChildBatchs() {
+ return 0;
+ }
+
+ @Override
+ public void addChildBatchs(SpeciesBatch childBatchs) {
+ }
+
+ @Override
+ public void addAllChildBatchs(Collection<SpeciesBatch> childBatchs) {
+ }
+
+ @Override
+ public boolean removeChildBatchs(SpeciesBatch childBatchs) {
+ return false;
+ }
+
+ @Override
+ public boolean removeAllChildBatchs(Collection<SpeciesBatch> childBatchs) {
+ return false;
+ }
+
+ @Override
+ public boolean containsChildBatchs(SpeciesBatch childBatchs) {
+ return false;
+ }
+
+ @Override
+ public boolean containsAllChildBatchs(Collection<SpeciesBatch> childBatchs) {
+ return false;
+ }
+
+ @Override
+ public List<SpeciesBatch> getChildBatchs() {
+ return null;
+ }
+
+ @Override
+ public void setChildBatchs(List<SpeciesBatch> childBatchs) {
+ }
+
+ //------------------------------------------------------------------------//
//-- Sample category --//
//------------------------------------------------------------------------//
@@ -330,20 +499,6 @@
}
//------------------------------------------------------------------------//
- //-- Species category --//
- //------------------------------------------------------------------------//
-
- public Species getSpecies() {
- return species;
- }
-
- public void setSpecies(Species species) {
- Object oldCategory = getSpecies();
- this.species = species;
- firePropertyChange(PROPERTY_SPECIES, oldCategory, species);
- }
-
- //------------------------------------------------------------------------//
//-- SortedUnsorted category --//
//------------------------------------------------------------------------//
@@ -564,61 +719,6 @@
}
//------------------------------------------------------------------------//
- //-- Navigation properties --//
- //------------------------------------------------------------------------//
-
- @Override
- public SpeciesBatchRowModel getParentBatch() {
- return parentBatch;
- }
-
- @Override
- public void setParentBatch(SpeciesBatch parentBatch) {
- }
-
- public void setParentBatch(SpeciesBatchRowModel parentBatch) {
- Object oldValue = getParentBatch();
- this.parentBatch = parentBatch;
- firePropertyChange(PROPERTY_PARENT_BATCH, oldValue, parentBatch);
- firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot());
- }
-
- public List<SpeciesBatchRowModel> getChildBatch() {
- return childBatch;
- }
-
- public void setChildBatch(List<SpeciesBatchRowModel> childBatch) {
- this.childBatch = childBatch;
- // force to propagate child changes
- firePropertyChange(PROPERTY_CHILD_BATCH, null, childBatch);
- firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf());
- }
-
- public boolean isBatchLeaf() {
- return CollectionUtils.isEmpty(childBatch);
- }
-
- public boolean isBatchRoot() {
- return parentBatch == null;
- }
-
- //------------------------------------------------------------------------//
- //-- CommentAware --//
- //------------------------------------------------------------------------//
-
- @Override
- public String getComment() {
- return comment;
- }
-
- @Override
- public void setComment(String comment) {
- Object oldValue = getComment();
- this.comment = comment;
- firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
- }
-
- //------------------------------------------------------------------------//
//-- AttachmentModelAware --//
//------------------------------------------------------------------------//
@@ -665,134 +765,25 @@
//-- Other properties --//
//------------------------------------------------------------------------//
- @Override
- public boolean isSpeciesToConfirm() {
- return speciesToConfirm;
+ public List<SpeciesBatchRowModel> getChildBatch() {
+ return childBatch;
}
- public void setSpeciesToConfirm(boolean speciesToConfirm) {
- Object oldValue = isSpeciesToConfirm();
- this.speciesToConfirm = speciesToConfirm;
- firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
+ public void setChildBatch(List<SpeciesBatchRowModel> childBatch) {
+ this.childBatch = childBatch;
+ // force to propagate child changes
+ firePropertyChange(PROPERTY_CHILD_BATCH, null, childBatch);
+ firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf());
}
- @Override
- public FishingOperation getFishingOperation() {
- return null;
+ public boolean isBatchLeaf() {
+ return CollectionUtils.isEmpty(childBatch);
}
- @Override
- public void setFishingOperation(FishingOperation fishingOperation) {
+ public boolean isBatchRoot() {
+ return getParentBatch() == null;
}
- @Override
- public Float getWeight() {
- return computedOrNotWeight.getData();
- }
-
- @Override
- public void setWeight(Float weight) {
- this.computedOrNotWeight.setData(weight);
- }
-
- @Override
- public SampleCategoryEnum getSampleCategoryType() {
- return null;
- }
-
- @Override
- public void setSampleCategoryType(SampleCategoryEnum sampleCategoryType) {
- }
-
- @Override
- public Serializable getSampleCategoryValue() {
- return null;
- }
-
- @Override
- public void setSampleCategoryValue(Serializable sampleCategoryValue) {
- }
-
- @Override
- public Float getSampleCategoryWeight() {
- return null;
- }
-
- @Override
- public void setSampleCategoryWeight(Float sampleCategoryWeight) {
- }
-
- @Override
- public Integer getNumber() {
- return computedOrNotNumber.getData();
- }
-
- @Override
- public void setNumber(Integer number) {
- computedOrNotNumber.setData(number);
- }
-
- @Override
- public Float getSampleCategoryComputedWeight() {
- return null;
- }
-
- @Override
- public void setSampleCategoryComputedWeight(Float sampleCategoryComputedWeight) {
- }
-
- @Override
- public SpeciesBatch getChildBatchs(int index) {
- return null;
- }
-
- @Override
- public boolean isChildBatchsEmpty() {
- return false;
- }
-
- @Override
- public int sizeChildBatchs() {
- return 0;
- }
-
- @Override
- public void addChildBatchs(SpeciesBatch childBatchs) {
- }
-
- @Override
- public void addAllChildBatchs(Collection<SpeciesBatch> childBatchs) {
- }
-
- @Override
- public boolean removeChildBatchs(SpeciesBatch childBatchs) {
- return false;
- }
-
- @Override
- public boolean removeAllChildBatchs(Collection<SpeciesBatch> childBatchs) {
- return false;
- }
-
- @Override
- public boolean containsChildBatchs(SpeciesBatch childBatchs) {
- return false;
- }
-
- @Override
- public boolean containsAllChildBatchs(Collection<SpeciesBatch> childBatchs) {
- return false;
- }
-
- @Override
- public List<SpeciesBatch> getChildBatchs() {
- return null;
- }
-
- @Override
- public void setChildBatchs(List<SpeciesBatch> childBatchs) {
- }
-
public List<SpeciesFrequencyRowModel> getFrequency() {
return frequency;
}
@@ -803,26 +794,6 @@
firePropertyChange(PROPERTY_FREQUENCY, null, frequency);
}
- @Override
- public Integer getComputedNumber() {
- return computedOrNotNumber.getComputedData();
- }
-
- @Override
- public void setComputedNumber(Integer computedNumber) {
- computedOrNotNumber.setComputedData(computedNumber);
- }
-
- @Override
- public Float getComputedWeight() {
- return computedOrNotWeight.getComputedData();
- }
-
- @Override
- public void setComputedWeight(Float computedWeight) {
- computedOrNotWeight.setComputedData(computedWeight);
- }
-
public TuttiComputedOrNotData<Integer> getComputedOrNotNumber() {
return computedOrNotNumber;
}
1
0
r729 - in trunk/tutti-persistence/src: main/java/fr/ifremer/tutti/persistence/service test/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 10:17:26 +0200 (Thu, 04 Apr 2013)
New Revision: 729
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/729
Log:
refs #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceWriteTest.java
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-04-04 08:17:10 UTC (rev 728)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-04-04 08:17:26 UTC (rev 729)
@@ -39,7 +39,6 @@
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.TuttiBatchEntity;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper;
@@ -103,21 +102,12 @@
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
- Collection<Batch> catchBatchChilds = catchBatch.getChildBatchs();
+ // Get marine litter root batch
+ SortingBatch vracMarineLitterBatch = getMarineLitterParentBatch(catchBatch);
- // Vrac / Marine Litter
- SortingBatch vracMarineLitterBatch = 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_MARINE_LITTER);
-
BatchContainer<MarineLitterBatch> result = new BatchContainer<>();
result.setId(vracMarineLitterBatch.getId());
@@ -144,16 +134,18 @@
public MarineLitterBatch createMarineLitterBatch(MarineLitterBatch bean) {
Preconditions.checkNotNull(bean);
Preconditions.checkArgument(bean.getId() == null);
+ Preconditions.checkNotNull(bean.getFishingOperation());
+ Preconditions.checkNotNull(bean.getFishingOperation().getId());
Preconditions.checkNotNull(bean.getMarineLitterCategory());
Preconditions.checkNotNull(bean.getMarineLitterSizeCategory());
-// Preconditions.checkNotNull(bean.getNumber());
+ Preconditions.checkNotNull(bean.getNumber());
// Preconditions.checkNotNull(bean.getWeight());
getCurrentSession().setFlushMode(FlushMode.COMMIT);
// Load full batch tree
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
SortingBatch batch = SortingBatch.Factory.newInstance();
marineLitterBatchToEntity(bean, batch, catchBatch);
@@ -175,7 +167,7 @@
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
getCurrentSession().setFlushMode(FlushMode.COMMIT);
@@ -234,7 +226,7 @@
protected void marineLitterBatchToEntity(MarineLitterBatch source,
SortingBatch target,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
+ CatchBatch catchBatch) {
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
@@ -258,7 +250,7 @@
// If parent and root need to be set
if (target.getId() == null || target.getRootBatch() == null) {
- setBatchParents(source, target, catchBatch);
+ setBatchParents(target, catchBatch);
}
// RankOrder (initialize once, at creation)
@@ -325,9 +317,8 @@
target.setWeight(source.getWeight());
// QualityFlag
- String qualityFlag;
- qualityFlag = enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED;
- target.setQualityFlag(load(QualityFlagImpl.class, qualityFlag));
+ QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
+ target.setQualityFlag(qualityFlag);
// Comments
target.setComments(source.getComment());
@@ -342,23 +333,14 @@
if (sortingMeasurements != null) {
sortingMeasurements.removeAll(notChangedSortingMeasurements);
}
-
}
- public void setBatchParents(TuttiBatchEntity source,
- SortingBatch target,
- CatchBatch catchBatch) {
+ public void setBatchParents(SortingBatch target, CatchBatch catchBatch) {
Preconditions.checkNotNull(target);
- Preconditions.checkNotNull(source.getFishingOperation());
- Preconditions.checkNotNull(source.getFishingOperation().getId());
// Load existing parent and root
- SortingBatch parentBatch = catchBatchDao.getSortingBatch(
- catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID,
- enumeration.PMFM_ID_SORTING_TYPE,
- enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER);
+ SortingBatch parentBatch = getMarineLitterParentBatch(catchBatch);
// Parent Batch
@@ -371,4 +353,16 @@
target.setParentBatch(parentBatch);
target.setRootBatch(catchBatch);
}
+
+ protected SortingBatch getMarineLitterParentBatch(CatchBatch catchBatch) {
+ SortingBatch parentBatch = catchBatchDao.getSortingBatch(
+ catchBatch.getChildBatchs(),
+ BatchPersistenceHelper.BATCH_PMFM_ID, // hors vrac
+ 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/test/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceWriteTest.java 2013-04-04 08:17:10 UTC (rev 728)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceWriteTest.java 2013-04-04 08:17:26 UTC (rev 729)
@@ -25,18 +25,34 @@
*/
import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
-import org.junit.Ignore;
import org.junit.Test;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* To test {@link MarineLitterBatchPersistenceService} for write operation.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-@Ignore
public class MarineLitterBatchPersistenceServiceWriteTest {
@ClassRule
@@ -44,22 +60,176 @@
protected MarineLitterBatchPersistenceService service;
+ /*
+ * Entities prepared in setUp() :
+ * */
+ protected FishingOperation fishingOperationNoCatchBatch;
+
+ protected FishingOperation fishingOperationWithEmptyBatch;
+
+ protected CatchBatch catchBacth;
+
+ protected Caracteristic marineLitterCategoryCaracteristic;
+
+ protected Caracteristic marineLitterSizeCategoryCaracteristic;
+
@Before
public void setUp() throws Exception {
service = TuttiPersistenceServiceLocator.getMarineLitterBatchPersistenceService();
+
+
+ CruisePersistenceService cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
+ CatchBatchPersistenceService catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
+ FishingOperationPersistenceService fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
+ ReferentialPersistenceService referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
+
+ marineLitterCategoryCaracteristic = referentialService.getMarineLitterCategoryCaracteristic();
+
+ marineLitterSizeCategoryCaracteristic = referentialService.getMarineLitterSizeCategoryCaracteristic();
+
+ Cruise cruise = cruiseService.getCruise(dbResource.getFixtures().cruiseId());
+ cruise.setId((String) null);
+ Calendar calendar = new GregorianCalendar();
+ cruise.setBeginDate(calendar.getTime());
+ calendar.add(Calendar.MONTH, 1); // add one month
+ cruise.setEndDate(calendar.getTime());
+ List<TuttiLocation> allHarbour = referentialService.getAllHarbour();
+ Assert.assertNotNull(allHarbour);
+ Assert.assertTrue(allHarbour.size() > 1);
+ cruise.setDepartureLocation(allHarbour.get(0));
+ cruise.setReturnLocation(allHarbour.get(1));
+
+ cruise = cruiseService.createCruise(cruise);
+
+ // Create a first operation, with no cacth batch : to test CatchBatch insert/update :
+ List<FishingOperation> fishingOperations = fishingOperationService.getAllFishingOperation(dbResource.getFixtures().cruiseId());
+ assertNotNull(fishingOperations);
+ assertTrue(fishingOperations.size() > 0);
+ fishingOperationNoCatchBatch = fishingOperations.get(0);
+ fishingOperationNoCatchBatch = fishingOperationService.getFishingOperation(fishingOperationNoCatchBatch.getId());
+ fishingOperationNoCatchBatch.setId((String) null);
+ fishingOperationNoCatchBatch.setCruise(cruise);
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 1);
+ calendar.set(Calendar.MILLISECOND, 0);
+ fishingOperationNoCatchBatch.setGearShootingStartDate(calendar.getTime());
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 10);
+ calendar.set(Calendar.MILLISECOND, 0);
+ fishingOperationNoCatchBatch.setGearShootingEndDate(calendar.getTime());
+ fishingOperationNoCatchBatch = fishingOperationService.createFishingOperation(fishingOperationNoCatchBatch);
+
+ // Create a second operation, with no cacth batch : to test CatchBatch insert/update :
+ fishingOperationWithEmptyBatch = fishingOperations.get(1);
+ fishingOperationWithEmptyBatch = fishingOperationService.getFishingOperation(fishingOperationWithEmptyBatch.getId());
+ fishingOperationWithEmptyBatch.setId((String) null);
+ fishingOperationWithEmptyBatch.setCruise(cruise);
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 11);
+ calendar.set(Calendar.MILLISECOND, 0);
+ fishingOperationWithEmptyBatch.setGearShootingStartDate(calendar.getTime());
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 12);
+ calendar.set(Calendar.MILLISECOND, 0);
+ fishingOperationWithEmptyBatch.setGearShootingEndDate(calendar.getTime());
+ fishingOperationWithEmptyBatch = fishingOperationService.createFishingOperation(fishingOperationWithEmptyBatch);
+
+ catchBacth = TuttiBeanFactory.newCatchBatch();
+ catchBacth.setFishingOperation(fishingOperationWithEmptyBatch);
+ catchBacth = catchBatchService.createCatchBatch(catchBacth);
}
@Test
public void createMarineLitterBatch(/*MarineLitterBatch bean*/) {
+ MarineLitterBatch newMarineLitter =
+ TuttiBeanFactory.newMarineLitterBatch();
+
+ newMarineLitter.setFishingOperation(fishingOperationWithEmptyBatch);
+ newMarineLitter.setMarineLitterCategory(marineLitterCategoryCaracteristic.getQualitativeValue(0));
+ newMarineLitter.setMarineLitterSizeCategory(marineLitterSizeCategoryCaracteristic.getQualitativeValue(0));
+ newMarineLitter.setNumber(10);
+
+ MarineLitterBatch createdBatch = service.createMarineLitterBatch(newMarineLitter);
+
+ assertMarineLitterBatch(newMarineLitter, createdBatch);
+
+ // then reload (for round trip check)
+ MarineLitterBatch reloadedBatch = getMarineLitterBatch(
+ newMarineLitter.getFishingOperation().getId(), createdBatch.getId());
+
+ assertMarineLitterBatch(newMarineLitter, reloadedBatch);
}
@Test
public void saveMarineLitterBatch(/*MarineLitterBatch bean*/) {
+ MarineLitterBatch newMarineLitter =
+ TuttiBeanFactory.newMarineLitterBatch();
+
+ newMarineLitter.setFishingOperation(fishingOperationWithEmptyBatch);
+ newMarineLitter.setMarineLitterCategory(marineLitterCategoryCaracteristic.getQualitativeValue(0));
+ newMarineLitter.setMarineLitterSizeCategory(marineLitterSizeCategoryCaracteristic.getQualitativeValue(0));
+ newMarineLitter.setNumber(10);
+
+ MarineLitterBatch createdBatch = service.createMarineLitterBatch(newMarineLitter);
+ newMarineLitter.setId(createdBatch.getId());
+
+ // modify some values
+ newMarineLitter.setComment("A comment");
+ newMarineLitter.setWeight(5.f);
+ newMarineLitter.setMarineLitterCategory(marineLitterCategoryCaracteristic.getQualitativeValue(1));
+ MarineLitterBatch savedMarineLitterBatch = service.saveMarineLitterBatch(newMarineLitter);
+
+ assertMarineLitterBatch(newMarineLitter, savedMarineLitterBatch);
}
@Test
public void deleteMarineLitterBatch(/*String id*/) {
+ MarineLitterBatch newMarineLitter =
+ TuttiBeanFactory.newMarineLitterBatch();
+
+ newMarineLitter.setFishingOperation(fishingOperationWithEmptyBatch);
+ newMarineLitter.setMarineLitterCategory(marineLitterCategoryCaracteristic.getQualitativeValue(0));
+ newMarineLitter.setMarineLitterSizeCategory(marineLitterSizeCategoryCaracteristic.getQualitativeValue(0));
+ newMarineLitter.setNumber(10);
+
+ MarineLitterBatch createdMarineLitterBatch = service.createMarineLitterBatch(newMarineLitter);
+
+ BatchContainer<MarineLitterBatch> rootMarineLitterBatch = service.getRootMarineLitterBatch(fishingOperationWithEmptyBatch.getId());
+ Assert.assertNotNull(rootMarineLitterBatch);
+ Assert.assertFalse(rootMarineLitterBatch.getChildren().isEmpty());
+
+ // delete it
+
+ service.deleteMarineLitterBatch(createdMarineLitterBatch.getId());
+
+ rootMarineLitterBatch = service.getRootMarineLitterBatch(fishingOperationWithEmptyBatch.getId());
+ Assert.assertNotNull(rootMarineLitterBatch);
+ Assert.assertTrue(rootMarineLitterBatch.getChildren().isEmpty());
+
}
+
+ protected void assertMarineLitterBatch(MarineLitterBatch expectedBatch,
+ MarineLitterBatch actualBatch) {
+ assertNotNull(actualBatch);
+ assertNotNull(actualBatch.getId());
+ assertEquals(expectedBatch.getId(), actualBatch.getId());
+
+ assertEquals(expectedBatch.getMarineLitterCategory(), actualBatch.getMarineLitterCategory());
+ assertEquals(expectedBatch.getMarineLitterSizeCategory(), actualBatch.getMarineLitterSizeCategory());
+ assertEquals(expectedBatch.getNumber(), actualBatch.getNumber());
+ assertEquals(expectedBatch.getWeight(), actualBatch.getWeight());
+ assertEquals(expectedBatch.getComment(), actualBatch.getComment());
+ }
+
+ protected MarineLitterBatch getMarineLitterBatch(String fishingOperationId, String id) {
+ BatchContainer<MarineLitterBatch> rootMarineLitterBatch = service.getRootMarineLitterBatch(fishingOperationId);
+ for (MarineLitterBatch marineLitterBatch : rootMarineLitterBatch.getChildren()) {
+ if (id.equals(marineLitterBatch.getId())) {
+ return marineLitterBatch;
+ }
+ }
+ return null;
+ }
}
1
0
04 Apr '13
Author: tchemit
Date: 2013-04-04 10:17:10 +0200 (Thu, 04 Apr 2013)
New Revision: 728
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/728
Log:
refs #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets
Modified:
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-service/src/main/resources/i18n/tutti-service_en_GB.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-04-04 07:48:18 UTC (rev 727)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-04-04 08:17:10 UTC (rev 728)
@@ -47,6 +47,7 @@
tutti.propety.no.vessel.name=
tutti.propety.no.zone=
tutti.propety.vessel.nation.registrationCode=
+tutti.service.catches.computeWeights.error.incoherentBenthosTotalSorted=
tutti.service.catches.computeWeights.error.incoherentCategoryWeight=
tutti.service.catches.computeWeights.error.incoherentParentCategoryWeight=
tutti.service.catches.computeWeights.error.incoherentRowWeightCategory=
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-04 07:48:18 UTC (rev 727)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-04-04 08:17:10 UTC (rev 728)
@@ -44,6 +44,7 @@
tutti.propety.no.vessel.name=Nom inconnu
tutti.propety.no.zone=Pas de zone
tutti.propety.vessel.nation.registrationCode=%s (nat.)
+tutti.service.catches.computeWeights.error.incoherentBenthosTotalSorted=
tutti.service.catches.computeWeights.error.incoherentCategoryWeight=Le poids total des mensurations est supérieur au poids de la catégorie
tutti.service.catches.computeWeights.error.incoherentParentCategoryWeight=Le poids de la catégorie est différent de la somme des poids de ses sous-catégories
tutti.service.catches.computeWeights.error.incoherentRowWeightCategory=Le poids de la catégorie ne peut pas être nul si le poids de sous-échantillonage est renseigné
1
0
r727 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 09:48:18 +0200 (Thu, 04 Apr 2013)
New Revision: 727
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/727
Log:
do not persist tremis and carroussel weights
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
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-04-04 07:47:59 UTC (rev 726)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-04-04 07:48:18 UTC (rev 727)
@@ -231,7 +231,7 @@
if (speciesBatch != null) {
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac> Species: " + speciesBatch.getId());
+ log.info("Loaded CatchBatch Hors Vrac > Species: " + speciesBatch.getId());
}
}
@@ -245,7 +245,7 @@
if (benthosBatch != null) {
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac> Benthos: " + benthosBatch.getId());
+ log.info("Loaded CatchBatch Hors Vrac > Benthos: " + benthosBatch.getId());
}
}
@@ -259,7 +259,7 @@
if (marineLitterBatch != null) {
if (log.isInfoEnabled()) {
- log.info("Loaded CatchBatch Hors Vrac> MarineLitter: " + marineLitterBatch.getId());
+ log.info("Loaded CatchBatch Hors Vrac > MarineLitter: " + marineLitterBatch.getId());
}
result.setMarineLitterTotalWeight(marineLitterBatch.getWeight());
@@ -373,13 +373,10 @@
if (quantificationMeasurements != null) {
quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
}
-// if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
-// for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
-// target.getQuantificationMeasurements().remove(qm);
-// }
-// }
- Map<Integer, SortingBatch> catchBatchChilds = getChildsMap(target, enumeration.PMFM_ID_SORTED_UNSORTED);
+ Map<Integer, SortingBatch> catchBatchChilds = getChildsMap(
+ target, enumeration.PMFM_ID_SORTED_UNSORTED);
+
// -----------------------------------------------------------------------------
// Vrac
// -----------------------------------------------------------------------------
@@ -389,18 +386,17 @@
batch = SortingBatch.Factory.newInstance();
target.getChildBatchs().add(batch);
}
- //FIXME-TC what is the point catchTotalSortedCarousselWeight and catchTotalSortedTremisWeight ?
+
beanToEntitySortingBatch(target,
target,
batch,
recorderDepartmentId,
enumeration.PMFM_ID_SORTED_UNSORTED,
enumeration.QUALITATIVE_VRAC_ID,
- source.getCatchTotalSortedCarousselWeight(),
- source.getCatchTotalSortedTremisWeight());
+ null,
+ null);
batch.setRankOrder((short) 1);
- // Manage childs :
{
if (batch.getChildBatchs() == null) {
batch.setChildBatchs(Lists.<Batch>newArrayList());
@@ -608,7 +604,6 @@
null);
batch.setRankOrder((short) 2);
- // Manage childs :
{
Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
@@ -699,7 +694,6 @@
source.getCatchTotalRejectedWeight(),
null);
unsortedBatch.setRankOrder((short) 3);
-
}
protected Map<Integer, SortingBatch> getChildsMap(Batch parentBatch, Integer pmfmId) {
1
0