Revision f77963a7
Added by Patrick Plitzner over 6 years ago
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