Changeset 7548

Show
Ignore:
Timestamp:
03/24/09 14:53:32 (16 months ago)
Author:
dragisak
Message:

Get methods in entities should not set fields.

Because of lazy loading, all values in the entity might not be initialized when get method is called. So simpleCollection might not have been initialized when getArticleList is called.

Addresses #1201, #1215 and #1228

Location:
head/ambra
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • head/ambra/libs/otm-models/src/main/java/org/topazproject/ambra/models/Issue.java

    r7467 r7548  
    22 * $Id$ 
    33 * 
    4  * Copyright (c) 2006-2008 by Topaz, Inc. 
     4 * Copyright (c) 2006-2009 by Topaz, Inc. 
    55 * http://topazproject.org 
    66 * 
     
    126126   */ 
    127127  public List<URI> getArticleList() { 
    128     if (articleList.isEmpty() && !super.getSimpleCollection().isEmpty()) 
    129       this.articleList = super.getSimpleCollection(); 
    130  
    131128    return this.articleList; 
    132129  } 
  • head/ambra/webapp/src/main/java/org/topazproject/ambra/admin/action/IssueManagementAction.java

    r7545 r7548  
    3333import java.util.List; 
    3434import java.util.ArrayList; 
    35 import java.util.Iterator; 
    3635import java.net.URI; 
    3736import java.net.URISyntaxException; 
     
    144143           * are ordering. 
    145144           */ 
    146           if (validateCSV(issue, issueURIs)) 
     145          if (validateCSV(issueURIs, browseService.getArticleList(issue))) 
    147146            issue = adminService.updateIssue(issueURI,imageURI,displayName,issueURIs,respectOrder); 
    148147 
     
    222221  /** 
    223222   * 
    224    * @param issue 
    225    * @param issueURIs 
     223   * @param issueURIs List of issue URI's 
     224   * @param articleList List of article URI's 
    226225   * @return 
    227226   * @throws URISyntaxException 
    228227   */ 
    229   public Boolean validateCSV(Issue issue, List<URI> issueURIs) throws URISyntaxException { 
    230     List<URI> curList = issue.getArticleList(); 
    231  
    232     if (issueURIs.size() != curList.size()) { 
     228  private Boolean validateCSV(List<URI> issueURIs, List<URI> articleList) throws URISyntaxException { 
     229 
     230    if (issueURIs.size() != articleList.size()) { 
    233231      addActionMessage("Issue not updated due to the following error."); 
    234232      addActionMessage("There has been an addition or deletion in the Article URI List."); 
     
    237235    } 
    238236 
    239     for(URI uri : curList) { 
     237    for(URI uri : articleList) { 
    240238      if (!issueURIs.contains(uri)) { 
    241239        addActionMessage("Issue not updated due to the following error."); 
  • head/ambra/webapp/src/main/java/org/topazproject/ambra/article/service/BrowseService.java

    r7484 r7548  
    342342                                        nextIssueURI, imageArticle, description, 
    343343                                        parentVolume == null ? null : parentVolume.getId()); 
    344     issueInfo.setArticleUriList(issue.getArticleList()); 
     344    issueInfo.setArticleUriList(getArticleList(issue)); 
    345345    return issueInfo; 
    346346  } 
     
    862862    return articleGroups; 
    863863  } 
     864 
     865  /** 
     866   * Get ordered list of articles. Either from articleList or from 
     867   * simpleCollection if articleList is empty. 
     868   * @param issue 
     869   * @return List of article URI's 
     870   */ 
     871  public List<URI> getArticleList(Issue issue) { 
     872    List<URI> articleList = issue.getArticleList(); 
     873    if (articleList.isEmpty() && !issue.getSimpleCollection().isEmpty()) 
     874      return new ArrayList<URI>(issue.getSimpleCollection()); 
     875 
     876    return articleList; 
     877  } 
     878 
    864879}