How to use Hashtable in Rules Engine. And objects within objects in rules

This is something to do with the JBoss Rules Engine.
I have an object called 'Employee' containing variables name(string), age(int), sex(string), an object Skill and other fields not relevant.
Now the Skill object contains name and desc as variables.
And now i have another seperate object called Test containing two hashtable: inputHT and outputHT.
i have appropriate data in each of the objects and the hashtable:
Employee e = new Employee();
e.setName("Name");
e.setAge(18);
e.setSex("f");
e.getSkill().setSkill("Trainer");
Hashtable ht = new Hashtable();
ht.put("age", new Integer(e.getAge());
ht.put("sex", e.getSex());
Test t = new Test();
t.setInputHT(ht);
Since this is something to do with drools rules: I have the appropriate code even for that.
Like obtaining the rules defined(.drl files) in a stream, constructing the package builder, rulebase and the working memory.
I will now explain u my .drl files(ie the rules that i have defined) and the error that i am encountering
when I have the rule as the following there is no error:
rule "testRule1"
when
e:Employee(age >= 18, sex == "f")
then
System.out.println("The lady can marry");
end
In the above rule we can see that only two simple variables contained in the employee object is being accessed and there is no error encountered.
But when I try to access the object "skill" in the employee object, the rule throws me an error when i am constructing the packageBuilder:
rule "testRule2"
when
e:Employee(skill.name == "Trainer")
then
System.out.println("The skill is trainer");
end
The error thrown is : unexpected token 'skill' and many other dump errors and also error: expected token ')'
I tried changing the when clause as the following:
when
e:Employee(skill.getName() == "Trainer")
and also
when
e:Employee(skill.getName().equals("Trainer"))
All of them throws the same above error.
But at the same time if i access only object without its variables, it is working fine. Like:
rule "testRule2"
when
e:Employee(skill == "Trainer")
then
System.out.println("The skill is trainer");
end
The above rule works properly and does not throw any error. But it is not a valid rule. But syntactically it is correct. and does not throw any error during packageBuilder.
Similarly, the problem is with the Hashtable
The below code works fine, but rulewise it is not valid, but syntactically correct. and does not throw any error
rule "testHT1"
when
t:Test(inputHT == "f")
then
System.out.println("Print this");
end
But the following code throws error, telling unexpected token 'inputHT' :
rule "testHT1"
when
t:Test(inputHT.get("sex") == "f")
then
System.out.println("Lady");
end
I even changed the when clause, but did not get the appropriate result and it threw me error.
when
t:Test(((String)input.get("sex")) == "f")
and also many other variants but of no use.
It would be of great help if u or anyone else could reply to this with some solution
Thank you in advance

http://forum.java.sun.com/thread.jspa?threadID=774018

Similar Messages

  • How to use ssd as boot drive and hdd as storage on a macbook pro 13

    Does anyone know how to use SSD as boot drive and have HDD in optical bay as storage on a Macbook pro 13. I mean in that both drives work as one . by formatting using mac software . I would like to run all programs and OS but would love to have my downloads and useless data on run on my 1tb 5400rpm hdd without me have to manual send it there..

    Does anyone know how to use SSD as boot drive and have HDD in optical bay as storage on a Macbook pro 13. I mean in that both drives work as one
    Each drive mounts as a separate volume. There is no convenient way to make them look like one contiguous volume.*
    Franky, with an hdd and a ssd I would recommend you put your home dir on the hdd and leave the ssd for the OS and your key applications.  It's relatively easy to do and I think better than moving only portions of your stuff.
    How to Move the Home Folder in OS X – and Why
    * There are ways to to make musltiple volumes appear as one large drive but I think it is beyond the scope of this discussion and not appropriate to this configuration.

  • How to use pen tool in Adobe and Illustrator?

    How to use pen tool in Adobe and Illustrator?

    With the pen tool in Indesign, is there a way of making the points not join if you want to make a few single lines?

  • How to use stored procedures in DIAdem and Can the stored procedures be used to return values?

    Can anyone please tell me how to use stored procedures in diadem and to return values from it. Its really important, can you please answer it at the earliest.
    Thanks In advance
    spiya

    Hi Spria,
    I'm very sorry for the mix-up, I thought Allen was going to answer you back with the particulars that we found out. Check out the attached Word document and the below tidbits:
    The built-in DIAdem ODBC functions {SQL_...()} can only call stored functions, which return a scaler result {found then in SQL_Result(1,1)}. The syntax for this with an ORACLE db is
    "select function(parameters) from package"
    ...where package defaults to "dual" if you don't use your own package.
    There might be exceptions to that though, and the syntax will be different for other databases. Note that stored ORACLE procedures can NOT be called from the ODBC functions, instead you must use either ADO function calls in the DIA
    dem VBScript or the OO4O COM wrapper that ORACLE provides (this is described in further detail in the below Word document).
    Hope this helps,
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    Attachments:
    Calling_ORACLE_Stored_Procedures_from_DIAdem.doc ‏28 KB

  • How to use same view as editable and read only in ADF

    Hi,
    how to use same view as editable and read only in ADF ?? How can we achieve this in TF's ???
    -mrudul

    Hi,
    Steven Davelaar wrote a presentation about this "Building Highly Reusable Taskflows"
    Starting slide 14 is where your use case comes into play
    Frank

  • How to use buttons in hcm process and forms?

    Hi Experts,
    I want to know how to use buttons in HCM process and form.
    And when i click on the button it was validating all the fields and it was throwing an error ( complete SACHP fields) i am not using this filed in any where of my form.
    So, please help in getting out of this error. And help me with some document, which method will  trigger once we click on the button.
    Thanks & Regards,
    Rocky

    You do not need to add this field to your list. In the view V_T588MFPROPS (SAP delivered), this field is set as mandatory. In configuration, you must maintain the view V_T588MFPROPC (Customer area) and make sure the field is not set to mandatory. This will override the SAP delivered setting and the error message will be not be displayed.
    Derrick Banks
    Banks & Company, LLC

  • Need help!! How to use super in equals() method and makeCopy() method?

    This is my Name class:
    class Name {
        private String title;
        private String name;
        public Name(){
             title=" ";
             name=" ";
        public Name(String title){
             setTitle(title);
             name=" ";
        public Name(String title,String name){
             setTitle(title);
             setName(name);
        public void setTitle(String title){
             this.title=title;
        public String getTitle(){
             return title;
        public void setName(String name){
             this.name=name;
        public String getName(){
             return name;
        }   This is my Person Class
    class Person extends Name{
        private String address;
        private String tel;
        private String email;     
        public Person(){
             super();
             address=" ";
             tel=" ";
             email=" ";
        public Person(String name){
             super(name);
             address=" ";
             tel=" ";
             email=" ";
        public Person(String title,String name,String addressStr){
             super(title,name);
             setAddress(addressStr);
             tel=" ";
             email=" ";
        public Person(String title,String name,String addressStr,String phoneNum){
             super(title,name);
             setAddress(addressStr);
             setTel(phoneNum);
             email=" ";
        public Person(String title,String name,String addressStr,String phoneNum,String emailStr){
             super(title,name);
             setAddress(addressStr);
             setTel(phoneNum);
             setEmail(emailStr);
        public void setAddress(String add){
             address=add;
        public String getAddress(){
             return address;
        public void setTel(String telephone){
             tel=telephone;
        public String getTel(){
             return tel;
        public void setEmail(String emailAdd){
             email=emailAdd;
        public String getEmail(){
             return email;
         public boolean equals(Person inputRecords){
             boolean equalOrNot=false;
             if(inputRecords.super(getTitle()).equals(title))         //this is wrong
                  if(inputRecords.super(getName()).equals(name))           //this is wrong
                       if(inputRecords.getAddress().equals(address))
                            if(inputRecords.getTel().equals(tel))
                                 if(inputRecords.getEmail().equals(email))
                                      equalOrNot=true;
             return equalOrNot;   
            public void makeCopy(Person copyInto){
                 copyInto.super(setTitle(title));             //this is wrong
                 copyInto.super(setName(name));           //this is wrong
                 copyInto.setAddress(address);
                 copyInto.setTel(tel);
                 copyInto.setEmail(email);
    }How can I correct the wrong part?
    I don't understand how to use super in equals() method and makeCopy() method.

    Try something like this ...
    public boolean equals(Object other) {
      if (other==null || !(other instanceof Person)) return false;
      Person that = (Person) other;
      return getTitle().equals(that.getTitle())
          && getName().equals(that.getName())
          && getAddress().equals(that.getAddress())
          && getTel().equals(that.getTel())
          && getEmail().equals(that.getEmail())
    Notes:
    * This overrides Object's public boolean equals(Object other), which is (probably) what you meant.
    * You don't need to call "super.getWhatever" explicitly... just call "getWhatever" and let java workout where it's defined... this is better because if you then override getTitle() for example you don't need to change your equals method (which you would otherwise probably forget to do, which would probably have some interesting side effects.
    Cheers. Keith.

  • How to use Microsoft Word's Find and Replace with HTML tags?

    Hello to all!
    I'm trying to figure out how to use the find and replace function in Word to replace html tags. I'd like to be able to change something like this:
    <span class="B01-K-ITAL">random text</span>
    To something like this:
    <em>random text</em>
    I want to replace the open and close tags without changing or interfering with the text between the tags. I'm pretty sure I should use wildcards, but I can't figure out how to use them properly.
    Anyone able to lend a hand?

    Here is my latest regular expression with Perl.   I think it matches the spirit of the request in the original post.
    Note, this isn't as easy as you think.  You need to code up the complete set of html rules in you implementation. You need to allow for a certain amount of mal-formed html.
    perl -0660pe 's^<[sS][pP][aA][nN]\s+class="B01-K-ITAL"\s*>(.*?)</[sS][pP][aA][nN]>^<em>$1</em>^gs' i.html >|o.html
    input text
     <html> <head>...</head> <body>I'd like to be able to change something like this: <span class="B01-K-ITAL">#1 one line</span> I want to replace the open and close tags without changing or interfering with the text between the tags. I'm pretty sure I should use wildcards, but I can't figure out how to use them properly. <p>note, this isn't as easy as you think.  You need to code up the complete set of html rules in you implementation. You need to allow for a certain amount of mal-formed html.</p> <span class="B01-K-ITAL">#2 don't be greedy</span> <span class="B01-K-ITAL">$3 multiline text</span> <span class="B01-K-ITAL">#4 multiline tag. I believe html allow a carriage return in white space of tags</span> <span class="B01-K-ITAL">#5 split after the class tag. optional white space</span> <sPan class="B01-K-ITAL">#6 mixed case tag</Span> <p>no text #7</p><span class="B01-K-ITAL"></span> <!-- Apparently, this is valid     http://www.positioniseverything.net/articles/cc-plus.html --> <!--[if IE]> <div id="IEroot"> <![endif]--> <p id="IE">This browser is IE.</p> <p id="notIE">This browser is not IE.</p><!--[if IE]> </div> <![endif]--></body> </html>
    output text
     <html> <head>...</head> <body>I'd like to be able to change something like this: <em>#1 one line</em> I want to replace the open and close tags without changing or interfering with the text between the tags. I'm pretty sure I should use wildcards, but I can't figure out how to use them properly. <p>note, this isn't as easy as you think.  You need to code up the complete set of html rules in you implementation. You need to allow for a certain amount of mal-formed html.</p> <em>#2 don't be greedy</em> <em>$3 multiline text</em> <em>#4 multiline tag. I believe html allow a carriage return in white space of tags</em> <em>#5 split after the class tag. optional white space</em> <em>#6 mixed case tag</em> <p>no text #7</p><em></em> <!-- Apparently, this is valid     http://www.positioniseverything.net/articles/cc-plus.html --> <!--[if IE]> <div id="IEroot"> <![endif]--> <p id="IE">This browser is IE.</p> <p id="notIE">This browser is not IE.</p><!--[if IE]> </div> <![endif]--></body> </html>

  • How To: Use Visual Studio, IIS Express, and Adobe Edge Inspect to view local projects

    You CAN view a Visual Studio project with Adobe Inspect. The work around takes a little bit of time.
    This involves using IIS Express to run your Visual Studio project, which is mainly a setting in Visual Studio, a Firewall change, a few command line and IIS Express config change.  It isn't actually all that bad, but will make your life A LOT easier.
    Here are the steps. (Note these are steps I used for Visual Studio 2012 and your project is part of a solution project.  Windows 7 or Windows 8)
    1. If IIS in not turned on, turn it on.How to: Enable Internet Information Services (IIS) - this should install IIS Express as well.
    2. In Visual Studio, find the port that Visual Studio will be using for your project by Running your web project (Debug), and note/write down/save the port number that shows up in the browser when the project launches. (ex.  http://localhost:12345)
    3. Add a NetShare Reservation (process for this will be different for Windows XP)
    Go to your Command Line (CMD) in Windows and in c:\Windows\system32> type in
    netsh http add urlacl url=http://yourIPaddress:yourPortNumber user=everyone
    (ex. netsh add urlacl url=http://12.34.56.78:12345 user=everyone)
    Hit Enter key. You should be a successful add reservation message
    3. Go to your Windows Explorer (File system) and go to c:/Users/YourName/MyDocuments (or Documents)/IISExpress/config/ and open 'applicationhost.config'
    In the 'applicationhost.config' file find your site in the <sites> section.
    Example:
    <sites>
    <site name="WebSite1" id="1" serverAutoStart="true">
                    <application path="/">
                        <virtualDirectory path="/" physicalPath="C:\MyProjects\TestSite" />
                    </application>
                    <bindings>
                        <binding protocol="http" bindingInformation=":12345:localhost" />
                    </bindings>
                </site>
    </sites>
    In this section ADD 2 new lines to the <bindings> section. Note add your own IP address and your own Computer Name
    <binding protocol="http" bindingInformation="*:12345:12.34.56.78" />
    <binding protocol="http" bindingInformation=":12345:MyComputerName" />
    Save the config file.
    4. Open up your Windows Firewall and go to 'Advanced Settings'. Here you want to create an Inbound Rule.
    Right click on Inbound Rule and select New Rule
    - Rule Type select 'Custom'
    - Program leave this
    - Protocol and Ports > Protocol Type select 'TCP' then Local Port select 'Specific Port' and fill in the port number you got from VS.  Leave Remote Port alone.
    - Scope
    There are a few ways of doing this. Typically you would go the the Remote IP address and select 'These IP addresses: and select ADD > select 'Predefined set of computers' and choose Local Subnet.  IF this does not work leave Remote IP addresses > Any IP address option selected instead.
    - Action leave this
    - Profile select Domain and Private
    - Name put IISExpressWeb for the name
    Select 'Finish'
    5. Go to Visual Studio. (Note if you have multiple projects in your solution, choose your start up project. Right click on your project in Solution Explorer in VS and select 'Set as Start Up Project' )
    Right click on your start up project again and you should see an option to 'Use IISExpress'
    In the DEBUG dropdown (from the main menu bar at the top) select 'YourProjectName Properties'. Mine was the last one in the list with a wrench icon next to it.
    This should open an new tab in your project, You should see a left hand list of option and a right hand column of options.
    In the left column select 'Web' and in this tab select Use Local IIS Web server and select 'Use IIS Express' and type in your IP Address and port number (same as before) in the Project Url text box.
    Save.
    NOW, you should be able to run your project in Visual Studio and use Adobe Edge Inspect on your device and view new results in Chrome. You can develop from there.
    If you still can not see it working, please be sure your device is on the same SubNet or Wireless network as your computer.  If you are in a large network but the domains can still see each other, the Firewall Setting detailed above to allow Any IP Address in your Scope section.

    Hi CMosqueda,
    Thank you for taking time to share this information with other users.
    Thanks,
    Preran

  • How to use an external XSLT engine for Oracle BPEL Process Manager

    Hi,
    is there a way to use an external XSLT engine instead of the build in provided in Oracle BPEL Process Manager?
    The reason is to perform some XSL Transformations that use an OWL Query language.
    Thanks!

    Yes. you can write your own xpath function which can connect to external xslt engine and pass-in your document:
    <copy>
    <from expression="my:myxslt-processor(bpws:getVariableData('var1','part'))"/>
    <to variable="v2" part="payload/>
    </copy>
    The following Thread discusses about how to create an extension xpath function:
    http://forums.oracle.com/forums/thread.jspa?forumID=212&threadID=305548

  • How to use multiple drop down lists and do not allow duplicates.

    I am creating a roster that has multiple positions on multiple pages. I have a drop-down list that is populated with all of the employees and want to make sure that the same employee cannot be selected for multiple posts. Ideally, when one is selected in a position, that person would not be an option in the other drop-down lists. Also, when the form is published, the end user will not use the drop-down lists in order. I have found script to remove selected items, but it only works when the user makes selections in order (List1, List2, List3 etc).
    First time posting, any help would be appreciated.

    Look into the ring control.  It behaves a lot like an enum, but you can dynamically set its contents and values associated with those contents.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to use an external hard drive and copy files to the disk for mac and windows??

    please tell me how to copy files to external hard disk and use it for both mac and windows. there is the fat32 formatting bt i dont wanna use formatting because i already have a lot of content on the exteral hard disk. thank you.

    It is simplest to have the HDD formatted to noe common to both Mac an PC.  ExFAT is one.  But to do that will erase all data on the HDD.
    If the HDD id formatted NTFS, Mac can read but not write to it.  The solution then is to use a third party application such as Paragon or Tuxera which will overcome that obstacle.  These applications do have mixed reviews.
    Ciao.

  • How to use counter as an start and stop trigger in 6009

    Hi ALL.
    I'm using USB 6009 as a subject of to acquire data.
    I would like to know on how to use the counter digital input as a start and stop trigger. 
    The acquisition will only start when the first pulse of the digital signal is received and it will stop when the desired number of pulse is received.
    I was trying to use the VI as attachment as my reference. However, after tried, the VI is not working for USB 6009 as the counter input cannot be used as a trigger.  
    I would be happy if anyone could suggest me some ideas on this matter.
    Thanks.
    Attachments:
    DigitalStartandStopTrigger.vi ‏32 KB

    Hi Kate. 
    Thanks for your response.
    For your information, I've design my VI using the counter method. However, it doesnt work well. Please see the figure below. The file also attached with this reply.
     At first, the first counter from Device 2 will start counting. If the counting equal 0, then the acquisition for Device 1/AIO also the counter of Device 1/ctr0 begin acquiring data and counting the edges respectively.
    However, when I did the test, it doesn't work as wanted. It is happened because when counter of device 2 in not equal to 0, the acquisition for Device 1 not happened as it will go to false state.
    Is there anything that someone could suggest on how to start the acquisition for device 1 only and if the counter of device 2 is equal to 1. I would like the acquisition of device 1 start only when the counter of device 2 is equal to 1. I cannot use the trigger as 6009 is not support for it. 
    -Fird- 
    Message Edited by Fird on 07-02-2009 04:28 AM
    Attachments:
    Acquire Data Test 4.vi ‏27 KB

  • 32gig Memory on Macpro 8 Core - How to use it all the memory and processor speed

    Hello Everyone,
    I was wondering if any of you out there know a way to have my Mac Pro use more of the memory it has. I have 32gig of memory and I would like to have it use more processor power and memory if possible. I am aware you can use the "renice -10 -p PIDNUMBER"
    How can I make it use more of the processors and memory my machine has. Ex. Running Photoshop or Final Cut, Imovie etc.

    Using the Unix nice command raises the priority of a process, but software will use the amount of memory it needs.  You cannot make a program use memory it does not need.  Same with processor cores, if software is written to use only one processor or core you cannot make it use more, the software has to be designed for multi-threading to do that.

  • How to use the method calendar.getTimeInMillis() and setTimeInMillis(bb)

    I have met some problems in writing my programme,I want to know what the time is after every 20 minutes so have written some codes as below ,but the compilar warned me that there are some errors in them ,and I don't know how to use them correctly ,can you help me?
    Thank you very much!
    the code is:
    begin=datime+" 00:00:00";
    Calendar calendar=Calendar.getInstance();
    DateFormat df = DateFormat.getDateInstance();
    Date start=df.parse(begin);
    calendar.setTime(start);
    long aa=calendar.getTimeInMillis();
    calendar.setTimeInMillis(aa);

    Hopefully the following snippet of code will help you out (note that the Date class seems more appropriate for what you need to do):
    import java.util.*;
    import java.text.*;
          String begin="00:00:00";
          SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
          df.setTimeZone(TimeZone.getTimeZone("GMT"));
          Date start=new Date();
          try {
             start=df.parse(begin);
          } catch (Throwable e) {
             System.out.println("Invalid time format");
          long aa=start.getTime();   // to get the time in milliseconds
          System.out.println(aa);    // just to see what the answer is (should be zero)
          start.setTime(aa);         // to set the time in milliseconds
    ...V.V.

Maybe you are looking for

  • Final Cut Client not playing Quicktime

    I have an end user trying to use FCS on a PC. The QT movies play for almost 2 minutes and then stop. This is true for multiple clips. She has FCS properly installed with IE*, Java 6 and QT 7.6.2. These clips work on my PC and others PC's. Any suggest

  • TreeCell Factory causing leak

    Hi, I have read few articles related to memory leak on tree cell factory and also read their work around by using weak binders. My question is that I am creating a tree on start up using custom cell factory which works perfectly fine without showing

  • Need help with voltage counter

    I have a system that passes current through a resistor when ever a button is pushed.  The voltage across the resistor (about 100mV) is read by a cFP-AI-102 Analog Input voltage module.  I'm trying to figure out a way to count the number of times this

  • Why my ipad devices no show in itunes?

    why i my batteries is not charging,no recognized any charger. devices dont shoe in Itunes

  • Re: StartHtm MFC when installing Online Manual

    Did anyone ever resolve this problem? I have windows 8.1 - 64bit I have the canon mx890 printer / scanner When I run the setup  software I get the error: starthtm mvc has stopped working It actually finishes running and I can print however I do not h