I have a table that has the conditions
size | Type | ID | Materials
1 | 2 | 1 | "Is"
faucet | Empty | Empty | "Default content"
1 | Empty | Empty | "Content for Size 1"
I get each row in the table in the list of objects.
class A {private string size = ""; Private string type = ""; Private string id = ""; Private string content = ""; } The requirement is to show content corresponding to the row that matches the maximum threshold, otherwise show the default message (related to 'blank, empty, null' row).
How can I do this in drools? I'm completely lost.
The data you are receiving as input for your content, slightly inconsistent with this question Looks.
The next thing you need is to show the domain of your problem with those objects. For example, create a pojo called ContentObject with the mapping of properties defining in its input file (note, you need an integer or some things that require compatibility to allow ordering). The next thing will be needed, which is a powzo to catch your maximum (maximum maximum single feature).
Create a stateless knowledge session and populate it with an object. Again, for the purpose of the example, say:
// Increase knowledge base Knowledgebase kbase = read Knowledgebase (); Stateless Knowledge session session ksession = kbase.newStateless knowledge session (); // Create session input objects ContentObject co1 = new content object (0, "T1", "id1", "some content1"); ContentObject co2 = new content object (1, "T2", "id2", "some content2"); ContentObject co3 = new content object (3, "T3", "id3", "some content 3"); Maximum max = new max (); // Set a fact set set & lt; Object & gt; Facts = New Hashtet & Lt; Object & gt; (); Facts.add (CO1); Facts.add (CO2); Facts.add (CO3); Facts.add (max); // run rule ksession.execute (facts); // Display results system.out.println (max.getMax ()); Define the following drool in a separate resouce:
package com. Yurpackage Import com.yourpackage.ContentObject; Quote "mvel" rule "GetMax" when M1: Content object () MX: max (m1.size> max) then mx.max = m1.size; Update (mx); Lastly, I think this thing is not so clear in the terms that how the objects are organized and used in working memory. Dorl's documentation is worth searching for the word "cross product"
Similarly, before you implement this trivial algorithm in Dorolus, note that a liner in Java will do the same thing ( Let's say you're implementing the comparative - CF Collections.
Comments
Post a Comment