本文整理汇总了Java中org.drools.builder.KnowledgeBuilderError类的典型用法代码示例。如果您正苦于以下问题:Java KnowledgeBuilderError类的具体用法?Java KnowledgeBuilderError怎么用?Java KnowledgeBuilderError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KnowledgeBuilderError类属于org.drools.builder包,在下文中一共展示了KnowledgeBuilderError类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readKnowledgeBase
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
public static KnowledgeBase readKnowledgeBase(List<RuleResource> resources) {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
for (RuleResource res: resources) {
try {
kbuilder.add(ResourceFactory.newClassPathResource(res.getRuleResourceFile()), res.getResType());
} catch (Exception ex) {
kbuilder.add(ResourceFactory.newFileResource(res.getRuleResourceFile()), res.getResType());
}
}
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
开发者ID:shuqin,项目名称:ALLIN,代码行数:21,代码来源:KnowledgeBaseHelper.java
示例2: readKnowledgeBase
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
/**
* A private method for rule parsing.
*
* @param path
* of the .drl file.
* @return KnowledgeBase.
* @throws Exception
* Exception.
*/
private static KnowledgeBase readKnowledgeBase(String path) throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
FileInputStream fis = new FileInputStream(path);
kbuilder.add(ResourceFactory.newInputStreamResource(fis), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error + " @line " + error.getLines());
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:DroolsEvaluation.java
示例3: addKnowledgePackages
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
private void addKnowledgePackages(KnowledgeBaseWrapper knowledgeBaseWrapper, DroolsRuleAddEvent droolsRuleAddEvent, String ruleName) {
String resourceType = droolsRuleAddEvent.getOriginalResourceType();
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(new PackageBuilderConfiguration(properties));
kbuilder.add(ResourceFactory.newByteArrayResource(droolsRuleAddEvent.getRuleBytes()), ResourceType.getResourceType(resourceType));
if(kbuilder.hasErrors()) {
for(KnowledgeBuilderError error : kbuilder.getErrors()) {
log.error(error.getMessage() + " on lines " + Arrays.toString(error.getLines()));
}
throw new IllegalArgumentException("Could not parse Rule: " + ruleName + " type: " + resourceType);
}
knowledgeBaseWrapper.getKnowledgeBase().addKnowledgePackages(kbuilder.getKnowledgePackages());
knowledgeBaseWrapper.setTotalRules(knowledgeBaseWrapper.getTotalRules() + 1);
}
开发者ID:Gigaspaces,项目名称:xap-drools-integration,代码行数:17,代码来源:DroolsRuleAddEventListener.java
示例4: getKnowledgeBuilder
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
private static KnowledgeBuilder getKnowledgeBuilder(String rulePackagePath,
String droolsEngineName) {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
changesetPath = "./";
createChangeSetInfo(rulePackagePath, droolsEngineName, true);
engineResource = ResourceFactory.newFileResource(changesetPath
+ droolsEngineName + ".xml");
kbuilder.add(engineResource, ResourceType.CHANGE_SET);
if (kbuilder.hasErrors()) {
startUpError = true;
Iterator<KnowledgeBuilderError> ite = kbuilder.getErrors()
.iterator();
while (ite.hasNext()) {
logger.error(ite.next().getMessage());
}
return null;
} else {
return kbuilder;
}
}
开发者ID:MusesProject,项目名称:MusesServer,代码行数:26,代码来源:TemporalDroolsEngineServiceImpl.java
示例5: getKnowledgeBuilder
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
private static KnowledgeBuilder getKnowledgeBuilder(String rulePackagePath,
String droolsEngineName) {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
changesetPath = "var/";
createChangeSetInfo(rulePackagePath, droolsEngineName, true);
engineResource = ResourceFactory.newFileResource(changesetPath
+ droolsEngineName + ".xml");
kbuilder.add(engineResource, ResourceType.CHANGE_SET);
if (kbuilder.hasErrors()) {
Iterator<KnowledgeBuilderError> ite = kbuilder.getErrors()
.iterator();
while (ite.hasNext()) {
log.error(ite.next().getMessage());
}
return null;
} else {
return kbuilder;
}
}
开发者ID:MusesProject,项目名称:MusesServer,代码行数:25,代码来源:DroolsEngineServiceImpl.java
示例6: initSession
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
@Produces
@Named("node1")
public GridNode initSession() {
log.info("Creating drools kbase");
GridNode node = new GridNodeImpl();
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("testRule.drl"), ResourceType.DRL);
if (kbuilder.hasErrors()) {
if (kbuilder.getErrors().size() > 0) {
for (KnowledgeBuilderError kerror : kbuilder.getErrors()) {
log.error(kerror.getMessage());
}
throw new RuntimeException(kbuilder.getErrors().toString());
}
}
node.set("ksession1", kbuilder.newKnowledgeBase().newStatelessKnowledgeSession());
return node;
}
开发者ID:gtudan,项目名称:camel-cdi-drools-test,代码行数:22,代码来源:DroolsComponentProducer.java
示例7: readKnowledgeBase
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
/**
*
* @return
* @throws Exception
*/
private static KnowledgeBase readKnowledgeBase(String path) throws Exception {
if(path != null) {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(path), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
} else { return null; }
}
开发者ID:xladde,项目名称:hsw,代码行数:22,代码来源:DroolsTools.java
示例8: readKnowledgeBase
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
开发者ID:liuyuping459,项目名称:FuzzyReasoningDemo,代码行数:16,代码来源:DroolsService.java
示例9: readKnowledgeBase
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Questions.drl"), ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("Knowledge.drl"), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
开发者ID:mescam,项目名称:carMechanic,代码行数:16,代码来源:DroolsTest.java
示例10: readKnowledgeBase
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
/**
* A private method for rule parsing.
* @param path of the .drl file.
* @return KnowledgeBase.
* @throws Exception Exception.
*/
private static KnowledgeBase readKnowledgeBase(String path) throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// Print out model by Holger
// try {
// LineNumberReader lnir = new LineNumberReader(new FileReader(new File(path)));
// String line;
// do {
// line = lnir.readLine();
// if (null != line) {
// System.out.println(line);
// }
// } while (null != line);
// lnir.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
FileInputStream fis = new FileInputStream(path);
kbuilder.add(ResourceFactory.newInputStreamResource(fis), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error + "@line " + error.getLines());
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:40,代码来源:DroolsEngine.java
示例11: createStatefulKnowledgeSession
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
/**
* Creates the stateful knowledge session.
*
* @return the stateful knowledge session
*/
private StatefulKnowledgeSession createStatefulKnowledgeSession() {
StatefulKnowledgeSession session = null;
try {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
String casRules = guvnorService.getVersionedRulesFromPackage();
kbuilder.add(
ResourceFactory.newByteArrayResource(casRules.getBytes()),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
LOGGER.error(error.toString());
}
}
KnowledgeBase knowledgeBase = KnowledgeBaseFactory
.newKnowledgeBase();
knowledgeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
session = knowledgeBase.newStatefulKnowledgeSession();
session.setGlobal("ruleExecutionContainer",
new RuleExecutionContainer());
} catch (Exception e) {
LOGGER.error(e.toString(), e);
}
return session;
}
开发者ID:tlin-fei,项目名称:ds4p,代码行数:37,代码来源:RuleExecutionServiceImpl.java
示例12: readKnowledgeBase
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
开发者ID:road-framework,项目名称:ROADDesigner,代码行数:15,代码来源:DroolsTest.java
示例13: check
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
private static void check(KnowledgeBuilder builder) {
if (builder.hasErrors()) {
for (KnowledgeBuilderError error : builder.getErrors())
System.out.println(error.toString());
System.exit(-1);
}
}
开发者ID:stefano-bragaglia,项目名称:Skimmer,代码行数:8,代码来源:Engine.java
示例14: init
import org.drools.builder.KnowledgeBuilderError; //导入依赖的package包/类
@PostConstruct
public void init() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource("waltz.drl", WaltzKb.class), ResourceType.DRL );
if (kbuilder.hasErrors()) {
for (KnowledgeBuilderError error : kbuilder.getErrors()) {
logger.error("DRL Error "+error);
}
}
Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( pkgs );
}
开发者ID:tarilabs,项目名称:waltzwsbenchmark,代码行数:14,代码来源:WaltzKb.java
注:本文中的org.drools.builder.KnowledgeBuilderError类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论