当前位置: 首页>>代码示例>>Java>>正文


Java KnowledgeBuilder.hasErrors方法代码示例

本文整理汇总了Java中org.drools.builder.KnowledgeBuilder.hasErrors方法的典型用法代码示例。如果您正苦于以下问题:Java KnowledgeBuilder.hasErrors方法的具体用法?Java KnowledgeBuilder.hasErrors怎么用?Java KnowledgeBuilder.hasErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.drools.builder.KnowledgeBuilder的用法示例。


在下文中一共展示了KnowledgeBuilder.hasErrors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addKnowledgePackages

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的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

示例2: getKnowlegeBase

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
private static KnowledgeBase getKnowlegeBase(List<EntityRuleDO> rules) {
	if (rules == null || rules.size() == 0) {
		return null;
	}

	StringBuilder sb = new StringBuilder();

	for (EntityRuleDO entityRuleDO : rules) {
		sb.append(entityRuleDO.getRule()).append("\n");
	}

	KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
	config.setOption(EvaluatorOption.get("startsWith", new StartsWithEvaluatorDefinition()));
	config.setOption(EvaluatorOption.get("endsWith", new EndsWithEvaluatorDefinition()));

	KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
	kbuilder.add(ResourceFactory.newByteArrayResource(sb.toString().getBytes()), ResourceType.DRL);

	if (kbuilder.hasErrors()) {
		throw new ServiceException("Problem building cross field validation rules: " + kbuilder.getErrors());
	}

	KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
	kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
	return kbase;
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:27,代码来源:RuleServiceImpl.java

示例3: beforeClass

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
	KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
	config.setOption(EvaluatorOption.get("endsWith", new EndsWithEvaluatorDefinition()));

	KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
	kbuilder.add(ResourceFactory.newClassPathResource("net/techreadiness/rules/ends-with.drl"), ResourceType.DRL);

	if (kbuilder.hasErrors()) {
		throw new ServiceException("Problem building cross field validation rules: " + kbuilder.getErrors());
	}

	knowlegeBase = KnowledgeBaseFactory.newKnowledgeBase();
	knowlegeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());

}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:17,代码来源:TestEndsWithOperator.java

示例4: beforeClass

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
	KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
	config.setOption(EvaluatorOption.get("startsWith", new StartsWithEvaluatorDefinition()));

	KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
	kbuilder.add(ResourceFactory.newClassPathResource("net/techreadiness/rules/starts-with-map-reference.drl"),
			ResourceType.DRL);

	if (kbuilder.hasErrors()) {
		throw new ServiceException("Problem building cross field validation rules.");
	}

	knowlegeBase = KnowledgeBaseFactory.newKnowledgeBase();
	knowlegeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:17,代码来源:TestStartsWithMapReferenceOperator.java

示例5: beforeClass

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
	KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
	config.setOption(EvaluatorOption.get("startsWith", new StartsWithEvaluatorDefinition()));

	KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
	kbuilder.add(ResourceFactory.newClassPathResource("net/techreadiness/rules/starts-with-map.drl"), ResourceType.DRL);

	if (kbuilder.hasErrors()) {
		kbuilder.getErrors();
		throw new ServiceException("Problem building cross field validation rules.");
	}

	knowlegeBase = KnowledgeBaseFactory.newKnowledgeBase();
	knowlegeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:17,代码来源:TestStartsWithMapOperator.java

示例6: beforeClass

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
	KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
	config.setOption(EvaluatorOption.get("endsWith", new EndsWithEvaluatorDefinition()));

	KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
	kbuilder.add(ResourceFactory.newClassPathResource("net/techreadiness/rules/ends-with-map.drl"), ResourceType.DRL);

	if (kbuilder.hasErrors()) {
		KnowledgeBuilderErrors errors = kbuilder.getErrors();
		throw new ServiceException("Problem building cross field validation rules: " + errors);
	}

	knowlegeBase = KnowledgeBaseFactory.newKnowledgeBase();
	knowlegeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:17,代码来源:TestEndsWithMapOperator.java

示例7: beforeClass

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
	KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
	config.setOption(EvaluatorOption.get("startsWith", new StartsWithEvaluatorDefinition()));

	KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
	kbuilder.add(ResourceFactory.newClassPathResource("net/techreadiness/rules/starts-with.drl"), ResourceType.DRL);

	if (kbuilder.hasErrors()) {
		throw new ServiceException("Problem building cross field validation rules.");
	}

	knowlegeBase = KnowledgeBaseFactory.newKnowledgeBase();
	knowlegeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());

}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:17,代码来源:TestStartsWithOperator.java

