use of org.drools.core.base.SalienceInteger in project drools by kiegroup.
the class KiePackagesBuilder method setRuleAttributes.
private void setRuleAttributes(Rule rule, RuleImpl ruleImpl) {
Boolean noLoop = setAttribute(rule, Rule.Attribute.NO_LOOP, ruleImpl::setNoLoop);
Boolean lockOnActive = setAttribute(rule, Rule.Attribute.LOCK_ON_ACTIVE, ruleImpl::setLockOnActive);
setAttribute(rule, Rule.Attribute.AUTO_FOCUS, ruleImpl::setAutoFocus);
setAttribute(rule, Rule.Attribute.ENABLED, e -> ruleImpl.setEnabled(new EnabledBoolean(e)));
setAttribute(rule, Rule.Attribute.SALIENCE, s -> ruleImpl.setSalience(new SalienceInteger(s)));
String agendaGroup = setAttribute(rule, Rule.Attribute.AGENDA_GROUP, ruleImpl::setAgendaGroup);
setAttribute(rule, Rule.Attribute.RULEFLOW_GROUP, rfg -> {
ruleImpl.setRuleFlowGroup(rfg);
if (agendaGroup == null) {
ruleImpl.setAgendaGroup(rfg);
}
});
setAttribute(rule, Rule.Attribute.ACTIVATION_GROUP, ruleImpl::setActivationGroup);
setAttribute(rule, Rule.Attribute.DURATION, t -> ruleImpl.setTimer(parseTimer(t)));
setAttribute(rule, Rule.Attribute.TIMER, t -> ruleImpl.setTimer(parseTimer(t)));
setAttribute(rule, Rule.Attribute.CALENDARS, ruleImpl::setCalendars);
setAttribute(rule, Rule.Attribute.DATE_EFFECTIVE, ruleImpl::setDateEffective);
setAttribute(rule, Rule.Attribute.DATE_EXPIRES, ruleImpl::setDateExpires);
ruleImpl.setEager(ruleImpl.isEager() || noLoop != null || lockOnActive != null);
}
use of org.drools.core.base.SalienceInteger in project drools by kiegroup.
the class RuleTest method testGetSalienceValue.
@Test
public void testGetSalienceValue() {
final RuleImpl rule = new RuleImpl("myrule");
final int salienceValue = 100;
Salience salience = new SalienceInteger(salienceValue);
rule.setSalience(salience);
assertEquals(salienceValue, rule.getSalienceValue());
assertFalse(rule.isSalienceDynamic());
}
use of org.drools.core.base.SalienceInteger in project drools by kiegroup.
the class RuleBuilder method buildSalience.
private static void buildSalience(final RuleBuildContext context) {
String salienceText = context.getRuleDescr().getSalience();
if (salienceText != null && !salienceText.equals("")) {
try {
// First check if it is an Integer
Salience salience = new SalienceInteger(Integer.parseInt(salienceText));
context.getRule().setSalience(salience);
} catch (Exception e) {
// It wasn't an integer, so build as an expression
context.getDialect().getSalienceBuilder().build(context);
}
}
}
Aggregations