Project

General

Profile

« Previous | Next » 

Revision 71b9b632

Added by Andreas Müller almost 3 years ago

ref #4311 first implementation for TeamOrPersonBase.collectorTitle

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/utils/ImportDeduplicationHelper.java
438 438
            Team team = (Team)author;
439 439
            //nomTitle is not necessarily cached when it is created
440 440
            team.setNomenclaturalTitle(nomTitle, team.isProtectedNomenclaturalTitleCache());
441
            String collectorCache = author.getCollectorTitleCache();
442
            if (! team.isProtectedCollectorTitleCache()){
443
                team.setCollectorTitleCache(collectorCache, false);
444
            }
441 445
        }else{
442 446
            author.setNomenclaturalTitle(nomTitle);
443 447
        }
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Person.java
30 30
import org.hibernate.envers.Audited;
31 31
import org.hibernate.search.annotations.Field;
32 32
import org.hibernate.search.annotations.FieldBridge;
33
import org.hibernate.search.annotations.Index;
33 34
import org.hibernate.search.annotations.IndexedEmbedded;
34 35
import org.springframework.beans.factory.annotation.Configurable;
35 36

  
......
67 68
	    "givenName",
68 69
	    "initials",
69 70
	    "suffix",
71
	    "collectorTitle",
70 72
	    "lifespan",
71 73
	    "orcid",
72 74
	    "institutionalMemberships"
......
81 83
	private static final long serialVersionUID = 4153566493065539763L;
82 84
	public static final Logger logger = Logger.getLogger(Person.class);
83 85

  
86
    //under construction #4311
87
    @XmlElement(name="CollectorTitle")
88
    @Field(index=Index.YES)
89
    @Column(length=255)
90
    private String collectorTitle;
91

  
84 92
    @XmlElement(name = "Prefix")
85 93
    @Field
86 94
  //TODO Val #3379
......
301 309
		this.givenName = isBlank(givenName) ? null : givenName;
302 310
	}
303 311

  
312
	//#4311
313
    public String getCollectorTitle() {
314
        return collectorTitle;
315
    }
316
    public void setCollectorTitle(String collectorTitle) {
317
        this.collectorTitle = collectorTitle;
318
    }
319

  
304 320
    /**
305 321
     * Returns the initials of this person as used in bibliographic
306 322
     * references. Usually these are the first letters of each givenname
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java
79 79
    @XmlElement(name = "ProtectedNomenclaturalTitleCache")
80 80
	private boolean protectedNomenclaturalTitleCache = false;
81 81

  
82
    //under construction #4311
83 82
    @XmlElement(name = "ProtectedCollectorTitleCache")
84
	private final boolean protectedCollectorTitleCache = false;
83
	private boolean protectedCollectorTitleCache = false;
85 84

  
86 85
	//An abbreviated name for the team (e. g. in case of nomenclatural authorteams).
87 86
    //A non abbreviated name for the team (e. g.
......
142 141
		addListenersToMembers();
143 142
	}
144 143

  
144
// ******************************************************************/
145

  
145 146
    @Override
146 147
    protected void initDefaultCacheStrategy() {
147 148
        this.cacheStrategy = TeamDefaultCacheStrategy.NewInstance();
148 149
    }
149 150

  
151
    @Override
152
    public void initListener(){
153
        PropertyChangeListener listener = new PropertyChangeListener() {
154
            @Override
155
            public void propertyChange(PropertyChangeEvent ev) {
156
                if (!ev.getPropertyName().equals("titleCache") &&
157
                        !ev.getPropertyName().equals("collectorTitleCache") &&
158
                        !ev.getPropertyName().equals("cacheStrategy")){
159
                    if (! isProtectedTitleCache()){
160
                        titleCache = null;
161
                    }
162
                    if (! isProtectedCollectorTitleCache()){
163
                        collectorTitleCache = null;
164
                    }
165
                }
166
            }
167
        };
168
        addPropertyChangeListener(listener);
169
    }
