Bug 754093 - Declarative type extension not working properly
Summary: Declarative type extension not working properly
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRM (Guvnor)
Version: BRMS 5.3.0.GA
Hardware: Unspecified
OS: Unspecified
Target Milestone: ER7
: BRMS 5.3.0.GA
Assignee: manstis
QA Contact: Lukáš Petrovický
Depends On: 796612
TreeView+ depends on / blocked
Reported: 2011-11-15 11:53 UTC by Zuzana Krejčová
Modified: 2020-04-27 01:12 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed:
Type: Bug

Attachments (Terms of Use)
rule (119.27 KB, image/png)
2012-04-25 15:20 UTC, Zuzana Krejčová
no flags Details
stacktrace (6.20 KB, text/plain)
2012-04-25 15:20 UTC, Zuzana Krejčová
no flags Details
repository (26.51 KB, application/xml)
2012-04-25 15:56 UTC, Zuzana Krejčová
no flags Details

System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBRULES-3417 0 Blocker Resolved 5.3.x Regression: SuperTypeName for a Declared Type extending reports as Object 2015-12-12 12:40:00 UTC
Red Hat Issue Tracker JBRULES-3418 0 Critical Resolved 5.3.x Regression: Declared Super-Types: Compile-time error 2015-12-12 12:40:00 UTC

Description Zuzana Krejčová 2011-11-15 11:53:11 UTC
Description of problem:

It should be possible (according to docs) to extend 

A) Facts inside the same Declarative Model: 
Works well.

B) Facts from a different D. Model from the same Package: 
It is NOT possible to do that in Guvnor - while creating a new Fact, there isn't the other (parent) Fact listed as a type to extend. There's a workaround for that, though not very good - export the repository, edit the xml so that the model has something like "declare fact extends anotherFact ...some fields... end", import it back into Guvnor.

C) Imported Java classes: 
This does not work at all. Not even after manually editing the repository.xml.

Version-Release number of selected component (if applicable):

BRMS 5.3.0 dev5

Comment 1 manstis 2012-01-22 10:23:31 UTC
Guvnor documentation states to extend a POJO you need to complete the following:- Extending a Java class

To extend a Java class the following steps need to be completed:-

* Import the applicable Java JAR into Guvnor

* If the Java package name in which the class belongs is different to the Guvnor package name in to which the JAR has been imported ensure the Guvnor package imports the class from which you want to extend. This is normally completed for you automatically when you upload a JAR model however if you have multiple classes with the same name in the JAR you should check the appropriate one has been imported.

* Within the Declarative Modelling screen define an empty type (i.e. with no fields) of the same name as that you want to extend.

* Create a new declarative type as appropriate, extending the empty declaration created in the preceeding step.

Please clarify what does not work as documented?

Comment 2 Zuzana Krejčová 2012-01-23 10:28:32 UTC
Doing it this way works - though I'd swear this bit of information (define an empty type of the same name, then extend this one) got added/changed after I reported the issue.. Never mind. 

Now I can't even find any specific mention of extending a fact from a different declarative model in the same package, as in B) - which still doesn't work.

Tested on BRMS 5.3.0 ER2.

Comment 3 manstis 2012-01-23 12:01:43 UTC
Hi Zuzana, 

I don't know why you couldn't find C) (it has always been this way in both Drools' DRL and Guvnor) but as you say, never mind.

I will hopefully work on B) soon - it should be quite simple (we only load declared types for use in the screen from the model being opened, I need to change it to load all Facts in all declarative models in the package).



Comment 4 manstis 2012-01-30 11:39:36 UTC
Fixed (B) and back-ported to 5.3.x branch.

(A) and (C) no longer issues.

Comment 5 Ryan Zhang 2012-02-15 09:12:15 UTC
Please verify the issue on 5.3 ER4.

Comment 6 Zuzana Krejčová 2012-02-21 12:31:28 UTC
Case B is still not working in ER4. 
What it does now:
It allows you to choose a fact to extend, but upon save, it changes it to Object - this, obviously, does not bring anything new to the fact...

Say I have a model with fact F1 which has a field f1. Then I create another model in the same package and create a new fact in it, F2, and choose it's to extend the fact F1. I add a field f2 to the fact and save the model.
Upon save, i see the "F2 extends F1" change to "F2 extends Object". Field f1 is not accessible from fact F2.

Comment 7 manstis 2012-02-21 12:46:28 UTC
This is due to a regression in Drools Expert. I have asked for a fix made to master to be back-ported... and am awaiting confirmation it has been completed.

Comment 8 Anne-Louise Tangring 2012-03-28 14:48:37 UTC
Setting Blocker flag as agreed on in triage meeting.

Comment 9 JBoss JIRA Server 2012-03-30 12:50:03 UTC
Michael Anstis <michael.anstis@gmail.com> updated the status of jira JBRULES-3418 to Coding In Progress

Comment 10 JBoss JIRA Server 2012-03-30 12:50:08 UTC
Michael Anstis <michael.anstis@gmail.com> updated the status of jira JBRULES-3417 to Coding In Progress

Comment 11 JBoss JIRA Server 2012-03-30 12:54:34 UTC
Michael Anstis <michael.anstis@gmail.com> updated the status of jira JBRULES-3418 to Resolved

Comment 12 JBoss JIRA Server 2012-03-30 12:54:42 UTC
Michael Anstis <michael.anstis@gmail.com> updated the status of jira JBRULES-3417 to Resolved

Comment 13 Ryan Zhang 2012-04-23 07:36:41 UTC
Update status to ON_QA. Please verify them against ER6.

Comment 14 Zuzana Krejčová 2012-04-25 15:19:16 UTC
I am sorry to say it still needs some tweaking.

I got "[rule] Unable to validate this asset. (Check log for detailed messages)." upon validation of a rule using such Facts (B) or either of the models.

I have a model parentModel:
declare ParentFact
    parentFiled: String

and another one childModel:
declare ChildFact
    childFiled: String

and a simple rule using both of those.

There's also NPE in the server log, "Unable to build asset." at org.drools.base.ClassTypeResolver.resolveType(ClassTypeResolver.java:130). 

See attachments for the rule and the stacktrace.

Comment 15 Zuzana Krejčová 2012-04-25 15:20:06 UTC
Created attachment 580190 [details]

Comment 16 Zuzana Krejčová 2012-04-25 15:20:37 UTC
Created attachment 580192 [details]

Comment 17 manstis 2012-04-25 15:23:14 UTC
Please attach your repository export too, it'll make tracking down the problem much easier. Thanks, Mike

Comment 18 Zuzana Krejčová 2012-04-25 15:56:08 UTC
Created attachment 580201 [details]

I have found out that this Error happens due to my model names, when the first letters aren't like this: childModel, ParentModel. 
Meaning, if I havechildModel, ParentModel, it is okay. 
If I have childModel, parentModel it is not, same with ChildModel and whatever.

Comment 19 manstis 2012-04-25 21:58:24 UTC
I suspect this relates to the ordering of Declarative model names. The DRL for the attached repository reads:-

4.	|	declare ChildFact extends ParentFact
5.	|	    childField: Boolean
6.	|	end
7.	|	
8.	|	declare ParentFact
9.	|	    parentField: String
10.	|	end

Hence we are trying to extend a type before the super-type is declared. This is further substantiated if you try to build the package - it fails :( We need to add some code to order the DRL by parent->child types where one extends another.

Comment 20 manstis 2012-04-27 15:35:13 UTC
Problem was that the sub-type was being declared in package DRL before super-type. Fixed in master and 5.3.x branch (https://github.com/droolsjbpm/guvnor/commit/7b32666c4451a075074a5f9a69a85e85dc093015)

Comment 24 Ryan Zhang 2012-05-14 08:16:16 UTC
The fixed for this issue should be included in ER7. Please do verification on it.

Note You need to log in before you can comment on or make changes to this bug.