*/
package eu.etaxonomy.taxeditor.editor.workingSet.matrix;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import eu.etaxonomy.cdm.model.description.CategoricalData;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.QuantitativeData;
-import eu.etaxonomy.taxeditor.model.DescriptionHelper;
+import eu.etaxonomy.cdm.model.description.State;
/**
* @author pplitzner
}
}
}
- String summaryString = "";
- if(minTotal!=null){
- summaryString += "from "+minTotal;
- }
- if(maxTotal!=null){
- summaryString += " up to "+maxTotal;
- }
+ String summaryString = (minTotal==null?"?":minTotal.toString())
+ +" - "
+ +(maxTotal==null?"?":maxTotal.toString());
return summaryString;
}
}
private class CategoricalSummaryProvider implements ISummaryProvider {
@Override
public Object summarize(int columnIndex) {
- String summaryString = "";
- String separator = ", ";
int rowCount = AggregationConfiguration.this.dataProvider.getRowCount();
+ Set<State> states = new HashSet<>();
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
Object dataValue = AggregationConfiguration.this.dataProvider.getDataValue(columnIndex,
rowIndex);
if(dataValue instanceof CategoricalData){
CategoricalData categoricalData = (CategoricalData)dataValue;
- summaryString += DescriptionHelper.getLabel(categoricalData)+separator;
+ states.addAll(categoricalData.getStatesOnly());
}
}
- if(summaryString.length()>separator.length()){
- summaryString = summaryString.substring(0, summaryString.length()-separator.length());
- }
- return summaryString;
+ return StringUtils.join(states, ", ");
}
}
-
}
*/
package eu.etaxonomy.taxeditor.editor.workingSet.matrix;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
import eu.etaxonomy.cdm.model.description.CategoricalData;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.QuantitativeData;
public class DescriptionElementCompareWrapper {
private DescriptionElementBase element;
+ private Set<UUID> stateUuids = new HashSet<>();
+ private Float min = null;
+ private Float max = null;
public DescriptionElementCompareWrapper(DescriptionElementBase element) {
this.element = element;
+ if(element.isInstanceOf(CategoricalData.class)){
+ CategoricalData elementData = (CategoricalData)element;
+ elementData.getStatesOnly().forEach(state->stateUuids.add(state.getUuid()));
+ }
+ else if(element.isInstanceOf(QuantitativeData.class)){
+ QuantitativeData elementData = (QuantitativeData)element;
+ min = elementData.getMin();
+ max = elementData.getMax();
+ }
}
public DescriptionElementBase unwrap() {
return element;
}
- public boolean equals(DescriptionElementCompareWrapper other) {
- DescriptionElementBase otherElement = other.unwrap();
- //TODO: Implement more elaborate equals() method
- if(element.isInstanceOf(CategoricalData.class) && otherElement instanceof CategoricalData){
- boolean equal = true;
- CategoricalData otherData = (CategoricalData)otherElement;
- CategoricalData elementData = (CategoricalData)element;
- equal &= elementData.getStatesOnly().equals(otherData.getStatesOnly());
- return equal;
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((max == null) ? 0 : max.hashCode());
+ result = prime * result + ((min == null) ? 0 : min.hashCode());
+ result = prime * result + ((stateUuids == null) ? 0 : stateUuids.hashCode());
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
}
- if(element.isInstanceOf(QuantitativeData.class) && otherElement instanceof QuantitativeData){
- boolean equal = true;
- QuantitativeData otherData = (QuantitativeData)otherElement;
- QuantitativeData elementData = (QuantitativeData)element;
- if(elementData.getMin()!=null && otherData.getMin()==null){
- return false;
- }
- if(elementData.getMin()==null && otherData.getMin()!=null){
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ DescriptionElementCompareWrapper other = (DescriptionElementCompareWrapper) obj;
+ if (max == null) {
+ if (other.max != null) {
return false;
}
- if(elementData.getMax()==null && otherData.getMax()!=null){
+ } else if (!max.equals(other.max)) {
+ return false;
+ }
+ if (min == null) {
+ if (other.min != null) {
return false;
}
- if(elementData.getMax()!=null && otherData.getMax()==null){
+ } else if (!min.equals(other.min)) {
+ return false;
+ }
+ if (stateUuids == null) {
+ if (other.stateUuids != null) {
return false;
}
- if(elementData.getMin()!=null && otherData.getMin()!=null){
- equal &= elementData.getMin().equals(otherData.getMin());
- }
- if(elementData.getMax()!=null && otherData.getMax()!=null){
- equal &= elementData.getMax().equals(otherData.getMax());
- }
- return equal;
+ } else if (!stateUuids.equals(other.stateUuids)) {
+ return false;
}
- return false;
+ return true;
}
}