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
April 2013
- 5 participants
- 210 discussions
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
r726 - trunk/tutti-persistence/src/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 09:47:59 +0200 (Thu, 04 Apr 2013)
New Revision: 726
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/726
Log:
improve tests
Modified:
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-04-04 06:12:12 UTC (rev 725)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-04-04 07:47:59 UTC (rev 726)
@@ -71,19 +71,9 @@
protected SpeciesBatchPersistenceService service;
- protected CatchBatchPersistenceService catchBatchService;
-
- protected CruisePersistenceService cruiseService;
-
- protected FishingOperationPersistenceService fishingOperationService;
-
- protected ReferentialPersistenceService referentialService;
-
/*
* Entities prepared in setUp() :
* */
- protected Cruise cruise;
-
protected FishingOperation fishingOperationNoCatchBatch;
protected FishingOperation fishingOperationWithEmptyBatch;
@@ -116,16 +106,17 @@
public void setUp() throws Exception {
service = TuttiPersistenceServiceLocator.getSpeciesBatchPersistenceService();
- cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
- catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
- fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
- referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
+ CruisePersistenceService cruiseService = TuttiPersistenceServiceLocator.getCruisePersistenceService();
+ CatchBatchPersistenceService catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
+ FishingOperationPersistenceService fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
+ ReferentialPersistenceService referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
+
species = referentialService.getAllSpecies();
assertNotNull(species);
assertTrue(species.size() > 2);
- cruise = cruiseService.getCruise(dbResource.getFixtures().cruiseId());
+ Cruise cruise = cruiseService.getCruise(dbResource.getFixtures().cruiseId());
cruise.setId((String) null);
Calendar calendar = new GregorianCalendar();
cruise.setBeginDate(calendar.getTime());
1
0
r725 - trunk/tutti-persistence/src/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 08:12:12 +0200 (Thu, 04 Apr 2013)
New Revision: 725
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/725
Log:
fix test
Modified:
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java 2013-04-04 05:49:42 UTC (rev 724)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java 2013-04-04 06:12:12 UTC (rev 725)
@@ -129,12 +129,12 @@
String zoneId = dbResource.getFixtures().zoneId();
List<TuttiLocation> result =
service.getAllFishingOperationSubStrata(zoneId, null);
- assertResultList(result, 76);
+ assertResultList(result, 0);
// try with a strataId
String strataId = dbResource.getFixtures().strataId();
result = service.getAllFishingOperationSubStrata(zoneId, strataId);
- assertResultList(result, 1);
+ assertResultList(result, 0);
}
@Test
1
0
r724 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch
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 07:49:42 +0200 (Thu, 04 Apr 2013)
New Revision: 724
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/724
Log:
refs #2227: [CAPTURE] Revoir la structure de l'arbre d'?\195?\169chantillonage (fix SpeciesBatch)
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-04-03 18:25:40 UTC (rev 723)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-04-04 05:49:42 UTC (rev 724)
@@ -347,17 +347,6 @@
if (sortingMeasurements != null) {
sortingMeasurements.removeAll(notChangedSortingMeasurements);
}
-// if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
-// for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
-// target.getQuantificationMeasurements().remove(qm);
-// }
-// }
-//
-// if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
-// for (SortingMeasurement sm : notChangedSortingMeasurements) {
-// target.getSortingMeasurements().remove(sm);
-// }
-// }
}
protected void setBatchParents(SpeciesBatch source,
@@ -388,18 +377,11 @@
}
Integer qualitativeValueId = convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
- //FIXME-TC Should have PMFM_ID_SORTING_TYPE > PMFM_ID_SORTING_TYPE_2 > pmfmId ?
-// parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
-// BATCH_PMFM_ID, pmfmId, qualitativeValueId,
-// BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId,
-// BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED);
parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+ BATCH_PMFM_ID, pmfmId, qualitativeValueId, // vrac | hors vrac
BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // species | Benthos
- BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED, // vivant trié
- BATCH_PMFM_ID, pmfmId, qualitativeValueId); // vrac | hors vrac
-
-// // Parent Batch
-// target.setParentBatch(parentBatch);
+ BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
+ );
}
@@ -487,17 +469,6 @@
if (sortingMeasurements != null) {
sortingMeasurements.removeAll(notChangedSortingMeasurements);
}
-
-// if (target.getQuantificationMeasurements() != null && notChangedQuantificationMeasurements.size() > 0) {
-// for (QuantificationMeasurement qm : notChangedQuantificationMeasurements) {
-// target.getQuantificationMeasurements().remove(qm);
-// }
-// }
-// if (target.getSortingMeasurements() != null && notChangedSortingMeasurements.size() > 0) {
-// for (SortingMeasurement sm : notChangedSortingMeasurements) {
-// target.getSortingMeasurements().remove(sm);
-// }
-// }
}
protected Integer convertSampleCategoryValueIntoQualitativeId(Serializable value) {
1
0
03 Apr '13
Author: tchemit
Date: 2013-04-03 20:25:40 +0200 (Wed, 03 Apr 2013)
New Revision: 723
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/723
Log:
- fix speciesToConfirm (Species and Benthos)
- refs #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets (contienu on ui)
- remove CommentModelAware
- continue to refactor models (using entity contract?\195?\160
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentModelAware.java
Modified:
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/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/MarineLitterBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.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/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/ButtonComment.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentCellEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentEditorUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-04-03 18:25:40 UTC (rev 723)
@@ -1,28 +1,5 @@
-###
-# #%L
-# Tutti :: UI
-# $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%
-###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Fri Mar 29 10:09:57 CET 2013
+#Wed Apr 03 18:09:43 CEST 2013
tutti.createBenthosBatch.action.addSpecies.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.cancel.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.save.help=createBenthosBatch.html\#actions
@@ -141,6 +118,7 @@
tutti.editFishingOperation.field.trawlDistance.help=editFishingOperation.html\#fields
tutti.editFishingOperation.field.vessel.help=editFishingOperation.html\#fields
tutti.editFishingOperation.help=editFishingOperation.html
+tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help=
tutti.editProgram.action.cancelProgram.help=editProgram.html\#actions
tutti.editProgram.action.saveProgram.help=editProgram.html\#actions
tutti.editProgram.field.description.help=editProgram.html\#fields
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-04-03 18:25:40 UTC (rev 723)
@@ -1,28 +1,5 @@
-###
-# #%L
-# Tutti :: UI
-# $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%
-###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Fri Mar 29 10:09:57 CET 2013
+#Wed Apr 03 18:09:43 CEST 2013
tutti.createBenthosBatch.action.addSpecies.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.cancel.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.save.help=createBenthosBatch.html\#actions
@@ -150,6 +127,7 @@
tutti.editFishingOperation.field.trawlDistance.help=editFishingOperation.html\#fields
tutti.editFishingOperation.field.vessel.help=editFishingOperation.html\#fields
tutti.editFishingOperation.help=editFishingOperation.html
+tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help=
tutti.editProgram.action.cancelProgram.help=editProgram.html\#actions
tutti.editProgram.action.saveProgram.help=editProgram.html\#actions
tutti.editProgram.field.description.help=editProgram.html\#fields
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -559,8 +559,8 @@
ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+ ui.getMarineLitterTabFishingOperationReminderLabel().setTitle(fishingOperationText);
// ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getMarineLitterTabFishingOperationReminderLabel().setTitle(fishingOperationText);
// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
if (loadOtherTabs) {
@@ -569,8 +569,8 @@
ui.getSpeciesTabContent().getHandler().selectFishingOperation(batch == null ? null : bean);
ui.getBenthosTabContent().getHandler().selectFishingOperation(batch == null ? null : bean);
+ ui.getMarineLitterTabContent().getHandler().selectFishingOperation(batch == null ? null : bean);
// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
-// ui.getMarineLitterTabContent().getHandler().selectFishingOperation(bean);
// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-04-03 18:25:40 UTC (rev 723)
@@ -68,6 +68,10 @@
rightDecoration: {benthosTabContent.getBenthosBatchTabToolBar()};
}
+#marineLitterTabFishingOperationReminderLabel {
+ rightDecoration: {marineLitterTabContent.getMarineLitterBatchTabToolBar()};
+}
+
#catchTable {
border: {BorderFactory.createTitledBorder(_("tutti.editCatchBatch.legend.total"))};
}
@@ -263,7 +267,6 @@
_computed: true;
}
-
#marineLitterTable {
border: {BorderFactory.createTitledBorder(_("tutti.editCatchBatch.legend.marineLitter"))};
}
@@ -277,17 +280,16 @@
}
#marineLitterTotalWeightField {
- _computed: true;
+ property: marineLitterTotalWeight;
+ model: {model.getMarineLitterTotalWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
}
#planktonTab {
enabled: {false};
}
-#marineLitterTab {
- enabled: {false};
-}
-
#accidentalTab {
enabled: {false};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-03 18:25:40 UTC (rev 723)
@@ -30,6 +30,7 @@
fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI
+ fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyUI
fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUI
@@ -75,10 +76,7 @@
<BeanValidator id='validator' bean='model'
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
<field name='catchTotalWeight' component='catchTotalWeightField'/>
- <!-- <field name='catchTotalSortedTremisWeight'
- component='catchTotalSortedTremisWeightField'/>
- <field name='catchTotalSortedCarousselWeight'
- component='catchTotalSortedCarousselWeightField'/>-->
+
<field name='catchTotalRejectedWeight'
component='catchTotalRejectedWeightField'/>
@@ -288,7 +286,8 @@
<JLabel id='marineLitterTotalWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <JTextField id='marineLitterTotalWeightField'/>
+ <NumberEditor id='marineLitterTotalWeightField'
+ constructorParams='this'/>
</cell>
</row>
@@ -347,16 +346,18 @@
</JXTitledPanel>
</JPanel>
</tab>
+ <tab id='marineLitterTab' title='tutti.label.tab.marineLitter'>
+ <JXTitledPanel id='marineLitterTabFishingOperationReminderLabel'>
+ <MarineLitterBatchUI id='marineLitterTabContent'
+ constructorParams='this'/>
+ </JXTitledPanel>
+ </tab>
<tab id='planktonTab' title='tutti.label.tab.plancton'>
<!--JXTitledPanel id='planktonTabFishingOperationReminderLabel'>
<PlanktonBatchUI id='planktonTabContent' constructorParams='this'/>
</JXTitledPanel-->
</tab>
- <tab id='marineLitterTab' title='tutti.label.tab.marineLitter'>
- <!--JXTitledPanel id='marineLitterTabFishingOperationReminderLabel'>
- <MarineLitterBatchUI id='marineLitterTabContent' constructorParams='this'/>
- </JXTitledPanel-->
- </tab>
+
<tab id='accidentalTab' title='tutti.label.tab.accidentel'>
<!--JXTitledPanel id='accidentalTabFishingOperationReminderLabel'>
<AccidentalBatchUI id='accidentalTabContent' constructorParams='this'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -86,6 +86,7 @@
super(parentUi.getHandler().getContext(), ui);
this.parentUi = parentUi;
this.catchBatchMonitor = new TuttiBeanMonitor<EditCatchesUIModel>(
+ EditCatchesUIModel.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT,
@@ -120,6 +121,7 @@
setCustomTab(0, model);
setCustomTab(1, ui.getSpeciesTabContent().getModel());
setCustomTab(2, ui.getBenthosTabContent().getModel());
+ setCustomTab(3, ui.getMarineLitterTabContent().getModel());
getParentUi().getFishingOperationTabContent().getModel()
.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_VESSEL, new PropertyChangeListener() {
@@ -141,8 +143,8 @@
// close batches tabs, then general tab
closeUI(ui.getSpeciesTabContent());
closeUI(ui.getBenthosTabContent());
+ closeUI(ui.getMarineLitterTabContent());
// closeUI(ui.getPlanktonTabContent());
-// closeUI(ui.getMarineLitterTabContent());
// closeUI(ui.getAccidentalTabContent());
}
@@ -185,6 +187,7 @@
ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI();
ui.getSpeciesTabContent().getSpeciesBatchAttachmentsButton().onCloseUI();
ui.getBenthosTabContent().getBenthosBatchAttachmentsButton().onCloseUI();
+ ui.getMarineLitterTabContent().getMarineLitterBatchAttachmentsButton().onCloseUI();
return super.onTabChanged(currentIndex, newIndex);
}
@@ -194,6 +197,7 @@
ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI();
ui.getSpeciesTabContent().getSpeciesBatchAttachmentsButton().onCloseUI();
ui.getBenthosTabContent().getBenthosBatchAttachmentsButton().onCloseUI();
+ ui.getMarineLitterTabContent().getMarineLitterBatchAttachmentsButton().onCloseUI();
//FIXME 20130203 kmorin: cannot change tab if model is modified
// (I do not even know why it is set to modified and have no time
// before the demo)
@@ -275,7 +279,9 @@
protected void registerValidators() {
registerValidators(getValidator(),
ui.getSpeciesTabContent().getHandler().getValidator(),
- ui.getBenthosTabContent().getHandler().getValidator());
+ ui.getBenthosTabContent().getHandler().getValidator(),
+ ui.getMarineLitterTabContent().getHandler().getValidator()
+ );
}
public void setSpeciesSelectedCard(String card) {
@@ -293,20 +299,24 @@
TuttiUI tuttiUi = null;
JXTitledPanel titlePanel = null;
String title = "";
- if (CREATE_BATCH_CARD.equals(card)) {
- tuttiUi = ui.getSpeciesTabCreateBatch();
- titlePanel = ui.getSpeciesTabCreateBatchReminderLabel();
- title = n_("tutti.createSpeciesBatch.title");
+ switch (card) {
+ case CREATE_BATCH_CARD:
+ tuttiUi = ui.getSpeciesTabCreateBatch();
+ titlePanel = ui.getSpeciesTabCreateBatchReminderLabel();
+ title = n_("tutti.createSpeciesBatch.title");
- } else if (SPLIT_BATCH_CARD.equals(card)) {
- tuttiUi = ui.getSpeciesTabSplitBatch();
- titlePanel = ui.getSpeciesTabSplitBatchReminderLabel();
- title = n_("tutti.splitSpeciesBatch.title");
+ break;
+ case SPLIT_BATCH_CARD:
+ tuttiUi = ui.getSpeciesTabSplitBatch();
+ titlePanel = ui.getSpeciesTabSplitBatchReminderLabel();
+ title = n_("tutti.splitSpeciesBatch.title");
- } else if (EDIT_FREQUENCY_CARD.equals(card)) {
- tuttiUi = ui.getSpeciesTabFrequencyEditor();
- titlePanel = ui.getSpeciesTabFrequencyEditorReminderLabel();
- title = n_("tutti.editSpeciesFrequencies.title");
+ break;
+ case EDIT_FREQUENCY_CARD:
+ tuttiUi = ui.getSpeciesTabFrequencyEditor();
+ titlePanel = ui.getSpeciesTabFrequencyEditorReminderLabel();
+ title = n_("tutti.editSpeciesFrequencies.title");
+ break;
}
if (tuttiUi != null) {
@@ -334,20 +344,24 @@
TuttiUI tuttiUi = null;
JXTitledPanel titlePanel = null;
String title = "";
- if (CREATE_BATCH_CARD.equals(card)) {
- tuttiUi = ui.getBenthosTabCreateBatch();
- titlePanel = ui.getBenthosTabCreateBatchReminderLabel();
- title = n_("tutti.createBenthosBatch.title");
+ switch (card) {
+ case CREATE_BATCH_CARD:
+ tuttiUi = ui.getBenthosTabCreateBatch();
+ titlePanel = ui.getBenthosTabCreateBatchReminderLabel();
+ title = n_("tutti.createBenthosBatch.title");
- } else if (SPLIT_BATCH_CARD.equals(card)) {
- tuttiUi = ui.getBenthosTabSplitBatch();
- titlePanel = ui.getBenthosTabSplitBatchReminderLabel();
- title = n_("tutti.splitBenthosBatch.title");
+ break;
+ case SPLIT_BATCH_CARD:
+ tuttiUi = ui.getBenthosTabSplitBatch();
+ titlePanel = ui.getBenthosTabSplitBatchReminderLabel();
+ title = n_("tutti.splitBenthosBatch.title");
- } else if (EDIT_FREQUENCY_CARD.equals(card)) {
- tuttiUi = ui.getBenthosTabFrequencyEditor();
- titlePanel = ui.getBenthosTabFrequencyEditorReminderLabel();
- title = n_("tutti.editBenthosFrequencies.title");
+ break;
+ case EDIT_FREQUENCY_CARD:
+ tuttiUi = ui.getBenthosTabFrequencyEditor();
+ titlePanel = ui.getBenthosTabFrequencyEditorReminderLabel();
+ title = n_("tutti.editBenthosFrequencies.title");
+ break;
}
if (tuttiUi != null) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -49,32 +49,15 @@
private static final long serialVersionUID = 1L;
- public static final String PROPERTY_SPECIES = "species";
-
- public static final String PROPERTY_WEIGHT = "weight";
-
/**
- * Species observed.
+ * Delegate edit object.
*
- * @since 0.2
+ * @since 1.3
*/
- protected Species species;
+ protected final AccidentalBatch editObject =
+ TuttiBeanFactory.newAccidentalBatch();
/**
- * Observed weight.
- *
- * @since 0.2
- */
- protected Float weight;
-
- /**
- * Comment.
- *
- * @since 0.2
- */
- protected String comment;
-
- /**
* Attachments.
*
* @since 0.2
@@ -98,48 +81,58 @@
fromBean(aBatch);
}
+ @Override
+ protected AccidentalBatch newEntity() {
+ return TuttiBeanFactory.newAccidentalBatch();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AccidentalBatch --//
+ //------------------------------------------------------------------------//
+
+ @Override
public Species getSpecies() {
- return species;
+ return editObject.getSpecies();
}
+ @Override
public void setSpecies(Species species) {
Object oldValue = getSpecies();
- this.species = species;
+ editObject.setSpecies(species);
firePropertyChange(PROPERTY_SPECIES, oldValue, species);
}
@Override
public FishingOperation getFishingOperation() {
- return null;
+ return editObject.getFishingOperation();
}
@Override
public void setFishingOperation(FishingOperation fishingOperation) {
+ editObject.setFishingOperation(fishingOperation);
}
+ @Override
public Float getWeight() {
- return weight;
+ return editObject.getWeight();
}
+ @Override
public void setWeight(Float weight) {
Object oldValue = getWeight();
- this.weight = weight;
+ editObject.setWeight(weight);
firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
}
- //------------------------------------------------------------------------//
- //-- CommentModelAware --//
- //------------------------------------------------------------------------//
-
@Override
public String getComment() {
- return comment;
+ return editObject.getComment();
}
@Override
public void setComment(String comment) {
Object oldValue = getComment();
- this.comment = comment;
+ editObject.setComment(comment);
firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
}
@@ -185,9 +178,4 @@
this.attachment.remove(attachment);
firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
}
-
- @Override
- protected AccidentalBatch newEntity() {
- return TuttiBeanFactory.newAccidentalBatch();
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -42,27 +42,27 @@
public static final ColumnIdentifier<AccidentalBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SPECIES,
n_("tutti.editAccidentalBatch.table.header.speciesByCode"),
- n_("tutti.editAccidentalBatch.table.header.speciesByCode"));
+ n_("tutti.editAccidentalBatch.table.header.speciesByCode.tip"));
public static final ColumnIdentifier<AccidentalBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SPECIES,
n_("tutti.editAccidentalBatch.table.header.speciesByGenusCode"),
- n_("tutti.editAccidentalBatch.table.header.speciesByGenusCode"));
+ n_("tutti.editAccidentalBatch.table.header.speciesByGenusCode.tip"));
public static final ColumnIdentifier<AccidentalBatchRowModel> WEIGHT = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_WEIGHT,
n_("tutti.editAccidentalBatch.table.header.weight"),
- n_("tutti.editAccidentalBatch.table.header.weight"));
+ n_("tutti.editAccidentalBatch.table.header.weight.tip"));
public static final ColumnIdentifier<AccidentalBatchRowModel> COMMENT = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_COMMENT,
n_("tutti.editAccidentalBatch.table.header.comment"),
- n_("tutti.editAccidentalBatch.table.header.comment"));
+ n_("tutti.editAccidentalBatch.table.header.comment.tip"));
- public static final ColumnIdentifier<AccidentalBatchRowModel> ATTACHMENT = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<AccidentalBatchRowModel> ATTACHMENT = ColumnIdentifier.newReadOnlyId(
AccidentalBatchRowModel.PROPERTY_ATTACHMENT,
n_("tutti.editAccidentalBatch.table.header.file"),
- n_("tutti.editAccidentalBatch.table.header.file"));
+ n_("tutti.editAccidentalBatch.table.header.file.tip"));
public AccidentalBatchTableModel(TableColumnModelExt columnModel) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -28,6 +28,7 @@
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
@@ -38,11 +39,11 @@
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
-import fr.ifremer.tutti.ui.swing.util.comment.CommentModelAware;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -53,7 +54,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, BenthosBatchRowModel> implements AttachmentModelAware, CommentModelAware {
+public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, BenthosBatchRowModel> implements SpeciesBatch, AttachmentModelAware {
private static final long serialVersionUID = 1L;
@@ -259,6 +260,11 @@
Collections.sort(frequency);
}
+ @Override
+ protected SpeciesBatch newEntity() {
+ return TuttiBeanFactory.newSpeciesBatch();
+ }
+
//------------------------------------------------------------------------//
//-- Sample category --//
//------------------------------------------------------------------------//
@@ -319,10 +325,12 @@
//-- Species category --//
//------------------------------------------------------------------------//
+ @Override
public Species getSpecies() {
return species;
}
+ @Override
public void setSpecies(Species species) {
Object oldCategory = getSpecies();
this.species = species;
@@ -494,6 +502,7 @@
//-- Navigation properties --//
//------------------------------------------------------------------------//
+ @Override
public BenthosBatchRowModel getParentBatch() {
return parentBatch;
}
@@ -525,7 +534,7 @@
}
//------------------------------------------------------------------------//
- //-- CommentModelAware --//
+ //-- CommentAware --//
//------------------------------------------------------------------------//
@Override
@@ -587,28 +596,34 @@
//-- Other properties --//
//------------------------------------------------------------------------//
- public Boolean getSpeciesToConfirm() {
+ @Override
+ public boolean isSpeciesToConfirm() {
return speciesToConfirm;
}
- public void setSpeciesToConfirm(Boolean speciesToConfirm) {
- Object oldValue = getSpeciesToConfirm();
+ @Override
+ public void setSpeciesToConfirm(boolean speciesToConfirm) {
+ Object oldValue = isSpeciesToConfirm();
this.speciesToConfirm = speciesToConfirm;
firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
}
+ @Override
public Float getWeight() {
return computedOrNotWeight.getData();
}
+ @Override
public void setWeight(Float weight) {
this.computedOrNotWeight.setData(weight);
}
+ @Override
public Integer getNumber() {
return computedOrNotNumber.getData();
}
+ @Override
public void setNumber(Integer number) {
computedOrNotNumber.setData(number);
}
@@ -623,18 +638,22 @@
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);
}
@@ -656,7 +675,103 @@
}
@Override
- protected SpeciesBatch newEntity() {
- return TuttiBeanFactory.newSpeciesBatch();
+ 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 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) {
+ }
+
+ @Override
+ public void setParentBatch(SpeciesBatch parentBatch) {
+ }
+
+ @Override
+ public FishingOperation getFishingOperation() {
+ return null;
+ }
+
+ @Override
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -48,67 +48,67 @@
public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SPECIES,
n_("tutti.editBenthosBatch.table.header.species"),
- n_("tutti.editBenthosBatch.table.header.species"));
+ n_("tutti.editBenthosBatch.table.header.species.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
SampleCategoryEnum.sortedUnsorted,
n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory"),
- n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory"));
+ n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY,
BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
SampleCategoryEnum.size,
n_("tutti.editBenthosBatch.table.header.sizeCategory"),
- n_("tutti.editBenthosBatch.table.header.sizeCategory"));
+ n_("tutti.editBenthosBatch.table.header.sizeCategory.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SEX_CATEGORY,
BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
SampleCategoryEnum.sex,
n_("tutti.editBenthosBatch.table.header.sexCategory"),
- n_("tutti.editBenthosBatch.table.header.sexCategory"));
+ n_("tutti.editBenthosBatch.table.header.sexCategory.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY,
BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
SampleCategoryEnum.maturity,
n_("tutti.editBenthosBatch.table.header.maturityCategory"),
- n_("tutti.editBenthosBatch.table.header.maturityCategory"));
+ n_("tutti.editBenthosBatch.table.header.maturityCategory.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_AGE_CATEGORY,
BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
SampleCategoryEnum.age,
n_("tutti.editBenthosBatch.table.header.ageCategory"),
- n_("tutti.editBenthosBatch.table.header.ageCategory"));
+ n_("tutti.editBenthosBatch.table.header.ageCategory.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> WEIGHT = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_COMPUTED_WEIGHT,
n_("tutti.editBenthosBatch.table.header.weight"),
- n_("tutti.editBenthosBatch.table.header.weight"));
+ n_("tutti.editBenthosBatch.table.header.weight.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> COMPUTED_NUMBER = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_COMPUTED_NUMBER,
n_("tutti.editBenthosBatch.table.header.computedNumber"),
- n_("tutti.editBenthosBatch.table.header.computedNumber"));
+ n_("tutti.editBenthosBatch.table.header.computedNumber.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> COMMENT = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_COMMENT,
n_("tutti.editBenthosBatch.table.header.comment"),
- n_("tutti.editBenthosBatch.table.header.comment"));
+ n_("tutti.editBenthosBatch.table.header.comment.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> ATTACHMENT = ColumnIdentifier.newReadOnlyId(
BenthosBatchRowModel.PROPERTY_ATTACHMENT,
n_("tutti.editBenthosBatch.table.header.file"),
- n_("tutti.editBenthosBatch.table.header.file"));
+ n_("tutti.editBenthosBatch.table.header.file.tip"));
public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_TO_CONFIRM = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
n_("tutti.editBenthosBatch.table.header.toConfirm"),
- n_("tutti.editBenthosBatch.table.header.toConfirm"));
+ n_("tutti.editBenthosBatch.table.header.toConfirm.tip"));
/**
* Columns for the frequency edition.
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-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -572,7 +572,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.getSpeciesToConfirm();
+ return row.isSpeciesToConfirm();
}
}, toConfirmColor);
@@ -593,7 +593,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.getSpeciesToConfirm() && !adapter.isEditable();
+ return row.isSpeciesToConfirm() && !adapter.isEditable();
}
}, toConfirmColor.darker());
@@ -1028,7 +1028,7 @@
// copy back parent data (mainly other sample categories)
newRow.setSpecies(parentRow.getSpecies());
- newRow.setSpeciesToConfirm(parentRow.getSpeciesToConfirm());
+ newRow.setSpeciesToConfirm(parentRow.isSpeciesToConfirm());
newRow.setParentBatch(parentRow);
newRow.setSpecies(parentRow.getSpecies());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -143,6 +143,25 @@
EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT);
}
+ @Override
+ public boolean isEmpty() {
+ return CollectionUtils.isEmpty(getRows())
+ && getBenthosTotalSortedWeight() == null
+ && getBenthosTotalInertWeight() == null
+ && getBenthosTotalLivingNotItemizedWeight() == null
+ && CollectionUtils.isEmpty(getAttachment());
+ }
+
+ @Override
+ public String getTitle() {
+ return "tutti.label.tab.benthos";
+ }
+
+ @Override
+ public String getIcon() {
+ return null;
+ }
+
public Float getBenthosTotalComputedWeight() {
return catchesUIModel.getBenthosTotalComputedWeight();
}
@@ -346,6 +365,10 @@
return rootBatchId;
}
+ //------------------------------------------------------------------------//
+ //-- AttachmentModelAware --//
+ //------------------------------------------------------------------------//
+
@Override
public AttachementObjectTypeEnum getObjectType() {
return AttachementObjectTypeEnum.CATCH_BATCH;
@@ -385,22 +408,4 @@
firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
}
- @Override
- public boolean isEmpty() {
- return CollectionUtils.isEmpty(getRows())
- && getBenthosTotalSortedWeight() == null
- && getBenthosTotalInertWeight() == null
- && getBenthosTotalLivingNotItemizedWeight() == null
- && CollectionUtils.isEmpty(getAttachment());
- }
-
- @Override
- public String getTitle() {
- return "tutti.label.tab.benthos";
- }
-
- @Override
- public String getIcon() {
- return null;
- }
}
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-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -49,50 +49,15 @@
private static final long serialVersionUID = 1L;
- public static final String PROPERTY_MARINE_LITTER_CATEGORY = "marineLitterCategory";
-
- public static final String PROPERTY_MARINE_LITTER_SIZE_CATEGORY = "marineLitterSizeCategory";
-
- public static final String PROPERTY_WEIGHT = "weight";
-
- public static final String PROPERTY_NUMBER = "number";
-
/**
- * MarineLitter category.
+ * Delegate edit object.
*
- * @since 0.2
+ * @since 1.3
*/
- protected CaracteristicQualitativeValue marineLitterCategory;
+ protected final MarineLitterBatch editObject =
+ TuttiBeanFactory.newMarineLitterBatch();
/**
- * MarineLitter size category.
- *
- * @since 0.3
- */
- protected CaracteristicQualitativeValue marineLitterSizeCategory;
-
- /**
- * Observed weight.
- *
- * @since 0.2
- */
- protected Float weight;
-
- /**
- * Observed number.
- *
- * @since 0.3
- */
- protected Integer number;
-
- /**
- * Comment on this batch.
- *
- * @since 0.2
- */
- protected String comment;
-
- /**
* Attachments (should never be null).
*
* @since 0.2
@@ -116,68 +81,82 @@
fromBean(aBatch);
}
+ @Override
+ protected MarineLitterBatch newEntity() {
+ return TuttiBeanFactory.newMarineLitterBatch();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- MarineLitterBatch --//
+ //------------------------------------------------------------------------//
+
+ @Override
public CaracteristicQualitativeValue getMarineLitterCategory() {
- return marineLitterCategory;
+ return editObject.getMarineLitterCategory();
}
+ @Override
public void setMarineLitterCategory(CaracteristicQualitativeValue marineLitterCategory) {
Object oldValue = getMarineLitterCategory();
- this.marineLitterCategory = marineLitterCategory;
+ editObject.setMarineLitterCategory(marineLitterCategory);
firePropertyChange(PROPERTY_MARINE_LITTER_CATEGORY, oldValue, marineLitterCategory);
}
+ @Override
public CaracteristicQualitativeValue getMarineLitterSizeCategory() {
- return marineLitterSizeCategory;
+ return editObject.getMarineLitterSizeCategory();
}
+ @Override
public void setMarineLitterSizeCategory(CaracteristicQualitativeValue marineLitterSizeCategory) {
Object oldValue = getMarineLitterSizeCategory();
- this.marineLitterSizeCategory = marineLitterSizeCategory;
+ editObject.setMarineLitterSizeCategory(marineLitterSizeCategory);
firePropertyChange(PROPERTY_MARINE_LITTER_SIZE_CATEGORY, oldValue, marineLitterSizeCategory);
}
@Override
public FishingOperation getFishingOperation() {
- return null;
+ return editObject.getFishingOperation();
}
@Override
public void setFishingOperation(FishingOperation fishingOperation) {
+ editObject.setFishingOperation(fishingOperation);
}
+ @Override
public Float getWeight() {
- return weight;
+ return editObject.getWeight();
}
+ @Override
public void setWeight(Float weight) {
Object oldValue = getWeight();
- this.weight = weight;
+ editObject.setWeight(weight);
firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
}
+ @Override
public Integer getNumber() {
- return number;
+ return editObject.getNumber();
}
+ @Override
public void setNumber(Integer number) {
Object oldValue = getNumber();
- this.number = number;
+ editObject.setNumber(number);
firePropertyChange(PROPERTY_NUMBER, oldValue, number);
}
- //------------------------------------------------------------------------//
- //-- CommentModelAware --//
- //------------------------------------------------------------------------//
-
@Override
public String getComment() {
- return comment;
+ return editObject.getComment();
}
@Override
public void setComment(String comment) {
Object oldValue = getComment();
- this.comment = comment;
+ editObject.setComment(comment);
firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
}
@@ -223,9 +202,4 @@
this.attachment.remove(attachment);
firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
}
-
- @Override
- protected MarineLitterBatch newEntity() {
- return TuttiBeanFactory.newMarineLitterBatch();
- }
}
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-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -41,32 +41,32 @@
public static final ColumnIdentifier<MarineLitterBatchRowModel> MACRO_WASTE_CATEGORY = ColumnIdentifier.newId(
MarineLitterBatchRowModel.PROPERTY_MARINE_LITTER_CATEGORY,
n_("tutti.editMarineLitterBatch.table.header.marineLitterCategory"),
- n_("tutti.editMarineLitterBatch.table.header.marineLitterCategory"));
+ n_("tutti.editMarineLitterBatch.table.header.marineLitterCategory.tip"));
public static final ColumnIdentifier<MarineLitterBatchRowModel> MACRO_WASTE_SIZE_CATEGORY = ColumnIdentifier.newId(
MarineLitterBatchRowModel.PROPERTY_MARINE_LITTER_SIZE_CATEGORY,
n_("tutti.editMarineLitterBatch.table.header.marineLitterSizeCategory"),
- n_("tutti.editMarineLitterBatch.table.header.marineLitterSizeCategory"));
+ n_("tutti.editMarineLitterBatch.table.header.marineLitterSizeCategory.tip"));
+ public static final ColumnIdentifier<MarineLitterBatchRowModel> NUMBER = ColumnIdentifier.newId(
+ MarineLitterBatchRowModel.PROPERTY_NUMBER,
+ n_("tutti.editMarineLitterBatch.table.header.number"),
+ n_("tutti.editMarineLitterBatch.table.header.number.tip"));
+
public static final ColumnIdentifier<MarineLitterBatchRowModel> WEIGHT = ColumnIdentifier.newId(
MarineLitterBatchRowModel.PROPERTY_WEIGHT,
n_("tutti.editMarineLitterBatch.table.header.weight"),
- n_("tutti.editMarineLitterBatch.table.header.weight"));
+ n_("tutti.editMarineLitterBatch.table.header.weight.tip"));
- public static final ColumnIdentifier<MarineLitterBatchRowModel> NUMBER = ColumnIdentifier.newId(
- MarineLitterBatchRowModel.PROPERTY_NUMBER,
- n_("tutti.editMarineLitterBatch.table.header.number"),
- n_("tutti.editMarineLitterBatch.table.header.number"));
-
public static final ColumnIdentifier<MarineLitterBatchRowModel> COMMENT = ColumnIdentifier.newId(
MarineLitterBatchRowModel.PROPERTY_COMMENT,
n_("tutti.editMarineLitterBatch.table.header.comment"),
- n_("tutti.editMarineLitterBatch.table.header.comment"));
+ n_("tutti.editMarineLitterBatch.table.header.comment.tip"));
- public static final ColumnIdentifier<MarineLitterBatchRowModel> ATTACHMENT = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<MarineLitterBatchRowModel> ATTACHMENT = ColumnIdentifier.newReadOnlyId(
MarineLitterBatchRowModel.PROPERTY_ATTACHMENT,
n_("tutti.editMarineLitterBatch.table.header.file"),
- n_("tutti.editMarineLitterBatch.table.header.file"));
+ n_("tutti.editMarineLitterBatch.table.header.file.tip"));
public MarineLitterBatchTableModel(TableColumnModelExt columnModel) {
super(columnModel, true, true);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-04-03 18:25:40 UTC (rev 723)
@@ -27,15 +27,28 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
bean: {model};
showReset: true;
+ _selectOnFocus: {true};
}
#editMarineLitterBatchTopPanel {
_help: {"tuttihelp.editMarineLitterBatch.help"};
}
+#marineLitterBatchTabToolBar {
+ floatable: false;
+ opaque: false;
+ borderPainted: false;
+}
+
+#marineLitterBatchAttachmentsButton {
+ enabled: {model.getObjectId() != null};
+}
+
#marineLitterTotalWeightLabel {
- text: "tutti.editCatchBatch.field.marineLitterTotalWeight";
+ text: "tutti.editMarineLitterBatch.field.marineLitterTotalWeight";
+ toolTipText: "tutti.editMarineLitterBatch.field.marineLitterTotalWeight.tip";
labelFor: {marineLitterTotalWeightField};
+ _help: {"tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help"};
}
#marineLitterTotalWeightField {
@@ -45,9 +58,23 @@
numberPattern: {INT_6_DIGITS_PATTERN};
}
+#tablePopup {
+ label: "tutti.editMarineLitterBatch.title.batchActions";
+}
+
#table {
selectionMode: {ListSelectionModel.SINGLE_SELECTION};
selectionBackground: {null};
selectionForeground: {Color.BLACK};
sortable: false;
}
+
+#removeSpeciesBatchMenu {
+ actionIcon: batch-delete;
+ text: "tutti.editMarineLitterBatch.action.removeBatch";
+ toolTipText: "tutti.editMarineLitterBatch.action.removeBatch.tip";
+ i18nMnemonic: "tutti.editMarineLitterBatch.action.removeBatch.mnemonic";
+ _tuttiAction: {RemoveMarineLitterBatchAction.class};
+ enabled: {model.isRemoveBatchEnabled()};
+ _help: {"tutti.editMarineLitterBatch.action.removeBatch.help"};
+}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx 2013-04-03 18:25:40 UTC (rev 723)
@@ -29,6 +29,7 @@
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
+ fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
jaxx.runtime.swing.editor.NumberEditor
@@ -68,6 +69,15 @@
<TuttiHelpBroker id='broker'
constructorParams='"tuttihelp.editMarineLitterBatch.help"'/>
+ <JToolBar id='marineLitterBatchTabToolBar'>
+ <ButtonAttachment id='marineLitterBatchAttachmentsButton'
+ constructorParams='getHandler().getContext(), getModel()'/>
+ </JToolBar>
+
+ <JPopupMenu id='tablePopup'>
+ <JMenuItem id='removeMarineLitterBatchMenu'/>
+ </JPopupMenu>
+
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total -->
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-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -25,6 +25,7 @@
*/
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.PropagatePropertyChangeListener;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
@@ -91,9 +92,21 @@
rows = Lists.newArrayList();
if (!TuttiEntities.isNew(bean)) {
+
+ // get all marine litter root
BatchContainer<MarineLitterBatch> batchContainer =
persistenceService.getRootMarineLitterBatch(bean.getId());
+ model.setRootBatchId(batchContainer.getId());
+
+ List<Attachment> attachments =
+ persistenceService.getAllAttachments(Integer.valueOf(model.getObjectId()));
+ model.addAllAttachment(attachments);
+
+ if (log.isInfoEnabled()) {
+ log.info("marineLitter root batch id: " + model.getRootBatchId());
+ }
+
for (MarineLitterBatch aBatch : batchContainer.getChildren()) {
MarineLitterBatchRowModel entry =
new MarineLitterBatchRowModel(aBatch);
@@ -102,6 +115,7 @@
}
}
model.setRows(rows);
+ recomputeBatchActionEnable();
}
//------------------------------------------------------------------------//
@@ -122,7 +136,7 @@
protected boolean isRowValid(MarineLitterBatchRowModel row) {
boolean result = row.getMarineLitterCategory() != null &&
row.getMarineLitterSizeCategory() != null &&
- row.getWeight() != null;
+ row.getNumber() != null;
return result;
}
@@ -133,6 +147,9 @@
Object oldValue,
Object newValue) {
recomputeRowValidState(row);
+
+ // when row valid state has changed, recompute action enabled states
+ recomputeBatchActionEnable();
}
@Override
@@ -160,17 +177,39 @@
// row is not valid can not save it
- MarineLitterBatch catchBean = row.toBean();
+ MarineLitterBatch batch = row.toBean();
- if (!TuttiEntities.isNew(catchBean)) {
+ if (!TuttiEntities.isNew(batch)) {
// remove this
- persistenceService.deleteMarineLitterBatch(catchBean.getId());
+ persistenceService.deleteMarineLitterBatch(batch.getId());
}
}
}
}
+ @Override
+ protected void onRowValidStateChanged(int rowIndex,
+ MarineLitterBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
+
+ // when row valid state has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+ }
+
+ @Override
+ protected void onAfterSelectedRowChanged(int oldRowIndex,
+ MarineLitterBatchRowModel oldRow,
+ int newRowIndex,
+ MarineLitterBatchRowModel newRow) {
+ super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
+
+ // when selected row has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -192,13 +231,20 @@
MarineLitterBatchUIModel model = new MarineLitterBatchUIModel(catchesUIModel);
ui.setContextValue(model);
+
+ // propagate when value is changing
+ PropagatePropertyChangeListener.listenAndPropagate(
+ catchesUIModel,
+ model,
+ EditCatchesUIModel.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT,
+ EditCatchesUIModel.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT);
}
@Override
public void afterInitUI() {
- if (log.isInfoEnabled()) {
- log.info("afterInit: " + ui);
+ if (log.isDebugEnabled()) {
+ log.debug("afterInit: " + ui);
}
initUI(ui);
@@ -231,6 +277,13 @@
decorator, persistenceService.getMarineLitterSizeCategoryCaracteristic().getQualitativeValue());
}
+ { // Number column
+
+ addIntegerColumnToModel(columnModel,
+ MarineLitterBatchTableModel.NUMBER,
+ TuttiUI.INT_3_DIGITS_PATTERN);
+ }
+
{ // Weight column
addFloatColumnToModel(columnModel,
@@ -238,13 +291,6 @@
TuttiUI.DECIMAL3_PATTERN);
}
- { // Number column
-
- addIntegerColumnToModel(columnModel,
- MarineLitterBatchTableModel.NUMBER,
- TuttiUI.INT_3_DIGITS_PATTERN);
- }
-
{ // Comment column
addColumnToModel(columnModel,
@@ -269,6 +315,7 @@
table.setColumnModel(columnModel);
initBatchTable(table, columnModel, tableModel);
+ recomputeBatchActionEnable();
}
@Override
@@ -276,6 +323,7 @@
if (log.isDebugEnabled()) {
log.debug("closing: " + ui);
}
+ ui.getMarineLitterBatchAttachmentsButton().onCloseUI();
}
//------------------------------------------------------------------------//
@@ -286,6 +334,23 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void recomputeBatchActionEnable() {
+
+ int rowIndex = getTable().getSelectedRow();
+
+ boolean enableRemove = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+
+ enableRemove = true;
+
+ }
+ MarineLitterBatchUIModel model = getModel();
+ model.setRemoveBatchEnabled(enableRemove);
+ }
+
protected void saveRow(MarineLitterBatchRowModel row) {
MarineLitterBatch catchBean = row.toBean();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -24,17 +24,40 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.util.TabContentModel;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
+import org.apache.commons.collections.CollectionUtils;
+import java.util.Collection;
+import java.util.List;
+
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class MarineLitterBatchUIModel extends AbstractTuttiBatchUIModel<MarineLitterBatchRowModel, MarineLitterBatchUIModel> {
+public class MarineLitterBatchUIModel extends AbstractTuttiBatchUIModel<MarineLitterBatchRowModel, MarineLitterBatchUIModel>
+ implements AttachmentModelAware, TabContentModel {
private static final long serialVersionUID = 1L;
+ public static final String PROPERTY_REMOVE_BATCH_ENABLED = "removeBatchEnabled";
+
+ protected final List<Attachment> attachment = Lists.newArrayList();
+
+ /**
+ * Can user remove a selected marineLitter batch?
+ *
+ * @since 1.3
+ */
+ protected boolean removeBatchEnabled;
+
+ private String rootBatchId;
+
public MarineLitterBatchUIModel(EditCatchesUIModel catchesUIModel) {
super(catchesUIModel,
EditCatchesUIModel.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT);
@@ -47,4 +70,100 @@
public void setMarineLitterTotalWeight(Float marineLitterTotalWeight) {
catchesUIModel.setMarineLitterTotalWeight(marineLitterTotalWeight);
}
+
+ public boolean isRemoveBatchEnabled() {
+ return removeBatchEnabled;
+ }
+
+ public void setRemoveBatchEnabled(boolean removeBatchEnabled) {
+ Object oldValue = isRemoveBatchEnabled();
+ this.removeBatchEnabled = removeBatchEnabled;
+ firePropertyChange(PROPERTY_REMOVE_BATCH_ENABLED, oldValue, removeBatchEnabled);
+ }
+
+ public void setRootBatchId(String rootBatchId) {
+ String oldValue = getObjectId();
+ this.rootBatchId = rootBatchId;
+ firePropertyChange(PROPERTY_OBJECT_ID, oldValue, getObjectId());
+ }
+
+ public String getRootBatchId() {
+ return rootBatchId;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AttachmentModelAware --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public AttachementObjectTypeEnum getObjectType() {
+ return AttachementObjectTypeEnum.CATCH_BATCH;
+ }
+
+ @Override
+ public String getObjectId() {
+ return rootBatchId;
+ }
+
+ @Override
+ public List<Attachment> getAttachment() {
+ return attachment;
+ }
+
+ @Override
+ public void addAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.addAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void addAttachment(Attachment attachment) {
+ this.attachment.add(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.removeAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAttachment(Attachment attachment) {
+ this.attachment.remove(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ //------------------------------------------------------------------------//
+ //-- TabContentModel --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public boolean isEmpty() {
+ boolean result = getMarineLitterTotalWeight() == null
+ && CollectionUtils.isEmpty(getAttachment());
+ if (result && CollectionUtils.isNotEmpty(getRows())) {
+
+ // check if every line is not valid
+ for (MarineLitterBatchRowModel row : rows) {
+ if (row.isValid()) {
+
+ // found a valid row so not empty
+ result = false;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String getTitle() {
+ return "tutti.label.tab.marineLitter";
+ }
+
+ @Override
+ public String getIcon() {
+ return null;
+ }
}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -0,0 +1,87 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter;
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.RemoveSpeciesSubBatchAction;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+
+/**
+ * To remove a selected marine litter batch in the table.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class RemoveMarineLitterBatchAction extends AbstractTuttiAction<MarineLitterBatchUIModel, MarineLitterBatchUI, MarineLitterBatchUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(RemoveMarineLitterBatchAction.class);
+
+ protected RemoveSpeciesSubBatchAction removeSpeciesSubBatchAction;
+
+ public RemoveMarineLitterBatchAction(MarineLitterBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ int rowIndex;
+
+ @Override
+ protected void doAction() throws Exception {
+
+ JXTable table = handler.getTable();
+
+ rowIndex = table.getSelectedRow();
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove batch if none is selected");
+
+ MarineLitterBatchTableModel tableModel = handler.getTableModel();
+ MarineLitterBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
+
+ boolean persisted = !TuttiEntities.isNew(selectedBatch);
+
+ if (persisted) {
+
+ // remove it from db
+
+ String id = selectedBatch.getId();
+
+ if (log.isInfoEnabled()) {
+ log.info("Remove marineLitter with id: " + id);
+ }
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ persistenceService.deleteMarineLitterBatch(id);
+ }
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ MarineLitterBatchTableModel tableModel = handler.getTableModel();
+
+ tableModel.removeRow(rowIndex);
+
+ if (!tableModel.getRows().isEmpty()) {
+
+ // select first row
+ AbstractSelectTableAction.doSelectCell(table, 0, 0);
+ }
+
+ if (table.isEditing()) {
+
+ // but no edit it
+ table.getCellEditor().stopCellEditing();
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -58,11 +58,12 @@
public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
/**
- * Species observed.
+ * Delegate edit object.
*
- * @since 0.2
+ * @since 1.3
*/
- protected Species species;
+ protected final PlanktonBatch editObject =
+ TuttiBeanFactory.newPlanktonBatch();
/**
* Is the species need to be confirmed?.
@@ -72,27 +73,6 @@
protected boolean speciesToConfirm;
/**
- * Observed weight.
- *
- * @since 0.2
- */
- protected Float weight;
-
- /**
- * Sample weight.
- *
- * @since 0.2
- */
- protected Float sampleWeight;
-
- /**
- * Comment.
- *
- * @since 0.2
- */
- protected String comment;
-
- /**
* Attachments (should never be null).
*
* @since 0.2
@@ -116,68 +96,80 @@
fromBean(aBatch);
}
- public Species getSpecies() {
- return species;
+ @Override
+ protected PlanktonBatch newEntity() {
+ return TuttiBeanFactory.newPlanktonBatch();
}
- public void setSpecies(Species species) {
- Object oldValue = getSpecies();
- this.species = species;
- firePropertyChange(PROPERTY_SPECIES, oldValue, species);
- }
-
- public Boolean getSpeciesToConfirm() {
+ public boolean isSpeciesToConfirm() {
return speciesToConfirm;
}
- public void setSpeciesToConfirm(Boolean speciesToConfirm) {
- Object oldValue = getSpeciesToConfirm();
+ public void setSpeciesToConfirm(boolean speciesToConfirm) {
+ Object oldValue = isSpeciesToConfirm();
this.speciesToConfirm = speciesToConfirm;
firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
}
+ //------------------------------------------------------------------------//
+ //-- PlanktonBatch --//
+ //------------------------------------------------------------------------//
+
@Override
+ public Species getSpecies() {
+ return editObject.getSpecies();
+ }
+
+ @Override
+ public void setSpecies(Species species) {
+ Object oldValue = getSpecies();
+ editObject.setSpecies(species);
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ @Override
public FishingOperation getFishingOperation() {
- return null;
+ return editObject.getFishingOperation();
}
@Override
public void setFishingOperation(FishingOperation fishingOperation) {
+ editObject.setFishingOperation(fishingOperation);
}
+ @Override
public Float getWeight() {
- return weight;
+ return editObject.getWeight();
}
+ @Override
public void setWeight(Float weight) {
Object oldValue = getWeight();
- this.weight = weight;
+ editObject.setWeight(weight);
firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
}
+ @Override
public Float getSampleWeight() {
- return sampleWeight;
+ return editObject.getSampleWeight();
}
+ @Override
public void setSampleWeight(Float sampleWeight) {
Object oldValue = getSampleWeight();
- this.sampleWeight = sampleWeight;
+ editObject.setSampleWeight(sampleWeight);
firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
}
- //------------------------------------------------------------------------//
- //-- CommentModelAware --//
- //------------------------------------------------------------------------//
-
@Override
public String getComment() {
- return comment;
+ return editObject.getComment();
}
@Override
public void setComment(String comment) {
Object oldValue = getComment();
- this.comment = comment;
+ editObject.setComment(comment);
firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
}
@@ -223,9 +215,4 @@
this.attachment.remove(attachment);
firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
}
-
- @Override
- protected PlanktonBatch newEntity() {
- return TuttiBeanFactory.newPlanktonBatch();
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -41,37 +41,37 @@
public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_TO_CONFIRM = ColumnIdentifier.newId(
PlanktonBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
n_("tutti.editPlanktonBatch.table.header.toConfirm"),
- n_("tutti.editPlanktonBatch.table.header.toConfirm"));
+ n_("tutti.editPlanktonBatch.table.header.toConfirm.tip"));
public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
PlanktonBatchRowModel.PROPERTY_SPECIES,
n_("tutti.editPlanktonBatch.table.header.speciesByCode"),
- n_("tutti.editPlanktonBatch.table.header.speciesByCode"));
+ n_("tutti.editPlanktonBatch.table.header.speciesByCode.tip"));
public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId(
PlanktonBatchRowModel.PROPERTY_SPECIES,
n_("tutti.editPlanktonBatch.table.header.speciesByGenusCode"),
- n_("tutti.editPlanktonBatch.table.header.speciesByGenusCode"));
+ n_("tutti.editPlanktonBatch.table.header.speciesByGenusCode.tip"));
public static final ColumnIdentifier<PlanktonBatchRowModel> WEIGHT = ColumnIdentifier.newId(
PlanktonBatchRowModel.PROPERTY_WEIGHT,
n_("tutti.editPlanktonBatch.table.header.weight"),
- n_("tutti.editPlanktonBatch.table.header.weight"));
+ n_("tutti.editPlanktonBatch.table.header.weight.tip"));
public static final ColumnIdentifier<PlanktonBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId(
PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
n_("tutti.editPlanktonBatch.table.header.sampleWeight"),
- n_("tutti.editPlanktonBatch.table.header.sampleWeight"));
+ n_("tutti.editPlanktonBatch.table.header.sampleWeight.tip"));
public static final ColumnIdentifier<PlanktonBatchRowModel> COMMENT = ColumnIdentifier.newId(
PlanktonBatchRowModel.PROPERTY_COMMENT,
n_("tutti.editPlanktonBatch.table.header.comment"),
- n_("tutti.editPlanktonBatch.table.header.comment"));
+ n_("tutti.editPlanktonBatch.table.header.comment.tip"));
- public static final ColumnIdentifier<PlanktonBatchRowModel> ATTACHMENT = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<PlanktonBatchRowModel> ATTACHMENT = ColumnIdentifier.newReadOnlyId(
PlanktonBatchRowModel.PROPERTY_ATTACHMENT,
n_("tutti.editPlanktonBatch.table.header.file"),
- n_("tutti.editPlanktonBatch.table.header.file"));
+ n_("tutti.editPlanktonBatch.table.header.file.tip"));
public PlanktonBatchTableModel(TableColumnModelExt columnModel) {
super(columnModel, true, true);
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-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -268,6 +268,11 @@
Collections.sort(frequency);
}
+ @Override
+ protected SpeciesBatch newEntity() {
+ return TuttiBeanFactory.newSpeciesBatch();
+ }
+
//------------------------------------------------------------------------//
//-- Sample category --//
//------------------------------------------------------------------------//
@@ -562,6 +567,7 @@
//-- Navigation properties --//
//------------------------------------------------------------------------//
+ @Override
public SpeciesBatchRowModel getParentBatch() {
return parentBatch;
}
@@ -597,7 +603,7 @@
}
//------------------------------------------------------------------------//
- //-- CommentModelAware --//
+ //-- CommentAware --//
//------------------------------------------------------------------------//
@Override
@@ -659,12 +665,13 @@
//-- Other properties --//
//------------------------------------------------------------------------//
- public Boolean getSpeciesToConfirm() {
+ @Override
+ public boolean isSpeciesToConfirm() {
return speciesToConfirm;
}
- public void setSpeciesToConfirm(Boolean speciesToConfirm) {
- Object oldValue = getSpeciesToConfirm();
+ public void setSpeciesToConfirm(boolean speciesToConfirm) {
+ Object oldValue = isSpeciesToConfirm();
this.speciesToConfirm = speciesToConfirm;
firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
}
@@ -678,10 +685,12 @@
public void setFishingOperation(FishingOperation fishingOperation) {
}
+ @Override
public Float getWeight() {
return computedOrNotWeight.getData();
}
+ @Override
public void setWeight(Float weight) {
this.computedOrNotWeight.setData(weight);
}
@@ -713,24 +722,17 @@
public void setSampleCategoryWeight(Float sampleCategoryWeight) {
}
+ @Override
public Integer getNumber() {
return computedOrNotNumber.getData();
}
+ @Override
public void setNumber(Integer number) {
computedOrNotNumber.setData(number);
}
@Override
- public boolean isSpeciesToConfirm() {
- return false;
- }
-
- @Override
- public void setSpeciesToConfirm(boolean speciesToConfirm) {
- }
-
- @Override
public Float getSampleCategoryComputedWeight() {
return null;
}
@@ -801,18 +803,22 @@
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);
}
@@ -833,8 +839,4 @@
this.computedOrNotWeight = computedOrNotWeight;
}
- @Override
- protected SpeciesBatch newEntity() {
- return TuttiBeanFactory.newSpeciesBatch();
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-04-03 18:25:40 UTC (rev 723)
@@ -28,7 +28,6 @@
<import>
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode
-
fr.ifremer.tutti.ui.swing.util.TuttiUI
fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
@@ -83,6 +82,7 @@
<JMenuItem id='renameSpeciesBatchMenu'/>
<JMenuItem id='createSpeciesMelagMenu'/>
</JPopupMenu>
+
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total / Poids total vrac -->
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-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -591,7 +591,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.getSpeciesToConfirm();
+ return row.isSpeciesToConfirm();
}
}, toConfirmColor);
@@ -612,7 +612,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.getSpeciesToConfirm() && !adapter.isEditable();
+ return row.isSpeciesToConfirm() && !adapter.isEditable();
}
}, toConfirmColor.darker());
@@ -1036,7 +1036,7 @@
// copy back parent data (mainly other sample categories)
newRow.setSpecies(parentRow.getSpecies());
- newRow.setSpeciesToConfirm(parentRow.getSpeciesToConfirm());
+ newRow.setSpeciesToConfirm(parentRow.isSpeciesToConfirm());
newRow.setParentBatch(parentRow);
newRow.setSpecies(parentRow.getSpecies());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -346,6 +346,10 @@
return rootBatchId;
}
+ //------------------------------------------------------------------------//
+ //-- AttachmentModelAware --//
+ //------------------------------------------------------------------------//
+
@Override
public AttachementObjectTypeEnum getObjectType() {
return AttachementObjectTypeEnum.CATCH_BATCH;
@@ -385,6 +389,10 @@
firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
}
+ //------------------------------------------------------------------------//
+ //-- TabContentModel --//
+ //------------------------------------------------------------------------//
+
@Override
public boolean isEmpty() {
return CollectionUtils.isEmpty(getRows())
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/ButtonComment.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/ButtonComment.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/ButtonComment.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.CommentAware;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import jaxx.runtime.SwingUtil;
@@ -55,7 +56,7 @@
protected boolean popupMoving;
public ButtonComment(TuttiUIContext context,
- CommentModelAware model) {
+ CommentAware model) {
setIcon(SwingUtil.createActionIcon("edit-comment"));
setToolTipText(_("tutti.commentEditor.action.tip"));
@@ -116,7 +117,7 @@
popup.getHandler().init();
}
- public void init(CommentModelAware model) {
+ public void init(CommentAware model) {
setBean(model);
init();
}
@@ -125,11 +126,11 @@
setSelected(false);
}
- public CommentModelAware getBean() {
+ public CommentAware getBean() {
return popup.getBean();
}
- protected void setBean(CommentModelAware model) {
+ protected void setBean(CommentAware model) {
popup.setBean(model);
init();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentCellEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentCellEditor.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentCellEditor.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -25,6 +25,7 @@
*/
import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.CommentAware;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
@@ -99,7 +100,7 @@
rowIndex = row;
columnIndex = column;
- CommentModelAware model = (CommentModelAware) tableModel.getEntry(row);
+ CommentAware model = (CommentAware) tableModel.getEntry(row);
editorButton.init(model);
@@ -114,7 +115,7 @@
@Override
public Object getCellEditorValue() {
- CommentModelAware model = editorButton.getBean();
+ CommentAware model = editorButton.getBean();
Preconditions.checkNotNull(model, "No model found in editor.");
Object result = model.getComment();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentEditorUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentEditorUI.jaxx 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentEditorUI.jaxx 2013-04-03 18:25:40 UTC (rev 723)
@@ -24,6 +24,7 @@
<JDialog id='commentDialog' layout='{new BorderLayout()}'>
<import>
+ fr.ifremer.tutti.persistence.entities.CommentAware
fr.ifremer.tutti.ui.swing.TuttiUIContext
org.jdesktop.swingx.JXTitledPanel
@@ -54,7 +55,7 @@
]]></script>
<!-- bean property -->
- <CommentModelAware id='bean' javaBean='null'/>
+ <CommentAware id='bean' javaBean='null'/>
<CommentEditorUIHandler id='handler'
initializer='getContextValue(CommentEditorUIHandler.class)'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentEditorUIHandler.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentEditorUIHandler.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.CommentAware;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.ComponentMover;
@@ -154,7 +155,7 @@
public void init() {
- CommentModelAware bean = ui.getBean();
+ CommentAware bean = ui.getBean();
String content = bean == null ? null : bean.getComment();
ui.getTextContent().setText(content);
}
@@ -181,7 +182,7 @@
/** pushes the typed text in the property of the bean */
public void setText(String value) {
- CommentModelAware bean = ui.getBean();
+ CommentAware bean = ui.getBean();
bean.setComment(value);
}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentModelAware.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentModelAware.java 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentModelAware.java 2013-04-03 18:25:40 UTC (rev 723)
@@ -1,40 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util.comment;
-
-/*
- * #%L
- * Tutti :: UI
- * $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%
- */
-
-/**
- * To place on model wich supports comment.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public interface CommentModelAware {
-
- String PROPERTY_COMMENT = "comment";
-
- String getComment();
-
- void setComment(String comment);
-}
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-04-03 18:25:40 UTC (rev 723)
@@ -172,10 +172,15 @@
tutti.dbManager.title.choose.dbExportFile=
tutti.dbManager.title.choose.dbImportFile=
tutti.editAccidentalBatch.table.header.comment=
+tutti.editAccidentalBatch.table.header.comment.tip=
tutti.editAccidentalBatch.table.header.file=
+tutti.editAccidentalBatch.table.header.file.tip=
tutti.editAccidentalBatch.table.header.speciesByCode=
+tutti.editAccidentalBatch.table.header.speciesByCode.tip=
tutti.editAccidentalBatch.table.header.speciesByGenusCode=
+tutti.editAccidentalBatch.table.header.speciesByGenusCode.tip=
tutti.editAccidentalBatch.table.header.weight=
+tutti.editAccidentalBatch.table.header.weight.tip=
tutti.editBenthosBatch.action.createBatch=
tutti.editBenthosBatch.action.createBatch.mnemonic=
tutti.editBenthosBatch.action.createBatch.tip=
@@ -212,20 +217,31 @@
tutti.editBenthosBatch.split.weightNotNull.message=
tutti.editBenthosBatch.split.weightNotNull.title=
tutti.editBenthosBatch.table.header.ageCategory=
+tutti.editBenthosBatch.table.header.ageCategory.tip=
tutti.editBenthosBatch.table.header.comment=
+tutti.editBenthosBatch.table.header.comment.tip=
tutti.editBenthosBatch.table.header.computedNumber=
+tutti.editBenthosBatch.table.header.computedNumber.tip=
tutti.editBenthosBatch.table.header.file=
+tutti.editBenthosBatch.table.header.file.tip=
tutti.editBenthosBatch.table.header.maturityCategory=
+tutti.editBenthosBatch.table.header.maturityCategory.tip=
tutti.editBenthosBatch.table.header.number=
tutti.editBenthosBatch.table.header.sampleWeight=
tutti.editBenthosBatch.table.header.sexCategory=
+tutti.editBenthosBatch.table.header.sexCategory.tip=
tutti.editBenthosBatch.table.header.sizeCategory=
+tutti.editBenthosBatch.table.header.sizeCategory.tip=
tutti.editBenthosBatch.table.header.sortedUnsortedCategory=
+tutti.editBenthosBatch.table.header.sortedUnsortedCategory.tip=
tutti.editBenthosBatch.table.header.species=
+tutti.editBenthosBatch.table.header.species.tip=
tutti.editBenthosBatch.table.header.speciesByCode=
tutti.editBenthosBatch.table.header.speciesByGenusCode=
tutti.editBenthosBatch.table.header.toConfirm=
+tutti.editBenthosBatch.table.header.toConfirm.tip=
tutti.editBenthosBatch.table.header.weight=
+tutti.editBenthosBatch.table.header.weight.tip=
tutti.editBenthosFrequencies.action.cancel=
tutti.editBenthosFrequencies.action.cancel.mnemonic=
tutti.editBenthosFrequencies.action.cancel.tip=
@@ -461,19 +477,34 @@
tutti.editFishingOperation.label.traitReminder.inCreation=
tutti.editFishingOperation.pane.other=
tutti.editFishingOperation.tab.general=
+tutti.editMarineLitterBatch.field.marineLitterTotalWeight=
+tutti.editMarineLitterBatch.field.marineLitterTotalWeight.tip=
tutti.editMarineLitterBatch.table.header.comment=
+tutti.editMarineLitterBatch.table.header.comment.tip=
tutti.editMarineLitterBatch.table.header.file=
+tutti.editMarineLitterBatch.table.header.file.tip=
tutti.editMarineLitterBatch.table.header.marineLitterCategory=
+tutti.editMarineLitterBatch.table.header.marineLitterCategory.tip=
tutti.editMarineLitterBatch.table.header.marineLitterSizeCategory=
+tutti.editMarineLitterBatch.table.header.marineLitterSizeCategory.tip=
tutti.editMarineLitterBatch.table.header.number=
+tutti.editMarineLitterBatch.table.header.number.tip=
tutti.editMarineLitterBatch.table.header.weight=
+tutti.editMarineLitterBatch.table.header.weight.tip=
tutti.editPlanktonBatch.table.header.comment=
+tutti.editPlanktonBatch.table.header.comment.tip=
tutti.editPlanktonBatch.table.header.file=
+tutti.editPlanktonBatch.table.header.file.tip=
tutti.editPlanktonBatch.table.header.sampleWeight=
+tutti.editPlanktonBatch.table.header.sampleWeight.tip=
tutti.editPlanktonBatch.table.header.speciesByCode=
+tutti.editPlanktonBatch.table.header.speciesByCode.tip=
tutti.editPlanktonBatch.table.header.speciesByGenusCode=
+tutti.editPlanktonBatch.table.header.speciesByGenusCode.tip=
tutti.editPlanktonBatch.table.header.toConfirm=
+tutti.editPlanktonBatch.table.header.toConfirm.tip=
tutti.editPlanktonBatch.table.header.weight=
+tutti.editPlanktonBatch.table.header.weight.tip=
tutti.editProgram.action.closeEditProgram=
tutti.editProgram.action.closeEditProgram.mnemonic=
tutti.editProgram.action.closeEditProgram.tip=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-03 17:29:52 UTC (rev 722)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-03 18:25:40 UTC (rev 723)
@@ -175,10 +175,15 @@
tutti.dbManager.title.choose.dbExportFile=Exporter la base de données
tutti.dbManager.title.choose.dbImportFile=Importer la base de données
tutti.editAccidentalBatch.table.header.comment=Commentaire
+tutti.editAccidentalBatch.table.header.comment.tip=
tutti.editAccidentalBatch.table.header.file=Pièces-jointes
+tutti.editAccidentalBatch.table.header.file.tip=
tutti.editAccidentalBatch.table.header.speciesByCode=Espèce
+tutti.editAccidentalBatch.table.header.speciesByCode.tip=
tutti.editAccidentalBatch.table.header.speciesByGenusCode=Espèce
+tutti.editAccidentalBatch.table.header.speciesByGenusCode.tip=
tutti.editAccidentalBatch.table.header.weight=Poids observé
+tutti.editAccidentalBatch.table.header.weight.tip=
tutti.editBenthosBatch.action.createBatch=Créer un lot pour une espèce
tutti.editBenthosBatch.action.createBatch.mnemonic=C
tutti.editBenthosBatch.action.createBatch.tip=Créer un nouveau lot pour une espèce
@@ -221,16 +226,27 @@
tutti.editBenthosBatch.split.weightNotNull.message=Pour catégoriser un lot, il ne doit pas avoir de poids sous-échantillonné.
tutti.editBenthosBatch.split.weightNotNull.title=Poids sous-échantillonné non nul
tutti.editBenthosBatch.table.header.ageCategory=Age
+tutti.editBenthosBatch.table.header.ageCategory.tip=
tutti.editBenthosBatch.table.header.comment=Commentaire
+tutti.editBenthosBatch.table.header.comment.tip=
tutti.editBenthosBatch.table.header.computedNumber=Nombre
+tutti.editBenthosBatch.table.header.computedNumber.tip=
tutti.editBenthosBatch.table.header.file=Pièces jointes
+tutti.editBenthosBatch.table.header.file.tip=
tutti.editBenthosBatch.table.header.maturityCategory=Maturité
+tutti.editBenthosBatch.table.header.maturityCategory.tip=
tutti.editBenthosBatch.table.header.sexCategory=Sexe
+tutti.editBenthosBatch.table.header.sexCategory.tip=
tutti.editBenthosBatch.table.header.sizeCategory=Class. Tri
+tutti.editBenthosBatch.table.header.sizeCategory.tip=
tutti.editBenthosBatch.table.header.sortedUnsortedCategory=V/HV (kg)
+tutti.editBenthosBatch.table.header.sortedUnsortedCategory.tip=
tutti.editBenthosBatch.table.header.species=Espèce
+tutti.editBenthosBatch.table.header.species.tip=
tutti.editBenthosBatch.table.header.toConfirm=A Confirmer
+tutti.editBenthosBatch.table.header.toConfirm.tip=
tutti.editBenthosBatch.table.header.weight=Poids sous-échantillonné (kg)
+tutti.editBenthosBatch.table.header.weight.tip=
tutti.editBenthosBatch.title.batchActions=Actions
tutti.editBenthosFrequencies.action.cancel=Annuler
tutti.editBenthosFrequencies.action.cancel.mnemonic=A
@@ -468,19 +484,34 @@
tutti.editFishingOperation.label.traitReminder.inCreation=en cours de création
tutti.editFishingOperation.pane.other=Autres caractéristiques
tutti.editFishingOperation.tab.general=Trait
+tutti.editMarineLitterBatch.field.marineLitterTotalWeight=Poids total (Kg)
+tutti.editMarineLitterBatch.field.marineLitterTotalWeight.tip=Poids total (Kg)
tutti.editMarineLitterBatch.table.header.comment=Commentaire
+tutti.editMarineLitterBatch.table.header.comment.tip=Commentaire
tutti.editMarineLitterBatch.table.header.file=Pièces jointes
+tutti.editMarineLitterBatch.table.header.file.tip=Pièces jointes
tutti.editMarineLitterBatch.table.header.marineLitterCategory=Catégorie
+tutti.editMarineLitterBatch.table.header.marineLitterCategory.tip=Catégorie de déchets
tutti.editMarineLitterBatch.table.header.marineLitterSizeCategory=Catégorie de taille
+tutti.editMarineLitterBatch.table.header.marineLitterSizeCategory.tip=Catégorie de taille
tutti.editMarineLitterBatch.table.header.number=Nombre
+tutti.editMarineLitterBatch.table.header.number.tip=Nombre d'objets
tutti.editMarineLitterBatch.table.header.weight=Poids
+tutti.editMarineLitterBatch.table.header.weight.tip=Poids (Kg)
tutti.editPlanktonBatch.table.header.comment=Commentaire
+tutti.editPlanktonBatch.table.header.comment.tip=
tutti.editPlanktonBatch.table.header.file=Pièces jointes
+tutti.editPlanktonBatch.table.header.file.tip=Pièces jointes
tutti.editPlanktonBatch.table.header.sampleWeight=Poids échantillonné
+tutti.editPlanktonBatch.table.header.sampleWeight.tip=
tutti.editPlanktonBatch.table.header.speciesByCode=Espèce
+tutti.editPlanktonBatch.table.header.speciesByCode.tip=
tutti.editPlanktonBatch.table.header.speciesByGenusCode=Espèce
+tutti.editPlanktonBatch.table.header.speciesByGenusCode.tip=
tutti.editPlanktonBatch.table.header.toConfirm=A Confirmer
+tutti.editPlanktonBatch.table.header.toConfirm.tip=
tutti.editPlanktonBatch.table.header.weight=Poids
+tutti.editPlanktonBatch.table.header.weight.tip=
tutti.editProgram.action.closeEditProgram=Fermer
tutti.editProgram.action.closeEditProgram.mnemonic=r
tutti.editProgram.action.closeEditProgram.tip=Annuler l'édition (ou la création) de la série de campagne
1
0
r722 - in trunk/tutti-service/src/main: java/fr/ifremer/tutti/service java/fr/ifremer/tutti/service/catches resources/i18n
by kmorin@users.forge.codelutin.com 03 Apr '13
by kmorin@users.forge.codelutin.com 03 Apr '13
03 Apr '13
Author: kmorin
Date: 2013-04-03 19:29:52 +0200 (Wed, 03 Apr 2013)
New Revision: 722
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/722
Log:
create service to compute the weights
Added:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
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
Added: 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 (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-04-03 17:29:52 UTC (rev 722)
@@ -0,0 +1,330 @@
+package fr.ifremer.tutti.service.catches;
+
+import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.persistence.entities.data.*;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.apache.commons.collections.CollectionUtils;
+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._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.3
+ */
+public class TuttiWeightComputingService extends AbstractTuttiService {
+
+ private static final Log log =
+ LogFactory.getLog(TuttiWeightComputingService.class);
+
+ protected PersistenceService persistenceService;
+
+ @Override
+ public void setServiceContext(TuttiServiceContext context) {
+ super.setServiceContext(context);
+ persistenceService = getService(PersistenceService.class);
+ }
+
+ public void computeCatchBatchWeights(CatchBatch catchBatch,
+ BatchContainer<SpeciesBatch> rootSpeciesBatch,
+ BatchContainer<SpeciesBatch> rootBenthosBatch) {
+
+ // Species
+ Float speciesTotalComputedSortedWeight = 0f;
+ Float speciesTotalComputedUnsortedWeight = 0f;
+
+ for (int i = 0; i < rootSpeciesBatch.getChildren().size(); i++) {
+ SpeciesBatch row = rootSpeciesBatch.getChildren().get(i);
+ Float weight = row.getSampleCategoryWeight();
+ if (weight == null) {
+ weight = row.getSampleCategoryComputedWeight();
+ }
+ if (weight == null) {
+ return;
+ }
+
+ CaracteristicQualitativeValue value = (CaracteristicQualitativeValue) row.getSampleCategoryValue();
+ if (SortedUnsortedEnum.SORTED.matchValue(value)) {
+ speciesTotalComputedSortedWeight += weight;
+ } else {
+ speciesTotalComputedUnsortedWeight += weight;
+ }
+ }
+
+ Number inertWeight = catchBatch.getSpeciesTotalInertWeight();
+ if (inertWeight != null) {
+ speciesTotalComputedSortedWeight += inertWeight.floatValue();
+ } else {
+ catchBatch.setSpeciesTotalInertComputedWeight(0f);
+ }
+
+ Number livingNotItemizedWeight = catchBatch.getSpeciesTotalLivingNotItemizedWeight();
+ if (livingNotItemizedWeight != null) {
+ speciesTotalComputedSortedWeight += livingNotItemizedWeight.floatValue();
+ } else {
+ catchBatch.setSpeciesTotalLivingNotItemizedComputedWeight(0f);
+ }
+
+ catchBatch.setSpeciesTotalSampleSortedComputedWeight(speciesTotalComputedSortedWeight);
+
+ Float speciesTotalSortedWeight = catchBatch.getSpeciesTotalSortedWeight();
+ if (speciesTotalSortedWeight == null) {
+ speciesTotalSortedWeight = speciesTotalComputedSortedWeight;
+ catchBatch.setSpeciesTotalSortedComputedWeight(speciesTotalSortedWeight);
+
+ } else if (speciesTotalSortedWeight < speciesTotalComputedSortedWeight) {
+ throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentSpeciesTotalSorted"));
+ }
+ catchBatch.setSpeciesTotalUnsortedComputedWeight(speciesTotalComputedUnsortedWeight);
+
+ if (speciesTotalSortedWeight == null) {
+ speciesTotalSortedWeight = catchBatch.getSpeciesTotalSortedComputedWeight();
+ }
+ Float speciesTotalWeight = speciesTotalComputedUnsortedWeight + speciesTotalSortedWeight;
+ catchBatch.setSpeciesTotalComputedWeight(speciesTotalWeight);
+
+ // Benthos
+ Float benthosTotalComputedSortedWeight = 0f;
+ Float benthosTotalComputedUnsortedWeight = 0f;
+
+ for (int i = 0; i < rootBenthosBatch.getChildren().size(); i++) {
+ SpeciesBatch row = rootBenthosBatch.getChildren().get(i);
+ Float weight = row.getSampleCategoryWeight();
+ if (weight == null) {
+ weight = row.getSampleCategoryComputedWeight();
+ }
+ if (weight == null) {
+ return;
+ }
+
+ CaracteristicQualitativeValue value = (CaracteristicQualitativeValue) row.getSampleCategoryValue();
+ if (SortedUnsortedEnum.SORTED.matchValue(value)) {
+ benthosTotalComputedSortedWeight += weight;
+ } else {
+ benthosTotalComputedUnsortedWeight += weight;
+ }
+ }
+
+ inertWeight = catchBatch.getBenthosTotalInertWeight();
+ if (inertWeight != null) {
+ benthosTotalComputedSortedWeight += inertWeight.floatValue();
+ } else {
+ catchBatch.setBenthosTotalInertComputedWeight(0f);
+ }
+
+ livingNotItemizedWeight = catchBatch.getBenthosTotalLivingNotItemizedWeight();
+ if (livingNotItemizedWeight != null) {
+ benthosTotalComputedSortedWeight += livingNotItemizedWeight.floatValue();
+ } else {
+ catchBatch.setBenthosTotalLivingNotItemizedComputedWeight(0f);
+ }
+
+ catchBatch.setBenthosTotalSampleSortedComputedWeight(benthosTotalComputedSortedWeight);
+
+ Float benthosTotalSortedWeight = catchBatch.getBenthosTotalSortedWeight();
+ if (benthosTotalSortedWeight == null) {
+ benthosTotalSortedWeight = benthosTotalComputedSortedWeight;
+ catchBatch.setBenthosTotalSortedComputedWeight(benthosTotalSortedWeight);
+
+ } else if (benthosTotalSortedWeight < benthosTotalComputedSortedWeight) {
+ throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentBenthosTotalSorted"));
+ }
+ catchBatch.setBenthosTotalUnsortedComputedWeight(benthosTotalComputedUnsortedWeight);
+
+ if (benthosTotalSortedWeight == null) {
+ benthosTotalSortedWeight = catchBatch.getBenthosTotalSortedComputedWeight();
+ }
+ Float benthosTotalWeight = benthosTotalComputedUnsortedWeight + benthosTotalSortedWeight;
+ catchBatch.setBenthosTotalComputedWeight(benthosTotalWeight);
+
+ // Catch
+ Float carrouselWeight = catchBatch.getCatchTotalSortedCarousselWeight();
+ Float totalUnsortedWeight = catchBatch.getSpeciesTotalUnsortedComputedWeight() +
+ catchBatch.getBenthosTotalUnsortedComputedWeight();
+ Float totalSortedWeight;
+ if (carrouselWeight != null) {
+ totalSortedWeight = carrouselWeight;
+ } else {
+ totalSortedWeight = speciesTotalSortedWeight + benthosTotalSortedWeight;
+ }
+ catchBatch.setCatchTotalSortedComputedWeight(totalSortedWeight);
+ catchBatch.setCatchTotalUnsortedComputedWeight(totalUnsortedWeight);
+
+ Float totalWeight = catchBatch.getCatchTotalWeight();
+ Float rejectedWeight = catchBatch.getCatchTotalRejectedWeight();
+
+ if (rejectedWeight == null && totalWeight != null) {
+ if (!totalWeight.equals(totalUnsortedWeight
+ + totalSortedWeight)) {
+ throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentTotal"));
+
+ } else {
+ catchBatch.setCatchTotalRejectedComputedWeight(totalWeight
+ - totalUnsortedWeight
+ - totalSortedWeight);
+ }
+
+ } else if (totalWeight == null) {
+ if (rejectedWeight == null) {
+ rejectedWeight = 0f;
+ catchBatch.setCatchTotalRejectedComputedWeight(0f);
+ }
+ catchBatch.setCatchTotalComputedWeight(totalUnsortedWeight
+ + totalSortedWeight
+ + rejectedWeight);
+
+ } else if (!totalWeight.equals(totalUnsortedWeight + totalSortedWeight + rejectedWeight)) {
+ throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentTotal"));
+ }
+ }
+
+ public BatchContainer<SpeciesBatch> getComputedSpeciesBatches(FishingOperation operation) {
+
+ BatchContainer<SpeciesBatch> rootSpeciesBatch =
+ persistenceService.getRootSpeciesBatch(operation.getId());
+
+ if (rootSpeciesBatch != null) {
+ List<SpeciesBatch> roots = rootSpeciesBatch.getChildren();
+
+ for (int i = 0; i < roots.size(); i++) {
+ SpeciesBatch batch = roots.get(i);
+ computeSpeciesBatch(batch);
+ }
+ }
+
+ return rootSpeciesBatch;
+ }
+
+ public BatchContainer<SpeciesBatch> getComputedBenthosBatches(FishingOperation operation) {
+
+ BatchContainer<SpeciesBatch> rootBenthosBatch =
+ persistenceService.getRootBenthosBatch(operation.getId());
+
+ List<SpeciesBatch> roots = rootBenthosBatch.getChildren();
+
+ for (int i = 0; i < roots.size(); i++) {
+ SpeciesBatch batch = roots.get(i);
+ computeSpeciesBatch(batch);
+ }
+
+ return rootBenthosBatch;
+ }
+
+ protected Float computeSpeciesBatch(SpeciesBatch batch) {
+ Float result = null;
+ Float categoryWeight = batch.getSampleCategoryWeight();
+ Float rowWeight = batch.getWeight();
+
+ List<SpeciesBatch> children = batch.getChildBatchs();
+ // if the row is not a leaf
+ if (batch.sizeChildBatchs() > 0) {
+ Float sum = 0f;
+ // make the sum of the children weights
+ for (SpeciesBatch child : children) {
+ Float weight = computeSpeciesBatch(child);
+ if (weight == null) {
+ sum = null;
+ break;
+ }
+ sum += weight;
+ }
+
+ if (sum != null) {
+// if (categoryWeight == null) {
+// finestCategory.setComputedWeight(sum);
+// for (SpeciesBatchRowModel child : children) {
+// child.getFinestCategory().setSubSample(false);
+// }
+//
+// } else if (categoryWeight < sum) {
+// throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight"));
+//
+// } else {
+// boolean subSample = categoryWeight > sum;
+// for (SpeciesBatchRowModel child : children) {
+// child.getFinestCategory().setSubSample(subSample);
+// }
+// sum = categoryWeight;
+// }
+// result = sum;
+ if (categoryWeight == null) {
+ batch.setSampleCategoryComputedWeight(sum);
+
+ } else if (categoryWeight < sum) {
+ throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentParentCategoryWeight"));
+
+ } else {
+ sum = categoryWeight;
+ }
+ result = sum;
+ }
+
+ } else {// the row is a leaf
+
+ batch.setComputedWeight(null);
+
+ List<SpeciesBatchFrequency> frequencies = persistenceService.getAllSpeciesBatchFrequency(batch.getId());
+
+ if (CollectionUtils.isNotEmpty(frequencies)) {
+ // if there are frequencies, then compute their weight
+ Float frequencyWeight = 0f;
+ for (SpeciesBatchFrequency frequency : frequencies) {
+ Float w = frequency.getWeight();
+ if (w == null) {
+
+ // can't sum when a null value appears
+ frequencyWeight = null;
+ break;
+
+ } else if (frequencyWeight != null) {
+
+ // still can sum weights
+ frequencyWeight += w;
+ }
+ }
+
+ if (categoryWeight == null && rowWeight != null) {
+ throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentRowWeightCategory"));
+
+ } else if (categoryWeight == null && frequencyWeight != null) {
+ // if the category weight is null and the frequencies have a weight,
+ // then this weight is the result
+ batch.setSampleCategoryComputedWeight(frequencyWeight);
+ result = frequencyWeight;
+
+ } else if (frequencyWeight != null
+ && !frequencyWeight.equals(categoryWeight)) {
+
+ // if the weight of the frequencies is different from the category
+ // weight, then set the weight of the sample
+ if (frequencyWeight > categoryWeight) {
+ throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentCategoryWeight"));
+
+ } else if (rowWeight == null) {
+ batch.setComputedWeight(frequencyWeight);
+
+ } else if (!rowWeight.equals(frequencyWeight)) {
+ throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentRowWeightFrequency"));
+ }
+ result = categoryWeight;
+
+ } else {
+ result = categoryWeight;
+ }
+
+ } else {
+ result = categoryWeight;
+ }
+ }
+
+ return result;
+ }
+
+}
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-03 15:15:57 UTC (rev 721)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-04-03 17:29:52 UTC (rev 722)
@@ -7,6 +7,10 @@
tutti.config.option.tmp.directory.description=
tutti.config.option.version.description=
tutti.config.service=
+tutti.editCatchBatch.action.computeWeights.error.incoherentCategoryWeight=
+tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight=
+tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightCategory=
+tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightFrequency=
tutti.property.attachment=
tutti.property.caracteristic=
tutti.property.country=
@@ -43,6 +47,12 @@
tutti.propety.no.vessel.name=
tutti.propety.no.zone=
tutti.propety.vessel.nation.registrationCode=
+tutti.service.catches.computeWeights.error.incoherentCategoryWeight=
+tutti.service.catches.computeWeights.error.incoherentParentCategoryWeight=
+tutti.service.catches.computeWeights.error.incoherentRowWeightCategory=
+tutti.service.catches.computeWeights.error.incoherentRowWeightFrequency=
+tutti.service.catches.computeWeights.error.incoherentSpeciesTotalSorted=
+tutti.service.catches.computeWeights.error.incoherentTotal=
tutti.validator.error.comment.too.long=
tutti.validator.error.cruise.beginDate.required=
tutti.validator.error.cruise.dates.endBeforeStart=
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-03 15:15:57 UTC (rev 721)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-04-03 17:29:52 UTC (rev 722)
@@ -7,6 +7,7 @@
tutti.config.option.tmp.directory.description=Répertoire temporaire utilisée par l'application (est nettoyé à chaque démarrage de l'application).
tutti.config.option.version.description=Version courante de l'application
tutti.config.service=Configuration des services de Tutti
+tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight=
tutti.property.attachment=Pièce jointe
tutti.property.caracteristic=Caractéristique
tutti.property.country=Pays
@@ -43,6 +44,12 @@
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.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é
+tutti.service.catches.computeWeights.error.incoherentRowWeightFrequency=Le poids total des mensurations est différent du poids du sous-échantillon
+tutti.service.catches.computeWeights.error.incoherentSpeciesTotalSorted=Le poids total Vrac des espèces est inférieur à la somme des poids Vrac triés, inerte trié et vivant non détaillé trié
+tutti.service.catches.computeWeights.error.incoherentTotal=Le poids total de la capture ne correspond pas à la somme des poids totaux Vrac, Hors Vrac et non triés
tutti.validator.error.comment.too.long=Taille de commentaire trop longue (limitée à %s caractères)
tutti.validator.error.cruise.beginDate.required=La date de début est obligatoire
tutti.validator.error.cruise.dates.endBeforeStart=La date de fin doit être après la date de début
1
0
Author: tchemit
Date: 2013-04-03 17:15:57 +0200 (Wed, 03 Apr 2013)
New Revision: 721
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/721
Log:
add more ignore test resources
Modified:
trunk/tutti-persistence/src/test/
Property changes on: trunk/tutti-persistence/src/test
___________________________________________________________________
Modified: svn:ignore
- db
+ db
dbEmpty
1
0