Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-5100

Delegator name is expected to be always "default" which is not the right approac

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Release 10.04
    • None
    • framework
    • All Environments

    • Bug Crush Event - 21/2/2015

    Description

      Problem

      For the below delegator configuration with a delegator.find call to a view Entity Engine is throwing error due wrong code in EntityExpr class

          <delegator name="newName" entity-model-reader="main" entity-group-reader="main">
              <group-map group-name="pegasus" datasource-name="pegasus"/>
              <group-map group-name="Bookstore" datasource-name="bookstore"/>
          </delegator>
      {code:xml}
      
      The code in EntityExpr.java
      
      {code:java}
      
            if (delegator == null) {
                  // this will be the common case for now as the delegator isn't available where we want to do this
                  // we'll cheat a little here and assume the default delegator
                  delegator = DelegatorFactory.getDelegator("default");
              }
      
      

      assumes the delegator name is default, instead it should use the delegator name kept in xml configuration.

      How to reproduce?

      1. Change the delegator name to something else from "default"
      2. Keep a view in entitymodel.xml

          <view-entity entity-name="simpleView"
                       package-name="org.ofbiz.entity.dummy"
                       title="Dummy">
          <member-entity entity-alias="cl" entity-name="c1"/>
          <member-entity entity-alias="ac" entity-name="a1"/>
          <alias-all entity-alias="ac" name="id" />
          <alias-all entity-alias="cl" name="id"/>
          <alias-all entity-alias="cl" name="firstName"/>
          <alias-all entity-alias="cl" name="sponsor"/>
          <alias-all entity-alias="ac" name="title"/>
          <view-link entity-alias="ac" rel-entity-alias="cl">
             <key-map field-name="id" rel-field-name="id"/>
          </view-link>
          <relation type="one" title="one" rel-entity-name="cl">
                  <key-map field-name="id" />
          </relation>
          </view-entity>
      

      3. Use this like below,

      Delegator delegator = DelegatorFactory.getDelegator("newName");
      List<EntityExpr> expr=UtilMisc.toList(EntityCondition.makeCondition("sponsor",EntityOperator.EQUALS, Long.valueOf("1")));
      EntityListIterator listIterator=delegator.find("simpleView", EntityCondition.makeCondition(expr, EntityOperator.OR), null,fieldToSelct, UtilMisc.toList("id"), null);
      

      It will throw GenericEntityException due to "default" is hard coded in EntityExpr.java

      Please let me know if I can submit a patch for this to avoid hard coded delegator name.

      Attachments

        Issue Links

          Activity

            People

              doogie Adam Heath
              tarunk Tarun Kumar
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: