Invocation Patterns
by Kenneth May
You are correct, Drools Flow may not be the best choice of technology.
I could certainly write what is required in core Java very easily!
However, there are a few reasons why this was my intended approach:
1) A large degree of flexibility may be required in the future. I
like the concept of being able to change or apply new logic fairly
easily.
2) Out of the box business activity monitorring is appealing
3) I'm keen to explore BPM and rules technology in more depth
4) The discussion in this (admittedly old) article suggested jBPM may
be a good fit: http://community.jboss.org/wiki/JBossRulesjBPMSQLorJava.
My understanding is that Drools Flow is an alternative to jBPM and
from what I can tell has a far better integration with rules.
That said: I'm not adverse to alternative approaches if what I'm
planning doesn't sound like a good fit. What I need to do is
essentially pretty simple: take a file and process it through several
steps (with some logic deciding which steps are relevant).
Thanks for your help!
Ken
14 years, 3 months
Help : Enabling Role Base Authorization in Guvnor
by Han Ming Low
Hi all,
I try to enable the Role Base Authorization in Guvnor after it was running
fine with the default login mechanism.
But, encountered some problem with the attempt.
What I did was that in the components.xml,
- commented out the default <security:identity
authenticate-method="#{defaultAuthenticator.authenticate}"/>
- uncomment the <security:identity
authenticate-method="#{authenticator.authenticate}"
jaas-config-name="other"/>
- change the role base authorization to true,
<security:role-based-permission-resolver
enable-role-based-authorization="true"/>
And at the login-config.xml
I have changed the "other" application policy to
<application-policy name = "other">
<authentication>
<login-module code =
"org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required" >
<module-option
name="usersProperties">props/guvnor-users.properties</module-option>
<module-option
name="rolesProperties">props/guvnor-roles.properties</module-option>
</login-module>
</authentication>
</application-policy>
guvnor-users.properties
admin=admin12
krisv=krisv
john=john
mary=mary
guvnor-roles.properties
admin=admin
krisv=admin,manager,user
john=admin,manager,user
mary=admin,manager,user
After restarting JBoss, I can login based on the user and password defined
in the guvnor-users.properties.
And, by changing the password in the properties, I verified that it is
taking in the value from the file itself.
However, when I login as user admin and tried to access the Administration |
User Permission or Event Log,
I'm prompt "Sorry, insufficient permissions to perform this action."
The error from the console is
11:15:36,046 INFO [STDOUT] ERROR 29-07 11:15:36,046
(LoggingHelper.java:error:76)
Service method 'public abstract java.util.Map
org.drools.guvnor.client.rpc.RepositoryService.listUserPermissions()
throws org.drools.guvnor.client.rpc.DetailedSerializationException'
threw an unexpected exception:
org.jboss.seam.security.AuthorizationException:
Authorization check failed for
permission[org.drools.guvnor.server.security.AdminType@bf7a4d,admin]
org.jboss.seam.security.AuthorizationException: Authorization check failed
for permission[org.drools.guvnor.server.security.AdminType@bf7a4d,admin]
at
org.jboss.seam.security.Identity.checkPermission(Identity.java:581)
at
org.drools.guvnor.server.ServiceImplementation.listUserPermissions(ServiceImplementation.java:2604)
.....
Checking on the org.drools.guvnor.server.security.RoleTypes code, the
available role should be
admin
analyst
analyst.readonly
package.admin
package.developer
package.readonly
Can anyone help to let me know what's wrong with my configuration?
Thanks.
Han Ming
14 years, 3 months
Need help to call method with input parameter and return type
by Sanjib Karmakar
Hi
I am new in drools. In my project I have to call the method define in xml
rule file using java
## Following is my rule xml
<?xml version="1.0" encoding="UTF-8"?>
<package name="com.sample"
xmlns="http://drools.org/drools-5.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0 drools.org/drools-5.0.xsd">
<import name="com.skyfusion.dto.FlifoDTO" />
<global identifier="flifoDTO" type="com.skyfusion.dto.FlifoDTO" />
<function return-type="FlifoDTO" name="show">
<parameter identifier="appId" type="FlifoDTO.appId"/>
<body>
System.out.println("appId " + appId);
if(appId==2)
{
flifoDTO.setChnlName("SKYFUSION.UNI.SIMU.TXT.QUEUE");
}
if(appId==3)
{
flifoDTO.setChnlName("SKYFUSION.BASE.MSGFLTR.TXT.TOPIC");
}
</body>
</function>
<rule name="Find Channel">
<lhs>
<pattern identifier="flDTO" object-type="FlifoDTO" >
<field-constraint field-name="flifoType">
<qualified-identifier-restriction
evaluator="==">FlifoDTO.FLIFO</qualified-identifier-restriction>
</field-constraint>
<field-binding field-name="appId" identifier="ruleDTO"/>
</pattern>
</lhs>
<rhs>
//System.out.println(ruleDTO);
System.out.println("Find Channel");
//show(appId);
</rhs>
</rule>
</package>
## Following is my DTO class
package com.skyfusion.dto;
public class FlifoDTO
{
public static final int FLIFO = 1;
private String ruleId;
private int appId;
private int flifoType;
private String chnlName;
public FlifoDTO() {
}
public int getAppId() {
return appId;
}
public void setAppId(int appId) {
this.appId = appId;
}
public String getChnlName() {
return chnlName;
}
public void setChnlName(String chnlName) {
this.chnlName = chnlName;
}
public void setRuleId(String ruleId) {
this.ruleId = ruleId;
}
public String getRuleId() {
return ruleId;
}
public int getFlifoType() {
return flifoType;
}
public void setFlifoType(int flifoType) {
this.flifoType = flifoType;
}
}
## Following is my rule execution class
package com.skyfusion.rule.handler;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import com.skyfusion.dto.FlifoDTO;
public class RuleHandler {
private StatefulKnowledgeSession ksession = null;
private KnowledgeBase kbase = null;
public RuleHandler()
{
try {
// load up the knowledge base
kbase = readKnowledgeBase();
ksession = kbase.newStatefulKnowledgeSession();
} catch (Exception t) {
t.printStackTrace();
}
}
private KnowledgeBase readKnowledgeBase()
throws Exception
{
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("fliforule.xml"),
ResourceType.XDRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.out.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
public FlifoDTO initMessage(String ruleID, FlifoDTO flDTO, int appId, int
type)
throws Exception
{
FlifoDTO flifoDTO = flDTO;
try
{
flifoDTO.setRuleId(ruleID);
flifoDTO.setAppId(appId);
flifoDTO.setFlifoType(type);
ksession.insert(flifoDTO);
ksession.fireAllRules();
}catch(Exception t)
{
t.printStackTrace();
}
return flifoDTO;
}
public static void main(String args[]){
RuleHandler rh = new RuleHandler();
FlifoDTO flifoDTO = new FlifoDTO();
try {
flifoDTO = rh.initMessage("Find Channel",flifoDTO,2,1);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(flifoDTO.getChnlName());
}
}
## I am getting the following exception
java.lang.IllegalArgumentException: Could not parse knowledge.
at
com.skyfusion.rule.handler.RuleHandler.readKnowledgeBase(RuleHandler.java:45)
at com.skyfusion.rule.handler.RuleHandler.<init>(RuleHandler.java:28)
at com.skyfusion.rule.handler.RuleHandler.main(RuleHandler.java:71)
java.lang.NullPointerException
at com.skyfusion.rule.handler.RuleHandler.initMessage(RuleHandler.java:61)
at com.skyfusion.rule.handler.RuleHandler.main(RuleHandler.java:74)
(null: 29, 54): schema_reference.4: Failed to read schema document
'drools.org/drools-5.0.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>.
(null: 31, 60): schema_reference.4: Failed to read schema document
'drools.org/drools-5.0.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>.
(null: 34, 7): schema_reference.4: Failed to read schema document
'drools.org/drools-5.0.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>.
Error importing : 'com.sample.Show.show'
[ show : unable to resolve type while building function
]
[ show : Function Compilation error
show (line:-2): FlifoDTO.appId cannot be resolved to a type
show (line:3): flifoDTO cannot be resolved
show (line:7): flifoDTO cannot be resolved
]
[ show : Function Compilation error
show (line:-2): FlifoDTO.appId cannot be resolved to a type
show (line:3): flifoDTO cannot be resolved
show (line:7): flifoDTO cannot be resolved
]
Rule Compilation error : [Rule name='Find Channel']
com/sample/Rule_Find_Channel_0.java (2:89) : The import com.sample.Show
cannot be resolved
Error importing : 'com.sample.Show.show'
null
## Please let me know I am missing.
Thanks in advance
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Need-help-to-call-met...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
Guvnor BRL format
by Sreenath Putta
Hi,
I have couples of questions regarding Guvnor BRL format:
We have a requirement to store the rules in XML format, for that we are
planning to use Guvnor Brl format.Right now Guvnor BRL format does not
support for defining Event correlation part (Temporal reasoning part). we
would end up something like putting these event correlation part in a
freeform.
First thing is will there be any support for event correlation in Guvnor in
near future?
If not we are willing to contribute for that effort. we just wanted to find
out what exactly is the process for going forward and defining these
elements?
Thanks,
Sreenath
14 years, 3 months
Failed to read schema document when trying to transform from XML to DRL
by Chang Liu
Hi there,
Error message:
(null: 5, 77): schema_reference.4: Failed to read schema document 'drools.org/drools-5.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
I ran into this issue when experimenting a project that transforming the rules back and forth from DRL to XML with utility classes as documented in following link:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/ht...
My code:
...
XmlPackageReader xmlReader = new XmlPackageReader(null);
StringReader sr = new StringReader(rulesInXml);
try {
PackageDescr packageDescr = xmlReader.read(sr);
DrlDumper drlDumper = new DrlDumper();
String drlString = drlDumper.dump(packageDescr);
}
catch (Exception ex) {
System.out.println(ex);
}
...
where string "rulesInXml" is the result xml string transformed from a valid .drl file. It looks like:
<?xml version="1.0" encoding="UTF-8"?>
<package name="com.sample"
xmlns="http://drools.org/drools-5.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0 drools.org/drools-5.0.xsd">
<import name="com.sample.DroolsTest.Message" />
<rule name="Hello World">
<lhs><pattern identifier="m" object-type="Message" >
<field-constraint field-name="status">
<qualified-identifier-restriction evaluator="==">Message.HELLO </qualified-identifier-restriction>
</field-constraint>
<field-binding field-name="message" identifier="myMessage" />
</pattern>
</lhs>
<rhs> System.out.println( myMessage );
m.setMessage( "Goodbye cruel world" );
m.setStatus( Message.GOODBYE );
update( m );
</rhs>
</rule>
<rule name="GoodBye">
<lhs><pattern object-type="Message" >
<field-constraint field-name="status">
<qualified-identifier-restriction evaluator="==">Message.GOODBYE </qualified-identifier-restriction>
</field-constraint>
<field-binding field-name="message" identifier="myMessage" />
</pattern>
</lhs>
<rhs> System.out.println( myMessage );
</rhs>
</rule>
</package>
What did I miss here?
Moreover, the Drools 5.0 API's for XML support are poorly-documented. For example, the constructors of class "XmlPackageReader" has an arg of "SemanticModules" type which is not documented. :(
Any help would be highly appreciated!
Thanks,
Chang
**********************************************************************
CONFIDENTIALITY NOTICE: The information contained in this email is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, dissemination, distribution or copying of this communication is prohibited and may be subject to legal restriction or sanction. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of the information and all copies. If you are the intended recipient but do not wish to receive communications through this medium, please advise the sender immediately. Thank you
14 years, 3 months
Drool Guvnor-Accessing Rules which are expired to do back dated calculations
by Minal Sarmokadam
Hi,
I am evaluating Drool Gunvor for to implement Rules for some finance related functionality.
I need help from users to implement following scenario is Drools-Guvnor
I have created simple Rule to Calculate House Rent Allowance i.e. HRA as
HRA = 0.12 * Basic salary .(Basic will come as Input Parameter).
This rule is valid from e.g. 01-Jan-2005 to 31-July-2010 as HRA rule is changed from 1st Aug 2010
I will have to create new Rule for HRA Rule with new formula as
HRA = 0.15 * Basic salary .(Basic will come as Input Parameter).
This rule is valid from 01-Aug-2010 to 01-Aug-2999
>From 1st Aug HRA should be calculated using New Rule. But at the same time if any Arrears to be calculated(back dated calculation) depending on the date old HRA rule should be applicable.I would need this to calculate Arrears i.e. doing backdated calculations
Can I achieve this in Gunor Drool. I could achieve first half by specifying date-expires . But I am not able to achieve second half i.e. referring old rule depending on the date. I would appreciate help to solve this problem .
Thanks in advance.
Regards
Minal S
________________________________
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
14 years, 3 months
How to write a simple DSL which can be used in setting / comparing the value prsent in hashmap
by bbarani
Hi,
I have created a very simple DSL file as below. It just reads the data from
hashmap and sets the decision based on the key value present in the hashmap
passed to Guvnor.
[consequence][]Decision for DynamicValue is set as
Denied=dec.setDecision("Denied");
[condition][]Decision Object=dec:Decisions()
[condition][]Map Object=mp:DynMap()
[condition][]Evaluate Dynamic value of
rules=eval(mp.getMap().get("AssetID").toString().trim()=="8-AIT-3243")
I now want to create a rule such that I am able to enter both LHS and RHS
dynamically and the rule will fetch the data based on the key value..
something like below
When dynamicAttribute("Assetid")="23" then System.out.println(Sucess); else
dynamicAttribute("repoid")="23" then System.out.println(Sucess);
end
My DSL works fine now just tht I want to make it more user frindly and want
the dynamic attribute to be listed in the dropdown for users to select it ..
Thanks,
BB
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-simple...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 4 months
.drl Rules without Java
by Baig, Kaleem
---------
There is a list of objects.
Each object has a property "score".
We need to select three objects with the highest scores.
How to create this rule in Guvnor (This would be easy in Java, but we want no code in the rules)?
Thank you!!!
14 years, 4 months