Hi Jason,

Just in case the following would be interested for you and the other.

With your help, I have done re-modeled ofbiz to meet my requirement of using 
View Entity (Instead of Entity WORK_EFFORT) in manufacturing module.

The reason of doing so is creating a view by joining different entities or 
views is much more flexible than using only entity.
However, the original ModelReader.java does NOT support to create relation for 
View (if I understand it correctly) so I have to adapt the functions in the 
ProductionRun.java from getRelated to EntityQuery so that the data could be 
properly mapped from the view.

In case anyone is also struggling in similar situations...
HIH

Mvh
Schumann
________________________________
From: Schumann Ye <schumanny...@hotmail.com>
Sent: Thursday, December 17, 2020 5:11 PM
To: user@ofbiz.apache.org <user@ofbiz.apache.org>
Subject: Re: Entity ChildWorkEffort

Hey Jason,

That is the answer I need.
Many thanks for your help.

Have a nice day.

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Jason RJ <jason_of...@reast.net>
Sent: Thursday, December 17, 2020 5:08:02 PM
To: user@ofbiz.apache.org <user@ofbiz.apache.org>
Subject: Re: Entity ChildWorkEffort

Hey Schumann,

I think there's some logic that makes this happen.

In the workeffort\entitydef\entitymodel_view.xml we have a Parent defintion:

       <relation type="one-nofk" title="Parent"
rel-entity-name="WorkEffort">
         <key-map field-name="workEffortParentId"
rel-field-name="workEffortId"/>
       </relation>

The code in ModelReader.java takes care of creating the reverse relation
for Child automatically:

        // create the new relationship even if one exists so we can show
what we are looking for in the info message
        // don't do relationship to the same entity, unless title is
"Parent", then do a "Child" automatically
        String title = modelRelation.getTitle();
        if
(curModelEntity.getEntityName().equals(relatedEnt.getEntityName()) &&
"Parent".equals(title)) {
            title = "Child";
        }

Hope that helps,

Jason


On 17/12/2020 06:10, Schumann Ye wrote:
> Dear all,
>
> Does anyone have any idea where the Entity ChildWorkEffort comes from ( in 
> what xml file it is defined ).
>
> This question came across to me when I checked the file ProductionRun.java 
> with the codes as follows:
> productionRunRoutingTasks =
> productionRun.getRelated("ChildWorkEffort", .....
>
> Then I search of the definition file with the title equal to "Child" and 
> rel-entity-name="WorkEffort" but could NOT find any match.
>
> Can anyone help?
>
> Mvh
> Schumann
>
>
> Get Outlook for Android<https://aka.ms/ghei36>
>

Reply via email to