Project

General

Profile

Download (12.4 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
        return stepList;
121

    
122
	}
123

    
124

    
125
	//7514
126
    private void updateConceptRelationshipSymbols(List<ISchemaUpdaterStep> stepList) {
127

    
128
        //Update misapplied name symbols
129
        String stepName = "Update misapplied name symbols";
130
        String query = "UPDATE @@DefinedTermBase@@ "
131
                + " SET symbol='––' , inverseSymbol = '-' "
132
                + " WHERE uuid = '1ed87175-59dd-437e-959e-0d71583d8417' ";
133
        String tableName = "DefinedTermBase";
134
        ISchemaUpdaterStep step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
135
        stepList.add(step);
136

    
137
        //Update pro parte misapplied name symbols
138
        stepName = "Update pro parte misapplied name symbols";
139
        query = "UPDATE @@DefinedTermBase@@ "
140
                + " SET symbol='––(p.p.)' , inverseSymbol = '-(p.p.)' "
141
                + " WHERE uuid = 'b59b4bd2-11ff-45d1-bae2-146efdeee206' ";
142
        tableName = "DefinedTermBase";
143
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
144
        stepList.add(step);
145

    
146
        //Update partial misapplied name symbols
147
        stepName = "Update partial misapplied name symbols";
148
        query = "UPDATE @@DefinedTermBase@@ "
149
                + " SET symbol='––(part.)' , inverseSymbol = '-(part.)' "
150
                + " WHERE uuid = '859fb615-b0e8-440b-866e-8a19f493cd36' ";
151
        tableName = "DefinedTermBase";
152
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
153
        stepList.add(step);
154

    
155
        //Update pro parte synonym symbols
156
        stepName = "Update pro parte synonym symbols";
157
        query = "UPDATE @@DefinedTermBase@@ "
158
                + " SET symbol='⊃p.p.' , inverseSymbol = 'p.p.' "
159
                + " WHERE uuid = '8a896603-0fa3-44c6-9cd7-df2d8792e577' ";
160
        tableName = "DefinedTermBase";
161
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
162
        stepList.add(step);
163

    
164
        //Update partial synonym symbols
165
        stepName = "Update partial synonym symbols";
166
        query = "UPDATE @@DefinedTermBase@@ "
167
                + " SET symbol='⊃part.' , inverseSymbol = 'part.' "
168
                + " WHERE uuid = '9d7a5e56-973c-474c-b6c3-a1cb00833a3c' ";
169
        tableName = "DefinedTermBase";
170
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
171
        stepList.add(step);
172

    
173
    }
174

    
175
    //7857 update name realtionships
176
    private void updateNameRelationships(List<ISchemaUpdaterStep> stepList) {
177

    
178
        //7857 Update symmetrical for name relationships
179
        String stepName = "Update symmetrical for name relationships";
180
        String query = "UPDATE @@DefinedTermBase@@ "
181
                + " SET symmetrical=0 "
182
                + " WHERE uuid IN ('049c6358-1094-4765-9fae-c9972a0e7780', '6e23ad45-3f2a-462b-ad87-d2389cd6e26c', "
183
                + " 'c6f9afcb-8287-4a2b-a6f6-4da3a073d5de', 'eeaea868-c4c1-497f-b9fe-52c9fc4aca53') ";
184
        String tableName = "DefinedTermBase";
185
        ISchemaUpdaterStep step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
186
        stepList.add(step);
187

    
188
        //orthographic variant for
189
        stepName = "orthographic variant for => is orthographic variant for";
190
        UUID uuidTerm = UUID.fromString("eeaea868-c4c1-497f-b9fe-52c9fc4aca53");
191
        UUID uuidLanguage = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523");
192
        String label = "is orthographic variant for";
193
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
194
                label, label, null, uuidLanguage);
195
        stepList.add(step);
196

    
197
        //original spelling for
198
        stepName = "original spelling for => is original spelling for";
199
        uuidTerm = UUID.fromString("264d2be4-e378-4168-9760-a9512ffbddc4");
