Project

General

Profile

Download (18.3 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
        return stepList;
124

    
125
	}
126

    
127
    //8006 update taxon realtionships
128
    private void updateTaxonRelationshipLabels(List<ISchemaUpdaterStep> stepList) {
129

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

    
140
        //Taxonomically Included in
141
        String stepName = "Taxonomically Included in => is taxonomically included in";
142
        UUID uuidTerm = UUID.fromString("d13fecdf-eb44-4dd7-9244-26679c05df1c");
143
        UUID uuidLanguage = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523");
144
        String label = "is taxonomically included in";
145
        ISchemaUpdaterStep step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
146
                label, label, null, uuidLanguage);
147
        stepList.add(step);
148

    
149
        stepName = "taxonomically includes => taxonomically includes";
150
        label = "taxonomically includes";
151
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
152
                label, label, null, uuidLanguage);
153
        stepList.add(step);
154

    
155
        //Misapplied Name for
156
        stepName = "Misapplied Name for => is misapplied name for";
157
        uuidTerm = UUID.fromString("1ed87175-59dd-437e-959e-0d71583d8417");
158
        label = "is misapplied name for";
159
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
160
                label, label, null, uuidLanguage);
161
        stepList.add(step);
162

    
163
        stepName = "Has Misapplied Name => has misapplied name";
164
        label = "has misapplied name";
165
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
166
                label, label, null, uuidLanguage);
167
        stepList.add(step);
168

    
169
        //Pro parte Misapplied Name for
170
        stepName = "Pro parte Misapplied Name for => is pro parte misapplied name for";
171
        uuidTerm = UUID.fromString("b59b4bd2-11ff-45d1-bae2-146efdeee206");
172
        label = "is pro parte misapplied name for";
173
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
174
                label, label, null, uuidLanguage);
175
        stepList.add(step);
176

    
177
        stepName = "Has Pro parte Misapplied Name => has pro parte misapplied name";
178
        label = "has pro parte misapplied name";
179
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
180
                label, label, null, uuidLanguage);
181
        stepList.add(step);
182

    
183
        //Partial Misapplied Name for
184
        stepName = "Partial Misapplied Name for => is partial misapplied name for";
185
        uuidTerm = UUID.fromString("859fb615-b0e8-440b-866e-8a19f493cd36");
186
        label = "is partial misapplied name for";
187
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
188
                label, label, null, uuidLanguage);
189
        stepList.add(step);
190

    
191
        stepName = "Has Partial Misapplied Name => has partial misapplied name";
192
        label = "has partial misapplied name";
193
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
194
                label, label, null, uuidLanguage);
195
        stepList.add(step);
196

    
197
        //Pro parte Synonym for
198
        stepName = "Pro parte Synonym for => is pro parte synonym for";
199
        uuidTerm = UUID.fromString("8a896603-0fa3-44c6-9cd7-df2d8792e577");
200
        label = "is pro parte synonym for";
201
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
202
                label, label, null, uuidLanguage);
203
        stepList.add(step);
204

    
205
        stepName = "Has Pro parte Synonym => has pro parte synonym";
206
        label = "has pro parte synonym";
207
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
208
                label, label, null, uuidLanguage);
209
        stepList.add(step);
210

    
211
        //Partial Synonym for
212
        stepName = "Partial Synonym for => is partial synonym for";
213
        uuidTerm = UUID.fromString("9d7a5e56-973c-474c-b6c3-a1cb00833a3c");
214
        label = "is partial synonym for";
215
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
216
                label, label, null, uuidLanguage);
217
        stepList.add(step);
218

    
219
        stepName = "Has Partial Synonym => has partial synonym";
220
        label = "has partial synonym";
221
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
222
                label, label, null, uuidLanguage);
223
        stepList.add(step);
224

    
225
        //Invalid Designation for
226
        stepName = "Invalid Designation for => is invalid designation for";
227
        uuidTerm = UUID.fromString("605b1d01-f2b1-4544-b2e0-6f08def3d6ed");
