以drools验证 [英] Validation in drools

查看:101
本文介绍了以drools验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的drools验证问题的第二部分。第一部分已经得到解答,我的代码中已经提出了解决方案。
第一部分

This is the second part of my drools validation question. First part has been already answered and proposed solutions has been implemented in my code. First Part

这是我的java类结构

This is my java class structure

public class Person {
 List<PersonAddress> personAddress;
 List<FinanceDetails> financeDetails;
}
public enum AddressStatus {
 CURRENT, PREVIOUS;
}
public enum AddressType {
 PHYSICAL, POSTAL;
}
public enum AddressUseType {
 HOME, OFFICE;
}
public class PersonAddress{    
  Address address;
  AddressType type
  AddressStatus status
  AddressUseType useType
  String ownerShipType
  Integer timeAtAddress;        
}
public class Address {
  String city;
  String country;
  String street;
}
public class FinanceDetails {
  String financeItemName;
  BigDecimal itemValue;
}

好的我的问题是,如果financeItemName,我需要验证FinanceDetails实例的itemValue是Land or Building,如果此用户的地址符合以下条件,

Ok my problem is, i need to validate itemValue of the FinanceDetails instance if financeItemName is "Land or Building", and if this user has an address which matches following criteria,

AddressStatus == CURRENT

AddressStatus == CURRENT

AddressType == PHYSICAL

AddressType == PHYSICAL

AddressUseType == HOME

AddressUseType == HOME

ownerShipType ==Own

ownerShipType == "Own"

Drools版本5.5.0.Final

Drools version 5.5.0.Final

Java 1.7

可以使用函数

需要一个示例流氓规则语法。谢谢

A sample drool rule syntax is needed. Thank you

推荐答案

在某些评论中添加了itemValue测试

rule "land-orbuilding..."
when
  Peson( $financeDetails: financeDetails, $personAddress: personAddress )
  FinanceDetails( financeItemName == "Land or Building", itemValue == null || itemValue == 0 ) from $financeDetails
  PersonAddress( status == AddressStatus.CURRENT,
                 type == AddressType.PHYSICAL,
                 useType == AddressUseType.HOME,
                 ownerShipType == "Own" ) from $personAddress
then
  //...
end

阅读部分文档怎么样?这非常像第一部分,只是一个微小的变化。

How about reading some of that documentation? This is very much like the "first part", and only a minor variation.

这篇关于以drools验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