本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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;
}