示例8: beforeClass

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
	KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
	config.setOption(EvaluatorOption.get("endsWith", new EndsWithEvaluatorDefinition()));

	KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
	kbuilder.add(ResourceFactory.newClassPathResource("net/techreadiness/rules/ends-with-map-reference.drl"),
			ResourceType.DRL);

	if (kbuilder.hasErrors()) {
		kbuilder.getErrors();
		throw new ServiceException("Problem building cross field validation rules.");
	}

	knowlegeBase = KnowledgeBaseFactory.newKnowledgeBase();
	knowlegeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:18,代码来源:TestEndsWithMapReferenceOperator.java

示例9: getKnowledgeBuilder

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的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

示例10: getKnowledgeBuilder

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的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

示例11: initSession

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的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

示例12: createKnowledgeBase

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
private KnowledgeBase createKnowledgeBase() {
    log().debug("createKnowledgeBase: Creating Drools KnowledgeBase");
    final Properties props = new Properties();
    props.setProperty("drools.dialect.java.compiler.lnglevel", "1.6");

    final PackageBuilderConfiguration conf = new PackageBuilderConfiguration(props);
    KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder(conf);
    
    // Use the rules file defined in the configuration file
    // We will not throw an exception if the rules failed to be parsed
    builder.add(ResourceFactory.newFileResource(m_configDao.getRulesFile()), ResourceType.DRL);
    if( builder.hasErrors() ) {
        log().error("Failed to create Drools KnowledgeBase: " + builder.getErrors().toString());
        return null;
    }
    
    KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
    knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());
    return knowledgeBase;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:21,代码来源:DroolsTicketerServiceLayer.java

示例13: testDroolsFrameLoader

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
@Test
@Ignore
public void testDroolsFrameLoader() throws Exception {
	// build the knowledge base
	KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
	kbuilder.add( ResourceFactory.newClassPathResource( "/gov/va/cpe/vpr/frames/HelloWorldAlert.drl", getClass()), ResourceType.DRL );
	if ( kbuilder.hasErrors() ) {
		fail(kbuilder.getErrors().toString());
	}
	KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
	kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
	
	// add it to the frame registry
	FrameRegistry.DroolsFrameLoader loader = new DroolsFrameLoader(kbase);
	List<IFrame> frames = loader.load();
	assertEquals(1, frames.size());
	assertTrue(frames.get(0) instanceof DroolsFrameAdapter);
	DroolsFrameAdapter frame = (DroolsFrameAdapter) frames.get(0);
	
	// create the patient, modify the name
       PatientDemographics p = POMUtils.newInstance(PatientDemographics.class, PatientDemographicsImporter.class.getResourceAsStream("patient.json"));
	p.setData("givenNames", "FOO");
	p.setData("familyName", "BAR");
	
	FrameRegistry registry = new FrameRegistry(loader);
	FrameRunner runner = new FrameRunner(registry);
	FrameJob job = runner.exec(new ArrayList<IFrameEvent<?>>(p.getEvents()));
	assertEquals(2, job.getActions().size());
	FrameAction action = job.getActions().get(1);
	System.out.println(job.getActions());
	assertTrue(action instanceof PatientAlert);
	PatientAlert aa = (PatientAlert) action;
	assertEquals("drools alert", aa.getTitle());
	assertEquals(p.getSsn(), aa.getDescription());
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:36,代码来源:FrameRegistryTests.java

示例14: buildKnowledgeSession

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的package包/类
public final void buildKnowledgeSession() {
	if (ksession == null) {
		LOG.debug("Building Drools Knowledge Session");
		// initialise the rules
        final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
                .newKnowledgeBuilder();

        // pickup the rules file from the classpath
        // this will parse and compile in one step
        LOG.info("Loading rules file " + rulesFileName);
        kbuilder.add( ResourceFactory.newClassPathResource( rulesFileName, QaRecommendationServiceImpl.class ),
                      ResourceType.DRL );

        // Check the builder for errors
        if ( kbuilder.hasErrors() ) {
        	LOG.error(kbuilder.getErrors().toString());
            throw new RuntimeException( "Unable to compile \"" + rulesFileName + "\"." );
        }

        // add the packages to a knowledgebase (deploy the knowledge packages).
        final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();      
		kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
		
		// set the knowledge session
		ksession = kbase.newStatefulKnowledgeSession();
		
		// set the configured message formats and advice
		ksession.setGlobal("globals", globals);
	}
	
}
 
开发者ID:DIA-NZ,项目名称:webcurator,代码行数:32,代码来源:QaRecommendationServiceImpl.java

示例15: check

import org.drools.builder.KnowledgeBuilder; //导入方法依赖的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


注:本文中的org.drools.builder.KnowledgeBuilder.hasErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。