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


Java Context类代码示例

本文整理汇总了Java中org.kuali.rice.krms.framework.engine.Context的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Context类属于org.kuali.rice.krms.framework.engine包,在下文中一共展示了Context类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: translateContextDefinition

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
@Override
public Context translateContextDefinition(ContextDefinition contextDefinition) {
	if (contextDefinition == null) {
		return null;
	}
	List<Agenda> agendas = new ArrayList<Agenda>();
	for (AgendaDefinition agendaDefinition : contextDefinition.getAgendas()) {
		Agenda agenda = translateAgendaDefinition(agendaDefinition);
		agendas.add(agenda);
	}
	
	List<TermResolverDefinition> termResolverDefs = 
		getTermRepositoryService().findTermResolversByNamespace(contextDefinition.getNamespace());
	
	List<TermResolver<?>> termResolvers = new ArrayList<TermResolver<?>>();

	if (!CollectionUtils.isEmpty(termResolverDefs)) for (TermResolverDefinition termResolverDef : termResolverDefs) {
		if (termResolverDef != null) {
			TermResolver<?> termResolver = translateTermResolver(termResolverDef);
			if (termResolver != null) termResolvers.add(termResolver);
		}
	}
	
	return new BasicContext(agendas, termResolvers); 
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:RepositoryToEngineTranslatorImpl.java

示例2: execute

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
/**
    * execute the engine against a trivial context containing the given agenda.
    * the given agenda qualifier will be used.
    * @param agenda
    * @param agendaQualifiers
    */
private void execute(Agenda agenda, Map<String, String> agendaQualifiers) {
	Map<String, String> contextQualifiers = new HashMap<String, String>();
	contextQualifiers.put("docTypeName", "Proposal");

	List<TermResolver<?>> testResolvers = new ArrayList<TermResolver<?>>();
	testResolvers.add(testResolver);
	
	Context context = new BasicContext(Arrays.asList(agenda), testResolvers);
	ContextProvider contextProvider = new ManualContextProvider(context);
	
	SelectionCriteria selectionCriteria = SelectionCriteria.createCriteria(null, contextQualifiers,
               agendaQualifiers);
	
	ProviderBasedEngine engine = new ProviderBasedEngine();
	engine.setContextProvider(contextProvider);

	// Set execution options to log execution
	ExecutionOptions executionOptions = new ExecutionOptions().setFlag(ExecutionFlag.LOG_EXECUTION, true);
	
	EngineResults results = engine.execute(selectionCriteria, Facts.EMPTY_FACTS, executionOptions);
	assertNotNull(results);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:AgendaTest.java

示例3: execute

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
/**
 * @param agenda
 */
private void execute(Agenda agenda, TermResolver ... termResolvers) {
	Map<String, String> contextQualifiers = new HashMap<String, String>();
	contextQualifiers.put("docTypeName", "Proposal");

	List<TermResolver<?>> testResolvers = Arrays.<TermResolver<?>>asList(termResolvers);
	
	Context context = new BasicContext(Arrays.asList(agenda), testResolvers);
	ContextProvider contextProvider = new ManualContextProvider(context);
	
	SelectionCriteria selectionCriteria = SelectionCriteria.createCriteria(null, contextQualifiers,
               Collections.singletonMap(AgendaDefinition.Constants.EVENT, "test"));
	
	ProviderBasedEngine engine = new ProviderBasedEngine();
	engine.setContextProvider(contextProvider);

	// Set execution options to log execution
	ExecutionOptions executionOptions = new ExecutionOptions().setFlag(ExecutionFlag.LOG_EXECUTION, true);
	
	EngineResults results = engine.execute(selectionCriteria, Facts.EMPTY_FACTS, executionOptions);
	assertNotNull(results);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:CollectionOfComparablesTermBasedPropositionTest.java

示例4: loadContext

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
@Override
public Context loadContext(SelectionCriteria selectionCriteria, Map<Term, Object> facts, ExecutionOptions executionOptions) {
	ContextSelectionCriteria contextSelectionCriteria = constructContextSelectionCriteria(selectionCriteria);
	ContextDefinition contextDefinition = ruleRepositoryService.selectContext(contextSelectionCriteria);
	
	// TODO should have an execution option that throws an error here if a context does not exist?
	
	if (contextDefinition != null) {
		return loadContextFromDefinition(contextDefinition);
	}
	return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:13,代码来源:RuleRepositoryContextProvider.java

示例5: compoundPropositionTest

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
@Test
public void compoundPropositionTest() {

	Proposition prop1 = new ComparableTermBasedProposition(operatorGreaterThan, totalCostTerm, Integer.valueOf(1));
	Proposition prop2 = new ComparableTermBasedProposition(operatorLessThan, totalCostTerm, Integer.valueOf(1000));
	Proposition prop3 = new ComparableTermBasedProposition(operatorGreaterThan, totalCostTerm, Integer.valueOf(1000));
	CompoundProposition compoundProp1 = new CompoundProposition(LogicalOperator.AND, Arrays.asList(prop1, prop2, prop3));
	
	Rule rule = new BasicRule("InBetween",compoundProp1, null);
	
	BasicAgendaTree agendaTree = new BasicAgendaTree(new BasicAgendaTreeEntry(rule)); 
	Agenda agenda = new BasicAgenda(Collections.singletonMap(AgendaDefinition.Constants.EVENT, "test"), agendaTree);
	
	Map<String, String> contextQualifiers = new HashMap<String, String>();
	contextQualifiers.put("docTypeName", "Proposal");
	
	List<TermResolver<?>> testResolvers = new ArrayList<TermResolver<?>>();
	testResolvers.add(testResolver);
	
	Context context = new BasicContext(Arrays.asList(agenda), testResolvers);
	ContextProvider contextProvider = new ManualContextProvider(context);
	
	SelectionCriteria selectionCriteria = SelectionCriteria.createCriteria(null, contextQualifiers,
               Collections.singletonMap(AgendaDefinition.Constants.EVENT, "test"));
	
	ProviderBasedEngine engine = new ProviderBasedEngine();
	engine.setContextProvider(contextProvider);
	
	// Set execution options to log execution
	ExecutionOptions executionOptions = new ExecutionOptions().setFlag(ExecutionFlag.LOG_EXECUTION, true);
	
	EngineResults results = engine.execute(selectionCriteria, Facts.EMPTY_FACTS, executionOptions);
	assertNotNull(results);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:35,代码来源:KRMSTest.java

示例6: loadContextFromDefinition

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
protected Context loadContextFromDefinition(ContextDefinition contextDefinition) {
	return repositoryToEngineTranslator.translateContextDefinition(contextDefinition);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:4,代码来源:RuleRepositoryContextProvider.java

示例7: ManualContextProvider

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
public ManualContextProvider(Context context) {
	this.context = context;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:4,代码来源:ManualContextProvider.java

示例8: loadContext

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
@Override
public Context loadContext(SelectionCriteria selectionCriteria, Map<Term, Object> facts, ExecutionOptions executionOptions) {
	return context;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:5,代码来源:ManualContextProvider.java

示例9: integrationTest

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
@Test
public void integrationTest() {

	// build a simple rule
       ComparisonOperator greaterThan = ComparisonOperator.GREATER_THAN;
       greaterThan.setComparisonOperatorService(ComparisonOperatorServiceImpl.getInstance());
       ComparisonOperator lessThan = ComparisonOperator.LESS_THAN;
       lessThan.setComparisonOperatorService(ComparisonOperatorServiceImpl.getInstance());

	Proposition prop1 = new ComparableTermBasedProposition(greaterThan, totalCostTerm, Integer.valueOf(1));
	Proposition prop2 = new ComparableTermBasedProposition(lessThan, totalCostTerm, Integer.valueOf(1000));
	CompoundProposition compoundProp1 = new CompoundProposition(LogicalOperator.AND, Arrays.asList(prop1, prop2));
	
	Action action1 = new SayHelloAction();
	Rule rule = new BasicRule("InBetween",compoundProp1, Arrays.asList(action1));
	
	BasicAgendaTree agendaTree = new BasicAgendaTree(new BasicAgendaTreeEntry(rule)); 
	Agenda agenda = new BasicAgenda(Collections.singletonMap(AgendaDefinition.Constants.EVENT, "test"), agendaTree);
	
	Map<String, String> contextQualifiers = new HashMap<String, String>();
	contextQualifiers.put("docTypeName", "Proposal");
	
	List<TermResolver<?>> testResolvers = new ArrayList<TermResolver<?>>();
	testResolvers.add(testResolver);
	
	Context context = new BasicContext(Arrays.asList(agenda), testResolvers);
	ContextProvider contextProvider = new ManualContextProvider(context);
	
	SelectionCriteria selectionCriteria = SelectionCriteria.createCriteria(null, contextQualifiers,
               Collections.singletonMap(AgendaDefinition.Constants.EVENT, "test"));
	
	ProviderBasedEngine engine = new ProviderBasedEngine();
	engine.setContextProvider(contextProvider);
	
	// Set execution options to log execution
	ExecutionOptions executionOptions = new ExecutionOptions().setFlag(ExecutionFlag.LOG_EXECUTION, true);
	
	EngineResults results = engine.execute(selectionCriteria, Facts.EMPTY_FACTS, executionOptions);
	assertNotNull(results);
	
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:42,代码来源:ResultLoggingTest.java

示例10: translateContextDefinition

import org.kuali.rice.krms.framework.engine.Context; //导入依赖的package包/类
public Context translateContextDefinition(ContextDefinition contextDefinition); 
开发者ID:kuali,项目名称:kc-rice,代码行数:2,代码来源:RepositoryToEngineTranslator.java


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