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


Java StatefulKnowledgeSession.fireAllRules方法代码示例

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


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

示例1: exec

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@Override
public void exec(FrameTask ctx) {
	StatefulKnowledgeSession kbsess = kb.newStatefulKnowledgeSession();
	try {
		// this knowledge session will be the session for all Drools rules
		kbsess.insert(ctx.getTriggerEvent());
		kbsess.setGlobal("DAO", ctx.getResource(IGenericPatientObjectDAO.class));
		kbsess.fireAllRules();
		
		// Harvest all the actions out of working memory
		ObjectFilter frameActionFilter = new ObjectFilter() {
			@Override
			public boolean accept(Object object) {
				return object instanceof FrameAction;
			}
		};
		Collection<FactHandle> actions = kbsess.getFactHandles(frameActionFilter);
		for (FactHandle handle : actions) {
			FrameAction action = (FrameAction) kbsess.getObject(handle);
			ctx.addAction(action);
		}
	} finally {
		// clear working memory for next transaction
		kbsess.dispose();
	}
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:27,代码来源:AdapterFrame.java

示例2: main

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public static void main(String[] args) {
	
	try {
		// load up the knowledge base
		KnowledgeBase kbase = readKnowledgeBase();
		StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
		KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
		// go !
		PI pi = new PI();
		pi.setIterStrategy(PI.IterStrategySetting.ballardMethod.getStrategy());
		ksession.insert(pi);
		ksession.fireAllRules();	
		System.out.println("PI: " + pi.getPi());
		logger.close();
	} catch (Throwable t) {
		t.printStackTrace();
	}			
	
}
 
开发者ID:shuqin,项目名称:ALLIN,代码行数:20,代码来源:CalcPI.java

示例3: main

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public static void main(String[] args) {
	
	try {
		// load up the knowledge base
		KnowledgeBase kbase = readKnowledgeBase();
		StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
		KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
		// go !
		Employ emp = new Employ();
		emp.setEduInfo("master");
		emp.setResume("tech");
		emp.setAnnualExam("good");
		emp.setAwardPunish("award");
		ksession.insert(emp);
		ksession.startProcess("myrules.salary");
		ksession.fireAllRules();	
		System.out.println("Basic Salary: " + emp.getBasicSalary());
		System.out.println("Duty Salary: " + emp.getDutySalary());
		System.out.println("Bonus      : " + emp.getBonus());
		System.out.println("rate       : " + emp.getPercent());
		System.out.printf("Total Salary: %.0f" , emp.getTotalSalary());
		logger.close();
	} catch (Throwable t) {
		t.printStackTrace();
	}			
	
}
 
开发者ID:shuqin,项目名称:ALLIN,代码行数:28,代码来源:EmployTest.java

示例4: evaluateInnerProjectScopes

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
/**
 * Method to evaluate rules in inner project scopes.
 * @param ksession Drools Knowledge session.
 */
private void evaluateInnerProjectScopes(StatefulKnowledgeSession ksession) {
    LinkedHashMap<String, Integer> importedProjectMap = droolsVisitor.getImportedProjectMap();
    Iterator<String> itr = importedProjectMap.keySet().iterator();
    while (itr.hasNext()) {
        String projectN = itr.next();
        for (int i = 0; i < importedProjectMap.get(projectN); i++) {
            ksession.getAgenda().getAgendaGroup("Group 0_" + i + projectN).setFocus();
            ksession.fireAllRules();
            ksession.getAgenda().getAgendaGroup("Group 2_" + i + projectN).setFocus();
            ksession.fireAllRules();
        }
        ksession.getAgenda().getAgendaGroup("Group 2" + projectN).setFocus();
        ksession.fireAllRules();
        
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:21,代码来源:DroolsEngine.java

示例5: main

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public static final void main(String[] args) {
	try {
		// load up the knowledge base
		KnowledgeBase kbase = readKnowledgeBase();
		StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
		KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
		// go !
		Message message = new Message();
		message.setMessage("Hello World");
		message.setStatus(Message.HELLO);
		ksession.insert(message);
		ksession.fireAllRules();
		logger.close();
	} catch (Throwable t) {
		t.printStackTrace();
	}
}
 
开发者ID:road-framework,项目名称:ROADDesigner,代码行数:18,代码来源:DroolsTest.java

示例6: performCrossFieldValidation

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public List<ValidationError> performCrossFieldValidation(ServiceContext context,
		final Map<String, String> extAttributes, Long scopeId, EntityTypeCode entityType) {
	List<ValidationError> errorList = new ArrayList<>();

	if (extAttributes != null) {
		StatefulKnowledgeSession ksession = ruleService.getRuleSessionForScopePath(context, scopeId, entityType);

		if (ksession != null) {
			ksession.setGlobal("errorList", errorList);
			ksession.insert(extAttributes);
			ksession.fireAllRules();
			ksession.dispose();
		}
	}
	return errorList;
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:17,代码来源:BaseServiceWithValidationImpl.java

示例7: createTicketFromAlarm

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
/**
* Called from API implemented method after successful retrieval of Alarm.
* 
* @param alarm OpenNMS Model class alarm
* @return OpenNMS Ticket processed by Drools logic.
*/
  protected Ticket createTicketFromAlarm(OnmsAlarm alarm) {
      log().debug("createTicketFromAlarm: Processing ticket.");
      
      // Call superclass method if the knowledge-base was not properly created.
      if( m_knowledgeBase == null ) {
          log().error("KnowledgeBase is NULL, creating basic ticket form alarm.");
          return super.createTicketFromAlarm(alarm);
      }
      
      Ticket ticket = new Ticket();
      StatefulKnowledgeSession session = m_knowledgeBase.newStatefulKnowledgeSession();
      try {
          // Pass the ticket as a global - the logic will fill the appropriate fields
          session.setGlobal("ticket", ticket);
          // Pass the alarm and the node objects
          session.insert(alarm);
          session.insert(alarm.getNode());
          session.fireAllRules();
      } finally {
          session.dispose();
      }
      
      log().debug("createTicketFromAlarm: Succesfully processed ticket.");
      return ticket;
  }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:32,代码来源:DroolsTicketerServiceLayer.java

示例8: fireMessage

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
/**
    * 
    * @param message
    * @param rule
    */
   public static Object fireMessage(Object message, String rule) {
	StatefulKnowledgeSession session;
	try {
		session = DroolsTools.getStatefulKnowledgeSession(rule);
		if(session != null) {
			session.insert(message);
			session.fireAllRules();
		} else {
			System.out.println("X:\tCannot create Session\n\t");
		}
	} catch(Throwable t) {
		System.out.println("X:\tCannot fire Message\n\t"+t.getMessage());
	}
	return message;
}
 
开发者ID:xladde,项目名称:hsw,代码行数:21,代码来源:DroolsTools.java

示例9: executeStatefulRules

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
protected void executeStatefulRules(StatefulKnowledgeSession session, List context) {
    handlers = new Hashtable<Object, FactHandle>();
    for (Object o : context) {
        if (o != null) {
            LOG.debug("inserting object " + o);
            handlers.put(o, session.insert(o));
        } else {
            LOG.warn("Attempted to insert a NULL object into the working memeory");
        }

    }

    session.fireAllRules();
    session.dispose();
    handlers.clear();
    handlers = null;
}
 
开发者ID:maxdelo77,项目名称:replyit-master-3.2-final,代码行数:18,代码来源:RulesBaseTask.java

示例10: waltz

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@WebMethod
public String waltz(@WebParam(name="WaltzDTO")WaltzDTO dto) {

	StatefulKnowledgeSession session = waltzKb.getKbase().newStatefulKnowledgeSession();

	for (Line l : dto.getLine()) {
		session.insert(l);
	}
	session.insert(dto.getStage());
	long start = System.currentTimeMillis();
	session.setGlobal( "time", start );

	session.fireAllRules();
	long time = System.currentTimeMillis() - start;
	System.err.println( time );

	session.dispose();
	return "time: "+time;
}
 
开发者ID:tarilabs,项目名称:waltzwsbenchmark,代码行数:20,代码来源:WaltzWs.java

示例11: main

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public static void main(String[] args) {
	
	try {
		// load up the knowledge base
		KnowledgeBase kbase = readKnowledgeBase();
		StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
		KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
		// go !
		Employ emp = new Employ();
		emp.setEduInfo("master");
		emp.setResume("tech");
		emp.setAnnualExam("good");
		emp.setAwardPunish("award");
		ksession.insert(emp);
		ksession.startProcess("ruleflow.salary");
		ksession.fireAllRules();	
		System.out.println("Basic Salary: " + emp.getBasicSalary());
		System.out.println("Duty Salary: " + emp.getDutySalary());
		System.out.println("Bonus      : " + emp.getBonus());
		System.out.println("rate       : " + emp.getPercent());
		System.out.printf("Total Salary: %.0f" , emp.getTotalSalary());
		logger.close();
	} catch (Throwable t) {
		t.printStackTrace();
	}			
	
}
 
开发者ID:shuqin,项目名称:ALLIN,代码行数:28,代码来源:EmployTest2.java

示例12: 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

示例13: 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

示例14: main

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public static final void main(String[] args) {
    try {
        // load up the knowledge base
        KnowledgeBase kbase = readKnowledgeBase();
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
        // go !
        ksession.fireAllRules();
        logger.close();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:mescam,项目名称:carMechanic,代码行数:14,代码来源:DroolsTest.java

示例15: 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


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