DRL always posting the format as txt instead of model.drl
by learnbrms
Hi,
I am using the following code to post or update the DRL using ATOM. But I am
seeing that DRL is always posted and displayed in Guvnor as .txt
(Format:txt) instead of Format:model.drl.
public int createUpdateTextAsset(String assetLoc, String ruleName, String
ruleDescription, String fileToUpload, String requestMethod)
{
System.out.println("--------Begin createUpdateTextAsset ----------");
System.out.println("assetLoc "+assetLoc+"\nruleName
"+ruleName+"\nruleDescription "+ruleDescription+"\nfileToUpload
"+fileToUpload+"\nrequestMethod "+requestMethod);
String authCode = user+":"+password;
StringBuilder content = null;
Scanner scanner = null;
client = WebClient.create(baseURL);
try
{ File f = new File(fileToUpload);
content = new StringBuilder();
String NL = System.getProperty("line.separator");
scanner = new Scanner(new FileInputStream(f));
while (scanner.hasNextLine()) {
content.append(scanner.nextLine() + NL);
}
String ruleContent=content.toString();
String atom = "";
Response response = null;
String authString = "";
authString = "Basic " + org.apache.cxf.common.util.Base64Utility
.encode(authCode.getBytes());
client.header("Authorization", authString);
atom = "<entry xmlns=\"http://www.w3.org/2005/Atom\"
xml:base=\"";
atom += assetLoc;
atom += "\"><title type=\"text\">";
atom += ruleName;
atom += "</title><summary type=\"text\">";
atom += ruleDescription;
atom += "</summary>";
atom +="<metadata>";
atom +="<property name=\"archived\" value=\"false\" />";
atom +="<property name=\"rule-format\" value=\"model.drl\"/>";
atom +="</metadata>";
atom += "<content type=\"application/xml\">";
atom += ruleContent;
atom += "</content></entry>";
System.out.println("Atom :"+atom);
if(requestMethod=="POST"){
response = client.path(assetLoc).type(MediaType.APPLICATION_ATOM_XML)
.header("slug", ruleName+".drl")
.post(atom);
}else{
response = client.path(assetLoc).type(MediaType.APPLICATION_ATOM_XML)
.put(atom);
}
System.out.println("--------End createUpdateTextAsset ----------status
"+response.getStatus());
return response.getStatus();
}
*Output:*
Title: bre-validation-service-processing-model
Categories:
Last modified : 2013-07-17 00:07
by:
Note:
Initial:
Created on:2013-07-17 00:07
Created by:admin
Package:TestPackage6
Edit
Is Disabled:
*Format:txt*
UUID:c8247b22-1a14-4258-9cdf-5033518adf6b
--
View this message in context: http://drools.46999.n3.nabble.com/DRL-always-posting-the-format-as-txt-in...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Business Logic Validation Using Rules
by Shazin Sadakath
Hi
I am currently writing a set of Rules to Validate Some Business Logic and
if The Criteria in When clause is met throw an Exception.
Currently I have two rules. I use a StatelessKnowledgeSession and
CommandExecutor.execute method to fire the rules.
But while testing I created a scenario to fire one of the rules and throw
an exception then created another scenario to not to throw an Exception
(Valid Domain Object). But in this case also it is throwing an Exception
with info related to Failed Domain Object.
Regards,
Shazin Sadakath
12 years, 5 months
Unable to get LastModified for ClasspathResource
by sottostee
Hi everyone,
I have got a problem that me go mad.
Clarify I'm working with a Maven project using Eclipse.
I'm trying to add at my KnowledgeBuilder, after i have correctly created a
new instance of it, a drl file.
In order of this, i call a method: void
org.drools.builder.KnowledgeBuilder.add(Resource arg0, ResourceType arg1),
give it like a Resource "ResourceFactory.newClassPathResource(String: name
of my drl)" and like ResourceType: "ResourceType.DRL".
As long as i run my project into Eclipse, all works well.
But, if i create a jar file of my project, when i run this, i have this
exception:
java.lang.RuntimeException: Unable to get LastModified for ClasspathResource
at
org.drools.io.impl.ClassPathResource.getLastModified(ClassPathResource.java:204)
at
org.drools.io.impl.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.drools.compiler.DrlParser.parse(DrlParser.java:145)
at org.drools.compiler.DrlParser.parse(DrlParser.java:139)
at
org.drools.compiler.PackageBuilder.drlToPackageDescr(PackageBuilder.java:477)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:466)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:694)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:51)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:40)
at rec.reasoner.Reasoner.init(Reasoner.java:192)
at rec.reasoner.Reasoner.<init>(Reasoner.java:176)
at rec.reasoner.Reasoner.newReasoner(Reasoner.java:51)
at rec.model.Model.<init>(Model.java:37)
at rec.controller.Controller.<init>(Controller.java:26)
at applet.Demo.<init>(Demo.java:18)
at applet.Demo.main(Demo.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at
org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.io.FileNotFoundException: 'General_multivalue.drl' cannot be
opened because it does not exist
at
org.drools.io.impl.ClassPathResource.getURL(ClassPathResource.java:165)
at
org.drools.io.impl.ClassPathResource.getLastModified(ClassPathResource.java:177)
... 20 more
line 192 is properly:
'builder.add(ResourceFactory.newClassPathResource("General.drl"),
ResourceType.DRL);'
Well....given that in my project I've got some classes which make use of
images, and given that, in this classes I call this method:
getClass().getResource(String of image).getFile() in order to load the
images, and all seems work very well; therefore I'm doing the same thing
with drl file:
I change the old method with:
builder.add(ResourceFactory.newClassPathResource(getClass().getResource("General.drl").getFile()),
ResourceType.DRL);
Now:
1) when i run jar file, the exception is:
java.lang.NullPointerException
at rec.reasoner.Reasoner.init(Reasoner.java:189)
at rec.reasoner.Reasoner.<init>(Reasoner.java:176)
at rec.reasoner.Reasoner.newReasoner(Reasoner.java:51)
at rec.model.Model.<init>(Model.java:37)
at rec.controller.Controller.<init>(Controller.java:26)
at applet.Demo.<init>(Demo.java:18)
at applet.Demo.main(Demo.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at
org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
2) and when i run the project into Eclipse, the exception is:
java.lang.RuntimeException: Unable to get LastModified for ClasspathResource
at
org.drools.io.impl.ClassPathResource.getLastModified(ClassPathResource.java:204)
at
org.drools.io.impl.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.drools.compiler.DrlParser.parse(DrlParser.java:145)
at org.drools.compiler.DrlParser.parse(DrlParser.java:139)
at
org.drools.compiler.PackageBuilder.drlToPackageDescr(PackageBuilder.java:477)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:466)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:694)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:51)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:40)
at rec.reasoner.Reasoner.init(Reasoner.java:189)
at rec.reasoner.Reasoner.<init>(Reasoner.java:176)
at rec.reasoner.Reasoner.newReasoner(Reasoner.java:51)
at rec.model.Model.<init>(Model.java:37)
at rec.controller.Controller.<init>(Controller.java:26)
at applet.Demo.<init>(Demo.java:18)
at applet.Demo.main(Demo.java:36)
Caused by: java.io.FileNotFoundException:
'/home/ste/workspace2/REC-mv/target/classes/rec/reasoner/General_multivalue.drl'
cannot be opened because it does not exist
at
org.drools.io.impl.ClassPathResource.getURL(ClassPathResource.java:165)
at
org.drools.io.impl.ClassPathResource.getLastModified(ClassPathResource.java:177)
... 15 more
but in '/home/ste/workspace2/REC-mv/target/classes/rec/reasoner/' the file
'General_multivalue.drl' EXISTS!!!!
Are there anyone who help me please?
Thanks in advance.
sotto
--
View this message in context: http://drools.46999.n3.nabble.com/Unable-to-get-LastModified-for-Classpat...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Drools in Hawaii
by Mark Proctor
I'm going to be in Hawaii for 3 weeks in september, visiting honolulu, kauaui and maui.
Is there a Drools community on any of those islands, I could be tempted to attend a user group and do a Drools 6 talk :)
Mark
12 years, 5 months
Drools Fusion in JEE environment
by IK81
Hi all,
i am planning to use the Drools engine in the stream mode within an JEE
application server. I have to process events of different users which can
define their own rules. So I plan to instantiate a stateful session for each
user and populate them with the user's rules. However, I am concerned how to
manage the firing of the rules - which might be delayed by some time because
of some rule statements (fire rule after having event A and no event B
within 3 minutes). Spawning a thread for each session and calling
fireUntilHalt is not an option in my opinion.
I've found a solution where somebody uses a scheduler within the container
to call fireAllRules at certain domain-specific intervals (e.g., every 10
seconds). I am wondering if there is a more clever approach. I am thinking
of providing a callback that can be used by Drools to notify when it has to
be "waked-up" again to fire the delayed rule.
Best regards,
Ingo
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Fusion-in-JEE-environment-tp4025...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Iterating string objects inside Arraylist
by Ganesh R.
I am a novice in Drools, sorry if this question is trivial and has already been discussed. I couldn't find the direct method for implementing the below behavior.
I have a class like this.
public class Account {
public int balance;
public String id;
public List<String> types;
// getter setters
}
I am trying to check the following:
Accounts having balance greater than $100 and types containing both Savings and Checking.
// Creating sample Facts in Java main
Account account = new Account();
account.setBalance(100);
account.setId("A1");
List<String> temp = new ArrayList<String>();
temp.add("Savings");
temp.add("Checking");
account.setTypes(temp);
// Creating rules
rule "Sample"
when
bat : Account(balance == 100)
then
if (bat.getTypes().contains("Savings") && bat.getTypes().contains("Checking")){
System.out.println("I got this");
}
end
Is there more proficient ways to do this?? like checking the contents of the arraylist (types as per the above example) in rule i.e. in "when" instead of doing it in "then" ??
Much appreciate your answers.
Thank you!
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
12 years, 5 months
VRP with multi-stream and heterogeneous fleet?
by Colin Sheppard
Hello all, I'm totally new to optaplanner / drools and would like to know
if the following is possible within the framework (I'd mostly likely use
version 6).
I have a VRP where we'd like to consider multiple waste streams
simultaneously (i.e. trash, recycling, food waste, and yard waste). We'd
also like to consider a fleet of split bin trucks (capable of collecting 2
streams at a time but with reduced capacity), single bin trucks, or a
mixture of split and single bin.
So the model would need to allow for a mixture of vehicle types, for nodes
to be visited more than once, and for simultaneous collection to occur in
the case of split bin trucks.
Does this sound like a feasible problem to implement? Would you anticipate
any major or intractable challenges?
Thanks for your advice, I hope I get the chance to start using optaplanner!
Colin Sheppard
--
Colin Sheppard
Research Engineer,
Schatz Energy Research Center
colin(a)humboldt.edu
707.633.8633
12 years, 5 months
Internet Explorer Compatibility
by rjr201
Hi,
I'm working for a client who wishes to use Guvnor with Internet Explorer.
I've tried Guvnor 5.5.0.Final with IE8 and IE9. However, I get an error when
trying to access a rule in the guided editor.
I read in another post
(http://drools.46999.n3.nabble.com/guvnor-5-5-problems-on-Internet-Explore...)
that there are problems with 5.5.0 in IE, that may have been fixed in the
current 5.5.x branch.
I have built the latest code on the branch, but seem to have even more
problems (it doesn't even let me get to the initial Guvnor landing page).
Does anyone have any experience/insight in getting Guvnor working in IE? Or
at least know what version of Guvnor does work in IE? Or just any advice on
this issue at all I would be grateful..
Thanks in advance,
Rich.
--
View this message in context: http://drools.46999.n3.nabble.com/Internet-Explorer-Compatibility-tp40249...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months