Project

General

Profile

« Previous | Next » 

Revision 826c86cb

Added by Andreas Müller almost 8 years ago

Fill empty titleCache only during save and improve classification titleCache generation #5849

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableEntity.java
75 75
 * The originalSource representing that taxon as it was found in IPNI would contain IPNI as the reference, the IPNI id of the taxon and the name of the taxon exactly as it was used in IPNI.
76 76
 *
77 77
 * @author m.doering
78
 * @version 1.0
79 78
 * @created 08-Nov-2007 13:06:27
80 79
 */
81 80
@XmlAccessorType(XmlAccessType.FIELD)
......
215 214
            this.titleCache = generateTitle();
216 215
            this.titleCache = getTruncatedCache(this.titleCache) ;
217 216
        }
218
        if(StringUtils.isBlank(titleCache)){
219
            titleCache = this.toString();
220
        }
217
        //removed due to #5849
218
//        if(StringUtils.isBlank(titleCache)){
219
//            titleCache = this.toString();
220
//        }
221 221
        return titleCache;
222 222
    }
223 223

  
......
263 263
    /**
264 264
     *
265 265
     * @return true, if the current state of the titleCache (without generating it new)
266
     * is the empty string. This is primarily meant for internal use.
266
     * is <code>null</code> or the empty string. This is primarily meant for internal use.
267 267
     */
268 268
    public boolean hasEmptyTitleCache(){
269
        return "".equals(this.titleCache);
269
        return this.titleCache == null || "".equals(this.titleCache);
270 270
    }
271 271

  
272 272
//**************************************************************************************
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/Classification.java
633 633

  
634 634
    @Override
635 635
    public String generateTitle() {
636
        return name.getText();
636
        //TODO implement as cache strategy
637
        if (protectedTitleCache){
638
            return this.titleCache;
639
        }else if (name != null){
640
            return name.getText();
641
        }else if (reference != null){
642
            return this.reference.getTitleCache();
643
        }else{
644
            return this.toString();
645
        }
637 646
    }
638 647

  
639 648
    public int compareTo(Object o) {
649
        //TODO needs to be implemented
640 650
        return 0;
641 651
    }
642 652

  
......
691 701
            return null;
692 702
        }
693 703

  
694

  
695

  
696

  
697

  
698 704
    }
699 705

  
700

  
701 706
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/CdmPreDataChangeListener.java
141 141
                    //title cache
142 142
                    identifiableEntity.getTitleCache();
143 143
                }
144
                //titleCache should never be empty, even if protected
144
                //titleCache should never be empty, even if protected #5763, #5849
145 145
                if (identifiableEntity.isProtectedTitleCache() && identifiableEntity.hasEmptyTitleCache()){
146 146
                    identifiableEntity.setTitleCache(null, false);
147 147
                    identifiableEntity.getTitleCache();
148 148
                }
149
                if (identifiableEntity.hasEmptyTitleCache()){
150
                    identifiableEntity.setTitleCache(identifiableEntity.toString(), false);
151
                }
152

  
149 153

  
150 154
            }else if(Amplification.class.isAssignableFrom(entityClazz)) {
151 155
                Amplification amplification = (Amplification)entity;

Also available in: Unified diff