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


Java StatelessKieSession.execute方法代码示例

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


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

示例1: determineWorkgroups

import org.kie.api.runtime.StatelessKieSession; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<String> determineWorkgroups(TaskTemplate taskTemplate, TaskInstance taskInstance) throws StrategyException {
    KieBase knowledgeBase = getKnowledgeBase();

    StatelessKieSession knowledgeSession = knowledgeBase.newStatelessKieSession();

    List<Object> facts = new ArrayList<Object>();
    facts.add(getParameters());
    knowledgeSession.setGlobal("taskTemplate", taskTemplate);
    knowledgeSession.setGlobal("taskInstance", taskInstance);
    knowledgeSession.setGlobal("now", new Date());

    knowledgeSession.execute(CommandFactory.newInsertElements(facts));

    return taskInstance.getWorkgroups();
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw-demo,代码行数:17,代码来源:RulesBasedRoutingStrategy.java

示例2: determineDueDate

import org.kie.api.runtime.StatelessKieSession; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Date determineDueDate(TaskTemplate taskTemplate) throws StrategyException {

    TaskInstance taskInstanceVO = new TaskInstance();  // for holding values

    // execute rules only once (results are stored in taskInstanceVO)
    KieBase knowledgeBase = getKnowledgeBase();
    StatelessKieSession knowledgeSession = knowledgeBase.newStatelessKieSession();

    List<Object> facts = new ArrayList<Object>();
    facts.add(getParameters());
    knowledgeSession.setGlobal("taskTemplate", taskTemplate);
    knowledgeSession.setGlobal("taskInstance", taskInstanceVO);

    knowledgeSession.execute(CommandFactory.newInsertElements(facts));

    return Date.from(taskInstanceVO.getDue());
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw-demo,代码行数:20,代码来源:RulesBasedPrioritizationStrategy.java

示例3: recommendMeal

import org.kie.api.runtime.StatelessKieSession; //导入方法依赖的package包/类
@Override
public Meal recommendMeal(Person person) throws BusinessException {
    StatelessKieSession kieSession = kContainer.newStatelessKieSession();

    InsertObjectCommand insertObjectCommand = new InsertObjectCommand(person);
    FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
    QueryCommand queryCommand = new QueryCommand("results", "getMeal", (Object[]) null);
    List<GenericCommand<?>> commands = new ArrayList<GenericCommand<?>>();
    commands.add(insertObjectCommand);
    commands.add(fireAllRulesCommand);
    commands.add(queryCommand);
    BatchExecutionCommand batch = new BatchExecutionCommandImpl(commands);

    ExecutionResults results = kieSession.execute(batch);
    QueryResults queryResults = (QueryResults) results.getValue("results");
    Iterator<QueryResultsRow> iterator = queryResults.iterator();
    while (iterator.hasNext()) {
        Meal meal = (Meal) iterator.next().get("$m");
        if (meal != null) {
            System.out.println("Meal : " + meal);
            return meal;
        }
    }

    return null;
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:27,代码来源:FoodRecommendationServiceImpl.java

示例4: execute

import org.kie.api.runtime.StatelessKieSession; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object execute(Asset rulesAsset, Operand input) throws ExecutionException {

    ClassLoader cloudClassLoader = null;
    if (input.getContext() != null && input.getContext().getPackage() != null)
        cloudClassLoader = input.getContext().getPackage().getCloudClassLoader();
    if (cloudClassLoader == null) // fall back to rules asset pkg classloader
        cloudClassLoader = PackageCache.getPackage(rulesAsset.getPackageName()).getCloudClassLoader();

    KnowledgeBaseAsset kbAsset = DroolsKnowledgeBaseCache
            .getKnowledgeBaseAsset(rulesAsset.getName(), null, null, cloudClassLoader);
    if (kbAsset == null) {
        throw new ExecutionException("Cannot load KnowledgeBase asset: "
                + rulesAsset.getPackageName() + "/" + rulesAsset.getLabel());
    }

    KieBase knowledgeBase = kbAsset.getKnowledgeBase();

    StatelessKieSession kSession = knowledgeBase.newStatelessKieSession();

    List<Object> facts = new ArrayList<Object>();
    if (input.getInput() != null) {
        facts.add(input.getInput()); // direct access
        if (input.getInput() instanceof Jsonable)
            facts.add(((Jsonable)input.getInput()).getJson());
    }

    kSession.setGlobal("operand", input);
    kSession.execute(CommandFactory.newInsertElements(facts));
    return input.getResult();
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw-demo,代码行数:33,代码来源:DroolsExecutor.java

示例5: getSubTaskPlan

import org.kie.api.runtime.StatelessKieSession; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public String getSubTaskPlan(TaskRuntimeContext masterTaskContext) throws StrategyException {
    TaskInstance masterTaskInstance = masterTaskContext.getTaskInstance();
    KieBase knowledgeBase = getKnowledgeBase();

    StatelessKieSession knowledgeSession = knowledgeBase.newStatelessKieSession();

    List<Object> facts = new ArrayList<Object>();
    facts.add(getParameters());
    knowledgeSession.setGlobal("masterTaskInstance", masterTaskInstance);
    SubTaskPlan subTaskPlan = new SubTaskPlan();
    knowledgeSession.setGlobal("subTaskPlan", subTaskPlan);
    knowledgeSession.setGlobal("now", new Date());

    knowledgeSession.execute(CommandFactory.newInsertElements(facts));
    try {
        String planXml = marshalJaxb(subTaskPlan);
        if (logger.isDebugEnabled()) {
            logger.debug("SubTask plan XML: " + planXml);
        }
        return planXml;
    }
    catch (Exception ex) {
        throw new StrategyException(ex.getMessage(), ex);
    }

}
 
开发者ID:CenturyLinkCloud,项目名称:mdw-demo,代码行数:28,代码来源:RulesBasedSubTaskStrategy.java

示例6: execute

import org.kie.api.runtime.StatelessKieSession; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void execute() throws ActivityException {

    String knowledgeBaseName = null;
    String knowledgeBaseVersion = null;
    try {
        knowledgeBaseName = getAttributeValueSmart(KNOWLEDGE_BASE);
        knowledgeBaseVersion = getAttributeValueSmart(KNOWLEDGE_BASE_ASSET_VERSION);
    }
    catch (PropertyException ex) {
        throw new ActivityException(ex.getMessage(), ex);
    }

    if (StringHelper.isEmpty(knowledgeBaseName))
        throw new ActivityException("Missing attribute: " + KNOWLEDGE_BASE);

    KieBase knowledgeBase = getKnowledgeBase(knowledgeBaseName, knowledgeBaseVersion);
    if (knowledgeBase == null)
        throw new ActivityException("Cannot load KnowledgeBase: " + knowledgeBaseName);

    // TODO stateful session option
    StatelessKieSession kSession = knowledgeBase.newStatelessKieSession();

    List<Object> facts = new ArrayList<Object>();
    Map<String,Object> values = new HashMap<String,Object>();

    for (VariableInstance variableInstance : getParameters()) {
        Object value = getVariableValue(variableInstance.getName());
        values.put(variableInstance.getName(), value);
    }
    facts.add(values);

    setGlobalValues(kSession);

    kSession.execute(CommandFactory.newInsertElements(facts));

    String temp = getAttributeValue(OUTPUTDOCS);
    setOutputDocuments(temp == null ? new String[0] : StringHelper.parseList(temp).toArray(new String[0]));

    // TODO handle document variables
    Process processVO = getProcessDefinition();
    for (Variable variable : processVO.getVariables()) {
        Object newValue = values.get(variable.getName());
        if (newValue != null)
            setVariableValue(variable.getName(), variable.getType(), newValue);
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw-demo,代码行数:49,代码来源:DroolsActivity.java


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