return measure.getValue() != null || measure.getData() != null
|| isNotEmpty;
}
static MeasureModel model(Measure measure, RuleFinder ruleFinder) {
MeasureModel model = new MeasureModel();
// we assume that the index has updated the metric
model.setMetricId(measure.getMetric().getId());
model.setDescription(measure.getDescription());
model.setData(measure.getData());
model.setAlertStatus(measure.getAlertStatus());
model.setAlertText(measure.getAlertText());
model.setTendency(measure.getTendency());
model.setVariationValue1(measure.getVariation1());
model.setVariationValue2(measure.getVariation2());
model.setVariationValue3(measure.getVariation3());
model.setVariationValue4(measure.getVariation4());
model.setVariationValue5(measure.getVariation5());
model.setUrl(measure.getUrl());
Characteristic characteristic = measure.getCharacteristic();
if (characteristic != null) {
model.setCharacteristicId(characteristic.id());
}
model.setPersonId(measure.getPersonId());
model.setValue(measure.getValue());
if (measure instanceof RuleMeasure) {
RuleMeasure ruleMeasure = (RuleMeasure) measure;
model.setRulePriority(ruleMeasure.getSeverity());
RuleKey ruleKey = ruleMeasure.ruleKey();
if (ruleKey != null) {
Rule ruleWithId = ruleFinder.findByKey(ruleKey);
if (ruleWithId == null) {
throw new IllegalStateException("Can not save a measure with unknown rule " + ruleMeasure);
}
model.setRuleId(ruleWithId.getId());
}
}
return model;
}