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


Java KnowledgeAgentFactory.newKnowledgeAgentConfiguration方法代碼示例

本文整理匯總了Java中org.drools.agent.KnowledgeAgentFactory.newKnowledgeAgentConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java KnowledgeAgentFactory.newKnowledgeAgentConfiguration方法的具體用法?Java KnowledgeAgentFactory.newKnowledgeAgentConfiguration怎麽用?Java KnowledgeAgentFactory.newKnowledgeAgentConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.drools.agent.KnowledgeAgentFactory的用法示例。


在下文中一共展示了KnowledgeAgentFactory.newKnowledgeAgentConfiguration方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkConfiguration

import org.drools.agent.KnowledgeAgentFactory; //導入方法依賴的package包/類
/**
 * <p>
 * Check if all fields are initialized properly.
 * </p>
 * <p>
 * In this class, this method will check if the servicePeriodSplitDates contains null.
 * </p>
 * 
 * @throws OPMConfigurationException if any needed field is not
 * initialized properly.
 * @since 1.1 OPM - Rules Engine - Scenarios Conversion 2 - Deduction Update Assembly
 */
@Override
@PostConstruct
public void checkConfiguration() {
    super.checkConfiguration();
    if (this.entityManager == null) {
        throw new OPMConfigurationException("entityManager cannot be null.");
    }
    if (servicePeriodSplitDates != null) {
        for (Date date : servicePeriodSplitDates) {
            if (date == null) {
                throw new OPMConfigurationException("Items in servicePeriodSplitDates list cannot be null.");
            }
        }
    }
    if (this.deductionTableTemplate == null) {
        throw new OPMConfigurationException("deductionTableTemplate cannot be null.");
    }
    try {
        // Generate deduction table
        this.generateDeductionTable();

        // Initialize knowledge agent
        KnowledgeAgentConfiguration config = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
        // We have to set the newInstance property to false so that the knowledge base changes can be reflected
        config.setProperty("drools.agent.newInstance", "false"); 
        KnowledgeAgent knowledgeAgent = KnowledgeAgentFactory.newKnowledgeAgent("deductionKnowledgeAgent", config);
        
        // Substitute the classpath resource location with the file system resource location
        String changeSet = ServiceHelper.inputStreamToString(
                ResourceFactory.newClassPathResource("deduction-change-set.xml").getInputStream());
        changeSet = changeSet.replace("classpath:rules/deduction_table.xls",
                "file:" + this.deductionTableTemplate.getDecisionTableFile());
        knowledgeAgent.applyChangeSet(ResourceFactory.newByteArrayResource(changeSet.getBytes("utf-8")));
        this.setKnowledgeAgent(knowledgeAgent);
    } catch (IOException e) {
        throw new OPMConfigurationException("Failed to initialize KnowledgeAgent.");
    }
}
 
開發者ID:NASA-Tournament-Lab,項目名稱:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代碼行數:51,代碼來源:DeductionCalculationRuleServiceImpl.java

示例2: checkConfiguration

import org.drools.agent.KnowledgeAgentFactory; //導入方法依賴的package包/類
/**
 * <p>
 * Check if all fields are initialized properly.
 * </p>
 * 
 * @throws OPMConfigurationException if any needed field is not
 * initialized properly.
 */
@Override
@PostConstruct
public void checkConfiguration() {
    super.checkConfiguration();
    if (this.entityManager == null) {
        throw new OPMConfigurationException("entityManager cannot be null.");
    }
    if (this.csrsInterestTemplate == null) {
        throw new OPMConfigurationException("csrsInterestTemplate cannot be null.");
    }
    if (this.csrsPeaceCorpsInterestTemplate == null) {
        throw new OPMConfigurationException("csrsPeaceCorpsInterestTemplate cannot be null.");
    }
    if (this.csrsRedepositInterestTemplate == null) {
        throw new OPMConfigurationException("csrsRedepositInterestTemplate cannot be null.");
    }
    if (this.fersInterestTemplate == null) {
        throw new OPMConfigurationException("fersInterestTemplate cannot be null.");
    }
    if (this.fersPeaceCorpsInterestTemplate == null) {
        throw new OPMConfigurationException("fersPeaceCorpsInterestTemplate cannot be null.");
    }
    if (this.fersRedepositInterestTemplate == null) {
        throw new OPMConfigurationException("fersRedepositInterestTemplate cannot be null.");
    }
    try {
        // Generate interest tables
        this.generateInterestTables();

        // Initialize knowledge agent
        KnowledgeAgentConfiguration config = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
        // We have to set the newInstance property to false so that the knowledge base changes can be reflected
        config.setProperty("drools.agent.newInstance", "false"); 
        KnowledgeAgent knowledgeAgent = KnowledgeAgentFactory.newKnowledgeAgent("interestKnowledgeAgent", config);
        
        // Substitute the classpath resource location with the file system resource location
        String changeSet = ServiceHelper.inputStreamToString(
                ResourceFactory.newClassPathResource("interest-change-set.xml").getInputStream());
        changeSet = changeSet.replace("classpath:rules/csrs_interest.xls",
                "file:" + this.csrsInterestTemplate.getDecisionTableFile());
        changeSet = changeSet.replace("classpath:rules/csrs_peacecorps_interest.xls",
                "file:" + this.csrsPeaceCorpsInterestTemplate.getDecisionTableFile());
        changeSet = changeSet.replace("classpath:rules/csrs_redeposit_interest.xls",
                "file:" + this.csrsRedepositInterestTemplate.getDecisionTableFile());
        changeSet = changeSet.replace("classpath:rules/fers_interest.xls",
                "file:" + this.fersInterestTemplate.getDecisionTableFile());
        changeSet = changeSet.replace("classpath:rules/fers_peacecorps_interest.xls",
                "file:" + this.fersPeaceCorpsInterestTemplate.getDecisionTableFile());
        changeSet = changeSet.replace("classpath:rules/fers_redeposit_interest.xls",
                "file:" + this.fersRedepositInterestTemplate.getDecisionTableFile());
        knowledgeAgent.applyChangeSet(ResourceFactory.newByteArrayResource(changeSet.getBytes("utf-8")));
        this.setKnowledgeAgent(knowledgeAgent);
    } catch (IOException e) {
        throw new OPMConfigurationException("Failed to initialize KnowledgeAgent.");
    }
}
 
開發者ID:NASA-Tournament-Lab,項目名稱:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代碼行數:65,代碼來源:InterestCalculationRuleServiceImpl.java


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