228
        label = "is invalid designation for";
229
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
230
                label, label, null, uuidLanguage);
231
        stepList.add(step);
232

    
233
        stepName = "Has Invalid Designation => has invalid designation";
234
        label = "has invalid designation";
235
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
236
                label, label, null, uuidLanguage);
237
        stepList.add(step);
238

    
239
        //Not yet worked on
240
        stepName = "Unclear => Not yet worked on";
241
        label = "Not yet worked on";
242
        uuidTerm = UUID.fromString("8d47e59a-790d-428f-8060-01d443519166");
243
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
244
                label, label, null, uuidLanguage);
245
        stepList.add(step);
246
    }
247

    
248

    
249
	//7514
250
    private void updateConceptRelationshipSymbols(List<ISchemaUpdaterStep> stepList) {
251

    
252
        //Update misapplied name symbols
253
        String stepName = "Update misapplied name symbols";
254
        String query = "UPDATE @@DefinedTermBase@@ "
255
                + " SET symbol='––' , inverseSymbol = '-' "
256
                + " WHERE uuid = '1ed87175-59dd-437e-959e-0d71583d8417' ";
257
        String tableName = "DefinedTermBase";
258
        ISchemaUpdaterStep step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
259
        stepList.add(step);
260

    
261
        //Update pro parte misapplied name symbols
262
        stepName = "Update pro parte misapplied name symbols";
263
        query = "UPDATE @@DefinedTermBase@@ "
264
                + " SET symbol='––(p.p.)' , inverseSymbol = '-(p.p.)' "
265
                + " WHERE uuid = 'b59b4bd2-11ff-45d1-bae2-146efdeee206' ";
266
        tableName = "DefinedTermBase";
267
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
268
        stepList.add(step);
269

    
270
        //Update partial misapplied name symbols
271
        stepName = "Update partial misapplied name symbols";
272
        query = "UPDATE @@DefinedTermBase@@ "
273
                + " SET symbol='––(part.)' , inverseSymbol = '-(part.)' "
274
                + " WHERE uuid = '859fb615-b0e8-440b-866e-8a19f493cd36' ";
275
        tableName = "DefinedTermBase";
276
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
277
        stepList.add(step);
278

    
279
        //Update pro parte synonym symbols
280
        stepName = "Update pro parte synonym symbols";
281
        query = "UPDATE @@DefinedTermBase@@ "
282
                + " SET symbol='⊃p.p.' , inverseSymbol = 'p.p.' "
283
                + " WHERE uuid = '8a896603-0fa3-44c6-9cd7-df2d8792e577' ";
284
        tableName = "DefinedTermBase";
285
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
286
        stepList.add(step);
287

    
288
        //Update partial synonym symbols
289
        stepName = "Update partial synonym symbols";
290
        query = "UPDATE @@DefinedTermBase@@ "
291
                + " SET symbol='⊃part.' , inverseSymbol = 'part.' "
292
                + " WHERE uuid = '9d7a5e56-973c-474c-b6c3-a1cb00833a3c' ";
293
        tableName = "DefinedTermBase";
294
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
295
        stepList.add(step);
296

    
297
    }
298

    
299
    //7857 update name realtionships
300
    private void updateNameRelationships(List<ISchemaUpdaterStep> stepList) {
301

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

    
312
        //orthographic variant for
313
        stepName = "orthographic variant for => is orthographic variant for";
314
        UUID uuidTerm = UUID.fromString("eeaea868-c4c1-497f-b9fe-52c9fc4aca53");
315
        UUID uuidLanguage = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523");
316
        String label = "is orthographic variant for";
317
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
318
                label, label, null, uuidLanguage);
319
        stepList.add(step);
320

    
321
        //original spelling for
322
        stepName = "original spelling for => is original spelling for";
323
        uuidTerm = UUID.fromString("264d2be4-e378-4168-9760-a9512ffbddc4");
324
        label = "is original spelling for";
