Project

General

Profile

« Previous | Next » 

Revision 9f6a56c9

Added by Andreas Müller almost 3 years ago

ref #9664 first implementation for TeamOrPersonBase.nomenclaturalTitleCache (update script still missing)

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/TeamOrPersonBase.java
34 34
 */
35 35
@XmlAccessorType(XmlAccessType.FIELD)
36 36
@XmlType(name = "TeamOrPersonBase", propOrder = {
37
    "nomenclaturalTitle",
37
    "nomenclaturalTitleCache",
38 38
    "collectorTitleCache"
39 39
})
40 40
@Entity
......
46 46
    private static final long serialVersionUID = 5216821307314001961L;
47 47
    public static final Logger logger = Logger.getLogger(TeamOrPersonBase.class);
48 48

  
49
    @XmlElement(name="NomenclaturalTitle")
50
    @Field(index=Index.YES)
51
  //TODO Val #3379
52
//    @NullOrNotEmpty
53
    @Column(length=255)
54
    protected String nomenclaturalTitle;
55

  
56 49
    //under construction #4311
57 50
    @XmlElement(name="CollectorTitleCache")
58 51
    @Field(index=Index.YES)
59 52
    @Column(length=800)//see #1592
60 53
    protected String collectorTitleCache;
61 54

  
55
    //under construction #9664
56
    @XmlElement(name="NomenclaturalTitleCache")
57
    @Field(index=Index.YES)
58
    @Column(length=800)//see #1592
59
    protected String nomenclaturalTitleCache;
60

  
62 61
//  from E+M import (still needed?)
63 62
//    @Column(length=255)
64 63
//    protected String originalNomenclaturalTitle;
......
70 69
    protected boolean isGeneratingTitleCache = false;  //state variable to avoid recursions when generating title cache and nomenclatural title
71 70

  
72 71

  
72
    //#9664
73
    @Override
74
    public String getNomenclaturalTitleCache() {
75
        // is title dirty, i.e. equal NULL?
76
        if (nomenclaturalTitleCache == null){
77
            this.nomenclaturalTitleCache = generateNomenclaturalTitleCache();
78
            this.nomenclaturalTitleCache = getTruncatedCache(this.nomenclaturalTitleCache) ;
79
        }
80
        return nomenclaturalTitleCache;
81
    }
82

  
73 83
    //#4311
74 84
    public String getCollectorTitleCache() {
75 85
        // is title dirty, i.e. equal NULL?
......
85 95
    }
86 96

  
87 97
    @SuppressWarnings("unchecked")
88
    private String generateCollectorTitleCache() {
98
    private String generateNomenclaturalTitleCache() {
89 99
        if (getCacheStrategy() == null){
90 100
            return this.getClass() + ": " + this.getUuid();
91 101
        }else{
92
            return getCacheStrategy().getCollectorTitleCache((T)this);
102
            return getCacheStrategy().getNomenclaturalTitleCache((T)this);
93 103
        }
94 104
    }
95 105

  
96
    /**
97
     * Returns the identification string (nomenclatural abbreviation) used in
98
     * nomenclature for this {@link Person person} or this {@link Team team}.
99
     *
100
     * @see  INomenclaturalAuthor#getNomenclaturalTitle()
101
     */
102
    @Override
103
    @Transient
104
    public String getNomenclaturalTitle() {
105
        String result = nomenclaturalTitle;
106
        if (isBlank(nomenclaturalTitle) && (isGeneratingTitleCache == false)){
107
            result = getTitleCache();
106
    @SuppressWarnings("unchecked")
107
    private String generateCollectorTitleCache() {
108
        if (getCacheStrategy() == null){
109
            return this.getClass() + ": " + this.getUuid();
110
        }else{
111
            return getCacheStrategy().getCollectorTitleCache((T)this);
108 112
        }
109
        return result;
110
    }
111

  
112
    /**
113
     * @see     #getNomenclaturalTitle()
114
     */
115
    @Override
116
    public void setNomenclaturalTitle(String nomenclaturalTitle) {
117
        this.nomenclaturalTitle = isBlank(nomenclaturalTitle) ? null : nomenclaturalTitle;
118 113
    }
119 114

  
120 115

  
......
151 146

  
152 147
    protected String replaceEmptyTitleByNomTitle(String result) {
153 148
        if (isBlank(result)){
154
            result = nomenclaturalTitle;
149
            result = nomenclaturalTitleCache;
155 150
        }
156 151
        if (isBlank(result)){
157 152
            result = super.getTitleCache();

Also available in: Unified diff