}
return result;
}
public void buildAttributes(final RuleBuildContext context) {
final Rule rule = context.getRule();
final RuleDescr ruleDescr = context.getRuleDescr();
boolean enforceEager = false;
for ( final AttributeDescr attributeDescr : ruleDescr.getAttributes().values() ) {
final String name = attributeDescr.getName();
if ( name.equals( "no-loop" ) ) {
rule.setNoLoop( getBooleanValue( attributeDescr,
true ) );
enforceEager = true;
} else if ( name.equals( "auto-focus" ) ) {
rule.setAutoFocus( getBooleanValue( attributeDescr,
true ) );
} else if ( name.equals( "agenda-group" ) ) {
if ( StringUtils.isEmpty(rule.getRuleFlowGroup())) {
rule.setAgendaGroup( attributeDescr.getValue() ); // don't override if RFG has already set this
}
} else if ( name.equals( "activation-group" ) ) {
rule.setActivationGroup( attributeDescr.getValue() );
} else if ( name.equals( "ruleflow-group" ) ) {
rule.setRuleFlowGroup( attributeDescr.getValue() );
rule.setAgendaGroup( attributeDescr.getValue() ); // assign AG to the same name as AG, as they are aliased to AGs anyway
} else if ( name.equals( "lock-on-active" ) ) {
boolean lockOnActive = getBooleanValue( attributeDescr, true );
rule.setLockOnActive( lockOnActive );
enforceEager |= lockOnActive;
} else if ( name.equals( DroolsSoftKeywords.DURATION ) || name.equals( DroolsSoftKeywords.TIMER ) ) {
String duration = attributeDescr.getValue();
buildTimer( rule, duration, context);
} else if ( name.equals( "calendars" ) ) {
buildCalendars( rule, attributeDescr.getValue(), context );
} else if ( name.equals( "date-effective" ) ) {
try {
Date date = DateUtils.parseDate( attributeDescr.getValue(),
context.getPackageBuilder().getDateFormats() );
final Calendar cal = Calendar.getInstance();
cal.setTime( date );
rule.setDateEffective( cal );
} catch (Exception e) {
DroolsError err = new RuleBuildError( rule, context.getParentDescr(), null,
"Wrong date-effective value: " + e.getMessage() );
context.addError( err );
}
} else if ( name.equals( "date-expires" ) ) {
try {
Date date = DateUtils.parseDate( attributeDescr.getValue(),
context.getPackageBuilder().getDateFormats() );
final Calendar cal = Calendar.getInstance();
cal.setTime( date );
rule.setDateExpires( cal );
} catch (Exception e) {
DroolsError err = new RuleBuildError( rule, context.getParentDescr(), null,
"Wrong date-expires value: " + e.getMessage() );
context.addError( err );
}
}
}
buildSalience( context );
buildEnabled( context );
AnnotationDescr ann = ruleDescr.getAnnotation( "activationListener" );
if ( ann != null && !StringUtils.isEmpty( ann.getSingleValue() ) ) {
rule.setActivationListener( MVELSafeHelper.getEvaluator().evalToString( ann.getSingleValue() ) );
}
ann = ruleDescr.getAnnotation( "Eager" );
if ( enforceEager || ( ann != null && trueOrDefault( ann.getSingleValue() ) ) ) {
rule.setEager( true );
}
ann = ruleDescr.getAnnotation( "Direct" );
if ( ann != null && trueOrDefault( ann.getSingleValue() ) ) {
rule.setActivationListener( "direct" );
}
// buildDuration( context );
}