170

  
150 171
	/**
151 172
	 * Adds a property change listener to all team members.
152 173
	 */
......
163 184
            public void propertyChange(PropertyChangeEvent e) {
164 185

  
165 186
// 			   ---- code with no effect below -----
166
//				if (! isProtectedTitleCache()){
167
//					titleCache = titleCache;
168
//				}
187
				if (! isProtectedTitleCache()){
188
					titleCache = null;
189
				}
169 190
//				if (! isProtectedNomenclaturalTitleCache()){
170 191
//					nomenclaturalTitle = nomenclaturalTitle;
171 192
//				}
193
              if (! isProtectedCollectorTitleCache()){
194
                  collectorTitleCache = null;
195
              }
172 196
			}
173 197
		};
174 198
		member.addPropertyChangeListener(listener);
175 199
	}
176 200

  
201
    public void resetCaches() {
202
        if(!protectedTitleCache){
203
            titleCache = null;
204
        }
205
        if (!protectedCollectorTitleCache){
206
            collectorTitleCache = null;
207
        }
208
    }
209

  
177 210
	/**
178 211
	 * Returns the list of {@link Person members} belonging to <i>this</i> team.
179 212
	 * A person may be a member of several distinct teams.
......
319 352
		return result;
320 353
	}
321 354

  
355
    //#4311
356
    @Override
357
    public String getCollectorTitleCache() {
358
        if (protectedCollectorTitleCache){
359
            return this.collectorTitleCache;
360
        }else{
361
            return super.getCollectorTitleCache();
362
        }
363
    }
364

  
322 365
	/**
323 366
	 * Protected nomenclatural title cache flag should be set to true, if
324 367
	 * the title cache is to be preferred against the atomized data.
......
329 372
	public boolean isProtectedNomenclaturalTitleCache() {
330 373
		return protectedNomenclaturalTitleCache;
331 374
	}
332

  
333
	public void setProtectedNomenclaturalTitleCache(
334
			boolean protectedNomenclaturalTitleCache) {
375
	public void setProtectedNomenclaturalTitleCache(boolean protectedNomenclaturalTitleCache) {
335 376
		this.protectedNomenclaturalTitleCache = protectedNomenclaturalTitleCache;
336 377
	}
337 378

  
338 379

  
339
	/**
380
	public boolean isProtectedCollectorTitleCache() {
381
        return protectedCollectorTitleCache;
382
    }
383
    public void setProtectedCollectorTitleCache(boolean protectedCollectorTitleCache) {
384
        this.protectedCollectorTitleCache = protectedCollectorTitleCache;
385
    }
386

  
387
    public void setCollectorTitleCache(String collectorTitleCache, boolean protectedCache) {
388
        this.collectorTitleCache = collectorTitleCache;
389
        this.protectedCollectorTitleCache = protectedCache;
390
    }
391

  
392
    /**
340 393
	 * The hasMoreMembers flag is true if this team has more members than
341 394
	 * mentioned in the {@link #teamMembers} list. This is usually the case
342 395
	 * when "et al." is used in the team representation. Formatters should add
......
356 409
        boolean result = super.updateCaches();
357 410
        if (this.protectedNomenclaturalTitleCache == false){
358 411
            String oldNomTitleCache = this.nomenclaturalTitle;
359
            this.protectedNomenclaturalTitleCache = false;
360 412

  
361 413
            String newNomTitleCache = getCacheStrategy().getNomenclaturalTitle(this);
362 414

  
363 415
            if ( oldNomTitleCache == null   || ! oldNomTitleCache.equals(newNomTitleCache) ){
364
                 this.setNomenclaturalTitle(null, false);
365
                 String newCache = this.getNomenclaturalTitle();
416
                this.setNomenclaturalTitle(null, false);
417
                String newCache = this.getNomenclaturalTitle();
418

  
419
                if (newCache == null){
420
                    logger.warn("New nomTitleCache should never be null");
421
                }
422
                if (oldNomTitleCache == null){
423
                    logger.info("Old nomTitleCache should never be null");
424
                }
425
                result = true;
426
            }
427
        }
428
        if (this.protectedCollectorTitleCache == false){
429
            String oldCollTitleCache = this.collectorTitleCache;
430
            String newCollTitleCache = getCacheStrategy().getCollectorTitleCache(this);
431

  
432
            if ( oldCollTitleCache == null || ! oldCollTitleCache.equals(newCollTitleCache) ){
433
                 this.setCollectorTitleCache(null, false);
434
                 String newCache = this.getCollectorTitleCache();
366 435

  
367 436
                 if (newCache == null){
368
                     logger.warn("New nomTitleCache should never be null");
437
                     logger.warn("New collectorTitleCache should never be null");
369 438
                 }
370
                 if (oldNomTitleCache == null){
371
                     logger.info("Old nomTitleCache should never be null");
439
                 if (oldCollTitleCache == null){
440
                     logger.info("Old collectorTitleCache should never be null");
372 441
                 }
373 442
                 result = true;
374 443
             }
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/TeamOrPersonBase.java
35 35
@XmlAccessorType(XmlAccessType.FIELD)
36 36
@XmlType(name = "TeamOrPersonBase", propOrder = {
37 37
    "nomenclaturalTitle",
38
    "collectorTitle"
38
    "collectorTitleCache"
39 39
})
40 40
@Entity
41 41
@Audited
......
54 54
    protected String nomenclaturalTitle;
55 55

  
56 56
    //under construction #4311
57
    @XmlElement(name="CollectorTitle")
57
    @XmlElement(name="CollectorTitleCache")
58 58
    @Field(index=Index.YES)
59
    @Column(length=255)
60
    protected String collectorTitle;
59
    @Column(length=800)//see #1592
60
    protected String collectorTitleCache;
61 61

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

  
72

  
73
    //#4311
74
    public String getCollectorTitleCache() {
75
        // is title dirty, i.e. equal NULL?
76
        if (collectorTitleCache == null){
77
            this.collectorTitleCache = generateCollectorTitleCache();
78
            this.collectorTitleCache = getTruncatedCache(this.collectorTitleCache) ;
79
        }
80
        return collectorTitleCache;
81
    }
82
    public void setCollectorTitleCache(String collectorTitleCache) {
83
        //TODO
84
        this.collectorTitleCache = collectorTitleCache;
85
    }
86

  
87
    @SuppressWarnings("unchecked")
88
    private String generateCollectorTitleCache() {
89
        if (getCacheStrategy() == null){
90
            return this.getClass() + ": " + this.getUuid();
91
        }else{
92
            return getCacheStrategy().getCollectorTitleCache((T)this);
93
        }
94
    }
95

  
72 96
    /**
73 97
     * Returns the identification string (nomenclatural abbreviation) used in
74 98
     * nomenclature for this {@link Person person} or this {@link Team team}.
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/agent/INomenclaturalAuthorCacheStrategy.java
38 38

  
39 39
    public String getFamilyTitle(T agent);
40 40

  
41
    public String getCollectorTitleCache(T agent);
42

  
43

  
41 44

  
42 45
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/agent/PersonDefaultCacheStrategy.java
88 88
        return person.toString();
89 89
    }
90 90

  
91
    @Override
92
    public String getCollectorTitleCache(Person person){
93
        if (isNotBlank(person.getCollectorTitle())){
94
            return person.getCollectorTitle();
95
        }else{
96
            return getTitleCache(person);
97
        }
98
    }
99

  
91 100
    private String addInitials(String existing, Person person) {
92 101
        String result = existing;
93 102
        String initials = person.getInitials();
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/agent/TeamDefaultCacheStrategy.java
122 122
                return member.getFullTitle();
123 123
            }else if (this == FAMILY){
124 124
                return member.getCacheStrategy().getFamilyTitle(member);
125
//          }else if (this == COLLECTOR){
126
//              return member.getCollectroCache();
125
            }else if (this == COLLECTOR){
126
              return member.getCollectorTitleCache();
127 127
            }
128 128
            throw new IllegalStateException("CacheType not supported: " + this);
129 129
        }
......
162 162
        return getCache(team, CacheType.FAMILY, etAlPositionFamilyTitle);
163 163
    }
164 164

  
165
    @Override
166
    public String getCollectorTitleCache(Team team) {
167
        return getCache(team, CacheType.COLLECTOR, etAlPositionCollectorTitle);
168
    }
169

  
165 170
    private String getCache(Team team, CacheType cacheType, int etAlPosition) {
166 171

  
167 172
        String result = "";
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/match/MatchStrategyFactory.java
66 66

  
67 67
            parsedTeamMatchStrategy.setMatchMode("hasMoreMembers", MatchMode.EQUAL);
68 68

  
69
            //TODO is this correct?
70 69
            parsedTeamMatchStrategy.setMatchMode("protectedCollectorTitleCache", MatchMode.EQUAL_OR_FIRST_NULL);
71 70
            parsedTeamMatchStrategy.setMatchMode("protectedNomenclaturalTitleCache", MatchMode.EQUAL);
72 71

  
73
            String[] equalOrNullParams = new String[]{"collectorTitle"};
72
            String[] equalOrNullParams = new String[]{};
74 73
            for(String param : equalOrNullParams){
75 74
                parsedTeamMatchStrategy.setMatchMode(param, MatchMode.EQUAL_OR_FIRST_NULL);
76 75
            }
......
286 285

  
287 286
        //TODO contact does not yet works, also not with EQUAL_OR_ONE_NULL, leads to agent.id=? or agent.id is null query
288 287
        //better should be even handled with MATCH.Equal_OR_ONE_NULL
289
        String[] equalOrNullParams = new String[]{"collectorTitle"};
288
        String[] equalOrNullParams = new String[]{};
290 289
        for(String param : equalOrNullParams){
291 290
            matchStrategy.setMatchMode(param, MatchMode.EQUAL_OR_FIRST_NULL);
292 291
        }
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/agent/PersonDefaultCacheStrategyTest.java
45 45
		person2.setFamilyName("P2FN");
46 46
		person2.setGivenName("P2GN");
47 47
		person2.setSuffix("P2Suff");
48
		person2.setCollectorTitle("P2CT");
48 49

  
49 50
		person3 = Person.NewInstance(); //empty person
50 51
	}
......
72 73
		Assert.assertEquals("Person3 title should start with Person#0", "Person#0", person3.getNomenclaturalTitle().substring(0, 8));
73 74
	}
74 75

  
76
   @Test
77
    public final void testGetCollectorTitleCache(){
78
        Assert.assertNotNull("person1 collector title cache must not to be null", person1.getCollectorTitleCache());
79
        Assert.assertEquals("Person1 collector title cache should be taken from titleCache", "P1FN, P.", person1.getCollectorTitleCache());
80
        person1.setSuffix(null);
81
        Assert.assertEquals("Person1 collector title cache should be taken from titleCache", "P1FN, P.", person1.getCollectorTitleCache());
82
        //peson2
83
        Assert.assertEquals("Person2 collector title cache should be P2CT", "P2CT", person2.getCollectorTitleCache());
84
        //person3
85
        Assert.assertNotNull("person3 collector title cache must not to be null", person3.getCollectorTitleCache());
86
        Assert.assertTrue("Person3 collector title cache must not be empty", StringUtils.isNotBlank(person3.getCollectorTitleCache()));
87
        //don't take to serious, may be also something different, but not empty
88
        Assert.assertEquals("Person3 title should start with Person#0", "Person#0", person3.getCollectorTitleCache().substring(0, 8));
89
    }
90

  
75 91
	@Test
76 92
	public final void testGetTitleCacheAdaptedFromOldVersion(){
77 93
	    Assert.assertNotNull("person1 title cache must not to be null", person1.getTitleCache());
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/agent/TeamDefaultCacheStrategyTest.java
49 49
		person1.setFamilyName("P1FN");
50 50
		person1.setPrefix("Dr1.");
51 51
		person1.setSuffix("Suff1");
52
		person1.setCollectorTitle("P1CT");
52 53

  
53 54
		person2 = Person.NewInstance();
54 55
		person2.setNomenclaturalTitle("P2NomT");
......
189 190
                TeamDefaultCacheStrategy.EMPTY_TEAM, team3.getFullTitle());
190 191
    }
191 192

  
193
    @Test
194
    public final void testGetCollectorTitleCache(){
195
        Assert.assertNotNull("team1 collector title cache must not to be null",
196
                team1.getCollectorTitleCache());
197
        Assert.assertEquals("team1 collector title cache title should be created by elements",
198
                "P1CT", team1.getCollectorTitleCache());
199
        person1.setSuffix(null);
200
        Assert.assertEquals("team1 collector title cache should be P1FN, P.",
201
                "P1CT", team1.getCollectorTitleCache());
202

  
203
        //team2
204
        Assert.assertEquals("team2 collector title cache should be 'P2FN, P., P1CT, P3NomT & P4FN'",
205
                "P2FN, P., P1CT, P3NomT & P4FN", team2.getCollectorTitleCache());
206
        //more
207
        team2.setHasMoreMembers(true);
208
        Assert.assertEquals("team2 collector title cache should be 'P2FN, P., P1CT, P3NomT, P4FN & al.'",
209
                "P2FN, P., P1CT, P3NomT, P4FN & al.", team2.getCollectorTitleCache());
210
        team2.setHasMoreMembers(false);
211
        //3 members
212
        team2.setCacheStrategy(TeamDefaultCacheStrategy.NewInstance(3));
213
        team2.resetCaches();
214
        Assert.assertEquals("team2 collector title cache should still be 'P2FN, P., P1CT & al.' now.",
215
                "P2FN, P., P1CT & al.", team2.getCollectorTitleCache());
216
        //4 members
217
        team2.setCacheStrategy(TeamDefaultCacheStrategy.NewInstance(4));
218
        team2.resetCaches();
219
        Assert.assertEquals("team2 collector title cache should still be 'P2FN, P., P1CT, P3NomT & P4FN' now.",
220
                "P2FN, P., P1CT, P3NomT & P4FN", team2.getCollectorTitleCache());
221

  
222

  
223
        //team3/empty team
224
        Assert.assertNotNull("team3 collector title cache must not to be null",
225
                team3.getCollectorTitleCache());
226
        Assert.assertTrue("team3 collector title cache must not be empty",
227
                StringUtils.isNotBlank(team3.getCollectorTitleCache()));
228

  
229
        //don't take next test to serious, may be also something different, but not empty
230
        Assert.assertEquals("team3 collector title cache should be empty team replacement string", TeamDefaultCacheStrategy.EMPTY_TEAM, team3.getCollectorTitleCache());
231
    }
232

  
192 233
	@Test
193 234
	public final void testListenersOnMembers(){
194 235
		Assert.assertNotNull("team1 title cache must not to be null", team1.getTitleCache());
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/data/FullCoverageDataGenerator.java
247 247
		Person person = Person.NewTitledInstance("Person Title");
248 248
		person.setGivenName("first name");
249 249
		person.setFamilyName("last name");
250
		person.setCollectorTitle("C. collector");
250 251
		person.setLifespan(TimePeriodParser.parseString("1905-1995"));
251 252
		person.setPrefix("prefix");
252 253
		person.setSuffix("suffix");
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v523_525/CollectorTitleUpdater.java
1
/**
2
* Copyright (C) 2021 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.database.update.v523_525;
10

  
11
import java.sql.ResultSet;
12
import java.sql.SQLException;
13
import java.util.ArrayList;
14
import java.util.List;
15

  
16
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.database.update.CaseType;
19
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
20
import eu.etaxonomy.cdm.database.update.SchemaUpdateResult;
21
import eu.etaxonomy.cdm.database.update.SchemaUpdaterStepBase;
22

  
23
/**
24
 * #4311
25
 * @author a.mueller
26
 * @since 22.04.2021
27
 */
