Revision f77963a7
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java | ||
---|---|---|
154 | 154 |
Collections.sort(features); |
155 | 155 |
|
156 | 156 |
|
157 |
EventList<SpecimenDescription> descriptions = GlazedLists.eventList(getDescriptions(workingSet));
|
|
158 |
SortedList<SpecimenDescription> sortedList = new SortedList<>(descriptions, null);
|
|
157 |
EventList<RowWrapper> descriptions = GlazedLists.eventList(getDescriptions(workingSet));
|
|
158 |
SortedList<RowWrapper> sortedList = new SortedList<>(descriptions, null);
|
|
159 | 159 |
|
160 | 160 |
/** |
161 | 161 |
* data provider |
162 | 162 |
*/ |
163 | 163 |
SpecimenColumnPropertyAccessor columnPropertyAccessor = new SpecimenColumnPropertyAccessor(this); |
164 |
IDataProvider bodyDataProvider = new ListDataProvider<SpecimenDescription>(sortedList, columnPropertyAccessor);
|
|
164 |
IDataProvider bodyDataProvider = new ListDataProvider<RowWrapper>(sortedList, columnPropertyAccessor);
|
|
165 | 165 |
|
166 | 166 |
/** |
167 | 167 |
* BODY layer |
... | ... | |
177 | 177 |
Feature feature = features.get(i); |
178 | 178 |
initLabels(columnLabelAccumulator, i, feature); |
179 | 179 |
} |
180 |
GlazedListsEventLayer<SpecimenDescription> eventLayer = new GlazedListsEventLayer<>(bodyDataLayer, sortedList);
|
|
180 |
GlazedListsEventLayer<RowWrapper> eventLayer = new GlazedListsEventLayer<>(bodyDataLayer, sortedList);
|
|
181 | 181 |
|
182 | 182 |
RowReorderLayer rowReorderLayer = new RowReorderLayer(eventLayer); |
183 | 183 |
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(rowReorderLayer); |
... | ... | |
366 | 366 |
|
367 | 367 |
} |
368 | 368 |
|
369 |
private List<SpecimenDescription> getDescriptions(WorkingSet workingSet) {
|
|
370 |
List<SpecimenDescription> descriptions = new ArrayList<>();
|
|
369 |
private List<RowWrapper> getDescriptions(WorkingSet workingSet) {
|
|
370 |
List<RowWrapper> rowWrappers = new ArrayList<>();
|
|
371 | 371 |
Set<DescriptionBase> wsDescriptions = workingSet.getDescriptions(); |
372 | 372 |
for (DescriptionBase descriptionBase : wsDescriptions) { |
373 | 373 |
if(descriptionBase instanceof SpecimenDescription){ |
374 |
descriptions.add((SpecimenDescription) descriptionBase);
|
|
374 |
rowWrappers.add(new RowWrapper((SpecimenDescription) descriptionBase));
|
|
375 | 375 |
} |
376 | 376 |
} |
377 |
return descriptions;
|
|
377 |
return rowWrappers;
|
|
378 | 378 |
} |
379 | 379 |
|
380 | 380 |
private String getProperty(Feature feature){ |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/RowWrapper.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.editor.workingSet.matrix; |
|
10 |
|
|
11 |
import java.util.Collection; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
14 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
15 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|
16 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
17 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
18 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
19 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
20 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
21 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
22 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
23 |
|
|
24 |
/** |
|
25 |
* @author pplitzner |
|
26 |
* @since Dec 14, 2017 |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class RowWrapper { |
|
30 |
|
|
31 |
private SpecimenDescription description; |
|
32 |
|
|
33 |
private Collection<TaxonBase<?>> associatedTaxa; |
|
34 |
private FieldUnit fieldUnit; |
|
35 |
private String identifier; |
|
36 |
private NamedArea country; |
|
37 |
|
|
38 |
public RowWrapper(SpecimenDescription description) { |
|
39 |
this.description = description; |
|
40 |
|
|
41 |
IOccurrenceService occurrenceService = CdmStore.getService(IOccurrenceService.class); |
|
42 |
SpecimenOrObservationBase<?> specimen = HibernateProxyHelper.deproxy(description.getDescribedSpecimenOrObservation(), SpecimenOrObservationBase.class); |
|
43 |
if(specimen!=null){ |
|
44 |
associatedTaxa = occurrenceService.listAssociatedTaxa(specimen, null, null, null, null); |
|
45 |
Collection<FieldUnit> fieldUnits = occurrenceService.getFieldUnits(specimen.getUuid()); |
|
46 |
if(fieldUnits.size()!=1){ |
|
47 |
MessagingUtils.error(RowWrapper.class, "More than one or no field unit found for specimen", null); |
|
48 |
} |
|
49 |
else{ |
|
50 |
fieldUnit = fieldUnits.iterator().next(); |
|
51 |
} |
|
52 |
if(specimen instanceof DerivedUnit){ |
|
53 |
identifier = occurrenceService.getMostSignificantIdentifier(HibernateProxyHelper.deproxy(specimen, DerivedUnit.class)); |
|
54 |
} |
|
55 |
if(fieldUnit!=null && fieldUnit.getGatheringEvent()!=null){ |
|
56 |
country = fieldUnit.getGatheringEvent().getCountry(); |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
public SpecimenDescription getSpecimenDescription() { |
|
62 |
return description; |
|
63 |
} |
|
64 |
|
|
65 |
public Collection<TaxonBase<?>> getAssociatedTaxa() { |
|
66 |
return associatedTaxa; |
|
67 |
} |
|
68 |
|
|
69 |
public FieldUnit getFieldUnit() { |
|
70 |
return fieldUnit; |
|
71 |
} |
|
72 |
|
|
73 |
public String getIdentifier() { |
|
74 |
return identifier; |
|
75 |
} |
|
76 |
|
|
77 |
public NamedArea getCountry() { |
|
78 |
return country; |
|
79 |
} |
|
80 |
|
|
81 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/SpecimenColumnPropertyAccessor.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor; |
17 | 17 |
|
18 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
19 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
20 | 18 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
21 | 19 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
22 | 20 |
import eu.etaxonomy.cdm.model.description.Feature; |
23 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|
24 | 21 |
import eu.etaxonomy.cdm.model.description.State; |
25 | 22 |
import eu.etaxonomy.cdm.model.description.StateData; |
26 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
27 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
28 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
29 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
30 | 23 |
|
31 | 24 |
/** |
32 | 25 |
* @author pplitzner |
33 | 26 |
* @since Nov 26, 2017 |
34 | 27 |
* |
35 | 28 |
*/ |
36 |
public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<SpecimenDescription>{
|
|
29 |
public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<RowWrapper>{
|
|
37 | 30 |
|
38 | 31 |
private CharacterMatrix matrix; |
39 | 32 |
|
... | ... | |
46 | 39 |
* {@inheritDoc} |
47 | 40 |
*/ |
48 | 41 |
@Override |
49 |
public Object getDataValue(SpecimenDescription rowObject, int columnIndex) { |
|
50 |
IOccurrenceService occurrenceService = CdmStore.getService(IOccurrenceService.class); |
|
51 |
SpecimenOrObservationBase<?> specimen = rowObject.getDescribedSpecimenOrObservation(); |
|
52 |
Collection<FieldUnit> fieldUnits = occurrenceService.getFieldUnits(specimen.getUuid()); |
|
42 |
public Object getDataValue(RowWrapper rowObject, int columnIndex) { |
|
53 | 43 |
switch (columnIndex) { |
54 | 44 |
case 0: |
55 |
return occurrenceService.listAssociatedTaxa(specimen, null, null, null, null);
|
|
45 |
return rowObject.getAssociatedTaxa();
|
|
56 | 46 |
case 1: |
57 |
if(fieldUnits.size()!=1){ |
|
58 |
return "More than one or no field unit found for specimen"; |
|
59 |
} |
|
60 |
return fieldUnits.iterator().next(); |
|
47 |
return rowObject.getFieldUnit(); |
|
61 | 48 |
case 2: |
62 |
if(specimen instanceof DerivedUnit){ |
|
63 |
return occurrenceService.getMostSignificantIdentifier(HibernateProxyHelper.deproxy(specimen, DerivedUnit.class)); |
|
64 |
} |
|
65 |
return null; |
|
49 |
return rowObject.getIdentifier(); |
|
66 | 50 |
case 3: |
67 |
if(fieldUnits.size()!=1){ |
|
68 |
return "More than one or no field unit found for specimen"; |
|
69 |
} |
|
70 |
FieldUnit fieldUnit = fieldUnits.iterator().next(); |
|
71 |
if(fieldUnit.getGatheringEvent()!=null){ |
|
72 |
return fieldUnit.getGatheringEvent().getCountry(); |
|
73 |
} |
|
74 |
return null; |
|
51 |
return rowObject.getCountry(); |
|
75 | 52 |
|
76 | 53 |
default: |
77 | 54 |
break; |
78 | 55 |
} |
79 | 56 |
Feature feature = matrix.getIndexToFeatureMap().get(columnIndex); |
80 |
Set<DescriptionElementBase> elements = rowObject.getElements(); |
|
57 |
Set<DescriptionElementBase> elements = rowObject.getSpecimenDescription().getElements();
|
|
81 | 58 |
for (DescriptionElementBase descriptionElementBase : elements) { |
82 | 59 |
if(descriptionElementBase.getFeature().equals(feature)){ |
83 | 60 |
return descriptionElementBase; |
... | ... | |
90 | 67 |
* {@inheritDoc} |
91 | 68 |
*/ |
92 | 69 |
@Override |
93 |
public void setDataValue(SpecimenDescription rowObject, int columnIndex, Object newValue) {
|
|
70 |
public void setDataValue(RowWrapper rowObject, int columnIndex, Object newValue) {
|
|
94 | 71 |
Feature feature = matrix.getIndexToFeatureMap().get(columnIndex); |
95 |
Set<DescriptionElementBase> elements = rowObject.getElements(); |
|
72 |
Set<DescriptionElementBase> elements = rowObject.getSpecimenDescription().getElements();
|
|
96 | 73 |
for (DescriptionElementBase descriptionElementBase : elements) { |
97 | 74 |
if(descriptionElementBase.getFeature().equals(feature)){ |
98 | 75 |
setDescriptionElement(descriptionElementBase, feature, newValue); |
Also available in: Unified diff
ref #7095 Wrap descriptions for performance optimization