Project

General

Profile

Download (18.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 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

    
10
package eu.etaxonomy.cdm.database.update.v50_51;
11

    
12
import java.util.ArrayList;
13
import java.util.List;
14
import java.util.UUID;
15

    
16
import org.apache.log4j.Logger;
17

    
18
import eu.etaxonomy.cdm.database.update.ColumnAdder;
19
import eu.etaxonomy.cdm.database.update.ColumnRemover;
20
import eu.etaxonomy.cdm.database.update.ColumnTypeChanger;
21
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
22
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
23
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
24
import eu.etaxonomy.cdm.database.update.SimpleSchemaUpdaterStep;
25
import eu.etaxonomy.cdm.database.update.TermRepresentationUpdater;
26
import eu.etaxonomy.cdm.database.update.v47_50.SchemaUpdater_47_50;
27

    
28
/**
29
/**
30
 * @author a.mueller
31
 * @date 09.06.2017
32
 *
33
 */
34
public class SchemaUpdater_50_55 extends SchemaUpdaterBase {
35

    
36
	@SuppressWarnings("unused")
37
	private static final Logger logger = Logger.getLogger(SchemaUpdater_50_55.class);
38
	private static final String startSchemaVersion = "5.0.0.0.20180514";
39
	private static final String endSchemaVersion = "5.5.0.0.20190122";
40

    
41
	// ********************** FACTORY METHOD *************************************
42

    
43
	public static SchemaUpdater_50_55 NewInstance() {
44
		return new SchemaUpdater_50_55();
45
	}
46

    
47
	/**
48
	 * @param startSchemaVersion
49
	 * @param endSchemaVersion
50
	 */
51
	protected SchemaUpdater_50_55() {
52
		super(startSchemaVersion, endSchemaVersion);
53
	}
54

    
55
	@Override
56
	protected List<ISchemaUpdaterStep> getUpdaterList() {
57

    
58
		String stepName;
59
		String tableName;
60
		ISchemaUpdaterStep step;
61
		String newColumnName;
62
		String query;
63

    
64
		List<ISchemaUpdaterStep> stepList = new ArrayList<>();
65

    
66

    
67
		//#6699 delete term version
68
		//just in case not fixed before yet
69
		stepName = "Delete term version";
70
		query = "DELETE FROM @@CdmMetaData@@ WHERE propertyName = 'TERM_VERSION'";
71
		step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
72
        stepList.add(step);
73

    
74
        //#7414 remove mediaCreatedOld column
75
        stepName = "remove mediaCreatedOld column";
76
        tableName = "Media";
77
        String oldColumnName = "mediaCreatedOld";
78
        step = ColumnRemover.NewInstance(stepName, tableName, oldColumnName, INCLUDE_AUDIT);
79
        stepList.add(step);
80

    
81
        //TODO remove proparte and partial columns
82

    
83
        //#8004 add sortindex to description element
84
        stepName = "Add sortindex to description element";
85
        tableName = "DescriptionElementBase";
86
        newColumnName = "sortIndex";
87
        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, null, !NOT_NULL);
88
        stepList.add(step);
89

    
90
        //7682 update Point.precision from 0 to null
91
        stepName = "update Point.precision from 0 to null";
92
        query = "UPDATE @@GatheringEvent@@ SET exactLocation_errorRadius = null WHERE exactLocation_errorRadius = 0 ";
93
        tableName = "GatheringEvent";
94
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
95
        stepList.add(step);
96

    
97
        //#7859 CdmPreference.value as CLOB
98
        stepName = "Make CdmPreference.value a CLOB";
99
        String columnName = "value";
100
        tableName = "CdmPreference";
101
        // TODO check non MySQL and with existing data (probably does not exist)
102
        step = ColumnTypeChanger.NewClobInstance(stepName, tableName,
103
                columnName, INCLUDE_AUDIT);
104
        stepList.add(step);
105

    
106
        //7857 update name realtionships
107
        updateNameRelationships(stepList);
108

    
109
        //#7683 allow null for ExternalLink_AUD.uuid
110
        stepName = "Allow null for ExternalLink_AUD.uuid ";
111
        columnName = "uuid";
112
        tableName = "ExternalLink_AUD";
113
        // TODO check non MySQL and with existing data (probably does not exist)
114
        step = ColumnTypeChanger.NewStringSizeInstance(stepName, tableName, columnName, 36, !INCLUDE_AUDIT);
115
        stepList.add(step);
116

    
117
        //7514 change symbols for pro parte synonyms and misapplied name relationship types
118
        updateConceptRelationshipSymbols(stepList);
119

    
120
        //8006
121
        updateTaxonRelationshipLabels(stepList);
122

    
123
        //#7372
124
        stepName = "Add allowDuplicates to feature tree";
125
        tableName = "FeatureTree";
126
        newColumnName = "allowDuplicates";
127
        step = ColumnAdder.NewBooleanInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, false);
128
        stepList.add(step);
129

    
130
        return stepList;
131

    
132
	}
