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


Java StatefulKnowledgeSession.dispose方法代码示例

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


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

示例1: changeTask

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
private void changeTask(long taskId,String username,StatusOperation operation,String faultMessage) {
	EntityManager em=getEntityManager();
	EntityTransaction trans=em.getTransaction();
	try{
		trans.begin();
		Task task=em.find(Task.class, taskId);
		if(StringUtils.isNotEmpty(faultMessage)){
			task.setFaultMessage(faultMessage);
		}
		if(changeTaskStatus(task,operation)){
			em.persist(task);				
		}
		TaskStatus status=task.getStatus();
		if(status.equals(TaskStatus.Completed) || status.equals(TaskStatus.Error) || status.equals(TaskStatus.Exited) || status.equals(TaskStatus.Obsolete) || status.equals(TaskStatus.Failed)){
			StatefulKnowledgeSession session=this.bpmService.getSession(task.getSessionId());
			session.getWorkItemManager().completeWorkItem(task.getWorkItemId(),null);	
			session.dispose();
		}
		trans.commit();
	}catch(Exception ex){
		trans.rollback();
		throw new RuntimeException(ex);
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:25,代码来源:TaskServiceImpl.java

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

示例3: getProcessInstanceVariables

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public synchronized Map<String, Object> getProcessInstanceVariables(
		long processInstanceId) {
	StatefulKnowledgeSession ksession = this.bpmService.createSession();
	try {
		ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
		if (processInstance != null) {
			Map<String, Object> variables = ((WorkflowProcessInstanceImpl) processInstance)
					.getVariables();
			if (variables == null) {
				return new HashMap<String, Object>();
			}
			// filter out null values
			Map<String, Object> result = new HashMap<String, Object>();
			for (Map.Entry<String, Object> entry : variables.entrySet()) {
				if (entry.getValue() != null) {
					result.put(entry.getKey(), entry.getValue());
				}
			}
			return result;
		} else {
			throw new IllegalArgumentException("Could not find process instance " + processInstanceId);
		}
	} finally {
		ksession.dispose();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:27,代码来源:ProcessServiceImpl.java

示例4: setProcessInstanceVariables

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public void setProcessInstanceVariables(long processInstanceId,
		Map<String, Object> variables) {
	StatefulKnowledgeSession ksession = this.bpmService.createSession();
	try {
		ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
		if (processInstance != null) {
               VariableScopeInstance variableScope = (VariableScopeInstance) 
                   ((org.jbpm.process.instance.ProcessInstance) processInstance)
                       .getContextInstance(VariableScope.VARIABLE_SCOPE);
               if (variableScope == null) {
                   throw new IllegalArgumentException("Could not find variable scope for process instance " + processInstanceId);
               }
               for (Map.Entry<String, Object> entry: variables.entrySet()) {
                   variableScope.setVariable(entry.getKey(), entry.getValue());
               }
           } else {
               throw new IllegalArgumentException("Could not find process instance " + processInstanceId);
           }
	} finally {
		ksession.dispose();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:ProcessServiceImpl.java

示例5: executeViewRule

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@Override
public boolean executeViewRule(ServiceContext context, Long ruleId, BaseObject<?> baseObject) {
	EntityRuleDO rule = entityRuleDAO.getById(ruleId);

	if (rule != null) {
		KnowledgeBase knowlegeBase = getKnowlegeBase(Lists.newArrayList(rule));
		StatefulKnowledgeSession session = knowlegeBase.newStatefulKnowledgeSession();
		for (Permission permission : userService.findAvailablePermissions(context)) {
			session.insert(permission);
		}
		List<ValidationError> errorList = Lists.newArrayList();

		session.setGlobal("errorList", errorList);
		session.insert(baseObject);
		session.fireAllRules();
		session.dispose();
		return errorList.isEmpty();
	}

	return true;
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:22,代码来源:RuleServiceImpl.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: 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

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

示例10: getProcessVariable

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public Object getProcessVariable(long taskId,String variableName){
	Task task=this.getTask(taskId);
	StatefulKnowledgeSession session=this.bpmService.getSession(task.getSessionId());
	try{
		RuleFlowProcessInstance pi=(RuleFlowProcessInstance)session.getProcessInstance(task.getProcessInstanceId());
		return pi.getVariable(variableName);
	}finally{
		session.dispose();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:11,代码来源:TaskServiceImpl.java

示例11: startProcess

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public synchronized ProcessInstance startProcess(String processId) {
	StatefulKnowledgeSession ksession = this.bpmService.createSession();
	try {
		Map<String, Object> map = this.initProcessVariables(null);
		ProcessInstance processInstance = ksession.startProcess(processId,map);
		return processInstance;
	} finally {
		ksession.dispose();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:11,代码来源:ProcessServiceImpl.java

示例12: abortProcessInstance

import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
public synchronized void abortProcessInstance(long processInstanceId) {
	StatefulKnowledgeSession ksession = this.bpmService.createSession();
	try {
		ksession.abortProcessInstance(processInstanceId);
	} finally {
		ksession.dispose();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:9,代码来源:ProcessServiceImpl.java

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

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

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