public static final IndexField DEBT_FUNCTION_TYPE = add(IndexField.Type.STRING, "debtRemFnType");
public static final IndexField DEBT_FUNCTION_COEFFICIENT = add(IndexField.Type.STRING, "debtRemFnCoefficient");
public static final IndexField DEBT_FUNCTION_OFFSET = add(IndexField.Type.STRING, "debtRemFnOffset");
- public static final IndexField SUB_CHARACTERISTIC = add(IndexField.Type.STRING, "debtSubChar");
+ public static final IndexField DEFAULT_CHARACTERISTIC = add(IndexField.Type.STRING, "_debtChar");
+ public static final IndexField DEFAULT_SUB_CHARACTERISTIC = add(IndexField.Type.STRING, "_debtSubChar");
public static final IndexField CHARACTERISTIC = add(IndexField.Type.STRING, "debtChar");
+ public static final IndexField SUB_CHARACTERISTIC = add(IndexField.Type.STRING, "debtSubChar");
public static final IndexField NOTE = add(IndexField.Type.TEXT, "markdownNote");
public static final IndexField NOTE_LOGIN = add(IndexField.Type.STRING, "noteLogin");
public static final IndexField NOTE_CREATED_AT = add(IndexField.Type.DATE, "noteCreatedAt");
//TODO Legacy ID in DTO should be Key
CharacteristicDto characteristic = null;
+ CharacteristicDto defaultCharacteristic = null;
if (rule.getDefaultSubCharacteristicId() != null) {
characteristic = db.debtCharacteristicDao().selectById(rule.getDefaultSubCharacteristicId(), session);
+ defaultCharacteristic = characteristic;
+ update.put(RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), defaultCharacteristic.getKey());
}
if (rule.getSubCharacteristicId() != null) {
characteristic = db.debtCharacteristicDao().selectById(rule.getSubCharacteristicId(), session);
if (characteristic != null && characteristic.getId() != -1) {
update.put(RuleField.SUB_CHARACTERISTIC.field(), characteristic.getKey());
if (characteristic.getParentId() != null) {
- update.put(RuleField.CHARACTERISTIC.field(),
- db.debtCharacteristicDao().selectById(characteristic.getParentId(), session).getKey());
+ CharacteristicDto parentCharacteristic =
+ db.debtCharacteristicDao().selectById(characteristic.getParentId(), session);
+ update.put(RuleField.CHARACTERISTIC.field(), parentCharacteristic.getKey());
+ if (characteristic.getId() == defaultCharacteristic.getId()) {
+ update.put(RuleField.DEFAULT_CHARACTERISTIC.field(), parentCharacteristic.getKey());
+ } else {
+ update.put(RuleField.DEFAULT_CHARACTERISTIC.field(),
+ db.debtCharacteristicDao().selectById(defaultCharacteristic.getParentId(), session)
+ .getKey());
+ }
}
} else {
update.put(RuleField.CHARACTERISTIC.field(), null);
addIndexStringField("templateKey", RuleNormalizer.RuleField.TEMPLATE_KEY.field());
addIndexArrayField("tags", RuleNormalizer.RuleField.TAGS.field());
addIndexArrayField("sysTags", RuleNormalizer.RuleField.SYSTEM_TAGS.field());
+ addIndexStringField("defaultDebtChar", RuleNormalizer.RuleField.DEFAULT_CHARACTERISTIC.field());
+ addIndexStringField("defaultDebtSubChar", RuleNormalizer.RuleField.DEFAULT_SUB_CHARACTERISTIC.field());
addField("debtChar", new IndexStringField("debtChar", RuleNormalizer.RuleField.CHARACTERISTIC.field()));
addField("debtChar", new IndexStringField("debtSubChar", RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field()));
addField("debtRemFn", new IndexStringField("debtRemFnType", RuleNormalizer.RuleField.DEBT_FUNCTION_TYPE.field()));
ruleDto.setSubCharacteristicId(char21.getId());
dao.update(dbSession, ruleDto);
-
dbSession.commit();
- // 4. Get non-default chars from Rule
rule = index.getByKey(ruleKey);
+
+ // 4. Get non-default chars from Rule
assertThat(rule.debtCharacteristicKey()).isEqualTo(char2.getKey());
assertThat(rule.debtSubCharacteristicKey()).isEqualTo(char21.getKey());
+
+ // 5 Assert still get the default one
+ assertThat(rule.debtOverloaded()).isTrue();
+ assertThat(rule.defaultDebtCharacteristicKey()).isEqualTo(char1.getKey());
+ assertThat(rule.defaultDebtSubCharacteristicKey()).isEqualTo(char11.getKey());
+
}