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.v47_49;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
|
18
|
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
|
19
|
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
|
20
|
import eu.etaxonomy.cdm.database.update.v41_47.SchemaUpdater_41_47;
|
21
|
|
22
|
/**
|
23
|
/**
|
24
|
* @author a.mueller
|
25
|
* @date 09.06.2017
|
26
|
*
|
27
|
*/
|
28
|
public class SchemaUpdater_47_49 extends SchemaUpdaterBase {
|
29
|
|
30
|
@SuppressWarnings("unused")
|
31
|
private static final Logger logger = Logger.getLogger(SchemaUpdater_47_49.class);
|
32
|
private static final String endSchemaVersion = "4.9.0.0.20170710";
|
33
|
private static final String startSchemaVersion = "4.7.0.0.201710040000";
|
34
|
|
35
|
// ********************** FACTORY METHOD *************************************
|
36
|
|
37
|
public static SchemaUpdater_47_49 NewInstance() {
|
38
|
return new SchemaUpdater_47_49();
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* @param startSchemaVersion
|
43
|
* @param endSchemaVersion
|
44
|
*/
|
45
|
protected SchemaUpdater_47_49() {
|
46
|
super(startSchemaVersion, endSchemaVersion);
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
protected List<ISchemaUpdaterStep> getUpdaterList() {
|
51
|
|
52
|
String stepName;
|
53
|
String tableName;
|
54
|
ISchemaUpdaterStep step;
|
55
|
String newColumnName;
|
56
|
|
57
|
List<ISchemaUpdaterStep> stepList = new ArrayList<>();
|
58
|
|
59
|
//remove remaining PolytomousKeyNodes (#6705)
|
60
|
|
61
|
//delete term version from CdmMetaData (#6699)
|
62
|
|
63
|
//make all microreferences OriginalSources (#6581) - startet with TaxonName.nomRef
|
64
|
|
65
|
|
66
|
// //#5149 remove unique index on Sequence_Reference.citations_id
|
67
|
// tableName = "Sequence_Reference";
|
68
|
// String columnName = "citations_id";
|
69
|
// step = UniqueIndexDropper.NewInstance(tableName, columnName, !INCLUDE_AUDIT);
|
70
|
// stepList.add(step);
|
71
|
//
|
72
|
//
|
73
|
// //#6340 nom status invalid updater
|
74
|
// step = NomStatusInvalidUpdater.NewInstance();
|
75
|
// stepList.add(step);
|
76
|
//
|
77
|
// //#6529
|
78
|
// //Extend WorkingSet to allow a more fine grained definiton of taxon set
|
79
|
// //min rank
|
80
|
// stepName = "Add minRank column";
|
81
|
// tableName = "WorkingSet";
|
82
|
// newColumnName = "minRank_id";
|
83
|
// String referencedTable = "DefinedTermBase";
|
84
|
// step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
85
|
// stepList.add(step);
|
86
|
//
|
87
|
// //max rank
|
88
|
// stepName = "Add maxRank column";
|
89
|
// tableName = "WorkingSet";
|
90
|
// newColumnName = "maxRank_id";
|
91
|
// referencedTable = "DefinedTermBase";
|
92
|
// step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
93
|
// stepList.add(step);
|
94
|
//
|
95
|
// //subtree filter
|
96
|
// stepName= "Add geo filter MN table to WorkingSet";
|
97
|
// String firstTableName = "WorkingSet";
|
98
|
// String secondTableAlias = "NamedArea";
|
99
|
// String secondTableName = "DefinedTermBase";
|
100
|
// String attributeName = "geoFilter";
|
101
|
// boolean isList = ! IS_LIST;
|
102
|
// step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
|
103
|
// stepList.add(step);
|
104
|
//
|
105
|
// //subtree filter
|
106
|
// stepName= "Add subtree filter MN table to WorkingSet";
|
107
|
// firstTableName = "WorkingSet";
|
108
|
// secondTableName = "TaxonNode";
|
109
|
// secondTableAlias = null;
|
110
|
// attributeName = "taxonSubtreeFilter";
|
111
|
// isList = ! IS_LIST;
|
112
|
// step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
|
113
|
// stepList.add(step);
|
114
|
//
|
115
|
// //#6258
|
116
|
// stepName = "Add Registration table";
|
117
|
// tableName = "Registration";
|
118
|
// String[] columnNames = new String[]{"identifier","specificIdentifier","registrationDate","status",
|
119
|
// "institution_id","name_id","submitter_id"};
|
120
|
// String[] referencedTables = new String[]{null, null, null, null,
|
121
|
// "AgentBase","TaxonNameBase","UserAccount"};
|
122
|
// String[] columnTypes = new String[]{"string_255","string_255","datetime","string_10","int","int","int"};
|
123
|
// step = TableCreator.NewAnnotatableInstance(stepName, tableName,
|
124
|
// columnNames, columnTypes, referencedTables, INCLUDE_AUDIT);
|
125
|
// stepList.add(step);
|
126
|
//
|
127
|
// //add blockedBy_id
|
128
|
// stepName= "Add blockedBy_id to Registration";
|
129
|
// firstTableName = "Registration";
|
130
|
// secondTableName = "Registration";
|
131
|
// attributeName = "blockedBy";
|
132
|
// isList = ! IS_LIST;
|
133
|
// step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, null, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
|
134
|
// stepList.add(step);
|
135
|
//
|
136
|
// //add type designations
|
137
|
// stepName= "Add type designations to Registration";
|
138
|
// firstTableName = "Registration";
|
139
|
// String firstColumnName = "registrations";
|
140
|
// secondTableName = "TypeDesignationBase";
|
141
|
// attributeName = "typeDesignations";
|
142
|
// isList = false;
|
143
|
// step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, firstColumnName, secondTableName, null, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
|
144
|
// stepList.add(step);
|
145
|
//
|
146
|
// //#5258
|
147
|
// //Add "accessed" to Reference
|
148
|
// stepName = "Add 'accessed' to Reference";
|
149
|
// tableName = "Reference";
|
150
|
// newColumnName = "accessed";
|
151
|
// step = ColumnAdder.NewDateTimeInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL);
|
152
|
// stepList.add(step);
|
153
|
//
|
154
|
// //#6618 Add structure column to DefinedTermBase (Character)
|
155
|
// stepName = "Add structure column to DefinedTermBase (Character)";
|
156
|
// tableName = "DefinedTermBase";
|
157
|
// newColumnName = "structure_id";
|
158
|
// referencedTable = "FeatureNode";
|
159
|
// step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
160
|
// stepList.add(step);
|
161
|
//
|
162
|
// //#6618 Add property column to DefinedTermBase (Character)
|
163
|
// stepName = "Add property column to DefinedTermBase (Character)";
|
164
|
// tableName = "DefinedTermBase";
|
165
|
// newColumnName = "property_id";
|
166
|
// referencedTable = "FeatureNode";
|
167
|
// step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
168
|
// stepList.add(step);
|
169
|
//
|
170
|
// //##6661 Add initials to agent base
|
171
|
// stepName = "Add initials to AgentBase";
|
172
|
// tableName = "AgentBase";
|
173
|
// newColumnName = "initials";
|
174
|
// int length = 80;
|
175
|
// step = ColumnAdder.NewStringInstance(stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
|
176
|
// stepList.add(step);
|
177
|
//
|
178
|
// stepName = "Update initials and firstname";
|
179
|
// step = InitialsUpdater.NewInstance();
|
180
|
// stepList.add(step);
|
181
|
//
|
182
|
// //#6663
|
183
|
// //Add "lastRetrieved" to Reference
|
184
|
// stepName = "Add 'lastRetrieved' to Reference";
|
185
|
// tableName = "Reference";
|
186
|
// newColumnName = "lastRetrieved";
|
187
|
// step = ColumnAdder.NewDateTimeInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL);
|
188
|
// stepList.add(step);
|
189
|
//
|
190
|
// stepName = "Add externalId to Reference";
|
191
|
// tableName = "Reference";
|
192
|
// newColumnName = "externalId";
|
193
|
// length = 255;
|
194
|
// step = ColumnAdder.NewStringInstance(stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
|
195
|
// stepList.add(step);
|
196
|
//
|
197
|
// stepName = "Add externalLink to Reference";
|
198
|
// tableName = "Reference";
|
199
|
// newColumnName = "externalLink";
|
200
|
// step = ColumnAdder.NewClobInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT);
|
201
|
// stepList.add(step);
|
202
|
//
|
203
|
// stepName = "Add authorityType to Reference";
|
204
|
// tableName = "Reference";
|
205
|
// newColumnName = "authorityType";
|
206
|
// length = 10;
|
207
|
// step = ColumnAdder.NewStringInstance(stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
|
208
|
// stepList.add(step);
|
209
|
//
|
210
|
// //#6472 add key to IntextReference
|
211
|
// stepName = "Add key to IntextReference";
|
212
|
// tableName = "IntextReference";
|
213
|
// newColumnName = "key_id";
|
214
|
// referencedTable = "PolytomousKey";
|
215
|
// step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
216
|
// stepList.add(step);
|
217
|
//
|
218
|
// //#5817 rename relationshipTermBase_inverseRepresentation
|
219
|
// stepName = "Rename relationshipTermBase_inverseRepresentation";
|
220
|
// String oldName = "RelationshipTermBase_inverseRepresentation";
|
221
|
// String newName = "TermBase_inverseRepresentation";
|
222
|
// step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT);
|
223
|
// stepList.add(step);
|
224
|
//
|
225
|
// //#5817 rename TermBase_inverseRepresentation.relationshipTermBase_id
|
226
|
// stepName = "Rename relationshipTermBase_inverseRepresentation.relationshipTermBase_id";
|
227
|
// tableName = newName;
|
228
|
// String oldColumnName = "relationshipTermBase_id";
|
229
|
// newColumnName = "term_id";
|
230
|
// step = ColumnNameChanger.NewIntegerInstance(stepName, tableName, oldColumnName, newColumnName, INCLUDE_AUDIT);
|
231
|
// stepList.add(step);
|
232
|
//
|
233
|
// //#6226 remove orphaned PolytomousKeyNodes
|
234
|
// stepName = "remove orphaned PolytomousKeyNodes";
|
235
|
// String query = " DELETE FROM @@PolytomousKeyNode@@ WHERE key_id NOT IN (SELECT id FROM @@PolytomousKey@@)";
|
236
|
// String aud_query = " DELETE FROM @@PolytomousKeyNode_AUD@@ WHERE key_id NOT IN (SELECT id FROM @@PolytomousKey_AUD@@)";
|
237
|
// step = SimpleSchemaUpdaterStep.NewExplicitAuditedInstance(stepName, query, aud_query, -99);
|
238
|
// stepList.add(step);
|
239
|
|
240
|
return stepList;
|
241
|
}
|
242
|
|
243
|
|
244
|
@Override
|
245
|
public ISchemaUpdater getNextUpdater() {
|
246
|
return null;
|
247
|
}
|
248
|
|
249
|
@Override
|
250
|
public ISchemaUpdater getPreviousUpdater() {
|
251
|
return SchemaUpdater_41_47.NewInstance();
|
252
|
}
|
253
|
|
254
|
}
|