133

    
134
    //8006 update taxon realtionships
135
    private void updateTaxonRelationshipLabels(List<ISchemaUpdaterStep> stepList) {
136

    
137
//        //7857 Update symmetrical for name relationships
138
//        String stepName = "Update symmetrical for name relationships";
139
//        String query = "UPDATE @@DefinedTermBase@@ "
140
//                + " SET symmetrical=0 "
141
//                + " WHERE uuid IN ('049c6358-1094-4765-9fae-c9972a0e7780', '6e23ad45-3f2a-462b-ad87-d2389cd6e26c', "
142
//                + " 'c6f9afcb-8287-4a2b-a6f6-4da3a073d5de', 'eeaea868-c4c1-497f-b9fe-52c9fc4aca53') ";
143
//        String tableName = "DefinedTermBase";
144
//        ISchemaUpdaterStep step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
145
//        stepList.add(step);
146

    
147
        //Taxonomically Included in
148
        String stepName = "Taxonomically Included in => is taxonomically included in";
149
        UUID uuidTerm = UUID.fromString("d13fecdf-eb44-4dd7-9244-26679c05df1c");
150
        UUID uuidLanguage = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523");
151
        String label = "is taxonomically included in";
152
        ISchemaUpdaterStep step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
153
                label, label, null, uuidLanguage);
154
        stepList.add(step);
155

    
156
        stepName = "taxonomically includes => taxonomically includes";
157
        label = "taxonomically includes";
158
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
159
                label, label, null, uuidLanguage);
160
        stepList.add(step);
161

    
162
        //Misapplied Name for
163
        stepName = "Misapplied Name for => is misapplied name for";
164
        uuidTerm = UUID.fromString("1ed87175-59dd-437e-959e-0d71583d8417");
165
        label = "is misapplied name for";
166
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
167
                label, label, null, uuidLanguage);
168
        stepList.add(step);
169

    
170
        stepName = "Has Misapplied Name => has misapplied name";
171
        label = "has misapplied name";
172
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
173
                label, label, null, uuidLanguage);
174
        stepList.add(step);
175

    
176
        //Pro parte Misapplied Name for
177
        stepName = "Pro parte Misapplied Name for => is pro parte misapplied name for";
178
        uuidTerm = UUID.fromString("b59b4bd2-11ff-45d1-bae2-146efdeee206");
179
        label = "is pro parte misapplied name for";
180
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
181
                label, label, null, uuidLanguage);
182
        stepList.add(step);
183

    
184
        stepName = "Has Pro parte Misapplied Name => has pro parte misapplied name";
185
        label = "has pro parte misapplied name";
186
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
187
                label, label, null, uuidLanguage);
188
        stepList.add(step);
189

    
190
        //Partial Misapplied Name for
191
        stepName = "Partial Misapplied Name for => is partial misapplied name for";
192
        uuidTerm = UUID.fromString("859fb615-b0e8-440b-866e-8a19f493cd36");
193
        label = "is partial misapplied name for";
194
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
195
                label, label, null, uuidLanguage);
196
        stepList.add(step);
197

    
198
        stepName = "Has Partial Misapplied Name => has partial misapplied name";
199
        label = "has partial misapplied name";
200
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
201
                label, label, null, uuidLanguage);
202
        stepList.add(step);
203

    
204
        //Pro parte Synonym for
205
        stepName = "Pro parte Synonym for => is pro parte synonym for";
206
        uuidTerm = UUID.fromString("8a896603-0fa3-44c6-9cd7-df2d8792e577");
207
        label = "is pro parte synonym for";
208
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
209
                label, label, null, uuidLanguage);
210
        stepList.add(step);
211

    
212
        stepName = "Has Pro parte Synonym => has pro parte synonym";
213
        label = "has pro parte synonym";
214
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
215
                label, label, null, uuidLanguage);
216
        stepList.add(step);
217

    
218
        //Partial Synonym for
219
        stepName = "Partial Synonym for => is partial synonym for";
220
        uuidTerm = UUID.fromString("9d7a5e56-973c-474c-b6c3-a1cb00833a3c");
221
        label = "is partial synonym for";
