Thanks Michael and Mark.
> If the member has a getter it is available in the LHS (=Guided Rule Editor
> lists it in "Modify constraints" popup)
Got it. I see it's true with a basic uploaded Pojo.
But, hmm, in my case, it's not.
If I annotate the Pojo in "New Declarable Model", the getter-only-member
becomes unavailable in the LHS (=Guided Rule Editor doesn't list it in "Modify
constraints" popup).
# Maybe you misread the word "Modify"? I meant the popup in LHS.
So it can be an issue only when I want to use existing beans and need to
annotate them (e.g. for CEP support).
=== Analysis ===
With a debugger, I observed that
SuggestionCompletionLoader.populateDeclaredFactType() overwrites
SuggestionCompletionEngineBuilder.fieldsForType if a Pojo is annotated as a
declarative model.
SuggestionCompletionLoader.java
407 private void populateDeclaredFactType(List<TypeDeclarationDescr> th) {
...
469 this.builder.addFieldsForType( declaredType,
470 fieldNames.toArray( new String[fieldNames.size()] ) );
...
473 }
SuggestionCompletionEngineBuilder.java
111 public void addFieldsForType(final String type,
112 final String[] fields) {
113 this.fieldsForType.put( type,
114 fields );
115 }
fieldsForType is overwritten based on TypeDeclarationDescr of the declarative
model.
The TypeDeclarationDescr is created in
SuggestionCompletionLoader.makePseudoTypeDeclarationDescrFromSuperClassType().
It accepts only setter+getter fields.
It looks intentional... but misses to concern the above use case?
Cheers,
Toshiya
----- Original Message -----
From: "Mark Proctor" <[email protected]>
To: [email protected]
Sent: Tuesday, December 20, 2011 1:28:09 AM
Subject: Re: [rules-users] Guided Rule Editor doesn't list no-setter-fields if
a fact is annotated
Sorry I misread what you said. I thought you said that beans are only usable in
the IDE if it has both a getter and a setter - my misundestanding.
M
On 19/12/2011 16:19, Michael Anstis wrote:
I'm not clear on what you are saying.
We reflect the methods of existing beans:-
• If the member has a getter it is available in the LHS
• If the member has a setter it is available in the RHS
• If the member has a getter and a setter it is available in both the LHS
and RHS
Members of declared types are available in both the LHS and RHS (as we
implicitly create getters and setters).
I don't understand "we should only support getters" but "be intelligent enough
not to allow the setter to be used in the IDE". If we only support getters
there is no setter; and if there is no setter how do we allow the user to set
the value? Of course my comments are from a Guvnor perspective, if you mean to
change the way declared types work, then... well, we'll have to change Guvnor
anyway :)
2011/12/19 Mark Proctor < [email protected] >
<blockquote>
On 19/12/2011 16:04, Michael Anstis wrote:
<blockquote>
You are not mistaken.
For POJO models we use reflection (class.getMethods) to determine whether a
Type's methods members are available in the LHS or RHS or both, according to
Java Bean conventions. Declarative models have their members available in both
the LHS and RHS by default as we generate "getters" and "setters" for them.
It probably looks like we should support only getters though, for existing
beans. We just need to be intelligent enough not to allow the setter to be used
in the IDE.
Toshiya: Sounds like a great introduction task, you up for the challenge?
Mark
<blockquote>
On 19 December 2011 05:47, Toshiya Kobayashi < [email protected] > wrote:
<blockquote>
Hello,
In Guvnor 5.3.0, I can use CEP feature support in Guided Rule Editor after
uploading a class by "Upload POJO Model jar" and annotating it in "New
Declarable Mode".
1. | declare TestPojo
2. | @role(value = event)
3. | end
But if some fields of the POJO class have only getter methods, Guided Rule
Editor won't list those fields in "Modify constraints" popup. (if a field has a
setter method, it will be listed)
public class TestPojo {
private String name;
public TestPojo() {}
public String getName() { return name; }
// public void setName(String name) { this.name = name; }
}
Am I missing something? If it's not an expected behaviour, I will raise a JIRA.
Cheers,
Toshiya
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
</blockquote>
_______________________________________________
rules-users mailing list [email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
</blockquote>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
</blockquote>
_______________________________________________
rules-users mailing list [email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
</blockquote>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users