28
public class CollectorTitleUpdater extends SchemaUpdaterStepBase {
29

  
30
    private static final String step = "Update collector title";
31

  
32
    public static CollectorTitleUpdater NewInstance (List<ISchemaUpdaterStep> stepList){
33
        return new CollectorTitleUpdater(stepList);
34
    }
35

  
36
    protected CollectorTitleUpdater(List<ISchemaUpdaterStep> stepList) {
37
        super(stepList, step);
38
    }
39
    @Override
40
    public List<ISchemaUpdaterStep> getInnerSteps() {
41
        List<ISchemaUpdaterStep> result = new ArrayList<>();
42

  
43
        return result;
44
    }
45

  
46
    @Override
47
    public void invoke(ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType,
48
            SchemaUpdateResult result) throws SQLException {
49

  
50
        //set collectorCache = titleCache for all persons and teams
51
        String sql = "UPDATE @@AgentBase@@ SET collectorTitleCache = titleCache WHERE DTYPE = 'Person' OR DTYPE = 'Team'";
52
        datasource.executeUpdate(caseType.replaceTableNames(sql));
53

  
54
        //for teams being part of gathering event
55
        sql = " SELECT ab.* FROM @@AgentBase@@ ab WHERE id IN (SELECT actor_id FROM @@GatheringEvent@@) ";
56
        ResultSet rs = datasource.executeQuery(caseType.replaceTableNames(sql));
57
        while (rs.next()){
58
            String dtype = rs.getString("DTYPE");
59
            int id = rs.getInt("id");
60
            if ("Team".equalsIgnoreCase(dtype)){
61
                boolean protectedTitleCache = rs.getBoolean("protectedTitleCache");
62
                if (protectedTitleCache){
63
                    //set protectedCollector = true if protectedTitleCache = true
64
                    sql = "UPDATE @@AgentBase@@ SET protectedCollectorTitleCache = "+getBoolean(true, datasource)+" WHERE id = " + id;
65
                    datasource.executeUpdate(caseType.replaceTableNames(sql));
66
                }else{
67
                    //for each team member handle like persons below
68
                    sql = "SELECT p.* FROM @@AgentBase_AgentBase@@ MN INNER JOIN @@AgentBase@@ p ON p.id = MN.teamMembers_id WHERE MN.team_ID = " + id;
69
                    ResultSet rs2 = datasource.executeQuery(caseType.replaceTableNames(sql));
70
                    while (rs2.next()){
71
                        handlePerson(rs2, datasource, caseType, result);
72
                    }
73
                    rs2.close();
74
                }
75
            }else if ("Person".equalsIgnoreCase(dtype)){
76
                //for each person in gathering event
77
                handlePerson(rs, datasource, caseType, result);
78
            }
79
        }
80
    }
81

  
82
    private void handlePerson(ResultSet rs, ICdmDataSource datasource, CaseType caseType, SchemaUpdateResult result) throws SQLException {
83
        //set collectorTitle = titleCache
84
        int id = rs.getInt("id");
85
        String sql = "UPDATE @@AgentBase@@ SET collectorTitle = titleCache WHERE id = " + id;
86
        datasource.executeUpdate(caseType.replaceTableNames(sql));
87
    }
88
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v523_525/SchemaUpdater_5230_5250.java
13 13

  
14 14
import org.apache.log4j.Logger;
15 15

  
16
import eu.etaxonomy.cdm.database.update.ColumnAdder;
16 17
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
17 18
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
18 19
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
......
50 51

  
51 52
		List<ISchemaUpdaterStep> stepList = new ArrayList<>();
52 53

  
54
		stepName = "Add collectorTitleCache to AgentBase";
55
		tableName = "AgentBase";
56
		newColumnName = "collectorTitleCache";
57
		int length = 255; //TODO
58
		ColumnAdder.NewStringInstance(stepList, stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
53 59

  
60
		CollectorTitleUpdater.NewInstance(stepList);
54 61

  
55 62
        return stepList;
56 63
    }
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/CdmPreDataChangeListener.java
143 143
        }
