update.put(RuleField.DEFAULT_CHARACTERISTIC.field(), null);
update.put(RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), null);
Integer defaultSubCharacteristicId = rule.getDefaultSubCharacteristicId();
if (defaultSubCharacteristicId != null) {
CharacteristicDto subCharacteristic = db.debtCharacteristicDao().selectById(defaultSubCharacteristicId, session);
if (subCharacteristic != null) {
Integer characteristicId = subCharacteristic.getParentId();
if (characteristicId != null) {
CharacteristicDto characteristic = db.debtCharacteristicDao().selectById(characteristicId);
if (characteristic != null) {
update.put(RuleField.DEFAULT_CHARACTERISTIC.field(), characteristic.getKey());
update.put(RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), subCharacteristic.getKey());
}
}
}
}
Integer subCharacteristicId = rule.getSubCharacteristicId();
if (subCharacteristicId != null) {
if (subCharacteristicId.equals(-1)) {
update.put(RuleField.CHARACTERISTIC.field(), DebtCharacteristic.NONE);
update.put(RuleField.SUB_CHARACTERISTIC.field(), DebtCharacteristic.NONE);
} else {
CharacteristicDto subCharacteristic = db.debtCharacteristicDao().selectById(subCharacteristicId, session);
if (subCharacteristic != null) {
Integer characteristicId = subCharacteristic.getParentId();
if (characteristicId != null) {
CharacteristicDto characteristic = db.debtCharacteristicDao().selectById(characteristicId);
if (characteristic != null) {
update.put(RuleField.CHARACTERISTIC.field(), characteristic.getKey());
update.put(RuleField.SUB_CHARACTERISTIC.field(), subCharacteristic.getKey());
}
}
}
}