• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java KnowledgePackage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.drools.definition.KnowledgePackage的典型用法代码示例。如果您正苦于以下问题:Java KnowledgePackage类的具体用法?Java KnowledgePackage怎么用?Java KnowledgePackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



KnowledgePackage类属于org.drools.definition包,在下文中一共展示了KnowledgePackage类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: DroolsFrameAdapter

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
public DroolsFrameAdapter(KnowledgeBase kb) {
	this.kb = kb;
	setName("Drools Runtime Engine");
	List<String> names = new ArrayList<String>();
	for (KnowledgePackage pkg : kb.getKnowledgePackages()) {
		names.add(pkg.getName());
	}
	addMeta("drools.packages", names);
	
	// custom 'ALL' trigger, let the KnowledgeBase resolve what it wants to do.
	addTrigger(new IFrameTrigger<PatientEvent<IPatientObject>>(PatientEvent.class, null) {
		protected boolean doEval(PatientEvent<IPatientObject> event) {
			// TODO: only return true if there was an activation?
			return true;
		}
	});
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:18,代码来源:AdapterFrame.java


示例2: initializeRules

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
public void initializeRules() {
	Resource ruleSet = null;
	if(ruleString != null) {
		ruleSet = ResourceFactory.newReaderResource(new StringReader(ruleString));
	} else {
		ruleSet = ResourceFactory.newFileResource(ruleFilePath);
	}
	kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
	kbuilder.add(ruleSet, ResourceType.DRL);
	
	if(kbuilder.hasErrors()) {
		System.out.println(kbuilder.getErrors().toString());
		throw new RuntimeException("Failed to compile drl");
	}
	
	Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
	
	kbase = KnowledgeBaseFactory.newKnowledgeBase();
	// Cache the knowledge base as its creation is intensive
	kbase.addKnowledgePackages(pkgs);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:RulesData.java


示例3: initializeRules

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
public void initializeRules() {
  Resource ruleSet = null;
  if (ruleString != null) {
    ruleSet = ResourceFactory.newReaderResource(new StringReader(ruleString));
  } else {
    ruleSet = ResourceFactory.newFileResource(ruleFilePath);
  }
  kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
  kbuilder.add(ruleSet, ResourceType.DRL);

  if (kbuilder.hasErrors()) {
    System.out.println(kbuilder.getErrors().toString());
    throw new RuntimeException(BaseMessages.getString(PKG, "RulesData.Error.CompileDRL")); //$NON-NLS-1$
  }

  Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();

  kbase = KnowledgeBaseFactory.newKnowledgeBase();
  // Cache the knowledge base as its creation is intensive
  kbase.addKnowledgePackages(pkgs);
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:22,代码来源:RulesExecutorData.java


示例4: registerKnowledgeBase

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
/**
 * register the knowledge base from the rule builder in the knowledge base.
 */
protected void registerKnowledgeBase() {	
	if (null != kbase) {
		// we don't need to register the knowledge-base again. 
		return;
	}
	log.debug("register knowledge base.");
	// get the compiled packages
	final Collection<KnowledgePackage> pkgs = kbuilder
		.getKnowledgePackages();

	// add the packages to a knowledge-base (deploy the knowledge packages).
	kbase = KnowledgeBaseFactory.newKnowledgeBase();
	kbase.addKnowledgePackages(pkgs);
}
 
开发者ID:Fosstrak,项目名称:fosstrak-capturingapp,代码行数:18,代码来源:ECReportsHandler.java


示例5: syncNow

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
private void syncNow() {
	LOG.debug("Initiating new synchornization");
	Date previousLastDate = lastDeploymentDate;
	LOG.debug("Previous deployment last date '{}'", previousLastDate);

	LOG.debug("Creating package builder and configuring it");
	PackageBuilder builder = new PackageBuilder();
	BPMN2ProcessFactory.configurePackageBuilder(builder);
	List<WorkflowDefinition> allDefs = workflowService.getAllWorkflowDefinition();
	int installed = 0;
	LOG.debug("Checking {} workflow definitions", allDefs.size());
	for (WorkflowDefinition def : allDefs) {
		Deployment deployment = workflowService.getDeployment(def.getDeploymemtId());
		LOG.debug("Check if deployment must be sincronized, deployment date: {} ", deployment.getDeploymentDate());
		if (deployment.getDeploymentDate().compareTo(previousLastDate) > 0) {
			try {
				LOG.debug("Need to deploy to kbase, building process for Workflow,  Id: {}, Key: {}, Version: {}",
						new Object[] { def.getId(), def.getKey(), def.getVersion() });
				builder.addProcessFromXml(getResourceFromDefinition(def));
				installed++;
				Date deploymentDate = deployment.getDeploymentDate();
				lastDeploymentDate = deploymentDate.compareTo(lastDeploymentDate) > 0 ? deploymentDate : lastDeploymentDate;
			} catch (Exception e) {
				LOG.error(String.format("Cant register process %s becouse has thorwn an exception", def.getKey()), e);
			}
		}
	}
	if (installed > 0 && builder.getPackage() != null) {
		LOG.debug("Total process builts: {}", installed);
		kbase.addKnowledgePackages(Arrays.asList((KnowledgePackage) new KnowledgePackageImp(builder.getPackage())));
	}
}
 
开发者ID:frincon,项目名称:openeos,代码行数:33,代码来源:JbpmSynchronizer.java


示例6: execute

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
public void execute(String ruleSet) {
    log.info("Starting PrintOutAllKnowledgePackages Execution");

    try {
    	KnowledgeBaseWrapper knowledgeBaseWrapper = gigaSpace.read(new KnowledgeBaseWrapper(ruleSet));
    	if(knowledgeBaseWrapper != null) {
    		KnowledgeBase knowledgeBase = knowledgeBaseWrapper.getKnowledgeBase();
    		
    		Collection<KnowledgePackage> knowledgePackages = knowledgeBase.getKnowledgePackages();
     	if(knowledgePackages != null) {
     		for(KnowledgePackage knowledgePackage : knowledgePackages) {
     			log.info("Begin KnowledgePackage: " + knowledgePackage.getName());
     			        			
     			Collection<Rule> rules = knowledgePackage.getRules();
     			if(rules != null) {
     				for(Rule rule : rules) {
     					log.info("Rule ID: " + rule.getId());
     					log.info("Rule Name: " + rule.getName());
     				}
     			}else {
 	    			log.info("rules are null for ruleSet: " + ruleSet);
 	        	}
     			
     			log.info("End KnowledgePackage: " + knowledgePackage.getName());
     		}
     	}else {
 			log.info("knowledgePackages are null for ruleSet: " + ruleSet);
     	}
    	}else {
			log.info("knowledgeBaseWrapper is null for ruleSet: " + ruleSet);
		}
    	
    }catch(Exception e) {
        log.error(e.getMessage(), e);
    }
    log.info("End PrintOutAllKnowledgePackages Execution");
}
 
开发者ID:Gigaspaces,项目名称:xap-drools-integration,代码行数:38,代码来源:PrintOutAllKnowledgePackages.java


示例7: execute

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
public void execute(String ruleSet, String packageName) {
    log.info("Starting PrintOutSingleKnowledgePackage Execution");

    try {
    	KnowledgeBaseWrapper knowledgeBaseWrapper = gigaSpace.read(new KnowledgeBaseWrapper(ruleSet));
    	if(knowledgeBaseWrapper != null) {
    		KnowledgeBase knowledgeBase = knowledgeBaseWrapper.getKnowledgeBase();
    		
    		KnowledgePackage knowledgePackage = knowledgeBase.getKnowledgePackage(packageName);
     	if(knowledgePackage != null) {
    			log.info("Begin KnowledgePackage: " + knowledgePackage.getName());
    			        			
    			Collection<Rule> rules = knowledgePackage.getRules();
    			if(rules != null) {
    				for(Rule rule : rules) {
    					log.info("Rule ID: " + rule.getId());
    					log.info("Rule Name: " + rule.getName());
    				}
    			}else {
	    			log.info("rules are null for ruleSet: " + ruleSet);
	        	}
    			
    			log.info("End KnowledgePackage: " + knowledgePackage.getName());
     	}else {
 			log.info("knowledgePackage is null : " + packageName);
     	}
    	}else {
			log.info("knowledgeBaseWrapper is null for ruleSet: " + ruleSet);
		}
    	
    }catch(Exception e) {
        log.error(e.getMessage(), e);
    }
    log.info("End PrintOutSingleKnowledgePackage Execution");
}
 
开发者ID:Gigaspaces,项目名称:xap-drools-integration,代码行数:36,代码来源:PrintOutSingleKnowledgePackage.java


示例8: initializeRules

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
public void initializeRules() {

    // To ensure the plugin classloader use for dependency resolution
    ClassLoader orig = Thread.currentThread().getContextClassLoader();
    ClassLoader loader = getClass().getClassLoader();
    Thread.currentThread().setContextClassLoader( loader );

    Resource ruleSet = null;
    if ( ruleString != null ) {
      ruleSet = ResourceFactory.newReaderResource( new StringReader( ruleString ) );
    } else {
      ruleSet = ResourceFactory.newFileResource( ruleFilePath );
    }
    kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add( ruleSet, ResourceType.DRL );

    if ( kbuilder.hasErrors() ) {
      System.out.println( kbuilder.getErrors().toString() );
      throw new RuntimeException( BaseMessages.getString( PKG, "RulesData.Error.CompileDRL" ) );
    }

    Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();

    kbase = KnowledgeBaseFactory.newKnowledgeBase();
    // Cache the knowledge base as its creation is intensive
    kbase.addKnowledgePackages( pkgs );

    // reset classloader back to original
    Thread.currentThread().setContextClassLoader( orig );
  }
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:31,代码来源:RulesExecutorData.java


示例9: init

import org.drools.definition.KnowledgePackage; //导入依赖的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


示例10: addRuleSet

import org.drools.definition.KnowledgePackage; //导入依赖的package包/类
public void addRuleSet(RuleSet ruleSet) throws RuleConfigurationException {

        for (Rule rule : ruleSet.getRules()) {
            InputStream ruleInputStream = RuleSetLoader.getRuleSetAsStream(rule, classLoader);

            if (rule.getResourceType().equals(Constants.RULE_RESOURCE_TYPE_REGULAR)) {

                //check the file type before adding it to knowledge builder for "file" source type
                if (rule.getSourceType().equalsIgnoreCase(Constants.RULE_SOURCE_TYPE_FILE) && (rule.getValue().lastIndexOf(".drl") < 0) ) {
                    throw new RuleConfigurationException(
                            "Error in rule service configuration : Select \"dtable\" as Resource Type for decision tables "
                                                                        + "or attached file is not supported by rule engine");
                } else {
                    this.knowledgeBuilder.add(ResourceFactory.newInputStreamResource(ruleInputStream), ResourceType.DRL);
                }

            } else if (rule.getResourceType().equals(Constants.RULE_RESOURCE_TYPE_DTABLE)) {

                //check the file type before adding it to knowledge builder for "file" source type
                if (rule.getSourceType().equalsIgnoreCase(Constants.RULE_SOURCE_TYPE_FILE) &&
                                                                            rule.getValue().lastIndexOf(".xls") < 0 &&
                                                                            rule.getValue().lastIndexOf(".csv") < 0) {
                    throw new RuleConfigurationException(
                            "Error in rule service configuration : Select \"regular\" as Resource Type for regular rules "
                                                                        + "or attached file is not supported by rule engine");
                } else {
                    DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();

                    //check whether the decision tables is base on .xsl file of .csv format (inline input or .csv file input)
                    if (rule.getSourceType().equalsIgnoreCase(Constants.RULE_SOURCE_TYPE_INLINE) ||
                                                                    rule.getValue().lastIndexOf(".csv") > 0) {
                        //decision table in .xls format
                        dtconf.setInputType(DecisionTableInputType.CSV);
                    } else {
                        //decision table in .xls format
                        dtconf.setInputType(DecisionTableInputType.XLS);
                    }
                    this.knowledgeBuilder.add(ResourceFactory.newInputStreamResource(ruleInputStream),
                                              ResourceType.DTABLE, dtconf);
                }

            }

            if (this.knowledgeBuilder.hasErrors()) {
                throw new RuleConfigurationException("Error during creating rule set: " +
                        this.knowledgeBuilder.getErrors());
            }

            Collection<KnowledgePackage> pkgs = this.knowledgeBuilder.getKnowledgePackages();
            this.knowledgeBase.addKnowledgePackages(pkgs);
        }

    }
 
开发者ID:wso2,项目名称:carbon-rules,代码行数:54,代码来源:DroolsBackendRuntime.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Database类代码示例发布时间:2022-05-22
下一篇:
Java FieldEncodedValue类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap