I have the following design problem and possible solution, but I'm
hoping that maybe I'm overlooking something obvious (and more
straightforward):
We have a system that inputs elements that have variable
attributes. There is a known list of "legal" attributes at runtime,
but not during development. The Java class representing this element
has a HashTable that holds the attribute values keyed on the attribute
name. The accessor function for an attribute is
public String getAttributeValue(String attributeName);
We would like the end-user of our system to be able to write Jess
rules that use all of the legal attributes. Since we cannot define
bean pattern accessor methods at development time, we need some way
to either do this definition at runtime, or to access these varied
attributes through a single slot in JESS.
My partial solution would be to have a single attribute that is
multivalued (think of an association list) and have the rules written
like
(defrule match-on-attribute-values ...
(element (OBJECT ?element)
(attribute $?front SOMEATTRIBUTENAME ?attribute_value1
$?unneeded ANOTHERATTRIBUTENAME ?attribute_value2
$?rest))
(element (OBJECT ?element2)
(attribute $?front SOMEATTRIBUTENAME ?attribute_value1
$?unneeded ANOTHERATTRIBUTENAME ?attribute_value2
$?rest))
=>
action
)
would this work if the getAttribute method returns a String array?
I've done this kind of pattern matching on facts before, but never on
a multislot. What if the matching needed to get more
complicated...like:
(defrule match-on-attribute-values ...
(element (OBJECT ?element)
(attribute $?front SOMEATTRIBUTENAME ?attribute_value1
$?unneeded ANOTHERATTRIBUTENAME ?attribute_value2
$?rest))
(element (OBJECT ?element2)
(attribute $?front SOMEATTRIBUTENAME
?att_value3&:(< ?att_value3 ?attribute_value1)
$?unneeded ANOTHERATTRIBUTENAME
?att_value4&:(> ?att_value4 ?attribute_value2 )
$?rest))
=>
action
)
alternatively, does anyone have a pattern for generating accessor
methods and properties at runtime so that we could get one property
per attribute?
Thanks,
Lauren
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------