Java Code Examples for org.kie.api.definition.rule.Rule#getName()

The following examples show how to use org.kie.api.definition.rule.Rule#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrackingAgendaEventListener.java    From qzr with Apache License 2.0 6 votes vote down vote up
@Override
public void afterMatchFired(AfterMatchFiredEvent event) {
    Rule rule = event.getMatch().getRule();

    String ruleName = rule.getName();
    Map<String, Object> ruleMetaDataMap = rule.getMetaData();

    addActivation(new Activation(ruleName));
    StringBuilder sb = new StringBuilder("Rule fired: " + ruleName);

    if (ruleMetaDataMap.size() > 0) {
        sb.append("\n  With [" + ruleMetaDataMap.size() + "] meta-data:");
        for (String key : ruleMetaDataMap.keySet()) {
            sb.append("\n    key=" + key + ", value="
                    + ruleMetaDataMap.get(key));
        }
    }

    log.debug(sb.toString());
}
 
Example 2
Source File: ConsequenceException.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public String getMessage() {
    StringBuilder sb = new StringBuilder( "Exception executing consequence for " );
    Rule rule = null;

    if( match != null && ( rule = match.getRule() ) != null ){
        String packageName = rule.getPackageName();
        String ruleName = rule.getName();
        sb.append( "rule \"" ).append( ruleName ).append( "\" in " ).append( packageName );
    } else {
        sb.append( "rule, name unknown" );
    }
    sb.append( ": " ).append( super.getMessage() );
    return sb.toString();
}
 
Example 3
Source File: TestingEventListener.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
private void record(Rule rule, Map<String, Integer> counts) {
    this.totalFires++;
    String name = rule.getName();
    if (!counts.containsKey(name)) {
        counts.put(name, 1);
    } else {
        counts.put(name, counts.get(name) + 1);
    }
}
 
Example 4
Source File: PublishingAgendaEventListener.java    From qzr with Apache License 2.0 5 votes vote down vote up
/**
 * Whenever a rule's LHS matches and causes the rule to activate, this
 * method will publish the name of that rule to the Stomp message broker,
 * using the {@link SimpMessagingTemplate}.
 */
@Override
public void afterMatchFired(AfterMatchFiredEvent event) {
    Rule rule = event.getMatch().getRule();

    System.out.println("Publishing: " + rule.getName());

    AgendaEventMessage msg = new AgendaEventMessage(rule.getName());

    this.template.convertAndSend("/queue/agendaevents/", msg);
}
 
Example 5
Source File: LoggingAgendaEventListener.java    From qzr with Apache License 2.0 5 votes vote down vote up
@Override
public void afterMatchFired(AfterMatchFiredEvent event) {
    Rule rule = event.getMatch().getRule();

    StringBuilder sb = new StringBuilder("Rule fired: " + rule.getName());

    log.debug(sb.toString());
}
 
Example 6
Source File: SerializedRule.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public SerializedRule(Rule rule) {
    this.name = rule.getName();
    this.packageName = rule.getPackageName();
    this.metaAttributes = new HashMap<String, Object>( rule.getMetaData() );
}
 
Example 7
Source File: SerializedRule.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public SerializedRule(Rule rule) {
    this.name = rule.getName();
    this.packageName = rule.getPackageName();
    this.metaAttributes = new HashMap<String, Object>( rule.getMetaData() );
}