简体   繁体   English

如何以编程方式从实体对象获取业务规则?

[英]How to get Business Rules from Entity Object programatically?

In my Fusion Web Application, I have defined several business rules in entity objects. 在我的Fusion Web应用程序中,我在实体对象中定义了一些业务规则。 Everything works fine. 一切正常。 The problem is that I can not get them programatically. 问题是我无法以编程方式获取它们。 I have searched through the EntityObjects Impl java class, but there is no method that should perform validation. 我已经搜索了EntityObjects Impl java类,但是没有应该执行验证的方法。 Does anyone know any way, how to get the business rules from an entity object? 有谁知道如何从实体对象获取业务规则? I need to get at least a list of those. 我至少需要得到这些清单。

Update: 更新:

EntityDefImpl eoDef = EntityDefImpl.findDefObject("package...MyEO");

            for (Object o : eoDef.getValidators()) {
                System.out.println("Rule: " + o);
            }

But even in this case, I do not get a list of business rules. 但是即使在这种情况下,我也没有得到业务规则列表。

Try the following instead of your implementation 尝试以下方法代替您的实现

EntityDefImpl eoDef = EntityDefImpl.findDefObject("package...MyEO");
AttributeDefImpl myAttribute=getAttributeDefImpl("MyAttribute"); //Get the first Attribute

for (Object o : myAttribute.getValidators()) {
            System.out.println("Rule: " + o);
 }

The one you did will get the Entity level validators only, this one will get you this specific attribute validators! 您所做的将只获得实体级别的验证器,这一将为您提供此特定的属性验证器!

Take a look at the EntityDefImpl class. 看一下EntityDefImpl类。 Since it applies to all EO instances it carries the validation. 由于它适用于所有EO实例,因此可以进行验证。 enter link description here 在此处输入链接说明

If you just want to call it, you can use the Validate function from ViewObjectImpl (Since you want to call it from the Web Application programmatically or your Application Module) 如果只想调用它,则可以使用ViewObjectImpl中的Validate函数(因为您想通过Web应用程序或应用程序模块来调用它)

If you want to add another Validation, then you should follow the first answer. 如果要添加另一个验证,则应遵循第一个答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM