use of org.jaffa.rules.rulemeta.IRuleHelper in project jaffa-framework by jaffa-projects.
the class CxfFunctionGuardInterceptor method getPropertyRuleMap.
/**
* Returns a Map containing a List of RuleMetaData instances per propertyName for the className+ruleName combination.
* The class-level RuleMetaData instances defined for the className+ruleName combination will be added to the Map with propertyName null.
* The className is obtained from the targetClass.
*
* @param targetClassName The target Class.
* @param ruleName the rule to search for.
* @return A Map containing a List of RuleMetaData instances per propertyName for the className+ruleName combination.
* @throws ApplicationExceptions if any application exception occurs.
* @throws FrameworkException if any internal error occurs.
*/
private Map<String, List<RuleMetaData>> getPropertyRuleMap(String targetClassName, String ruleName) throws ApplicationExceptions, FrameworkException {
if (targetClassName == null) {
return null;
}
Map<String, List<RuleMetaData>> map = MetaDataRepository.instance().getPropertyRuleMap(targetClassName, ruleName);
if (map == null) {
return null;
}
IRuleHelper ruleHelper = RuleHelperFactory.instance(ruleName);
Map<String, List<RuleMetaData>> newMap = null;
for (Map.Entry<String, List<RuleMetaData>> me : map.entrySet()) {
List<RuleMetaData> rules = ruleHelper.getApplicableRules(targetClassName, null, me.getValue(), true);
if (rules != null && rules.size() > 0) {
if (newMap == null) {
newMap = new LinkedHashMap<>();
}
newMap.put(me.getKey(), rules);
}
}
return newMap;
}
use of org.jaffa.rules.rulemeta.IRuleHelper 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;
}
use of org.jaffa.rules.rulemeta.IRuleHelper in project jaffa-framework by jaffa-projects.
the class MetaDataIntrospector method findPropertyRulesMap.
/**
* Returns a Map of propertyName and applicable rules for the className/ruleName combination.
*/
private Map<String, List<RuleMetaData>> findPropertyRulesMap(String className, Object obj, String ruleName) {
try {
Map<String, List<RuleMetaData>> ruleMap = MetaDataRepository.instance().getPropertyRuleMap(className, ruleName);
if (ruleMap != null) {
Map<String, List<RuleMetaData>> output = new LinkedHashMap<String, List<RuleMetaData>>();
IRuleHelper ruleHelper = RuleHelperFactory.instance(ruleName);
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);
}
return output;
}
} catch (Exception e) {
// do nothing
if (log.isDebugEnabled())
log.debug("Error in finding the applicable rules of type " + ruleName, e);
}
return null;
}
use of org.jaffa.rules.rulemeta.IRuleHelper in project jaffa-framework by jaffa-projects.
the class RuleActor method getPropertyRuleMap.
/**
* Returns a Map containing a List of RuleMetaData instances per propertyName for the className+ruleName combination.
* The class-level RuleMetaData instances defined for the className+ruleName combination will be added to the Map with propertyName null.
* The className is obtained from the targetClass.
*
* @param targetClassName The target Class.
* @param ruleName the rule to search for.
* @return a Map containing a List of RuleMetaData instances per propertyName for the className+ruleName combination.
* @throws ApplicationExceptions if any application exception occurs.
* @throws FrameworkException if any internal error occurs.
*/
protected Map<String, List<RuleMetaData>> getPropertyRuleMap(String targetClassName, String ruleName) throws ApplicationExceptions, FrameworkException {
if (targetClassName != null) {
Map<String, List<RuleMetaData>> map = MetaDataRepository.instance().getPropertyRuleMap(targetClassName, ruleName);
if (map != null) {
IRuleHelper ruleHelper = RuleHelperFactory.instance(ruleName);
Map<String, List<RuleMetaData>> newMap = null;
for (Map.Entry<String, List<RuleMetaData>> me : map.entrySet()) {
List<RuleMetaData> rules = ruleHelper.getApplicableRules(targetClassName, me.getValue(), true);
if (rules != null && rules.size() > 0) {
if (newMap == null) {
newMap = new LinkedHashMap<>();
}
newMap.put(me.getKey(), rules);
}
}
map = newMap;
}
return map;
} else {
return null;
}
}
use of org.jaffa.rules.rulemeta.IRuleHelper in project jaffa-framework by jaffa-projects.
the class RuleValidatorFactory method getPropertyRuleMap.
/**
* Returns a Map containing a List of RuleMetaData instances per propertyName for the className+ruleName combination.
* The class-level RuleMetaData instances defined for the className+ruleName combination will be added to the Map with propertyName null.
* The className is obtained from the targetClass.
*
* @param targetClassName The target Class.
* @param ruleName the rule to search for.
* @return a Map containing a List of RuleMetaData instances per propertyName for the className+ruleName combination.
* @throws org.jaffa.exceptions.ApplicationExceptions if any application exception occurs.
* @throws org.jaffa.exceptions.FrameworkException if any internal error occurs.
*/
protected Map<String, List<RuleMetaData>> getPropertyRuleMap(String targetClassName, String ruleName) throws ApplicationExceptions, FrameworkException {
if (targetClassName != null) {
Map<String, List<RuleMetaData>> map = MetaDataRepository.instance().getPropertyRuleMap(targetClassName, ruleName);
if (map != null) {
IRuleHelper ruleHelper = RuleHelperFactory.instance(ruleName);
Map<String, List<RuleMetaData>> newMap = null;
for (Map.Entry<String, List<RuleMetaData>> me : map.entrySet()) {
List<RuleMetaData> rules = ruleHelper.getApplicableRules(targetClassName, me.getValue(), true);
if (rules != null && rules.size() > 0) {
if (newMap == null)
newMap = new LinkedHashMap<>();
newMap.put(me.getKey(), rules);
}
}
map = newMap;
}
return map;
} else {
return null;
}
}
Aggregations