當前位置: 首頁>>代碼示例>>Java>>正文


Java CompoundProposition類代碼示例

本文整理匯總了Java中org.kuali.rice.krms.framework.engine.CompoundProposition的典型用法代碼示例。如果您正苦於以下問題:Java CompoundProposition類的具體用法?Java CompoundProposition怎麽用?Java CompoundProposition使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CompoundProposition類屬於org.kuali.rice.krms.framework.engine包,在下文中一共展示了CompoundProposition類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadProposition

import org.kuali.rice.krms.framework.engine.CompoundProposition; //導入依賴的package包/類
@Override
public Proposition loadProposition(PropositionDefinition propositionDefinition) {
	if (translator == null) {
		throw new IllegalStateException("Service not configured properly, no translator available.");
	}
	if (propositionDefinition == null) {
		throw new IllegalArgumentException("propositionDefinition was null");
	}
	if (PropositionType.COMPOUND != PropositionType.fromCode(propositionDefinition.getPropositionTypeCode())) {
		throw new IllegalArgumentException("Given proposition definition was not compound, type code was: " + propositionDefinition.getPropositionTypeCode());
	}
	List<Proposition> propositions = new ArrayList<Proposition>();
	for (PropositionDefinition subProp : propositionDefinition.getCompoundComponents()) {
		propositions.add(translator.translatePropositionDefinition(subProp));
	}
	LogicalOperator operator = LogicalOperator.fromCode(propositionDefinition.getCompoundOpCode());
	return new CompoundProposition(operator, propositions);
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:19,代碼來源:CompoundPropositionTypeService.java

示例2: compoundPropositionTest

import org.kuali.rice.krms.framework.engine.CompoundProposition; //導入依賴的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

示例3: integrationTest

import org.kuali.rice.krms.framework.engine.CompoundProposition; //導入依賴的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


注:本文中的org.kuali.rice.krms.framework.engine.CompoundProposition類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。