.setStatus(RuleStatus.valueOf(ruleDto.getStatus()));
// TODO should we set metadata ?
- if (ruleDto.hasCharacteristic()) {
+ if (hasCharacteristic(ruleDto)) {
newRule.setDebtCharacteristic(effectiveCharacteristic(ruleDto, ruleKey, debtModel).key());
newRule.setDebtRemediationFunction(effectiveFunction(ruleDto, ruleKey, durations));
}
offset != null ? durations.decode(offset) : null);
}
+ /**
+ * Return true is the characteristic has not been overridden and a default characteristic is existing or
+ * if the characteristic has been overridden but is not disabled
+ */
+ private boolean hasCharacteristic(RuleDto ruleDto){
+ Integer subCharacteristicId = ruleDto.getSubCharacteristicId();
+ return (subCharacteristicId == null && ruleDto.getDefaultSubCharacteristicId() != null) ||
+ (subCharacteristicId != null && !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(subCharacteristicId));
+ }
+
}
return this;
}
- public boolean hasCharacteristic(){
- return (subCharacteristicId != null && !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(subCharacteristicId)) || (subCharacteristicId == null && defaultSubCharacteristicId != null);
- }
-
@Override
public boolean equals(Object obj) {
if (!(obj instanceof RuleDto)) {