222
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
223
                label, label, null, uuidLanguage);
224
        stepList.add(step);
225

    
226
        stepName = "Has Partial Synonym => has partial synonym";
227
        label = "has partial synonym";
228
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
229
                label, label, null, uuidLanguage);
230
        stepList.add(step);
231

    
232
        //Invalid Designation for
233
        stepName = "Invalid Designation for => is invalid designation for";
234
        uuidTerm = UUID.fromString("605b1d01-f2b1-4544-b2e0-6f08def3d6ed");
235
        label = "is invalid designation for";
236
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
237
                label, label, null, uuidLanguage);
238
        stepList.add(step);
239

    
240
        stepName = "Has Invalid Designation => has invalid designation";
241
        label = "has invalid designation";
242
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
243
                label, label, null, uuidLanguage);
244
        stepList.add(step);
245

    
246
        //Not yet worked on
247
        stepName = "Unclear => Not yet worked on";
248
        label = "Not yet worked on";
249
        uuidTerm = UUID.fromString("8d47e59a-790d-428f-8060-01d443519166");
250
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
251
                label, label, null, uuidLanguage);
252
        stepList.add(step);
253
    }
254

    
255

    
256
	//7514
257
    private void updateConceptRelationshipSymbols(List<ISchemaUpdaterStep> stepList) {
258

    
259
        //Update misapplied name symbols
260
        String stepName = "Update misapplied name symbols";
261
        String query = "UPDATE @@DefinedTermBase@@ "
262
                + " SET symbol='––' , inverseSymbol = '-' "
263
                + " WHERE uuid = '1ed87175-59dd-437e-959e-0d71583d8417' ";
264
        String tableName = "DefinedTermBase";
265
        ISchemaUpdaterStep step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
266
        stepList.add(step);
267

    
268
        //Update pro parte misapplied name symbols
269
        stepName = "Update pro parte misapplied name symbols";
270
        query = "UPDATE @@DefinedTermBase@@ "
271
                + " SET symbol='––(p.p.)' , inverseSymbol = '-(p.p.)' "
272
                + " WHERE uuid = 'b59b4bd2-11ff-45d1-bae2-146efdeee206' ";
273
        tableName = "DefinedTermBase";
274
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
275
        stepList.add(step);
276

    
277
        //Update partial misapplied name symbols
278
        stepName = "Update partial misapplied name symbols";
279
        query = "UPDATE @@DefinedTermBase@@ "
280
                + " SET symbol='––(part.)' , inverseSymbol = '-(part.)' "
281
                + " WHERE uuid = '859fb615-b0e8-440b-866e-8a19f493cd36' ";
282
        tableName = "DefinedTermBase";
283
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
284
        stepList.add(step);
285

    
286
        //Update pro parte synonym symbols
287
        stepName = "Update pro parte synonym symbols";
288
        query = "UPDATE @@DefinedTermBase@@ "
289
                + " SET symbol='⊃p.p.' , inverseSymbol = 'p.p.' "
290
                + " WHERE uuid = '8a896603-0fa3-44c6-9cd7-df2d8792e577' ";
291
        tableName = "DefinedTermBase";
292
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
293
        stepList.add(step);
294

    
295
        //Update partial synonym symbols
296
        stepName = "Update partial synonym symbols";
297
        query = "UPDATE @@DefinedTermBase@@ "
298
                + " SET symbol='⊃part.' , inverseSymbol = 'part.' "
299
                + " WHERE uuid = '9d7a5e56-973c-474c-b6c3-a1cb00833a3c' ";
300
        tableName = "DefinedTermBase";
301
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
302
        stepList.add(step);
303

    
304
    }
305

    
306
    //7857 update name realtionships
307
    private void updateNameRelationships(List<ISchemaUpdaterStep> stepList) {
308

    
309
        //7857 Update symmetrical for name relationships
310
        String stepName = "Update symmetrical for name relationships";
311
        String query = "UPDATE @@DefinedTermBase@@ "
312
                + " SET symmetrical=0 "
313
                + " WHERE uuid IN ('049c6358-1094-4765-9fae-c9972a0e7780', '6e23ad45-3f2a-462b-ad87-d2389cd6e26c', "
314
                + " 'c6f9afcb-8287-4a2b-a6f6-4da3a073d5de', 'eeaea868-c4c1-497f-b9fe-52c9fc4aca53') ";
315
        String tableName = "DefinedTermBase";
316
        ISchemaUpdaterStep step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
317
        stepList.add(step);
318

    
319
        //orthographic variant for
320
        stepName = "orthographic variant for => is orthographic variant for";
321
        UUID uuidTerm = UUID.fromString("eeaea868-c4c1-497f-b9fe-52c9fc4aca53");
322
        UUID uuidLanguage = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523");
323
        String label = "is orthographic variant for";
324
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
325
                label, label, null, uuidLanguage);