200
        label = "is original spelling for";
201
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
202
                label, label, null, uuidLanguage);
203
        stepList.add(step);
204

    
205
        //misspelling for
206
        stepName = "misspelling for => is misspelling for";
207
        uuidTerm = UUID.fromString("c6f9afcb-8287-4a2b-a6f6-4da3a073d5de");
208
        label = "is misspelling for";
209
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
210
                label, label, null, uuidLanguage);
211
        stepList.add(step);
212

    
213
        //later homonym for
214
        stepName = "later homonym for => is later homonym for";
215
        uuidTerm = UUID.fromString("80f06f65-58e0-4209-b811-cb40ad7220a6");
216
        label = "is later homonym for";
217
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
218
                label, label, null, uuidLanguage);
219
        stepList.add(step);
220

    
221
        //treated as later homonym for
222
        stepName = " => is treated as later homonym for";
223
        uuidTerm = UUID.fromString("2990a884-3302-4c8b-90b2-dfd31aaa2778");
224
        label = "is treated as later homonym for";
225
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
226
                label, label, null, uuidLanguage);
227
        stepList.add(step);
228

    
229
        //alternative name for
230
        stepName = "alternative name for => is alternative name for";
231
        uuidTerm = UUID.fromString("049c6358-1094-4765-9fae-c9972a0e7780");
232
        label = "is alternative name for";
233
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
234
                label, label, null, uuidLanguage);
235
        stepList.add(step);
236

    
237
        //basionym for
238
        stepName = "basionym for => is basionym for";
239
        uuidTerm = UUID.fromString("25792738-98de-4762-bac1-8c156faded4a");
240
        label = "is basionym for";
241
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
242
                label, label, null, uuidLanguage);
243
        stepList.add(step);
244

    
245
        //replaced synonym for
246
        stepName = "replaced synonym for => is replaced synonym for";
247
        uuidTerm = UUID.fromString("71c67c38-d162-445b-b0c2-7aba56106696");
248
        label = "is replaced synonym for";
249
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
250
                label, label, null, uuidLanguage);
251
        stepList.add(step);
252

    
253
        //conserved against
254
        stepName = "conserved against => is conserved against";
255
        uuidTerm = UUID.fromString("e6439f95-bcac-4ebb-a8b5-69fa5ce79e6a");
256
        label = "is conserved against";
257
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
258
                label, label, null, uuidLanguage);
259
        stepList.add(step);
260

    
261
        //validated by
262
        stepName = "validated by => is validated by";
263
        uuidTerm = UUID.fromString("a176c9ad-b4c2-4c57-addd-90373f8270eb");
264
        label = "is validated by";
265
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
266
                label, label, null, uuidLanguage);
267
        stepList.add(step);
268

    
269
        //later validated by
270
        stepName = "later validated by => is later validated by";
271
        uuidTerm = UUID.fromString("a25ee4c1-863a-4dab-9499-290bf9b89639");
272
        label = "is later validated by";
273
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
274
                label, label, null, uuidLanguage);
275
        stepList.add(step);
276

    
277
        //blocking name for
278
        stepName = "blocking name for => is blocking name for";
279
        uuidTerm = UUID.fromString("1dab357f-2e12-4511-97a4-e5153589e6a6");
280
        label = "blocking name for";
281
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
282
                label, label, null, uuidLanguage);
283
        stepList.add(step);
284

    
285
        //emendation for
286
        stepName = "emendation for => is emendation for";
287
        uuidTerm = UUID.fromString("6e23ad45-3f2a-462b-ad87-d2389cd6e26c");
288
        label = "is emendation for";
289
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
290
                label, label, null, uuidLanguage);
291
        stepList.add(step);
292
    }
293

    
294
    @Override
295
	public ISchemaUpdater getNextUpdater() {
296
		return null;
297
	}
298

    
299
	@Override
300
	public ISchemaUpdater getPreviousUpdater() {
301
		return SchemaUpdater_47_50.NewInstance();
302
	}
303

    
304
}
    (1-1/1)