[tutti] branch develop updated (ed91683 -> fc62939)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository tutti. See http://git.codelutin.com/tutti.git from ed91683 fixes #5699: [CAPTURE] l'élévation des poids remet l'ordre des lignes selon l'ordre saisie mais ne remet pas le filtre à Tri/Saisie donc il y a une incohérence à l'écran new fc62939 fixes #5699: [CAPTURE] l'élévation des poids remet l'ordre des lignes selon l'ordre saisie mais ne remet pas le filtre à Tri/Saisie donc il y a une incohérence à l'écran The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit fc62939e72c4289aecb775cc242ee947a43b85bf Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Aug 30 11:22:34 2014 +0200 fixes #5699: [CAPTURE] l'élévation des poids remet l'ordre des lignes selon l'ordre saisie mais ne remet pas le filtre à Tri/Saisie donc il y a une incohérence à l'écran Summary of changes: .../ui/swing/action/ComputeBatchWeightsAction.java | 79 +++- .../SpeciesBatchNaturalOrderComparator.java | 78 +++- .../catches/benthos/BenthosBatchRowModel.java | 467 ++++++++++----------- 3 files changed, 371 insertions(+), 253 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit fc62939e72c4289aecb775cc242ee947a43b85bf Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Aug 30 11:22:34 2014 +0200 fixes #5699: [CAPTURE] l'élévation des poids remet l'ordre des lignes selon l'ordre saisie mais ne remet pas le filtre à Tri/Saisie donc il y a une incohérence à l'écran --- .../ui/swing/action/ComputeBatchWeightsAction.java | 79 +++- .../SpeciesBatchNaturalOrderComparator.java | 78 +++- .../catches/benthos/BenthosBatchRowModel.java | 467 ++++++++++----------- 3 files changed, 371 insertions(+), 253 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java index 10d4edf..1d3c7bf 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java @@ -1,4 +1,3 @@ - package fr.ifremer.tutti.ui.swing.action; /* @@ -39,8 +38,12 @@ import fr.ifremer.tutti.service.catches.WeightComputingService; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SpeciesBatchNaturalOrderComparator; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SpeciesSortMode; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.util.Numbers; @@ -121,7 +124,28 @@ public class ComputeBatchWeightsAction extends AbstractTuttiAction<EditCatchesUI getUI().getTabPane().setSelectedIndex(1); int index = e.getIndex(); - SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getModel().getRows().get(index); + SpeciesBatchUIModel speciesBatchUIModel = getUI().getSpeciesTabContent().getModel(); + + SpeciesBatchRowModel row; + + if (speciesBatchUIModel.getSpeciesSortMode() != SpeciesSortMode.NONE) { + + // must resort rows in natural order (in service we use this order) + List<SpeciesBatchRowModel> rows = Lists.newArrayList(speciesBatchUIModel.getRows()); + SpeciesBatchNaturalOrderComparator.sort(rows); + // get the row + row = rows.get(index); + // get the correct rowIndex in the sorted list + index = speciesBatchUIModel.getRows().indexOf(row); + + } else { + + // correct order can directly get row from list + List<SpeciesBatchRowModel> rows = speciesBatchUIModel.getRows(); + row = rows.get(index); + + } + int column; if (SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) { column = getFinestCategoryColumn(row.getFinestCategory().getCategoryId()); @@ -148,7 +172,29 @@ public class ComputeBatchWeightsAction extends AbstractTuttiAction<EditCatchesUI getUI().getTabPane().setSelectedIndex(2); int index = e.getIndex(); - BenthosBatchRowModel row = getUI().getBenthosTabContent().getModel().getRows().get(index); + + BenthosBatchUIModel benthosBatchUIModel = getUI().getBenthosTabContent().getModel(); + + BenthosBatchRowModel row; + if (benthosBatchUIModel.getSpeciesSortMode() != SpeciesSortMode.NONE) { + + // must resort rows in natural order (in service we use this order) + List<BenthosBatchRowModel> rows = Lists.newArrayList(benthosBatchUIModel.getRows()); + SpeciesBatchNaturalOrderComparator.sort(rows); + // get the row + row = rows.get(index); + // get the correct rowIndex in the sorted list + index = benthosBatchUIModel.getRows().indexOf(row); + + } else { + + // correct order can directly get row from list + List<BenthosBatchRowModel> rows = benthosBatchUIModel.getRows(); + row = rows.get(index); + + } + + int column; if (BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) { column = getFinestCategoryColumn(row.getFinestCategory().getCategoryId()); @@ -261,6 +307,33 @@ public class ComputeBatchWeightsAction extends AbstractTuttiAction<EditCatchesUI public void postSuccessAction() { super.postSuccessAction(); + // keep sortMode + // see https://forge.codelutin.com/issues/5699 + + { + SpeciesBatchUIModel model = getUI().getSpeciesTabContent().getModel(); + SpeciesSortMode sortMode = model.getSpeciesSortMode(); + if (sortMode != SpeciesSortMode.NONE) { + + // must reload order + model.setSpeciesSortMode(SpeciesSortMode.NONE); + model.setSpeciesSortMode(sortMode); + + } + } + + { + BenthosBatchUIModel model = getUI().getBenthosTabContent().getModel(); + SpeciesSortMode sortMode = model.getSpeciesSortMode(); + if (sortMode != SpeciesSortMode.NONE) { + + // must reload order + model.setSpeciesSortMode(SpeciesSortMode.NONE); + model.setSpeciesSortMode(sortMode); + + } + } + getUI().repaint(); // see http://forge.codelutin.com/issues/3853 SwingUtilities.invokeLater( diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesBatchNaturalOrderComparator.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesBatchNaturalOrderComparator.java index 1573c48..3744370 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesBatchNaturalOrderComparator.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesBatchNaturalOrderComparator.java @@ -1,10 +1,84 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches; +import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** + * To compare some rows on their natural order. Means the order the data were stored. + * + * For this we use the {@link SpeciesAbleBatch#getRankOrder()} for the parents and keep using the + * rowIndex for the children. + * * Created on 8/30/14. * * @author Tony Chemit - chemit@codelutin.com - * @since XXX + * @since 3.7 */ -public class SpeciesBatchNaturalOrderComparator { +public class SpeciesBatchNaturalOrderComparator<R extends SpeciesAbleBatch> implements Comparator<R>, Serializable { + + private static final long serialVersionUID = 1L; + + public static <R extends SpeciesAbleBatch> void sort(List<R> data) { + + SpeciesBatchNaturalOrderComparator<R> comparator = new SpeciesBatchNaturalOrderComparator<>(data); + Collections.sort(data, comparator); + + } + + private final Map<R, Integer> data; + + public SpeciesBatchNaturalOrderComparator(List<R> data) { + + this.data = new HashMap<>(); + int index = 0; + for (R r : data) { + this.data.put(r, index++); + } + + } + + @Override + public int compare(R o1, R o2) { + + SpeciesAbleBatch o1ParentBatch = getRootBatch(o1); + SpeciesAbleBatch o2ParentBatch = getRootBatch(o2); + + int result = o1ParentBatch.getRankOrder() - o2ParentBatch.getRankOrder(); + + if (result == 0) { + + // on same root batch, compare then their rowIndex + int o1Index = data.get(o1); + int o2Index = data.get(o2); + + result = o1Index - o2Index; + + } + + return result; + } + + protected SpeciesAbleBatch getRootBatch(SpeciesAbleBatch o) { + + SpeciesAbleBatch root; + + if (o.getParentBatch() == null) { + + root = o; + + } else { + + root = getRootBatch(o.getParentBatch()); + + } + + return root; + + } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java index 05776a1..ee97522 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java @@ -97,11 +97,11 @@ public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, public static final String PROPERTY_BATCH_ROOT = "batchRoot"; /** - * Species. + * Delegate edit object. * - * @since 0.3 + * @since 1.3 */ - protected Species species; + protected final BenthosBatch editObject = BenthosBatchs.newBenthosBatch(); /** * All categories(can not be null). @@ -111,13 +111,6 @@ public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, protected final SampleCategory<?>[] categories; /** - * Is the species need to be confirmed?. - * - * @since 0.2 - */ - protected boolean speciesToConfirm; - - /** * Observed weight. * * @since 0.2 @@ -134,13 +127,6 @@ public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, new ComputableData<Integer>(); /** - * Comment. - * - * @since 0.2 - */ - protected String comment; - - /** * Attachments (should never be null). * * @since 0.2 @@ -155,14 +141,6 @@ public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, protected List<BenthosFrequencyRowModel> frequency = Lists.newArrayList(); /** - * Parent of this batch (can be null if batch is root). - * - * @see #isBatchRoot() - * @since 0.3 - */ - protected BenthosBatchRowModel parentBatch; - - /** * List of child batches (can be null or empty if batch is a leaf). * * @see #isBatchLeaf() @@ -269,404 +247,405 @@ public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, // convert sample category weight Float categoryWeight = sampleCategory.getCategoryWeight(); result.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight)); + return result; } //------------------------------------------------------------------------// - //-- SampleCategoryAble --// + //-- SpeciesBatch --// //------------------------------------------------------------------------// @Override - public Integer getCategoryIndex(Integer id) { - Integer result = null; - for (SampleCategory<?> category : categories) { - if (category != null && id.equals(category.getCategoryId())) { - result = category.getCategoryDef().getOrder(); - break; - } - } - return result; + public Species getSpecies() { + return editObject.getSpecies(); } @Override - public void setSampleCategory(SampleCategory sampleCategory) { - int index = sampleCategory.getCategoryDef().getOrder(); - SampleCategory<?> oldCategory = categories[index]; - Object oldValue = oldCategory.getCategoryValue(); - Object oldWeight = oldCategory.getCategoryWeight(); - Object oldComputedWeight = oldCategory.getComputedWeight(); - categories[index] = sampleCategory; - //FIXME (indexed) - fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY, index, oldCategory, sampleCategory); - fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, index, oldValue, sampleCategory.getCategoryValue()); - fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_WEIGHT, index, oldWeight, sampleCategory.getCategoryWeight()); - fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_COMPUTED_WEIGHT, index, oldComputedWeight, sampleCategory.getComputedWeight()); + public void setSpecies(Species species) { + Object oldCategory = getSpecies(); + editObject.setSpecies(species); + firePropertyChange(PROPERTY_SPECIES, oldCategory, species); } @Override - public SampleCategory<?> getFirstSampleCategory() { - return categories[0]; + public String getComment() { + return editObject.getComment(); } @Override - public SampleCategory getFinestCategory() { - SampleCategory result = null; - for (int i = categories.length - 1; i > -1; i--) { - SampleCategory<?> category = categories[i]; - if (category != null && category.isValid()) { - result = category; - break; - } - } - return result; + public void setComment(String comment) { + Object oldValue = getComment(); + editObject.setComment(comment); + firePropertyChange(PROPERTY_COMMENT, oldValue, comment); } @Override - public SampleCategory<?> getSampleCategoryById(Integer sampleCategoryId) { - Integer index = getCategoryIndex(sampleCategoryId); - SampleCategory<?> result = index == null ? null : categories[index]; - return result; + public boolean isSpeciesToConfirm() { + return editObject.isSpeciesToConfirm(); } - public SampleCategory<?> getSampleCategoryByIndex(int sampleCategoryIndex) { - SampleCategory<?> result = categories[sampleCategoryIndex]; - return result; + @Override + public void setSpeciesToConfirm(boolean speciesToConfirm) { + boolean oldValue = isSpeciesToConfirm(); + editObject.setSpeciesToConfirm(speciesToConfirm); + firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm); } @Override - public void setSampleCategoryValue(Integer sampleCategoryId, Serializable value) { - SampleCategory<?> sampleCategory = - getSampleCategoryById(sampleCategoryId); - TuttiEntities.setProperty(sampleCategory, - SampleCategory.PROPERTY_CATEGORY_VALUE, value); - firePropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, null, sampleCategory); + public Integer getComputedNumber() { + return computedOrNotNumber.getComputedData(); } @Override - public void setSampleCategoryWeight(Integer sampleCategoryId, Object value) { - SampleCategory<?> sampleCategory = - getSampleCategoryById(sampleCategoryId); - TuttiEntities.setProperty(sampleCategory, - SampleCategory.PROPERTY_CATEGORY_WEIGHT, value); - firePropertyChange(PROPERTY_SAMPLE_CATEGORY_WEIGHT, null, sampleCategory); + public void setComputedNumber(Integer computedNumber) { + computedOrNotNumber.setComputedData(computedNumber); } @Override - public BenthosBatchRowModel getFirstAncestor(SampleCategory<?> entrySampleCategory) { - BenthosBatchRowModel result = this; - if (getParentBatch() != null) { - BenthosBatchRowModel parentBatch = getParentBatch(); - SampleCategory<?> parentSampleCategory = parentBatch.getSampleCategoryById(entrySampleCategory.getCategoryId()); - if (Objects.equals(entrySampleCategory, parentSampleCategory)) { - - result = parentBatch.getFirstAncestor(entrySampleCategory); - } - } - return result; + public Float getComputedWeight() { + return computedOrNotWeight.getComputedData(); } @Override - public Iterator<SampleCategory<?>> iterator() { - return Arrays.asList(categories).iterator(); + public void setComputedWeight(Float computedWeight) { + computedOrNotWeight.setComputedData(computedWeight); } - //------------------------------------------------------------------------// - //-- Species category --// - //------------------------------------------------------------------------// - @Override - public Species getSpecies() { - return species; + public FishingOperation getFishingOperation() { + return editObject.getFishingOperation(); } @Override - public void setSpecies(Species species) { - Object oldCategory = getSpecies(); - this.species = species; - firePropertyChange(PROPERTY_SPECIES, oldCategory, species); + public void setFishingOperation(FishingOperation fishingOperation) { + editObject.setFishingOperation(fishingOperation); } - //------------------------------------------------------------------------// - //-- Navigation properties --// - //------------------------------------------------------------------------// - @Override public BenthosBatchRowModel getParentBatch() { - return parentBatch; + return (BenthosBatchRowModel) editObject.getParentBatch(); } - public void setParentBatch(BenthosBatchRowModel parentBatch) { + @Override + public void setParentBatch(BenthosBatch parentBatch) { Object oldValue = getParentBatch(); - this.parentBatch = parentBatch; + editObject.setParentBatch(parentBatch); firePropertyChange(PROPERTY_PARENT_BATCH, oldValue, parentBatch); firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot()); } - public List<BenthosBatchRowModel> getChildBatch() { - return childBatch; + @Override + public Float getWeight() { + return computedOrNotWeight.getData(); } - public void setChildBatch(List<BenthosBatchRowModel> childBatch) { - this.childBatch = childBatch; - // force to propagate child changes - firePropertyChange(PROPERTY_CHILD_BATCH, null, childBatch); - firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf()); + @Override + public void setWeight(Float weight) { + this.computedOrNotWeight.setData(weight); } - public boolean isBatchLeaf() { - return CollectionUtils.isEmpty(childBatch); + @Override + public Integer getSampleCategoryId() { + return null; } - public boolean isBatchRoot() { - return parentBatch == null; + @Override + public void setSampleCategoryId(Integer sampleCategoryId) { } - //------------------------------------------------------------------------// - //-- CommentAware --// - //------------------------------------------------------------------------// - @Override - public String getComment() { - return comment; + public Serializable getSampleCategoryValue() { + return null; } @Override - public void setComment(String comment) { - Object oldValue = getComment(); - this.comment = comment; - firePropertyChange(PROPERTY_COMMENT, oldValue, comment); + public void setSampleCategoryValue(Serializable sampleCategoryValue) { } - //------------------------------------------------------------------------// - //-- AttachmentModelAware --// - //------------------------------------------------------------------------// - @Override - public ObjectTypeCode2 getObjectType() { - return ObjectTypeCode2.BATCH; + public Float getSampleCategoryWeight() { + return null; } @Override - public Integer getObjectId() { - return getIdAsInt(); + public void setSampleCategoryWeight(Float sampleCategoryWeight) { } @Override - public List<Attachment> getAttachment() { - return attachment; + public Integer getNumber() { + return computedOrNotNumber.getData(); } @Override - public void addAllAttachment(Collection<Attachment> attachments) { - this.attachment.addAll(attachments); - firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); + public void setNumber(Integer number) { + computedOrNotNumber.setData(number); } @Override - public void addAttachment(Attachment attachment) { - this.attachment.add(attachment); - firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); + public Float getSampleCategoryComputedWeight() { + return null; } @Override - public void removeAllAttachment(Collection<Attachment> attachments) { - this.attachment.removeAll(attachments); - firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); + public void setSampleCategoryComputedWeight(Float sampleCategoryComputedWeight) { } @Override - public void removeAttachment(Attachment attachment) { - this.attachment.remove(attachment); - firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); + public BenthosBatch getChildBatchs(int index) { + return childBatch.get(index); } - //------------------------------------------------------------------------// - //-- Other properties --// - //------------------------------------------------------------------------// - - public BenthosBatchRowModel getFirstAncestor(Integer sampleCategoryId) { - SampleCategory<?> sampleCategory = getSampleCategoryById(sampleCategoryId); - BenthosBatchRowModel firstAncestor = getFirstAncestor(sampleCategory); - return firstAncestor; + @Override + public boolean isChildBatchsEmpty() { + return childBatch == null || childBatch.isEmpty(); } @Override - public boolean isSpeciesToConfirm() { - return speciesToConfirm; + public int sizeChildBatchs() { + return childBatch == null ? 0 : childBatch.size(); } @Override - public void setSpeciesToConfirm(boolean speciesToConfirm) { - boolean oldValue = isSpeciesToConfirm(); - this.speciesToConfirm = speciesToConfirm; - firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm); + public void addChildBatchs(BenthosBatch childBatchs) { } @Override - public Float getWeight() { - return computedOrNotWeight.getData(); + public void addAllChildBatchs(Collection<BenthosBatch> childBatchs) { } @Override - public void setWeight(Float weight) { - this.computedOrNotWeight.setData(weight); + public boolean removeChildBatchs(BenthosBatch childBatchs) { + return false; } @Override - public Integer getNumber() { - return computedOrNotNumber.getData(); + public boolean removeAllChildBatchs(Collection<BenthosBatch> childBatchs) { + return false; } @Override - public void setNumber(Integer number) { - computedOrNotNumber.setData(number); + public boolean containsChildBatchs(BenthosBatch childBatchs) { + return false; } - public List<BenthosFrequencyRowModel> getFrequency() { - return frequency; + @Override + public boolean containsAllChildBatchs(Collection<BenthosBatch> childBatchs) { + return false; } - public void setFrequency(List<BenthosFrequencyRowModel> frequency) { - this.frequency = frequency; - // force to propagate frequencies changes - firePropertyChange(PROPERTY_FREQUENCY, null, frequency); + @Override + public List<BenthosBatch> getChildBatchs() { + return null; } @Override - public Integer getComputedNumber() { - return computedOrNotNumber.getComputedData(); + public void setChildBatchs(List<BenthosBatch> childBatchs) { } @Override - public void setComputedNumber(Integer computedNumber) { - computedOrNotNumber.setComputedData(computedNumber); + public Integer getRankOrder() { + return editObject.getRankOrder(); } @Override - public Float getComputedWeight() { - return computedOrNotWeight.getComputedData(); + public void setRankOrder(Integer rankOrder) { + editObject.setRankOrder(rankOrder); } + //------------------------------------------------------------------------// + //-- SampleCategoryAble --// + //------------------------------------------------------------------------// + @Override - public void setComputedWeight(Float computedWeight) { - computedOrNotWeight.setComputedData(computedWeight); + public Integer getCategoryIndex(Integer id) { + Integer result = null; + for (SampleCategory<?> category : categories) { + if (category != null && id.equals(category.getCategoryId())) { + result = category.getCategoryDef().getOrder(); + break; + } + } + return result; } - public ComputableData<Integer> getComputedOrNotNumber() { - return computedOrNotNumber; + @Override + public void setSampleCategory(SampleCategory sampleCategory) { + int index = sampleCategory.getCategoryDef().getOrder(); + SampleCategory<?> oldCategory = categories[index]; + Object oldValue = oldCategory.getCategoryValue(); + Object oldWeight = oldCategory.getCategoryWeight(); + Object oldComputedWeight = oldCategory.getComputedWeight(); + categories[index] = sampleCategory; + //FIXME (indexed) + fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY, index, oldCategory, sampleCategory); + fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, index, oldValue, sampleCategory.getCategoryValue()); + fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_WEIGHT, index, oldWeight, sampleCategory.getCategoryWeight()); + fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_COMPUTED_WEIGHT, index, oldComputedWeight, sampleCategory.getComputedWeight()); } - public void setComputedOrNotNumber(ComputableData<Integer> computedOrNotNumber) { - this.computedOrNotNumber = computedOrNotNumber; + @Override + public SampleCategory<?> getSampleCategoryById(Integer sampleCategoryId) { + Integer index = getCategoryIndex(sampleCategoryId); + SampleCategory<?> result = index == null ? null : categories[index]; + return result; } - public ComputableData<Float> getComputedOrNotWeight() { - return computedOrNotWeight; + public SampleCategory<?> getSampleCategoryByIndex(int sampleCategoryIndex) { + SampleCategory<?> result = categories[sampleCategoryIndex]; + return result; } - public void setComputedOrNotWeight(ComputableData<Float> computedOrNotWeight) { - this.computedOrNotWeight = computedOrNotWeight; + @Override + public void setSampleCategoryValue(Integer sampleCategoryId, Serializable value) { + SampleCategory<?> sampleCategory = + getSampleCategoryById(sampleCategoryId); + TuttiEntities.setProperty(sampleCategory, + SampleCategory.PROPERTY_CATEGORY_VALUE, value); + firePropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, null, sampleCategory); } @Override - public Integer getSampleCategoryId() { - return null; + public void setSampleCategoryWeight(Integer sampleCategoryId, Object value) { + SampleCategory<?> sampleCategory = + getSampleCategoryById(sampleCategoryId); + TuttiEntities.setProperty(sampleCategory, + SampleCategory.PROPERTY_CATEGORY_WEIGHT, value); + firePropertyChange(PROPERTY_SAMPLE_CATEGORY_WEIGHT, null, sampleCategory); } @Override - public void setSampleCategoryId(Integer sampleCategoryId) { + public SampleCategory getFinestCategory() { + SampleCategory result = null; + for (int i = categories.length - 1; i > -1; i--) { + SampleCategory<?> category = categories[i]; + if (category != null && category.isValid()) { + result = category; + break; + } + } + return result; } @Override - public Serializable getSampleCategoryValue() { - return null; + public SampleCategory<?> getFirstSampleCategory() { + return categories[0]; } @Override - public void setSampleCategoryValue(Serializable sampleCategoryValue) { + public BenthosBatchRowModel getFirstAncestor(SampleCategory<?> entrySampleCategory) { + BenthosBatchRowModel result = this; + if (getParentBatch() != null) { + BenthosBatchRowModel parentBatch = getParentBatch(); + SampleCategory<?> parentSampleCategory = parentBatch.getSampleCategoryById(entrySampleCategory.getCategoryId()); + if (Objects.equals(entrySampleCategory, parentSampleCategory)) { + + result = parentBatch.getFirstAncestor(entrySampleCategory); + } + } + return result; } @Override - public Float getSampleCategoryWeight() { - return null; + public Iterator<SampleCategory<?>> iterator() { + return Arrays.asList(categories).iterator(); } + //------------------------------------------------------------------------// + //-- AttachmentModelAware --// + //------------------------------------------------------------------------// + @Override - public void setSampleCategoryWeight(Float sampleCategoryWeight) { + public ObjectTypeCode2 getObjectType() { + return ObjectTypeCode2.BATCH; } @Override - public Float getSampleCategoryComputedWeight() { - return null; + public Integer getObjectId() { + return getIdAsInt(); } @Override - public void setSampleCategoryComputedWeight(Float sampleCategoryComputedWeight) { + public List<Attachment> getAttachment() { + return attachment; } @Override - public BenthosBatch getChildBatchs(int index) { - return childBatch.get(index); + public void addAllAttachment(Collection<Attachment> attachments) { + this.attachment.addAll(attachments); + firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); } @Override - public boolean isChildBatchsEmpty() { - return childBatch == null || childBatch.isEmpty(); + public void addAttachment(Attachment attachment) { + this.attachment.add(attachment); + firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); } @Override - public int sizeChildBatchs() { - return childBatch == null ? 0 : childBatch.size(); + public void removeAllAttachment(Collection<Attachment> attachments) { + this.attachment.removeAll(attachments); + firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); } @Override - public void addChildBatchs(BenthosBatch childBatchs) { + public void removeAttachment(Attachment attachment) { + this.attachment.remove(attachment); + firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); } - @Override - public void addAllChildBatchs(Collection<BenthosBatch> childBatchs) { + //------------------------------------------------------------------------// + //-- Other properties --// + //------------------------------------------------------------------------// + + public BenthosBatchRowModel getFirstAncestor(Integer sampleCategoryId) { + SampleCategory<?> sampleCategory = getSampleCategoryById(sampleCategoryId); + BenthosBatchRowModel firstAncestor = getFirstAncestor(sampleCategory); + return firstAncestor; } - @Override - public boolean removeChildBatchs(BenthosBatch childBatchs) { - return false; + public List<BenthosBatchRowModel> getChildBatch() { + return childBatch; } - @Override - public boolean removeAllChildBatchs(Collection<BenthosBatch> childBatchs) { - return false; + public void setChildBatch(List<BenthosBatchRowModel> childBatch) { + this.childBatch = childBatch; + // force to propagate child changes + firePropertyChange(PROPERTY_CHILD_BATCH, null, childBatch); + firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf()); } - @Override - public boolean containsChildBatchs(BenthosBatch childBatchs) { - return false; + public boolean isBatchLeaf() { + return CollectionUtils.isEmpty(childBatch); } - @Override - public boolean containsAllChildBatchs(Collection<BenthosBatch> childBatchs) { - return false; + public boolean isBatchRoot() { + return getParentBatch() == null; } - @Override - public List<BenthosBatch> getChildBatchs() { - return null; + public List<BenthosFrequencyRowModel> getFrequency() { + return frequency; } - @Override - public void setChildBatchs(List<BenthosBatch> childBatchs) { + public void setFrequency(List<BenthosFrequencyRowModel> frequency) { + this.frequency = frequency; + // force to propagate frequencies changes + firePropertyChange(PROPERTY_FREQUENCY, null, frequency); } - @Override - public void setParentBatch(BenthosBatch parentBatch) { + public ComputableData<Integer> getComputedOrNotNumber() { + return computedOrNotNumber; } - @Override - public FishingOperation getFishingOperation() { - return null; + public void setComputedOrNotNumber(ComputableData<Integer> computedOrNotNumber) { + this.computedOrNotNumber = computedOrNotNumber; } - @Override - public void setFishingOperation(FishingOperation fishingOperation) { + public ComputableData<Float> getComputedOrNotWeight() { + return computedOrNotWeight; + } + + public void setComputedOrNotWeight(ComputableData<Float> computedOrNotWeight) { + this.computedOrNotWeight = computedOrNotWeight; } public void collectShell(Set<BenthosBatchRowModel> collectedRows) { @@ -682,12 +661,4 @@ public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, } } - @Override - public Integer getRankOrder() { - return null; - } - - @Override - public void setRankOrder(Integer rankOrder) { - } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm