Fw: Guvnor Sample Rule
by Sumeet Karawal
Hi
For this I saved the schema (change-set-1.0.0.xsd) on my local machine and
gave the path in the ChangeSet.xml
Now its working fine...
Regards,
Sumeet Karawal
Mailto: sumeet.karawal(a)tcs.com
----- Forwarded by Sumeet Karawal/MUM/TCS on 08/22/2011 03:44 PM -----
From: Sumeet Karawal <sumeet.karawal(a)tcs.com>
To: rules-users(a)lists.jboss.org
Date: 08/18/2011 06:24 PM
Subject: [rules-users] Guvnor Sample Rule
Sent by: rules-users-bounces(a)lists.jboss.org
Hi,
I am trying to create rule in Guvnor and runnig it in Java Application on
Eclipse.
I have gone through the mortgages example provided in the distribution. I
am not sure that I am doing it correctly The steps I did are as follows :
1) Uploaded a POJO jar in Guvnor
2) Created a rule for checking the value of POJO data member
3) Built the package
4) Downloaded the ChangeSet.xml provided
5) Imported that ChangeSet.xml in Eclipse project under com.test package.
6) Created KnowledgeBase and fired the rules
My POJO :
package com.test;
public class CardHolder {
private int accno;
private double discount;
public int getAccno() {
return accno;
}
public void setAccno(int accno) {
this.accno = accno;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
}
My Rule Running Class :
package com.test;
import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.io.Resource;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class Discount_Provider {
public static void main(String[] args) {
CardHolder c1 = new CardHolder();
c1.setAccno(1005);
try{
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
ksession.insert(c1);
ksession.fireAllRules();
System.out.println("The discount applied is : "+
c1.getDiscount());
}
catch (Exception ex)
{
System.out.println("Exception is :
"+ex);
}
}
private static KnowledgeBase readKnowledgeBase()
{
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent
("DiscAgent");
Resource changeset = ResourceFactory.newClassPathResource
("com/test/ChangeSet.xml");
kagent.applyChangeSet(changeset);
KnowledgeBase kbase = kagent.getKnowledgeBase();
kagent.dispose();
return kbase;
}
}
My Rule Content :
1.|rule "Discount_CardHolder"
2.| dialect "mvel"
3.| when
4.| $c : CardHolder( accno > 1001 )
5.| then
6.| $c.setDiscount( 10 );
7.| update( $c );
8.|end
Link from where I download the ChangeSet from Guvnor :
Change Set:
|-------------------------------------------------------------------------------------------------------------------------------------------->
|
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Test...
|
|-------------------------------------------------------------------------------------------------------------------------------------------->
>-------------|
|(Embedded |
|image moved |
|to file: |
|pic19477.gif)|
>-------------|
Contents of 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/...'
>
<add>
<resource
source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Test...'
type='PKG' />
</add>
</change-set>
Errors that I get :
(null: 3, 175): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
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: 3, 175): cvc-elt.1: Cannot find the declaration of element
'change-set'.
(null: 4, 10): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
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: 5, 130): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
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>.
The discount applied is : 0.0
I am not able to get what should be done to make it run properly. Earlier
also I had tried to do this but faced many issues. By referring the
Mortgages example I tried to create the calling class. It would be very
helpful if some body could help me on this.
Thanks & Regards,
Sumeet
Mailto: sumeet.karawal(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
[attachment "pic19477.gif" deleted by Sumeet Karawal/MUM/TCS]
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
14 years, 4 months
Checking for a lack of an object
by Chris Richmond
How do I fire a rule if an object with certain characterstics does not
exists.
For example my class Foo, if I have a rule:
rule "Identify Foos with values"
when
Foo(stringProp=="blah", intProp==5)
then
System.err.println("A Foo was found!");
end
So how do I check for lack of existence of an object with certain
characteristics
I tried:
rule "Flag missing Foos with values"
when
not(Foo(stringProp=="blah", intProp==5))
then
System.err.println("A proper foo does not exist");
end
I also tried:
rule "Flag missing Foos with values"
when
not(exists(Foo(stringProp=="blah", intProp==5)))
then
System.err.println("A proper foo does not exist");
end
14 years, 4 months
Rule(s) based on different (fact) dates (date-effective/date-expired?)
by dhartford
Hey all,
I see a couple of posts in the mailing list/forum around the date-effective
and date-expired.
Forgive my ignorance, I'm still learning as I go, but I have this example
and I'm wondering if that is where I should look, or if that is the wrong
path:
Given the mortgage example, lets say you have LoanApplications come in with
an 'Application Date'.
There may be one rule that has 3 different versions (all versions 'active')
depending on the date of the application, and the application may come in
later, and/or a rule may be a retroactive rule (I just made a new rule, but
it came into effect two days ago (say during a weekend and is only for those
two days), so any ApplicationDate based loan applications that show up on
Monday with dates from the past two days should use that retroactive rule
instead of, potentially, a new 'current' rule).
This is not the same as history (what *was* the rule(s) as of prior Friday),
which is also important, which is why I'm asking if someone has tackled this
area that will help someone new understand the best approach for date-based
rules while understanding/retaining history.
thanks!
-Darren
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-s-based-on-different-fact-dates-da...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 4 months
Do really support the containsKey() function on maps?
by dvsnmurty
Hello all,
I am having trouble with the following drools file:
===========================================================
rule "vam"
when
$pfMapType : MapType( name == "vam" )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
then
$pfMapType.setQueryFilterCheck(true);
end
rule "transport"
when
$pfMapType : MapType( name == "transport" )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
eval(
($ldapResponseMap.get("zimbraMailDeliveryAddress").equals($inputKey)) ||
(($ldapResponseMap.containsKey("zimbraDomainName") == true)
&& ($ldapResponseMap.get("zimbraDomainName").equals($inputKey))) )
then
$pfMapType.setQueryFilterCheck(true);
end
===========================================================
In the above, the rule "vam" works fine. But the rule "transport" never
works. Could it be because of the use of containsKey() function?
Alternatively, I tries replacing the rule "transport" with the following
with no luck still:
===========================================================
rule "transport"
when
$pfMapType : MapType( name == "transport" )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
eval(
($ldapResponseMap.get("zimbraMailDeliveryAddress").equals($inputKey)) ||
(($ldapResponseMap.keySet().contains("zimbraDomainName")) &&
($ldapResponseMap.get("zimbraDomainName").equals($inputKey))) )
then
$pfMapType.setQueryFilterCheck(true);
end
===========================================================
Appreciate your kind attention on this.
Regards,
Murty.
--
View this message in context: http://drools.46999.n3.nabble.com/Do-really-support-the-containsKey-funct...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 4 months
San Francisco Bay Area startup looking for Drools developer
by Roger Smith
San Francisco Bay area based technology startup looking for an experienced
Drools developer.
Must have extensive knowledge on Drools and excellent Java coding skills.
Part time or full time.
Please send me an email if interested.
Roger Smith
rogersmith1711 AT yahoo DOT com
14 years, 4 months
String.format question in the RHS
by Dean Whisnant
Hello,
Can anyone see an issue with the following RHS? The String.format is failing. I've copied it straight into java to verify my intentions and it works there.
What I'm trying to accomplish is to concatenate the string UH005 with a sequence number that is a fixed 10 digits, zero filled. So if CurrentClaimSeq_48 is the number 123, then I expect that TRN02_Check... would be populated with UH0050000000123.
Again, this is working fine in straight java, but not in a rule. What am I missing? Is there a better way to try to accomplish this in a rule?
rule "L1000_TRN02_UHC_BPA"
dialect "mvel"
when
CLM_835_SUPP( seq : currentClaimSeq_48 != ( null ) )
CLM_DET_LOAD( )
trn : x221TransactionHeader_TRN_ReassociationTraceNumber( )
then
trn.setTRN02_CheckOrEftTraceNumber( "UH005" + String.format ("%010d", seq) );
end
Here are the data types of the two fields involved.
private Integer CurrentClaimSeq_48;
public String TRN02_CheckOrEftTraceNumber;
Thank you!
Dean
14 years, 4 months
Guvnor 5.2 and Designer 1.0.0.054 "connection refused"
by dhartford
Hey all,
I'm trying to get the BPMN flow designer installed beside Guvnor on a jboss
5.1 system.
It opens the editor fine, and things look ok until I try to save, at which
point any work done for workflow designing disappears.
I was getting a different connection refused error, which led me to a post
to change the designer.war/profiles/jbpm.xml file, which I did, but still
getting 'connection refused'.
==============
16:37:49,827 INFO [STDOUT] ERROR 18-08 16:37:49,825
(LoggingHelper.java:error:69) Connection refused
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
.....
at
org.drools.guvnor.server.contenthandler.BPMN2ProcessHandler.serialize(BPMN2ProcessHandler.java:149)
at
org.drools.guvnor.server.contenthandler.BPMN2ProcessHandler.storeAssetContent(BPMN2ProcessHandler.java:120)
at
org.drools.guvnor.server.RepositoryAssetOperations.checkinVersion(RepositoryAssetOperations.java:125)
at
org.drools.guvnor.server.RepositoryAssetService.checkinVersion(RepositoryAssetService.java:226)
=======
jbpm.xml file segment:
<externalloadurl protocol="http" host="mypc.domain.com:48080"
subdomain="guvnor/org.drools.guvnor.Guvnor/oryxeditor" usr="guest"/>
========
jboss starting and working through port 48080, with a -b binding for
mypc.domain.com.
Any help would be appreciated, thanks!
-D
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-5-2-and-Designer-1-0-0-054-conne...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 4 months
Planner: Packing items together
by JimK
Working from the cloud computing example I am modifying it as a learning
exercise that might have real world use for a client. The client makes items
that vary in size and weight. I have built rules to handle the weight and
size constraints to optimize loading of a box. Planner does a great job of
optimizing loading of the boxes with those rules. The one sticking point is
a sales order line must be packed in the same box or series of boxes. Can’t
quite get my head around how to craft rule(s) to enforce it.
1. Each order line is a job.
2. Each job is run complete from start to finish.
3. Jobs can be manufactured in any sequence.
4. Weight varies from order line to order line
5. Thickness varies from order line to order line.
6. Items on same order line are identical in thickness and weight.
7. Items are loaded into box as they come off line.
8. Items from different sales order lines can be packed in the same box.
Rules:
1. Total thickness of items in box must not exceed depth of box.
2. Total weight of items in box must not exceed weight capacity of box.
3. All items on the same order line must be packed in same box or sequential
boxes.
Thickness and weight are not always connected in the same direction. A
thicker item can be heavier or lighter than a thinner item.
Goal: Optimize the sequence that sales order lines come off the
manufacturing line to minimize the number of boxes needed without exceeding
depth or weight limitations of box.
Example:
• Order line X for Quantity 100
All in one box, OK
Box 1 100
Box 2 0
Started in Box 1, rest in box 2, OK
Box 1 25
Box 2 75
Box 3 0
Spread over multiple sequential boxes, OK
Box 1 25 (could have other sales order lines)
Box 2 50 (box can only contain Line X)
Box 3 25 (could have other sales order lines)
Some in one box, rest in a non-adjacent box, Not Allowed.
Box 1: 25
Box 2: 0 (box has items from other order lines)
Box 3: 75
This looks to be similar to the lecture compactness goal in the examination
problem. I can almost see what needs to be done but can’t quite articulate
it into rule(s) to ensure an order line has been packed sequentially in a
contiguous series of boxes.
Thanks much for any assistance
Jim Kinneman
--
View this message in context: http://drools.46999.n3.nabble.com/Planner-Packing-items-together-tp326226...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 4 months