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


Java StatefulKnowledgeSession.getObjects方法代码示例

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


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

示例1: execute

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@Override
public void execute(DelegateExecution execution) {
    ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(execution.getProcessDefinitionId());
    String deploymentId = processDefinition.getDeploymentId();

    KnowledgeBase knowledgeBase = RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);
    StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();

    if (variablesInputExpressions != null) {
        Iterator<Expression> itVariable = variablesInputExpressions.iterator();
        while (itVariable.hasNext()) {
            Expression variable = itVariable.next();
            ksession.insert(variable.getValue(execution));
        }
    }

    if (!rulesExpressions.isEmpty()) {
        RulesAgendaFilter filter = new RulesAgendaFilter();
        Iterator<Expression> itRuleNames = rulesExpressions.iterator();
        while (itRuleNames.hasNext()) {
            Expression ruleName = itRuleNames.next();
            filter.addSuffic(ruleName.getValue(execution).toString());
        }
        filter.setAccept(!exclude);
        ksession.fireAllRules(filter);

    } else {
        ksession.fireAllRules();
    }

    Collection<Object> ruleOutputObjects = ksession.getObjects();
    if (ruleOutputObjects != null && !ruleOutputObjects.isEmpty()) {
        Collection<Object> outputVariables = new ArrayList<>();
        outputVariables.addAll(ruleOutputObjects);
        execution.setVariable(resultVariable, outputVariables);
    }
    ksession.dispose();
    leave(execution);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:40,代码来源:BusinessRuleTaskActivityBehavior.java

示例2: execute

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@Override
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    PvmProcessDefinition processDefinition = activityExecution.getActivity().getProcessDefinition();
    String deploymentId = processDefinition.getDeploymentId();

    KnowledgeBase knowledgeBase = RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);
    StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();

    if (variablesInputExpressions != null) {
        Iterator<Expression> itVariable = variablesInputExpressions.iterator();
        while (itVariable.hasNext()) {
            Expression variable = itVariable.next();
            ksession.insert(variable.getValue(execution));
        }
    }

    if (!rulesExpressions.isEmpty()) {
        RulesAgendaFilter filter = new RulesAgendaFilter();
        Iterator<Expression> itRuleNames = rulesExpressions.iterator();
        while (itRuleNames.hasNext()) {
            Expression ruleName = itRuleNames.next();
            filter.addSuffic(ruleName.getValue(execution).toString());
        }
        filter.setAccept(!exclude);
        ksession.fireAllRules(filter);

    } else {
        ksession.fireAllRules();
    }

    Collection<Object> ruleOutputObjects = ksession.getObjects();
    if (ruleOutputObjects != null && !ruleOutputObjects.isEmpty()) {
        Collection<Object> outputVariables = new ArrayList<>();
        outputVariables.addAll(ruleOutputObjects);
        execution.setVariable(resultVariable, outputVariables);
    }
    ksession.dispose();
    leave(activityExecution);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:41,代码来源:BusinessRuleTaskActivityBehavior.java

示例3: execute

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public void execute(ActivityExecution execution) throws Exception {
  PvmProcessDefinition processDefinition = execution.getActivity().getProcessDefinition();
  String deploymentId = processDefinition.getDeploymentId();
  
  KnowledgeBase knowledgeBase = RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId); 
  StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
  
  if (variablesInputExpressions != null) {
    Iterator<Expression> itVariable = variablesInputExpressions.iterator();
    while (itVariable.hasNext()) {
      Expression variable = itVariable.next();
      ksession.insert(variable.getValue(execution));
    }
  }
  
  if (rulesExpressions.size() > 0) {
    RulesAgendaFilter filter = new RulesAgendaFilter();
    Iterator<Expression> itRuleNames = rulesExpressions.iterator();
    while (itRuleNames.hasNext()) {
      Expression ruleName = itRuleNames.next();
      filter.addSuffic(ruleName.getValue(execution).toString());
    }
    filter.setAccept(!exclude);
    ksession.fireAllRules(filter);
    
  } else {
    ksession.fireAllRules();
  }
  
  Collection<Object> ruleOutputObjects = ksession.getObjects();
  if (ruleOutputObjects != null && ruleOutputObjects.size() > 0) {
    Collection<Object> outputVariables = new ArrayList<Object>();
    for (Object object : ruleOutputObjects) {
      outputVariables.add(object);
    }
    execution.setVariable(resultVariable, outputVariables);
  }
  ksession.dispose();
  leave(execution);
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:41,代码来源:BusinessRuleTaskActivityBehavior.java

示例4: main

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    KnowledgeBuilderConfiguration conf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
    KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(conf);

    kBuilder.add(ResourceFactory.newClassPathResource("ru/joker/drools/drl/logic/Smart.drl"), ResourceType.DRL);
    kBuilder.add(ResourceFactory.newClassPathResource("ru/joker/drools/drl/billing/Accounting.drl"), ResourceType.DRL);
    kBuilder.add(ResourceFactory.newClassPathResource("ru/joker/drools/drl/logic/General.drl"), ResourceType.DRL);

    KnowledgeBase kBase = kBuilder.newKnowledgeBase();

    StatefulKnowledgeSession session = kBase.newStatefulKnowledgeSession();

    try {
        session.setGlobal("log", LOG);

        for (Customer customer : DAO.findCustomers()) {
            session.insert(customer);
        }

        for (Sms sms : DAO.findSmses()) {
            session.insert(sms);
        }

        DateTime startOfMonth = new DateTime().withDayOfMonth(1).withMillisOfDay(0);

        session.insert(new Interval(startOfMonth, startOfMonth.plusMonths(1)));

        session.fireAllRules();

        Collection<Object> invoices = session.getObjects(new ClassObjectFilter(Invoice.class));

        LOG.info("Invoices: {}", new ArrayList<Object>(invoices));
    } finally {
        session.dispose();
    }
}
 
开发者ID:victor-cr,项目名称:drools-joker-mobile,代码行数:37,代码来源:DroolsLauncher.java

示例5: fetchColumns

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
protected Collection<Object> fetchColumns( StatefulKnowledgeSession session ) {
  Collection<Object> oList = session.getObjects( new ObjectFilter() {
    @Override
    public boolean accept( Object o ) {
      if ( o instanceof Column && !( (Column) o ).isExternalSource() ) {
        return true;
      }
      return false;
    }
  } );
  return oList;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:13,代码来源:RulesExecutorData.java


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