本文整理了Java中org.kie.api.runtime.rule.Match.getRule()
方法的一些代码示例,展示了Match.getRule()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Match.getRule()
方法的具体详情如下:
包路径:org.kie.api.runtime.rule.Match
类名称:Match
方法名:getRule
暂无
代码示例来源:origin: kiegroup/jbpm
public boolean accept(Match activation) {
return !"Cancel".equals(activation.getRule().getName());
}
}
代码示例来源:origin: kiegroup/jbpm
public void matchCreated(MatchCreatedEvent event) {
String ruleFlowGroup = ((RuleImpl) event.getMatch().getRule()).getRuleFlowGroup();
if ( "DROOLS_SYSTEM".equals( ruleFlowGroup ) ) {
String ruleName = event.getMatch().getRule().getName();
if ( ruleName.startsWith( "RuleFlowStateNode-" )) {
int index = ruleName.indexOf( '-',
String ruleName = event.getMatch().getRule().getName();
if ( ruleName.startsWith( "RuleFlow-Start-" )) {
String processId = ruleName.replace("RuleFlow-Start-", "");
代码示例来源:origin: kiegroup/jbpm
public void matchCreated(MatchCreatedEvent event) {
// check whether this activation is from the DROOLS_SYSTEM agenda group
String ruleFlowGroup = ((RuleImpl) event.getMatch().getRule()).getRuleFlowGroup();
if ("DROOLS_SYSTEM".equals(ruleFlowGroup)) {
// new activations of the rule associate with a milestone node
// trigger node instances of that milestone node
String ruleName = event.getMatch().getRule().getName();
String milestoneName = "RuleFlow-AdHocComplete-" + getProcessInstance().getProcessId() + "-" + getNodeId();
if (milestoneName.equals(ruleName) && checkProcessInstance((Activation) event.getMatch()) && checkDeclarationMatch(event.getMatch(), (String) getVariable("MatchVariable"))) {
synchronized(getProcessInstance()) {
DynamicNodeInstance.this.removeEventListeners();
DynamicNodeInstance.this.triggerCompleted(NodeImpl.CONNECTION_DEFAULT_TYPE);
}
}
}
}
代码示例来源:origin: kiegroup/jbpm
@Override
public void signalEvent(String type, Object event) {
if ("timerTriggered".equals(type)) {
TimerInstance timerInstance = (TimerInstance) event;
if (timerInstances != null && timerInstances.contains(timerInstance.getId())) {
triggerTimer(timerInstance);
} else if (timerInstance.getId() == slaTimerId) {
handleSLAViolation();
}
} else if (("slaViolation:" + getId()).equals(type)) {
handleSLAViolation();
} else if (type.equals(getActivationType())) {
if (event instanceof MatchCreatedEvent) {
String name = ((MatchCreatedEvent)event).getMatch().getRule().getName();
if (checkProcessInstance((Activation) ((MatchCreatedEvent)event).getMatch())) {
((MatchCreatedEvent)event).getKieRuntime().signalEvent(name, null);
}
}
}
}
代码示例来源:origin: kiegroup/jbpm
public void matchCreated(MatchCreatedEvent event) {
// check whether this activation is from the DROOLS_SYSTEM agenda group
String ruleFlowGroup = ((RuleImpl) event.getMatch().getRule()).getRuleFlowGroup();
if ("DROOLS_SYSTEM".equals(ruleFlowGroup)) {
// new activations of the rule associate with a milestone node
// trigger node instances of that milestone node
String ruleName = event.getMatch().getRule().getName();
String milestoneName = "RuleFlow-Milestone-" + getProcessInstance().getProcessId() + "-" + getMilestoneNode().getUniqueId();
if (milestoneName.equals(ruleName) && checkProcessInstance((Activation) event.getMatch()) && checkDeclarationMatch(event.getMatch(), getMilestoneNode().getMatchVariable())) {
synchronized(getProcessInstance()) {
removeEventListeners();
triggerCompleted();
}
}
}
}
代码示例来源:origin: kiegroup/jbpm
public void activationCreated(MatchCreatedEvent event) {
Connection selected = null;
for (Connection connection: getNode().getOutgoingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE)) {
Constraint constraint = getStateNode().getConstraint(connection);
if (constraint != null) {
String constraintName = getActivationEventType() + "-"
+ connection.getTo().getId() + "-" + connection.getToType();
if (constraintName.equals(event.getMatch().getRule().getName())
&& checkProcessInstance((Activation) event.getMatch())) {
selected = connection;
}
}
}
if (selected != null) {
removeEventListeners();
((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
triggerConnection(selected);
}
}
代码示例来源:origin: org.kie/kie-api
@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();
}
代码示例来源:origin: org.drools/drools-compiler
@Override
public void onDeleteMatch( Match match ) {
String rule = match.getRule().getName();
if (rule.equals( "Negative" )) {
list.remove("-" + match.getDeclarationValue( "$n" ));
}
}
} );
代码示例来源:origin: org.drools/drools-compiler
public void afterMatchFired( AfterMatchFiredEvent event ) {
fired.add( event.getMatch().getRule().getName() );
}
} );
代码示例来源:origin: org.drools/drools-compiler
public void matchCreated( MatchCreatedEvent event ) {
created.add( event.getMatch().getRule().getName() );
}
代码示例来源:origin: org.drools/drools-compiler
public void matchCancelled( MatchCancelledEvent event ) {
cancelled.add( event.getMatch().getRule().getName() );
}
代码示例来源:origin: org.drools/drools-compiler
public void afterMatchFired( AfterMatchFiredEvent event ) {
fired.add( event.getMatch().getRule().getName() );
}
} );
代码示例来源:origin: org.drools/drools-compiler
@Override
public void afterMatchFired(final AfterMatchFiredEvent event) {
final String name = event.getMatch().getRule().getName();
System.out.println(name + " fired!");
synchronized (ruleCalls) {
Integer calls = ruleCalls.get(name);
if (calls == null) {
calls = 1;
} else {
calls++;
}
ruleCalls.put(name, calls);
}
}
});
代码示例来源:origin: org.drools/drools-compiler
public void matchCancelled( MatchCancelledEvent event ) {
cancelled.add( event.getMatch().getRule().getName() );
}
代码示例来源:origin: org.drools/drools-compiler
public void matchCreated( MatchCreatedEvent event ) {
created.add( event.getMatch().getRule().getName() );
}
代码示例来源:origin: org.drools/drools-compiler
@Override
public void onDeleteMatch( Match match ) {
String rule = match.getRule().getName();
if (rule.equals( "Positive" )) {
list.remove("+" + match.getDeclarationValue( "$n" ));
} else if (rule.equals( "Negative" )) {
list.remove("-" + match.getDeclarationValue( "$n" ));
}
}
} );
代码示例来源:origin: org.drools/drools-compiler
@Override
public void onDeleteMatch( Match match ) {
String rule = match.getRule().getName();
if (rule.equals( "Positive" )) {
list.remove("+" + match.getDeclarationValue( "$n" ));
} else if (rule.equals( "Negative" )) {
list.remove("-" + match.getDeclarationValue( "$n" ));
}
}
} );
代码示例来源:origin: org.drools/drools-compiler
private void testAgendaFilter(final AgendaFilter agendaFilter, final String expectedMatchingRuleName) {
final String str = "package org.drools.compiler\n" +
"rule Aaa when then end\n" +
"rule Bbb when then end\n";
final KieBase kbase = loadKnowledgeBaseFromString(str);
final KieSession ksession = createKnowledgeSession(kbase);
final org.kie.api.event.rule.AgendaEventListener ael = mock(org.kie.api.event.rule.AgendaEventListener.class);
ksession.addEventListener(ael);
final int rules = ksession.fireAllRules(agendaFilter);
assertEquals(1, rules);
final ArgumentCaptor<org.kie.api.event.rule.AfterMatchFiredEvent> arg = ArgumentCaptor.forClass(org.kie.api.event.rule.AfterMatchFiredEvent.class);
verify(ael).afterMatchFired(arg.capture());
assertThat(arg.getValue().getMatch().getRule().getName(), is(expectedMatchingRuleName));
}
}
代码示例来源:origin: org.drools/drools-compiler
@Test
public void testMapNullConstraint() throws Exception {
final KieBase kbase = loadKnowledgeBase("test_mapNullConstraints.drl");
final KieSession ksession = createKnowledgeSession(kbase);
final org.kie.api.event.rule.AgendaEventListener ael = mock(org.kie.api.event.rule.AgendaEventListener.class);
ksession.addEventListener(ael);
new WorkingMemoryConsoleLogger((WorkingMemory) ksession);
final Map addresses = new HashMap();
addresses.put("home", new Address("home street"));
final Person bob = new Person("Bob");
bob.setNamedAddresses(addresses);
ksession.insert(bob);
ksession.fireAllRules();
final ArgumentCaptor<AfterMatchFiredEvent> arg = ArgumentCaptor.forClass(org.kie.api.event.rule.AfterMatchFiredEvent.class);
verify(ael, times(4)).afterMatchFired(arg.capture());
org.kie.api.event.rule.AfterMatchFiredEvent aaf = arg.getAllValues().get(0);
assertThat(aaf.getMatch().getRule().getName(), is("1. home != null"));
aaf = arg.getAllValues().get(1);
assertThat(aaf.getMatch().getRule().getName(), is("2. not home == null"));
aaf = arg.getAllValues().get(2);
assertThat(aaf.getMatch().getRule().getName(), is("7. work == null"));
aaf = arg.getAllValues().get(3);
assertThat(aaf.getMatch().getRule().getName(), is("8. not work != null"));
}
代码示例来源:origin: org.drools/drools-compiler
@Test(timeout=10000)
public void testIsAOperator() {
String source = "org/drools/compiler/factmodel/traits/testTraitIsA2.drl";
KieSession ksession = getSession( source );
TraitFactory.setMode( mode, ksession.getKieBase() );
AgendaEventListener ael = mock( AgendaEventListener.class );
ksession.addEventListener( ael );
Person student = new Person( "student", 18 );
ksession.insert( student );
ksession.fireAllRules();
ArgumentCaptor<AfterMatchFiredEvent> cap = ArgumentCaptor.forClass( AfterMatchFiredEvent.class );
verify( ael,
times( 3 ) ).afterMatchFired( cap.capture() );
List<AfterMatchFiredEvent> values = cap.getAllValues();
assertThat( values.get( 0 ).getMatch().getRule().getName(),
is( "create student" ) );
assertThat( values.get( 1 ).getMatch().getRule().getName(),
is( "print student" ) );
assertThat( values.get( 2 ).getMatch().getRule().getName(),
is( "print school" ) );
}
内容来源于网络,如有侵权,请联系作者删除!