本文整理汇总了Java中org.drools.runtime.StatefulKnowledgeSession.startProcess方法的典型用法代码示例。如果您正苦于以下问题:Java StatefulKnowledgeSession.startProcess方法的具体用法?Java StatefulKnowledgeSession.startProcess怎么用?Java StatefulKnowledgeSession.startProcess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.drools.runtime.StatefulKnowledgeSession
的用法示例。
在下文中一共展示了StatefulKnowledgeSession.startProcess方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: testHasRooms
import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@Test
public void testHasRooms() {
MockitoAnnotations.initMocks(this);
when(roomResolver.getAvailableRoomOrDefault(-1)).thenReturn(-1);
StatefulKnowledgeSession ksession = createKnowledgeSession("com/craigstjean/workflow/bpmn/hotel.bpmn");
TestWorkItemHandler testHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", testHandler);
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("roomResolver", roomResolver);
ProcessInstance processInstance = ksession.startProcess("com.craigstjean.workflow.bpmn.hotel", variables);
//assertProcessInstanceAborted(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "StartProcess", "Customer Requests Room");
WorkItem workItem = testHandler.getWorkItem();
assertNotNull(workItem);
assertEquals("Human Task", workItem.getName());
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
//assertProcessInstanceCompleted(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "Clerk Looks for Rooms");
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: startProcess
import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
@Override
@Transactional
public Long startProcess() {
StatefulKnowledgeSession ksession = jbpmService.getSession("com/craigstjean/workflow/bpmn/hotel.bpmn");
ProcessInstance processInstance = ksession.startProcess("com.craigstjean.workflow.bpmn.hotel", null);
return processInstance.getId();
}
示例6: execute
import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
/**
* <p>
* Executes the rules to the extended service periods to calculate their
* interests.
* </p>
*
* @param request
* that contains the extended service periods and the date to
* calculated to.
*
* @return the response of the extended service periods with calculated
* interests.
*
* @throws IllegalArgumentException if the request is null.
* @throws RuleServiceException
* if any error occurs when executing the rule.
*/
@Override
public InterestCalculationResponse execute(InterestCalculationRequest request)
throws RuleServiceException {
// log the entrance
String signature = CLASS_NAME + "#execute(InterestCalculationRequest request)";
LoggingHelper.logEntrance(getLogger(), signature,
new String[] {"request"}, new Object[] {request});
ServiceHelper.checkNull(request, "request");
StatefulKnowledgeSession ksession = null;
KnowledgeRuntimeLogger logger = null;
try {
// start new session and the file logger
ksession = getKnowledgeBase().newStatefulKnowledgeSession();
logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, getKnowledgeLogFileName());
// Set global variables
ksession.setGlobal(INTEREST_CALCULATED_TO_DATE, request.getInterestCalculatedToDate());
// Populate facts
for (ExtendedServicePeriod esp : request.getExtendedServicePeriods()) {
ksession.insert(esp);
}
// start ruleflow process
ksession.startProcess("Interest");
// Fire all rules
ksession.fireAllRules();
// populate the final result
InterestCalculationResponse response = new InterestCalculationResponse();
response.setExtendedServicePeriods(request.getExtendedServicePeriods());
ksession.dispose();
// log and return
LoggingHelper.logExit(getLogger(), signature, new Object[] {response});
return response;
} catch (RuntimeException e) {
// log the exception and wrap it to RuleServiceException
throw LoggingHelper.logException(getLogger(), signature,
new RuleServiceException("Unable to complete rule execution.", e));
} finally {
// closes the resources
if (logger != null) {
logger.close();
}
if (ksession != null) {
ksession.dispose();
}
}
}
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:80,代码来源:InterestCalculationRuleServiceImpl.java
示例7: execute
import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
/**
* <p>
* Executes the rules to the extended service periods to calculate their
* interests.
* </p>
*
* @param request
* that contains the extended service periods and the date to
* calculated to.
*
* @return the response of the extended service periods with calculated
* interests.
*
* @throws IllegalArgumentException if the request is null.
* @throws RuleServiceException
* if any error occurs when executing the rule.
*/
@Override
public InterestCalculationResponse execute(InterestCalculationRequest request)
throws RuleServiceException {
// log the entrance
String signature = CLASS_NAME + "#execute(InterestCalculationRequest request)";
LoggingHelper.logEntrance(getLogger(), signature,
new String[] {"request"}, new Object[] {request});
ServiceHelper.checkNull(request, "request");
StatefulKnowledgeSession ksession = null;
KnowledgeRuntimeLogger logger = null;
try {
// start new session and the file logger
ksession = getKnowledgeBase().newStatefulKnowledgeSession();
logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, getKnowledgeLogFileName());
// Populate facts
for (ExtendedServicePeriod esp : request.getExtendedServicePeriods()) {
ksession.insert(esp);
}
// Set global variables
ksession.setGlobal(INTEREST_CALCULATED_TO_DATE, request.getInterestCalculatedToDate());
// start ruleflow process
ksession.startProcess("Interest");
// Fire all rules
ksession.fireAllRules();
// populate the final result
InterestCalculationResponse response = new InterestCalculationResponse();
response.setExtendedServicePeriods(request.getExtendedServicePeriods());
// log and return
LoggingHelper.logExit(getLogger(), signature, new Object[] {response});
return response;
} catch (RuntimeException e) {
// log the exception and wrap it to RuleServiceException
throw LoggingHelper.logException(getLogger(), signature,
new RuleServiceException("Unable to complete rule execution.", e));
} finally {
// closes the resources
if (logger != null) {
logger.close();
}
if (ksession != null) {
ksession.dispose();
}
}
}
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:76,代码来源:InterestCalculationRuleServiceImpl.java
示例8: execute
import org.drools.runtime.StatefulKnowledgeSession; //导入方法依赖的package包/类
/**
* <p>
* Executes the rules to the service periods to calculate their
* deductions. This methods also merges the service period to extended service period.
* </p>
*
* @param request
* that contains the service periods to calculate.
*
* @return the response of the extended service periods with calculated
* deductions (and also earnings, mid-point etc.).
*
* @throws IllegalArgumentException if the request is null.
* @throws RuleServiceException
* if any error occurs when executing the rule.
*/
@Override
public DeductionCalculationResponse execute(DeductionCalculationRequest request)
throws RuleServiceException {
// log the entrance
String signature = CLASS_NAME + "#execute(DeductionCalculationRequest request)";
LoggingHelper.logEntrance(getLogger(), signature,
new String[] {"request"}, new Object[] {request});
// validate the parameters
ServiceHelper.checkNull(request, "request");
StatefulKnowledgeSession ksession = null;
KnowledgeRuntimeLogger logger = null;
try {
// start new session and the file logger
ksession = getKnowledgeBase().newStatefulKnowledgeSession();
logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, getKnowledgeLogFileName());
// Populate facts
for (ServicePeriod sp : request.getServicePeriods()) {
ksession.insert(sp);
}
// Set global variables
List<ExtendedServicePeriod> esps = new ArrayList<ExtendedServicePeriod>();
ksession.setGlobal(EXTENDED_SERVICE_PERIODS, esps);
ksession.setGlobal(SERVICE_PERIOD_SPLIT_DATES,
servicePeriodSplitDates == null ? Collections.EMPTY_LIST : servicePeriodSplitDates);
// Start deduction process
ksession.startProcess("Deduction");
// Fire all rules
ksession.fireAllRules();
// populate the final result
DeductionCalculationResponse response = new DeductionCalculationResponse();
response.setExtendedServicePeriods(esps);
// log and return
LoggingHelper.logExit(getLogger(), signature, new Object[] {response});
return response;
} catch (RuntimeException e) {
// log the exception and wrap it to RuleServiceException
throw LoggingHelper.logException(getLogger(), signature,
new RuleServiceException("Unable to complete rule execution.", e));
} finally {
// closes the resources
if (logger != null) {
logger.close();
}
if (ksession != null) {
ksession.dispose();
}
}
}
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:80,代码来源:DeductionCalculationRuleServiceImpl.java