Search in sources :

Example 1 with AuditRuleHelper

use of org.jaffa.rules.rulemeta.AuditRuleHelper in project jaffa-framework by jaffa-projects.

the class MetaDataAuditIntrospector method findPropertyRuleMap.

/**
 * Returns a Map of propertyName and first applicable rule for the className/ruleName combination.
 */
private Map<String, RuleMetaData> findPropertyRuleMap(String className, Object obj, String ruleName) {
    try {
        Map<String, List<RuleMetaData>> ruleMap = MetaDataRepository.instance().getPropertyRuleMap(className, ruleName);
        if (ruleMap != null) {
            Map<String, RuleMetaData> output = new LinkedHashMap<String, RuleMetaData>();
            IRuleHelper ruleHelper = new AuditRuleHelper();
            for (Map.Entry<String, List<RuleMetaData>> me : ruleMap.entrySet()) {
                List<RuleMetaData> applicableRules = ruleHelper.getApplicableRules(className, obj, me.getValue(), false);
                if (applicableRules != null && applicableRules.size() > 0)
                    output.put(me.getKey(), applicableRules.get(0));
            }
            return output;
        }
    } catch (Exception e) {
        // do nothing
        if (log.isDebugEnabled())
            log.debug("Error in finding the applicable rules of type " + ruleName, e);
    }
    return null;
}
Also used : IRuleHelper(org.jaffa.rules.rulemeta.IRuleHelper) List(java.util.List) AuditRuleHelper(org.jaffa.rules.rulemeta.AuditRuleHelper) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 AuditRuleHelper (org.jaffa.rules.rulemeta.AuditRuleHelper)1 IRuleHelper (org.jaffa.rules.rulemeta.IRuleHelper)1