use of eu.etaxonomy.cdm.model.description.QuantitativeData in project cdmlib by cybertaxonomy.
the class QuantitativeDataFormatterTest method testFormat.
@Test
public void testFormat() {
QuantitativeData quantData = QuantitativeData.NewInstance(Feature.CHROMOSOME_NUMBER());
FormatKey[] formatKey = null;
quantData.addStatisticalValue(min1);
quantData.addStatisticalValue(max1);
QuantitativeDataFormatter formatter = new QuantitativeDataFormatter(quantData, formatKey);
String text = formatter.format(quantData, formatKey);
Assert.assertEquals("0.1-1.3", text);
quantData.addStatisticalValue(n1);
MeasurementUnit unit = MeasurementUnit.METER();
quantData.setUnit(unit);
text = formatter.format(quantData, formatKey);
Assert.assertEquals("0.1-1.3 m [n=2]", text);
}
use of eu.etaxonomy.cdm.model.description.QuantitativeData in project cdmlib by cybertaxonomy.
the class RowWrapperDTO method generateQuantitativeDataString.
private String generateQuantitativeDataString(QuantitativeDataDto quantitativeData) {
String displayData;
displayData = "";
BigDecimal min = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.MIN().getUuid());
BigDecimal max = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.MAX().getUuid());
BigDecimal mean = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.AVERAGE().getUuid());
BigDecimal low = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.TYPICAL_LOWER_BOUNDARY().getUuid());
BigDecimal high = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.TYPICAL_UPPER_BOUNDARY().getUuid());
BigDecimal size = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.SAMPLE_SIZE().getUuid());
String typicalValues = "";
if (low != null || high != null) {
typicalValues += low != null ? low.toString() : "";
typicalValues += high != null ? "-" + high.toString() : "";
}
if (min != null || max != null) {
if (min != null && max != null && min.intValue() == max.intValue()) {
displayData += "(" + min.toString() + ")" + typicalValues;
} else {
if (StringUtils.isBlank(typicalValues)) {
displayData += "(" + (min != null ? min.toString() : "?") + "-" + (max != null ? max.toString() : "?") + ") ";
} else {
displayData += "(" + (min != null ? min.toString() : "?") + "-)" + typicalValues;
displayData += "(-" + (max != null ? max.toString() : "?") + ") ";
}
}
}
displayData += quantitativeData.getValues().stream().filter(value -> value.getType().getUuid().equals(StatisticalMeasure.EXACT_VALUE().getUuid())).map(exact -> exact.getValue().toString()).collect(Collectors.joining(", "));
if (quantitativeData.getMeasurementUnit() != null && StringUtils.isNotBlank(displayData)) {
displayData += " " + quantitativeData.getMeasurementIdInVocabulary();
}
return displayData;
}
use of eu.etaxonomy.cdm.model.description.QuantitativeData in project cdmlib by cybertaxonomy.
the class DescriptiveDataSetServiceTest method addQuantitativeData.
private void addQuantitativeData(DescriptionBase<?> desc, UUID uuidFeature, BigDecimal min, BigDecimal max) {
Feature feature = (Feature) termService.find(uuidFeature);
QuantitativeData qd = QuantitativeData.NewInstance(feature);
StatisticalMeasurementValue smv = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.MIN(), min);
qd.addStatisticalValue(smv);
smv = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.MAX(), max);
qd.addStatisticalValue(smv);
desc.addElement(qd);
}
use of eu.etaxonomy.cdm.model.description.QuantitativeData in project cdmlib by cybertaxonomy.
the class StructuredDescriptionAggregationTest method addQuantitativeData.
private void addQuantitativeData(DescriptionBase<?> desc, UUID uuidFeature, BigDecimal min, BigDecimal max) {
Feature feature = (Feature) termService.find(uuidFeature);
QuantitativeData qd = QuantitativeData.NewInstance(feature);
StatisticalMeasurementValue smv = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.MIN(), min);
qd.addStatisticalValue(smv);
smv = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.MAX(), max);
qd.addStatisticalValue(smv);
desc.addElement(qd);
}
use of eu.etaxonomy.cdm.model.description.QuantitativeData in project cdmlib by cybertaxonomy.
the class StructuredDescriptionAggregationTest method addQuantitativeData.
private void addQuantitativeData(DescriptionBase<?> desc, UUID uuidFeature, StatisticalMeasure type, BigDecimal value) {
Feature feature = (Feature) termService.find(uuidFeature);
QuantitativeData qd = QuantitativeData.NewInstance(feature);
StatisticalMeasurementValue smv = StatisticalMeasurementValue.NewInstance(type, value);
qd.addStatisticalValue(smv);
Assert.assertNotNull(MeasurementUnit.METER());
qd.setUnit(MeasurementUnit.METER());
desc.addElement(qd);
}
Aggregations