144 144
    }
145 145

  
146
    //TODO shouldn't we use the "updateCaches" method instead?
146 147
    public static void generateCaches(Object entity){
147 148
        if (entity != null){
148 149
            entity = CdmBase.deproxy(entity);
......
165 166
                        Team team = (Team)teamOrPerson;
166 167
                        //nomTitle is not necessarily cached when it is created
167 168
                        team.setNomenclaturalTitle(nomTitle, team.isProtectedNomenclaturalTitleCache());
169
                        String collectorCache = team.getCollectorTitleCache();
170
                        if (! team.isProtectedCollectorTitleCache()){
171
                            team.setCollectorTitleCache(collectorCache, false);
172
                        }
168 173
                    }else{
169 174
                        teamOrPerson.setNomenclaturalTitle(nomTitle);
170 175
                    }
......
173 178
                        teamOrPerson.setTitleCache(titleCache, false);
174 179
                    }
175 180
                    //if this is changed in future, change also in ImportDeduplicationHelper
176

  
181
                    teamOrPerson.getCollectorTitleCache();
177 182
                }else if(Reference.class.isAssignableFrom(entityClazz)){
178 183
                    //reference caches
179 184
                    Reference ref = (Reference)entity;
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/HandlingCdmEntitiesTest.java
196 196
        // that the teamMembers are not initialized, so no exception is thrown
197 197

  
198 198
        team.setProtectedTitleCache(true);
199
        team.setProtectedCollectorTitleCache(true);
199 200
        taxonService.update(taxon);
200 201

  
201 202
    }
