[rules-users] How to modify changeset.xml in guvnor

rtowler1 rtowler1 at yahoo.com
Sun Sep 5 23:53:42 EDT 2010


Thanks, Problem solved 

I updated the mortgage example to use KnowledgeAgent & ChangeSet.xml (files
included below) & everything works with 5.1 guvnor.

Now if this Pom can only sort out the pom.xml for the fusion examples I'd be
really happy as I could get back to evaluate fusion for use if a project.
I'm fighting against a group that are pushing Progress's CEP but I'm having
problems just getting the fusion example running.

--------------- MortgageApplication.java ----------------------------

package com.notidiots;

import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.definition.type.FactType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatelessKnowledgeSession;

public class MortgageApplicationTest511 {    
	/**
	 * @param args
	 * @throws IllegalAccessException
	 * @throws InstantiationException
	 */
	public static void main(String[] args) throws InstantiationException,
IllegalAccessException {
	    
        KnowledgeAgent ka =
KnowledgeAgentFactory.newKnowledgeAgent("MyAgent");
        ka.applyChangeSet(
ResourceFactory.newFileResource("bin/ChangeSet.xml") );
        KnowledgeBase kb = ka.getKnowledgeBase();

		FactType appType = kb.getFactType("mortgages", "LoanApplication");
		FactType incomeType = kb.getFactType("mortgages", "IncomeSource");

		Object application = appType.newInstance();
		Object income = incomeType.newInstance();

		appType.set(application, "amount", 25000);
		appType.set(application, "deposit", 1500);
		appType.set(application, "lengthYears", 20);

		incomeType.set(income, "type", "Job");
		incomeType.set(income, "amount", 65000);     
        
        StatelessKnowledgeSession ks = kb.newStatelessKnowledgeSession();

        ks.execute( new Object[] {application, income} );
        
        System.out.println(application);
	}
}

-------------------- ChangeSet.xml
----------------------------------------------

<change-set xmlns='http://drools.org/drools-5.0/change-set'
    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
    xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd'
>
    <add>
         <resource
source='http://localhost:8080/drools-5.1.1-guvnor/org.drools.guvnor.Guvnor/package/mortgages/TEST'
         		 type='PKG' basicAuthentication="enabled" username="admin"
password="admin" />
    </add>
</change-set>


----------------------------------------------------------------------------------


-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-modify-changeset-xml-in-guvnor-tp1404619p1424203.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list