[ 
https://issues.apache.org/jira/browse/OFBIZ-5377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13809598#comment-13809598
 ] 

Christian Carlow commented on OFBIZ-5377:
-----------------------------------------

I've encountered difficulties implementing this functionality as expected.

Inner-SELECT WHERE clauses are created using <condition-expr> in <view-entity> 
and associated with the ModelViewEntity object upon startup.  Normally a value 
attribute is specified in <condition-expr> but in my case the value isn't known 
beforehand so I need to be able to set it after the ModelViewEntity object has 
been created.  The problem with this is that is seems ModelViewEntities are not 
supposed to be changed once created at startup (otherwise a system restart 
wouldn't be necessary when entity/view-entity are changed).

Upon startup, this line in ModelViewEntity.java seems responsible for 
associating conditions with a view-entity:
            Element entityConditionElement = 
UtilXml.firstChildElement(viewLinkElement, "entity-condition");
            if (entityConditionElement != null) {
                this.viewEntityCondition = new 
ViewEntityCondition(modelViewEntity, this, entityConditionElement);
            } 

I thought about just setting the this.viewEntityCondition to a condition I need 
but there are two problems with this.  First is that I'm trying to apply the 
condition to an entity (OrderShipment) not a view entity so view-entity methods 
wouldn't be relevant.  Secondly, if I were to set the viewEntityCondition 
manually based on a value I fed in from some DynamicViewEntity method, it could 
cause the condition to be applied when it is not needed such as when the 
view-entity is referenced on another page.  For latter problem, the condition 
could be removed after finishing but it seems there could still be a chance 
that it gets applied at the wrong time.

I've been looking into the DynamicViewEntity class more and have found method 
such as setEntityName().  This suggested to me that the entity could be named 
and registered with the system for later use but apparently the 
DynamicViewEntity is not registered with the system the way that entity and 
view-entity objects are registered.  If I were to create a DynamicViewEntity 
and use setEntityName("OrderShipmentDVE") I'm not able to reference it as an 
entity with the name "OrderShipmentDVE."  Allowing such functionality could be 
a potential solution but having a way to associate conditions with the DVE 
without the query being executed would still be necessary.

Anyone have an explanation for the DynamicViewEntity setEntityName() function?  
Were DynamicViewEntities meant to be referenced by name after being created but 
the functionality never implemented?

> Add ability to join entitites with parameterized conditions to other entities
> -----------------------------------------------------------------------------
>
>                 Key: OFBIZ-5377
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5377
>             Project: OFBiz
>          Issue Type: Improvement
>            Reporter: Christian Carlow
>
> OFBiz should be improved to allow entities with parameterized conditions to 
> be joined with other entities.
> I need to be able to apply a condition to the OrderShipment entity where 
> OrderShipment.shipmentId = parameters.shipmentId which might produce this 
> query:
> SELECT * ORDER_SHIPMENT WHERE SHIPMENT_ID = '10000';
> Then I need to be able to take that query and join it to the 
> OrderItemShipGroupAssoc entity to product a query such as this:
> SELECT * FROM ORDER_ITEM_SHIP_GROUP_ASSOC OISGA LEFT JOIN (SELECT * FROM 
> ORDER_SHIPMENT WHERE SHIPMENT_ID = '10000') OS ON OISGA.ORDER_ID = 
> OS.ORDER_ID AND OISGA.ORDER_ITEM_SEQ_ID = OS.ORDER_ITEM_SEQ_ID AND 
> OISGA.SHIP_GROUP_SEQ_ID = OS.SHIP_GROUP_SEQ_ID



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to