325
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
326
                label, label, null, uuidLanguage);
327
        stepList.add(step);
328

    
329
        //misspelling for
330
        stepName = "misspelling for => is misspelling for";
331
        uuidTerm = UUID.fromString("c6f9afcb-8287-4a2b-a6f6-4da3a073d5de");
332
        label = "is misspelling for";
333
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
334
                label, label, null, uuidLanguage);
335
        stepList.add(step);
336

    
337
        //later homonym for
338
        stepName = "later homonym for => is later homonym for";
339
        uuidTerm = UUID.fromString("80f06f65-58e0-4209-b811-cb40ad7220a6");
340
        label = "is later homonym for";
341
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
342
                label, label, null, uuidLanguage);
343
        stepList.add(step);
344

    
345
        //treated as later homonym for
346
        stepName = " => is treated as later homonym for";
347
        uuidTerm = UUID.fromString("2990a884-3302-4c8b-90b2-dfd31aaa2778");
348
        label = "is treated as later homonym for";
349
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
350
                label, label, null, uuidLanguage);
351
        stepList.add(step);
352

    
353
        //alternative name for
354
        stepName = "alternative name for => is alternative name for";
355
        uuidTerm = UUID.fromString("049c6358-1094-4765-9fae-c9972a0e7780");
356
        label = "is alternative name for";
357
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
358
                label, label, null, uuidLanguage);
359
        stepList.add(step);
360

    
361
        //basionym for
362
        stepName = "basionym for => is basionym for";
363
        uuidTerm = UUID.fromString("25792738-98de-4762-bac1-8c156faded4a");
364
        label = "is basionym for";
365
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
366
                label, label, null, uuidLanguage);
367
        stepList.add(step);
368

    
369
        //replaced synonym for
370
        stepName = "replaced synonym for => is replaced synonym for";
371
        uuidTerm = UUID.fromString("71c67c38-d162-445b-b0c2-7aba56106696");
372
        label = "is replaced synonym for";
373
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
374
                label, label, null, uuidLanguage);
375
        stepList.add(step);
376

    
377
        //conserved against
378
        stepName = "conserved against => is conserved against";
379
        uuidTerm = UUID.fromString("e6439f95-bcac-4ebb-a8b5-69fa5ce79e6a");
380
        label = "is conserved against";
381
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
382
                label, label, null, uuidLanguage);
383
        stepList.add(step);
384

    
385
        //validated by
386
        stepName = "validated by => is validated by";
387
        uuidTerm = UUID.fromString("a176c9ad-b4c2-4c57-addd-90373f8270eb");
388
        label = "is validated by";
389
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
390
                label, label, null, uuidLanguage);
391
        stepList.add(step);
392

    
393
        //later validated by
394
        stepName = "later validated by => is later validated by";
395
        uuidTerm = UUID.fromString("a25ee4c1-863a-4dab-9499-290bf9b89639");
396
        label = "is later validated by";
397
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
398
                label, label, null, uuidLanguage);
399
        stepList.add(step);
400

    
401
        //blocking name for
402
        stepName = "blocking name for => is blocking name for";
403
        uuidTerm = UUID.fromString("1dab357f-2e12-4511-97a4-e5153589e6a6");
404
        label = "blocking name for";
405
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
406
                label, label, null, uuidLanguage);
407
        stepList.add(step);
408

    
409
        //emendation for
410
        stepName = "emendation for => is emendation for";
411
        uuidTerm = UUID.fromString("6e23ad45-3f2a-462b-ad87-d2389cd6e26c");
412
        label = "is emendation for";
413
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
414
                label, label, null, uuidLanguage);
415
        stepList.add(step);
416
    }
417

    
418
    @Override
419
	public ISchemaUpdater getNextUpdater() {
420
		return null;
421
	}
422

    
423
	@Override
424
	public ISchemaUpdater getPreviousUpdater() {
425
		return SchemaUpdater_47_50.NewInstance();
426
	}
427

    
428
}
    (1-1/1)