cdmlib-test/src/main/resources/dbscripts/001-cdm.h2.sql
74 74
        CODE varchar(255),
75 75
        NAME varchar(255),
76 76
        COLLECTORTITLE varchar(255),
77
        COLLECTORTITLECACHE varchar(255),
77 78
        NOMENCLATURALTITLE varchar(255),
78 79
        FAMILYNAME varchar(255),
79 80
        GIVENNAME varchar(255),
......
158 159
        NAME varchar(255),
159 160
        ISPARTOF_ID integer,
160 161
        COLLECTORTITLE varchar(255),
162
        COLLECTORTITLECACHE varchar(255),
161 163
        NOMENCLATURALTITLE varchar(255),
162 164
        HASMOREMEMBERS boolean,
163 165
        PROTECTEDCOLLECTORTITLECACHE boolean,
cdmlib-test/src/main/resources/eu/etaxonomy/cdm/database/schema/dataset.dtd
385 385
    LSID CDATA #IMPLIED
386 386
    PROTECTEDTITLECACHE CDATA #IMPLIED
387 387
    TITLECACHE CDATA #IMPLIED
388
    COLLECTORTITLE CDATA #IMPLIED
389
    COLLECTORTITLECACHE CDATA #IMPLIED
390
    PROTECTEDCOLLECTORTITLECACHE CDATA #IMPLIED
388 391
    CODE CDATA #IMPLIED
389 392
    NAME CDATA #IMPLIED
390 393
    NOMENCLATURALTITLE CDATA #IMPLIED
......
445 448
    LSID CDATA #IMPLIED
446 449
    PROTECTEDTITLECACHE CDATA #IMPLIED
447 450
    TITLECACHE CDATA #IMPLIED
451
    COLLECTORTITLE CDATA #IMPLIED
452
    COLLECTORTITLECACHE CDATA #IMPLIED
453
    PROTECTEDCOLLECTORTITLECACHE CDATA #IMPLIED
448 454
    CREATEDBY_ID CDATA #IMPLIED
449 455
    UPDATEDBY_ID CDATA #IMPLIED
450 456
    NOMENCLATURALTITLE CDATA #IMPLIED

Also available in: Unified diff