326
        stepList.add(step);
327

    
328
        //original spelling for
329
        stepName = "original spelling for => is original spelling for";
330
        uuidTerm = UUID.fromString("264d2be4-e378-4168-9760-a9512ffbddc4");
331
        label = "is original spelling for";
332
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
333
                label, label, null, uuidLanguage);
334
        stepList.add(step);
335

    
336
        //misspelling for
337
        stepName = "misspelling for => is misspelling for";
338
        uuidTerm = UUID.fromString("c6f9afcb-8287-4a2b-a6f6-4da3a073d5de");
339
        label = "is misspelling for";
340
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
341
                label, label, null, uuidLanguage);
342
        stepList.add(step);
343

    
344
        //later homonym for
345
        stepName = "later homonym for => is later homonym for";
346
        uuidTerm = UUID.fromString("80f06f65-58e0-4209-b811-cb40ad7220a6");
347
        label = "is later homonym for";
348
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
349
                label, label, null, uuidLanguage);
350
        stepList.add(step);
351

    
352
        //treated as later homonym for
353
        stepName = " => is treated as later homonym for";
354
        uuidTerm = UUID.fromString("2990a884-3302-4c8b-90b2-dfd31aaa2778");
355
        label = "is treated as later homonym for";
356
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
357
                label, label, null, uuidLanguage);
358
        stepList.add(step);
359

    
360
        //alternative name for
361
        stepName = "alternative name for => is alternative name for";
362
        uuidTerm = UUID.fromString("049c6358-1094-4765-9fae-c9972a0e7780");
363
        label = "is alternative name for";
364
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
365
                label, label, null, uuidLanguage);
366
        stepList.add(step);
367

    
368
        //basionym for
369
        stepName = "basionym for => is basionym for";
370
        uuidTerm = UUID.fromString("25792738-98de-4762-bac1-8c156faded4a");
371
        label = "is basionym for";
372
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
373
                label, label, null, uuidLanguage);
374
        stepList.add(step);
375

    
376
        //replaced synonym for
377
        stepName = "replaced synonym for => is replaced synonym for";
378
        uuidTerm = UUID.fromString("71c67c38-d162-445b-b0c2-7aba56106696");
379
        label = "is replaced synonym for";
380
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
381
                label, label, null, uuidLanguage);
382
        stepList.add(step);
383

    
384
        //conserved against
385
        stepName = "conserved against => is conserved against";
386
        uuidTerm = UUID.fromString("e6439f95-bcac-4ebb-a8b5-69fa5ce79e6a");
387
        label = "is conserved against";
388
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
389
                label, label, null, uuidLanguage);
390
        stepList.add(step);
391

    
392
        //validated by
393
        stepName = "validated by => is validated by";
394
        uuidTerm = UUID.fromString("a176c9ad-b4c2-4c57-addd-90373f8270eb");
395
        label = "is validated by";
396
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
397
                label, label, null, uuidLanguage);
398
        stepList.add(step);
399

    
400
        //later validated by
401
        stepName = "later validated by => is later validated by";
402
        uuidTerm = UUID.fromString("a25ee4c1-863a-4dab-9499-290bf9b89639");
403
        label = "is later validated by";
404
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
405
                label, label, null, uuidLanguage);
406
        stepList.add(step);
407

    
408
        //blocking name for
409
        stepName = "blocking name for => is blocking name for";
410
        uuidTerm = UUID.fromString("1dab357f-2e12-4511-97a4-e5153589e6a6");
411
        label = "blocking name for";
412
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
413
                label, label, null, uuidLanguage);
414
        stepList.add(step);
415

    
416
        //emendation for
417
        stepName = "emendation for => is emendation for";
418
        uuidTerm = UUID.fromString("6e23ad45-3f2a-462b-ad87-d2389cd6e26c");
419
        label = "is emendation for";
420
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
421
                label, label, null, uuidLanguage);
422
        stepList.add(step);
423
    }
424

    
425
    @Override
426
	public ISchemaUpdater getNextUpdater() {
427
		return null;
428
	}
429

    
430
	@Override
431
	public ISchemaUpdater getPreviousUpdater() {
432
		return SchemaUpdater_47_50.NewInstance();
433
	}
434

    
435
}
    (1-1/1)