Skip to content


Improved: Change current view-link requirement to allow use of
Browse files Browse the repository at this point in the history
entity-condition only in view-entities

To explain the subject, i will give an example encountered recently:

We used, for a customer project, a view with Agreement, Virtual and Variant 
product entities and where the agreement can be attached to a virtual OR a 
variant product.
So to make a view returning Variant Product, Virtual Product AND Agreement 
informations, i could not create a view, as the key-map link is mandatory and 
made it impossible.

I can not have an alternative relation to the same entity so we have to 
duplicate member-entity and an alternative relation path. 
The result is a complicated and ugly entity-view

I think this can have been much simpler if i could have done it directly 
through the entity-condition (see the AGPA/PDTA view link in attached file 

So the purpose is to add the possibility to create a view-link without key map,  
if there is an entity-condition.

You can test by applying the given patch and add the entity view from attached 
file ExampleWithoutKeyMap.xml

Thanks: Leila Mekika

git-svn-id: 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
JacquesLeRoux committed Sep 5, 2019
1 parent 5fb61ec commit 180ca71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion framework/entity/dtd/entitymodel.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ under the License.
<xs:element minOccurs="0" ref="description"/>
<xs:element maxOccurs="unbounded" ref="key-map"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="key-map"/>
<xs:element minOccurs="0" ref="entity-condition"/>
<xs:attributeGroup ref="attlist.view-link"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public static String makeFromClause(ModelEntity modelEntity, ModelFieldTypeReade

StringBuilder condBuffer = new StringBuilder();

ModelViewEntity.ViewEntityCondition viewEntityCondition = viewLink.getViewEntityCondition();
for (int j = 0; j < viewLink.getKeyMapsSize(); j++) {
ModelKeyMap keyMap = viewLink.getKeyMap(j);
ModelField linkField = linkEntity.getField(keyMap.getFieldName());
Expand All @@ -218,14 +219,13 @@ public static String makeFromClause(ModelEntity modelEntity, ModelFieldTypeReade
if (condBuffer.length() == 0) {
if (condBuffer.length() == 0 && viewEntityCondition == null) {
throw new GenericModelException("No view-link/join key-maps found for the " + viewLink.getEntityAlias() + " and the " + viewLink.getRelEntityAlias() + " member-entities of the " + modelViewEntity.getEntityName() + " view-entity.");

ModelViewEntity.ViewEntityCondition viewEntityCondition = viewLink.getViewEntityCondition();
if (viewEntityCondition != null) {
EntityCondition whereCondition = viewEntityCondition.getWhereCondition(modelFieldTypeReader, null);
condBuffer.append(" AND ");
if (condBuffer.length() > 0) condBuffer.append(" AND ");
condBuffer.append(whereCondition.makeWhereString(modelEntity, null, datasourceInfo));

Expand Down

0 comments on commit 180ca71

Please sign in to comment.