[rules-users] Drools 5.0 concat string in matches of regular expression

Lukas Svoboda lukasvoboda at googlemail.com
Wed Jan 13 11:54:55 EST 2010


I'm getting some generic not-anything-saying error message:
     [java] Unable to determine the used declarations.
     [java] unexpected symbol ' ' : [Rule name='BL: Block mail domain']

When I remove that concatenated matches expression (".*@" +
blacklistItemValue + ".*") it compiles.

Complete rule looks like:
rule "BL: Block mail domain" ruleflow-group "black-list"
salience 1001
	when
		not RejectionResult();
		
		customer : CustomerPartyDRL();
		blackList: BlacklistDRL();

		onBlackList : ArrayList( size > 0 ) 
               from collect( BlacklistItemDRL( blacklistItemType matches
"MAIL_DOMAIN" && customer.currentContactInformation.partyEmailAddress.email
matches blacklistItemValue )
                             from blackList.getItems())
	then 
		auditLogger.addDeclineRule( "BL: Block mail domain " + 
		
customer.getCurrentContactInformation().getPartyEmailAddress().getEmailLowercase()); 
		
		RejectionResult rejection = new OrderRejectionResult( );
		rejection.setMessage("BL: Block mail domain " + 
		
customer.getCurrentContactInformation().getPartyEmailAddress().getEmailLowercase());
		
		insert( rejection  );
		
end


And fragment of the code I'm using to compile rule package is:

		Reader testSource = new
InputStreamReader(RuleCompiler.class.getResourceAsStream("/perthTestRule.drl"));
		Reader sourceFlow = new
InputStreamReader(RuleCompiler.class.getResourceAsStream("/perthScoreCustomerFlow.rf"));

		// add the package to a rulebase (deploy the rule package).
		KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
		KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

		kbuilder.add(ResourceFactory.newReaderResource(testSource),
ResourceType.DRL);
		kbuilder.add(ResourceFactory.newReaderResource(sourceFlow),
ResourceType.DRF);

		System.out.println(kbuilder.getErrors().toString());

		Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();

		try {
			kbase.addKnowledgePackages(pkgs);

			StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

			System.out.println("Knowladge session initialized...");
		} catch (Exception e) {
			e.printStackTrace();
		}


Edson Tirelli-4 wrote:
> 
>    It should work... what error do you see?
> 
>    Edson
> 
> 2010/1/13 Lukas Svoboda <lukasvoboda at googlemail.com>
> 
>>
>> How can I get drools 5.0.1 compiled if I have regular expression matches
>> part
>> concat from static text + dynamic string?
>>
>> See example:
>>                onBlackList : ArrayList( size > 0 )
>>               from collect( BlacklistItemDRL( blacklistItemType matches
>> "MAIL_DOMAIN" &&
>> customer.currentContactInformation.partyEmailAddress.email
>> matches (".*@" + blacklistItemValue + ".*") )
>>                             from blackList.getItems())
>>
>>
>> Problem is when I'm trying to do email matches (".*@" +
>> blacklistItemValue
>> +
>> ".*"), which worked in drools 4.0.7 but can't be compiled now in 5.0.1
>>
>> Is there any way how to use in matches part of reg exp dynamic property
>> value plus static string?
>>
>> Thanks,
>> Lukas
>> --
>> View this message in context:
>> http://n3.nabble.com/Drools-5-0-concat-string-in-matches-of-regular-expression-tp119197p119197.html
>> Sent from the Drools - User mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> 
> 
> 
> -- 
>  Edson Tirelli
>  JBoss Drools Core Development
>  JBoss by Red Hat @ www.jboss.com
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://n3.nabble.com/Drools-5-0-concat-string-in-matches-of-regular-expression-tp119197p119353.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list