Login  Register

[jira] [Commented] (OFBIZ-4349) commit r1077940 breaks the function to retrieve i18n translation from real entity underlying a view

Posted by Nicolas Malin (Jira) on Jul 26, 2011; 2:57am
URL: http://ofbiz.116.s1.nabble.com/jira-Created-OFBIZ-4349-commit-r1077940-breaks-the-function-to-retrieve-i18n-translation-from-real-ew-tp3686061p3694764.html


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

Leon commented on OFBIZ-4349:
-----------------------------

Erwan, I think you consider too much and make things a little complex. The method get(ModelEntity modelEntity, ModelEntity modelEntityToUse, String name, String resource, Locale locale) is private and only invoked by method get(String name, String resource, Locale locale). In the latter one, it tries to get i18n value from entity firstly (no matter it's view entity or real), if failed, then it will try to get i18n value from member entity again if it's a view entity. So you do not need to repleat the same implementation in get(ModelEntity modelEntity, ModelEntity modelEntityToUse, String name, String resource, Locale locale). I extract some code from get(String name, String resource, Locale locale) method and paste them below. You will find that it's very similar as that in your patch.

{noformat}
        ModelEntity modelEntityToUse = this.getModelEntity();
        Object resourceValue = get(this.getModelEntity(), modelEntityToUse, name, resource, locale);
        if (resourceValue == null) {
          if (modelEntityToUse instanceof ModelViewEntity) {
              //  now try to retrieve with the field heading from the real entity linked to the view
              ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntityToUse;
              Iterator<ModelAlias> it = modelViewEntity.getAliasesIterator();
              while (it.hasNext()) {
                  ModelAlias modelAlias = it.next();
                  if (modelAlias.getName().equalsIgnoreCase(name)) {
                      modelEntityToUse = modelViewEntity.getMemberModelEntity(modelAlias.getEntityAlias());
                      name = modelAlias.getField();
                      break;
                  }
              }
              resourceValue = get(this.getModelEntity(), modelEntityToUse, name, resource, locale);
              if (resourceValue == null) {
                  return fieldValue;
              } else {
                  return resourceValue;
              }
          } else {
              return fieldValue;
          }
        } else {
            return resourceValue;
        }
{noformat}


> commit r1077940 breaks the function to retrieve i18n translation from real entity underlying a view
> ---------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-4349
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4349
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: SVN trunk
>            Reporter: Leon
>         Attachments: OFBIZ-4349.patch
>
>
> in r1077940 changeset ([https://fisheye6.atlassian.com/changelog/ofbiz?cs=1077940]), it gets the pk fiels from view entity instead of previous real entity. I cannot understand what author erwan commented: "When using a view and fields with different names than in the original entity, the model was taking the original names so this could lead to warnings". The consequence of this commit is it cannot retrieve i18n translation from real entity now because the pks of view entity is usually different than that of its base tables.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira