package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
import java.util.Optional;
+import java.util.Set;
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
+import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
import eu.etaxonomy.cdm.model.description.CategoricalData;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.DescriptionType;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.QuantitativeData;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
/**
if(columnPosition==0){
configLabels.addLabel(CharacterMatrix.LABEL_TAXON_LITERATURE_DESCRIPTION_ICON);
}
+ // check for existing default values
+ if(columnPosition>=CharacterMatrix.LEADING_COLUMN_COUNT){
+ Feature feature = matrix.getFeatures().get(columnPosition-CharacterMatrix.LEADING_COLUMN_COUNT);
+ if(hasDefaultValue(feature, taxonRowWrapper)){
+ configLabels.addLabel(HAS_DEFAULT);
+ if(hasDefaultOverriddenValue(feature, taxonRowWrapper)){
+ configLabels.removeLabel(HAS_DEFAULT);
+ configLabels.addLabel(DEFAULT_OVERRIDDEN);
+ }
+ }
+ }
}
//check for supplemental data
if(!taxonRowWrapper.getDescription().getSources().isEmpty() && columnPosition==0){
}
}
- private boolean hasDefaultOverriddenValue(Feature feature, SpecimenRowWrapperDTO specimenRowWrapper) {
- DescriptionElementBase dataValueForFeature = specimenRowWrapper.getDataValueForFeature(feature);
+ private boolean hasDefaultOverriddenValue(Feature feature, RowWrapperDTO<?> rowWrapper) {
+ DescriptionElementBase dataValueForFeature = rowWrapper.getDataValueForFeature(feature);
if(dataValueForFeature!=null){
if(dataValueForFeature instanceof CategoricalData){
return !((CategoricalData) dataValueForFeature).getStatesOnly().isEmpty();
return false;
}
- private boolean hasDefaultValue(Feature feature, SpecimenRowWrapperDTO specimenRowWrapper) {
- TaxonRowWrapperDTO defaultDescription = specimenRowWrapper.getDefaultDescription();
+ private boolean hasDefaultValue(Feature feature, RowWrapperDTO<?> rowWrapperDTO) {
+ if(rowWrapperDTO instanceof SpecimenRowWrapperDTO){
+ SpecimenRowWrapperDTO specimenRowWrapper = (SpecimenRowWrapperDTO)rowWrapperDTO;
+ return hasDefaultValue(feature, specimenRowWrapper.getDefaultDescription().getDescription());
+ }
+ else if(rowWrapperDTO instanceof TaxonRowWrapperDTO){
+ TaxonRowWrapperDTO taxonRowWrapper = (TaxonRowWrapperDTO)rowWrapperDTO;
+ Set<TaxonDescription> descriptions = taxonRowWrapper.getDescription().getTaxon().getDescriptions();
+ for (TaxonDescription taxonDescription : descriptions) {
+ if(matrix.getDescriptiveDataSet().getDescriptions().contains(taxonDescription)
+ && taxonDescription.getTypes().contains(DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION)){
+ return hasDefaultValue(feature, taxonDescription);
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean hasDefaultValue(Feature feature, TaxonDescription defaultDescription) {
if(defaultDescription!=null){
- Optional<DescriptionElementBase> descriptionElement = defaultDescription.getDescription().getElements().stream()
+ Optional<DescriptionElementBase> descriptionElement = defaultDescription.getElements().stream()
.filter(element->element.getFeature().equals(feature))
.findAny();
if(descriptionElement.isPresent() && descriptionElement.get() instanceof CategoricalData){