Hi all,

Thanks for your suggestions Ernest and Wolfgang, they definitely
helped. I am now using the following rule:

  (defrule check-printout3
    (BooleanPropertyImpl (OBJECT ?property))
    (PageImpl (OBJECT ?container))
    (test
      (member$ ?property (?container getChildren))
    )
    =>
    ((System.out) println "Property with a container:")
    ((System.out) println ?property)
    ((System.out) println "IN:")
    ((System.out) println ?container)
  )

However I am still having a problem with accessing the children of the
object. I now get the following error:

  Jess reported an error in routine Value.listValue
    while executing (member$ ?property(0,4,-1) (call
?container(1,6,-1) getChildren))
    while executing rule LHS (Node2)
    while executing rule LHS (TECT).
    Message: '<Java-Object:org.eclipse.emf.ecore.util.EObjectContainmentEList>'
is JAVA_OBJECT, not  a list.
    at jess.Value.a(Unknown Source)

As the message describes, PageImpl.getChildren() returns an
org.eclipse.emf.ecore.util.EObjectContainmentEList. However, this
object is an object that implements java.util.List and
java.util.Collection, and extends java.util.AbstractList [1].

Any suggestions on how to access the contents of this list? Or do I
need to write some form of a wrapper or translation layer? Thanks for
all your help.

Jevon

[1]: 
http://download.eclipse.org/modeling/emf/emf/javadoc/2.4.2/org/eclipse/emf/ecore/util/EObjectContainmentEList.html

On Sat, Mar 5, 2011 at 1:31 AM, Ernest Friedman-Hill <ejfr...@sandia.gov> wrote:
>
> Hi Jevon,
> Read number 17 in our FAQ: http://www.jessrules.com/jess/FAQ.shtml#Q17
> The right way to write your final rule might be something like this,
> depending on what kind of facts these are:
> (defrule debug-four
> (BooleanPropertyImpl (OBJECT ?property))
> (PageImpl (OBJECT ?container))
> (test (progn
> (bind ?children (get-member ?container children)))
> (member$ ?property ?children)))
> =>
> ((System.out) println "...")
> )
>
> On Mar 4, 2011, at 2:18 AM, Jevon Wright wrote:
>
> Hi all,
>
> I am trying to write a Jess rule program to perform inference on an
> EMF-based model instance. I can successfully load all of the model
> elements into Jess, and check that these facts all exist:
>
> (defrule debug-one
> ?property <- (BooleanPropertyImpl)
> =>
> ((System.out) println "Found property:")
> ((System.out) println ?property)
> )
>
> This rule works fine, and all of the BooleanPropertyImpl in the model
> are found successfully. But I am having trouble with accessing members
> of the elements, using either get-member, or call, or bind.
>
> (defrule debug-three
> ?container <- (BooleanPropertyImpl)
> (bind ?name (get-member ?container name))
> =>
> ((System.out) println "Found name:")
> ((System.out) println ?name)
> )
>
> I expect this to bind object.getName() to ?name, but instead the parse
> fails:
>
> Jess reported an error in routine Jesp.parsePattern.
>  Message: Bad slot value at token '('.
>  Program text: ( defrule debug-three ?container <- (
> BooleanPropertyImpl ) ( bind ?name (  at line 44 in file
> rules/jess-test.clp.
> at jess.Jesp.error(Unknown Source)
>
> What does this mean? Is this a syntax error? Is this an error with my
> Java objects? Am I missing a runtime library? Should I be importing
> other packages? I can't think of any other way to approach this
> problem.
>
> The reason I am using get-member is that I was trying to see if an
> elements' List contains another element:
>
> (defrule debug-four
> ?property <- (BooleanPropertyImpl)
> ?container <- (PageImpl)
> (bind ?children (get-member ?container children)))
> (member$ ?property ?children)
> =>
> ((System.out) println "...")
> )
>
> However, this also fails with the exception above. Any ideas or
> suggestions would be most welcome. :)
>
> Thanks
> Jevon
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
> in the BODY of a message to majord...@sandia.gov, NOT to the list
> (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
> --------------------------------------------------------------------
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs
> PO Box 969, MS 9012                            ejfr...@sandia.gov
> Livermore, CA 94550                             http://www.jessrules.com
>
>
>
>




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to