Project

General

Profile

Download (9.48 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.ColumnNameChanger;
20
import eu.etaxonomy.cdm.database.update.ColumnRemover;
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 = ColumnNameChanger.NewClobInstance(stepName, tableName,
103
                columnName, columnName, INCLUDE_AUDIT);
104
        stepList.add(step);
105

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

    
109
        return stepList;
110

    
111
	}
112

    
113

    
114
	//7857 update name realtionships
115
    private void updateNameRelationships(List<ISchemaUpdaterStep> stepList) {
116

    
117
        //7857 Update symmetrical for name relationships
118
        String stepName = "Update symmetrical for name relationships";
119
        String query = "UPDATE @@DefinedTermBase@@ "
120
                + " SET symmetrical=0 "
121
                + " WHERE uuid IN ('049c6358-1094-4765-9fae-c9972a0e7780', '6e23ad45-3f2a-462b-ad87-d2389cd6e26c', "
122
                + " 'c6f9afcb-8287-4a2b-a6f6-4da3a073d5de', 'eeaea868-c4c1-497f-b9fe-52c9fc4aca53') ";
123
        String tableName = "DefinedTermBase";
124
        ISchemaUpdaterStep step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
125
        stepList.add(step);
126

    
127
        //orthographic variant for
128
        stepName = "orthographic variant for => is orthographic variant for";
129
        UUID uuidTerm = UUID.fromString("eeaea868-c4c1-497f-b9fe-52c9fc4aca53");
130
        UUID uuidLanguage = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523");
131
        String label = "is orthographic variant for";
132
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
133
                label, label, null, uuidLanguage);
134
        stepList.add(step);
135

    
136
        //original spelling for
137
        stepName = "original spelling for => is original spelling for";
138
        uuidTerm = UUID.fromString("264d2be4-e378-4168-9760-a9512ffbddc4");
139
        label = "is original spelling for";
140
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
141
                label, label, null, uuidLanguage);
142
        stepList.add(step);
143

    
144
        //misspelling for
145
        stepName = "misspelling for => is misspelling for";
146
        uuidTerm = UUID.fromString("c6f9afcb-8287-4a2b-a6f6-4da3a073d5de");
147
        label = "is misspelling for";
148
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
149
                label, label, null, uuidLanguage);
150
        stepList.add(step);
151

    
152
        //later homonym for
153
        stepName = "later homonym for => is later homonym for";
154
        uuidTerm = UUID.fromString("80f06f65-58e0-4209-b811-cb40ad7220a6");
155
        label = "is later homonym for";
156
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
157
                label, label, null, uuidLanguage);
158
        stepList.add(step);
159

    
160
        //treated as later homonym for
161
        stepName = " => is treated as later homonym for";
162
        uuidTerm = UUID.fromString("2990a884-3302-4c8b-90b2-dfd31aaa2778");
163
        label = "is treated as later homonym for";
164
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
165
                label, label, null, uuidLanguage);
166
        stepList.add(step);
167

    
168
        //alternative name for
169
        stepName = "alternative name for => is alternative name for";
170
        uuidTerm = UUID.fromString("049c6358-1094-4765-9fae-c9972a0e7780");
171
        label = "is alternative name for";
172
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
173
                label, label, null, uuidLanguage);
174
        stepList.add(step);
175

    
176
        //basionym for
177
        stepName = "basionym for => is basionym for";
178
        uuidTerm = UUID.fromString("25792738-98de-4762-bac1-8c156faded4a");
179
        label = "is basionym for";
180
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
181
                label, label, null, uuidLanguage);
182
        stepList.add(step);
183

    
184
        //replaced synonym for
185
        stepName = "replaced synonym for => is replaced synonym for";
186
        uuidTerm = UUID.fromString("71c67c38-d162-445b-b0c2-7aba56106696");
187
        label = "is replaced synonym for";
188
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
189
                label, label, null, uuidLanguage);
190
        stepList.add(step);
191

    
192
        //conserved against
193
        stepName = "conserved against => is conserved against";
194
        uuidTerm = UUID.fromString("e6439f95-bcac-4ebb-a8b5-69fa5ce79e6a");
195
        label = "is conserved against";
196
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
197
                label, label, null, uuidLanguage);
198
        stepList.add(step);
199

    
200
        //validated by
201
        stepName = "validated by => is validated by";
202
        uuidTerm = UUID.fromString("a176c9ad-b4c2-4c57-addd-90373f8270eb");
203
        label = "is validated by";
204
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
205
                label, label, null, uuidLanguage);
206
        stepList.add(step);
207

    
208
        //later validated by
209
        stepName = "later validated by => is later validated by";
210
        uuidTerm = UUID.fromString("a25ee4c1-863a-4dab-9499-290bf9b89639");
211
        label = "is later validated by";
212
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
213
                label, label, null, uuidLanguage);
214
        stepList.add(step);
215

    
216
        //blocking name for
217
        stepName = "blocking name for => is blocking name for";
218
        uuidTerm = UUID.fromString("1dab357f-2e12-4511-97a4-e5153589e6a6");
219
        label = "blocking name for";
220
        step = TermRepresentationUpdater.NewInstanceWithTitleCache(stepName, uuidTerm,
221
                label, label, null, uuidLanguage);
222
        stepList.add(step);
223

    
224
        //emendation for
225
        stepName = "emendation for => is emendation for";
226
        uuidTerm = UUID.fromString("6e23ad45-3f2a-462b-ad87-d2389cd6e26c");
227
        label = "is emendation for";
228
        step = TermRepresentationUpdater.NewReverseInstance(stepName, uuidTerm,
229
                label, label, null, uuidLanguage);
230
        stepList.add(step);
231
    }
232

    
233
    @Override
234
	public ISchemaUpdater getNextUpdater() {
235
		return null;
236
	}
237

    
238
	@Override
239
	public ISchemaUpdater getPreviousUpdater() {
240
		return SchemaUpdater_47_50.NewInstance();
241
	}
242

    
243
}
    (1-1/1)