Search in sources :

Example 21 with QuantitativeData

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);
}
Also used : MeasurementUnit(eu.etaxonomy.cdm.model.description.MeasurementUnit) FormatKey(eu.etaxonomy.cdm.format.ICdmFormatter.FormatKey) QuantitativeData(eu.etaxonomy.cdm.model.description.QuantitativeData) Test(org.junit.Test)

Example 22 with QuantitativeData

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;
}
Also used : TermDto(eu.etaxonomy.cdm.persistence.dto.TermDto) FeatureDto(eu.etaxonomy.cdm.persistence.dto.FeatureDto) StatisticalMeasure(eu.etaxonomy.cdm.model.description.StatisticalMeasure) HashMap(java.util.HashMap) CategoricalData(eu.etaxonomy.cdm.model.description.CategoricalData) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) TaxonNodeDto(eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto) BigDecimal(java.math.BigDecimal) Map(java.util.Map) StateData(eu.etaxonomy.cdm.model.description.StateData) DescriptionElementBase(eu.etaxonomy.cdm.model.description.DescriptionElementBase) Collection(java.util.Collection) Character(eu.etaxonomy.cdm.model.description.Character) Set(java.util.Set) UUID(java.util.UUID) QuantitativeData(eu.etaxonomy.cdm.model.description.QuantitativeData) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) List(java.util.List) DescriptionBase(eu.etaxonomy.cdm.model.description.DescriptionBase) Feature(eu.etaxonomy.cdm.model.description.Feature) Comparator(java.util.Comparator) DefinedTermBase(eu.etaxonomy.cdm.model.term.DefinedTermBase) Collections(java.util.Collections) BigDecimal(java.math.BigDecimal)

Example 23 with QuantitativeData

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);
}
Also used : QuantitativeData(eu.etaxonomy.cdm.model.description.QuantitativeData) Feature(eu.etaxonomy.cdm.model.description.Feature) StatisticalMeasurementValue(eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue)

Example 24 with QuantitativeData

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);
}
Also used : QuantitativeData(eu.etaxonomy.cdm.model.description.QuantitativeData) Feature(eu.etaxonomy.cdm.model.description.Feature) StatisticalMeasurementValue(eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue)

Example 25 with QuantitativeData

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);
}
Also used : QuantitativeData(eu.etaxonomy.cdm.model.description.QuantitativeData) Feature(eu.etaxonomy.cdm.model.description.Feature) StatisticalMeasurementValue(eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue)

Aggregations

QuantitativeData (eu.etaxonomy.cdm.model.description.QuantitativeData)25 Feature (eu.etaxonomy.cdm.model.description.Feature)19 CategoricalData (eu.etaxonomy.cdm.model.description.CategoricalData)13 StatisticalMeasurementValue (eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue)12 BigDecimal (java.math.BigDecimal)12 ArrayList (java.util.ArrayList)10 DescriptionElementBase (eu.etaxonomy.cdm.model.description.DescriptionElementBase)9 MeasurementUnit (eu.etaxonomy.cdm.model.description.MeasurementUnit)9 TaxonDescription (eu.etaxonomy.cdm.model.description.TaxonDescription)9 TextData (eu.etaxonomy.cdm.model.description.TextData)9 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)8 HashSet (java.util.HashSet)8 Set (java.util.Set)7 DescriptiveDataSet (eu.etaxonomy.cdm.model.description.DescriptiveDataSet)6 SpecimenDescription (eu.etaxonomy.cdm.model.description.SpecimenDescription)6 State (eu.etaxonomy.cdm.model.description.State)6 StateData (eu.etaxonomy.cdm.model.description.StateData)6 StatisticalMeasure (eu.etaxonomy.cdm.model.description.StatisticalMeasure)6 TermDto (eu.etaxonomy.cdm.persistence.dto.TermDto)5 UUID (java.util.UUID)5