org.kie.api.definition.rule.Rule.getMetaData()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.kie.api.definition.rule.Rule.getMetaData方法的一些代码示例,展示了Rule.getMetaData的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rule.getMetaData方法的具体详情如下:
包路径:org.kie.api.definition.rule.Rule
类名称:Rule
方法名:getMetaData

Rule.getMetaData介绍

[英]Returns an immutable Map<String key, Object value> of all meta data attributes associated with this rule object.
[中]返回与此规则对象关联的所有元数据属性的不可变映射<String key,Object value>。

代码示例

代码示例来源:origin: org.drools/knowledge-api

public Map<String, Object> getMetaData() {
  return delegate.getMetaData();
}

代码示例来源:origin: deepu105/drools-demo

@Override
public void afterMatchFired(AfterMatchFiredEvent event) {
  Rule rule = event.getMatch().getRule();
  String ruleName = rule.getName();
  Map<String, Object> ruleMetaDataMap = rule.getMetaData();
  activationList.add(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());
}

代码示例来源:origin: gratiartis/qzr

@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());
}

代码示例来源:origin: stackoverflow.com

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

代码示例来源:origin: org.drools/drools-reteoo

@Test
public void testRuleMetaAttributes() throws Exception {
  String drl = "";
  drl += "package test\n";
  drl += "rule \"test meta attributes\"\n";
  drl += "    @id(1234 ) @author(  john_doe  ) @text(\"It's an escaped\\\" string\"  )\n";
  drl += "when\n";
  drl += "then\n";
  drl += "    // some comment\n";
  drl += "end\n";
  KnowledgeBase kbase = loadKnowledgeBaseFromString( drl );
  Rule rule = kbase.getRule( "test", "test meta attributes" );
  assertNotNull( rule );
  assertThat( (Integer) rule.getMetaData().get( "id" ),
        is( 1234 ) );
  assertThat( (String) rule.getMetaData().get( "author" ),
        is( "john_doe" ) );
  assertThat( (String) rule.getMetaData().get( "text" ),
        is( "It's an escaped\" string" ) );
}

代码示例来源:origin: org.drools/drools-pmml

public void checkGeneratedRules( String pack ) {
  for ( Rule r : getKbase().getKiePackage( pack ).getRules() ) {
    assertTrue( r.getMetaData().containsKey( "Generated" ) );
  }
}

代码示例来源:origin: org.drools/kie-pmml

public void checkGeneratedRules(String pack) {
  for (Rule r : getKbase().getKiePackage(pack).getRules()) {
    assertTrue(r.getMetaData().containsKey("Generated"));
  }
}

代码示例来源:origin: org.drools/drools-reteoo

rule.getMetaData().get( "author" ) );
Assert.assertEquals( "Hello World!",
           rule.getMetaData().get( "output" ) );
Assert.assertEquals( 20,
           ((Number)rule.getMetaData().get( "value" )).intValue() );
Assert.assertEquals( "Hello World!",
           rule.getMetaData().get( "alt" ) );

代码示例来源:origin: org.drools/drools-reteoo

@Test
public void testRuleAnnotation2() {
  String drl = "package org.drools.compiler.integrationtests\n" +
         "import " + Person.class.getCanonicalName() + "; \n" +
         "rule X\n" +
         "    @alt(\" \\\"<- these are supposed to be the only quotes ->\\\" \")\n" +
         "when\n"+
         "    Person()\n" +
         "then\n" +
         "end";
  KieBaseConfiguration conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
  conf.setOption( EventProcessingOption.STREAM );
  conf.setOption( MBeansOption.ENABLED );
  KnowledgeBase kbase = loadKnowledgeBase( "kb1",
                       drl,
                       conf );
  Rule rule = kbase.getRule( "org.drools.compiler.integrationtests",
                "X" );
  Assert.assertEquals( " \"<- these are supposed to be the only quotes ->\" ",
             rule.getMetaData().get( "alt" ) );
}

相关文章