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.v512_515;
|
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.ColumnAdder;
|
18
|
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
|
19
|
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
|
20
|
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
|
21
|
import eu.etaxonomy.cdm.database.update.TableCreator;
|
22
|
import eu.etaxonomy.cdm.database.update.v515_518.SchemaUpdater_5152_5180;
|
23
|
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.CdmVersion;
|
24
|
|
25
|
/**
|
26
|
* @author a.mueller
|
27
|
* @date 10.06.2020
|
28
|
*/
|
29
|
public class SchemaUpdater_5151_5152 extends SchemaUpdaterBase {
|
30
|
|
31
|
@SuppressWarnings("unused")
|
32
|
private static final Logger logger = Logger.getLogger(SchemaUpdater_5151_5152.class);
|
33
|
|
34
|
private static final CdmVersion startSchemaVersion = CdmVersion.V_05_15_01;
|
35
|
private static final CdmVersion endSchemaVersion = CdmVersion.V_05_15_02;
|
36
|
|
37
|
// ********************** FACTORY METHOD *************************************
|
38
|
|
39
|
public static SchemaUpdater_5151_5152 NewInstance() {
|
40
|
return new SchemaUpdater_5151_5152();
|
41
|
}
|
42
|
|
43
|
protected SchemaUpdater_5151_5152() {
|
44
|
super(startSchemaVersion.versionString(), endSchemaVersion.versionString());
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
protected List<ISchemaUpdaterStep> getUpdaterList() {
|
49
|
//
|
50
|
String stepName;
|
51
|
String tableName;
|
52
|
String newColumnName;
|
53
|
String referencedTable;
|
54
|
|
55
|
List<ISchemaUpdaterStep> stepList = new ArrayList<>();
|
56
|
|
57
|
addExternalLinkTables(stepList);
|
58
|
|
59
|
//#9067
|
60
|
stepName = "Add link to Media";
|
61
|
tableName = "Media";
|
62
|
newColumnName = "link_id";
|
63
|
referencedTable = "ExternalLink";
|
64
|
ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
65
|
|
66
|
//9004
|
67
|
stepName = "Add source to TaxonNode";
|
68
|
tableName = "TaxonNode";
|
69
|
newColumnName = "source_id";
|
70
|
referencedTable = "OriginalSourceBase";
|
71
|
ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
72
|
|
73
|
stepName = "Move taxon node citation 2 original source";
|
74
|
Reference2SourceMover.NewInstance(stepList, stepName, tableName, "referenceForParentChildRelation_id", "microReferenceForParentChildRelation", "source_id");
|
75
|
|
76
|
//6581
|
77
|
stepName = "Add source to Classification";
|
78
|
tableName = "Classification";
|
79
|
newColumnName = "source_id";
|
80
|
referencedTable = "OriginalSourceBase";
|
81
|
ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
82
|
|
83
|
//6581
|
84
|
stepName = "Add source to NomenclaturalStatus";
|
85
|
tableName = "NomenclaturalStatus";
|
86
|
newColumnName = "source_id";
|
87
|
referencedTable = "OriginalSourceBase";
|
88
|
ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
89
|
|
90
|
//6581
|
91
|
stepName = "Add source to TypeDesignationBase";
|
92
|
tableName = "TypeDesignationBase";
|
93
|
newColumnName = "source_id";
|
94
|
referencedTable = "OriginalSourceBase";
|
95
|
ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
96
|
|
97
|
//6581
|
98
|
stepName = "Add source to TaxonRelationship";
|
99
|
tableName = "TaxonRelationship";
|
100
|
newColumnName = "source_id";
|
101
|
referencedTable = "OriginalSourceBase";
|
102
|
ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
103
|
|
104
|
//6581
|
105
|
stepName = "Add source to NameRelationship";
|
106
|
tableName = "NameRelationship";
|
107
|
newColumnName = "source_id";
|
108
|
referencedTable = "OriginalSourceBase";
|
109
|
ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
110
|
|
111
|
//6581
|
112
|
stepName = "Add source to HybridRelationship";
|
113
|
tableName = "HybridRelationship";
|
114
|
newColumnName = "source_id";
|
115
|
referencedTable = "OriginalSourceBase";
|
116
|
ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
|
117
|
|
118
|
return stepList;
|
119
|
}
|
120
|
|
121
|
private void addExternalLinkTables(List<ISchemaUpdaterStep> stepList) {
|
122
|
|
123
|
//Table itself exists already
|
124
|
// String stepName = "Create Identifier table";
|
125
|
// boolean includeCdmBaseAttributes = true;
|
126
|
// String tableName = "ExternalLink";
|
127
|
// String[] columnNames = new String[]{"identifier","identifiedObj_type", "identifiedObj_id","type_id"};
|
128
|
// String[] columnTypes = new String[]{"string_800","string_255","int","int"};
|
129
|
// String[] referencedTables = new String[]{null,null,null,"DefinedTermBase"};
|
130
|
// TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
131
|
|
132
|
//AgentBase_ExternalLink
|
133
|
String stepName = "Create AgentBase_ExternalLink table";
|
134
|
boolean includeCdmBaseAttributes = false;
|
135
|
String tableName = "AgentBase_ExternalLink";
|
136
|
String[] columnNames = new String[]{"AgentBase_id","links_id","sortIndex"};
|
137
|
String[] columnTypes = new String[]{"int","int","int"};
|
138
|
String[] referencedTables = new String[]{"AgentBase","ExternalLink",null};
|
139
|
TableCreator step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
140
|
step.setPrimaryKeyParams("AgentBase_id,links_id", "REV,AgentBase_id,links_id");
|
141
|
|
142
|
//Classification_ExternalLink
|
143
|
stepName = "Create Classification_ExternalLink table";
|
144
|
includeCdmBaseAttributes = false;
|
145
|
tableName = "Classification_ExternalLink";
|
146
|
columnNames = new String[]{"Classification_id","links_id","sortIndex"};
|
147
|
columnTypes = new String[]{"int","int","int"};
|
148
|
referencedTables = new String[]{"Classification","ExternalLink",null};
|
149
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
150
|
step.setPrimaryKeyParams("Classification_id,links_id", "REV,Classification_id,links_id");
|
151
|
|
152
|
//Collection_ExternalLink
|
153
|
stepName = "Create Collection_ExternalLink table";
|
154
|
includeCdmBaseAttributes = false;
|
155
|
tableName = "Collection_ExternalLink";
|
156
|
columnNames = new String[]{"Collection_id","links_id","sortIndex"};
|
157
|
columnTypes = new String[]{"int","int","int"};
|
158
|
referencedTables = new String[]{"Collection","ExternalLink",null};
|
159
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
160
|
step.setPrimaryKeyParams("Collection_id,links_id", "REV,Collection_id,links_id");
|
161
|
|
162
|
//DefinedTermBase_ExternalLink
|
163
|
stepName = "Create DefinedTermBase_ExternalLink table";
|
164
|
includeCdmBaseAttributes = false;
|
165
|
tableName = "DefinedTermBase_ExternalLink";
|
166
|
columnNames = new String[]{"DefinedTermBase_id","links_id","sortIndex"};
|
167
|
columnTypes = new String[]{"int","int","int"};
|
168
|
referencedTables = new String[]{"DefinedTermBase","ExternalLink",null};
|
169
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
170
|
step.setPrimaryKeyParams("DefinedTermBase_id,links_id", "REV,DefinedTermBase_id,links_id");
|
171
|
|
172
|
//DescriptionBase_ExternalLink
|
173
|
stepName = "Create DescriptionBase_ExternalLink table";
|
174
|
includeCdmBaseAttributes = false;
|
175
|
tableName = "DescriptionBase_ExternalLink";
|
176
|
columnNames = new String[]{"DescriptionBase_id","links_id","sortIndex"};
|
177
|
columnTypes = new String[]{"int","int","int"};
|
178
|
referencedTables = new String[]{"DescriptionBase","ExternalLink",null};
|
179
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
180
|
step.setPrimaryKeyParams("DescriptionBase_id,links_id", "REV,DescriptionBase_id,links_id");
|
181
|
|
182
|
//DescriptiveDataSet_ExternalLink
|
183
|
stepName = "Create DescriptiveDataSet_ExternalLink table";
|
184
|
includeCdmBaseAttributes = false;
|
185
|
tableName = "DescriptiveDataSet_ExternalLink";
|
186
|
columnNames = new String[]{"DescriptiveDataSet_id","links_id","sortIndex"};
|
187
|
columnTypes = new String[]{"int","int","int"};
|
188
|
referencedTables = new String[]{"DescriptiveDataSet","ExternalLink",null};
|
189
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
190
|
step.setPrimaryKeyParams("DescriptiveDataSet_id,links_id", "REV,DescriptiveDataSet_id,links_id");
|
191
|
|
192
|
//Media_ExternalLink
|
193
|
stepName = "Create Media_ExternalLink table";
|
194
|
includeCdmBaseAttributes = false;
|
195
|
tableName = "Media_ExternalLink";
|
196
|
columnNames = new String[]{"Media_id","links_id","sortIndex"};
|
197
|
columnTypes = new String[]{"int","int","int"};
|
198
|
referencedTables = new String[]{"Media","ExternalLink",null};
|
199
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
200
|
step.setPrimaryKeyParams("Media_id,links_id", "REV,Media_id,links_id");
|
201
|
|
202
|
//PolytomousKey_ExternalLink
|
203
|
stepName = "Create PolytomousKey_ExternalLink table";
|
204
|
includeCdmBaseAttributes = false;
|
205
|
tableName = "PolytomousKey_ExternalLink";
|
206
|
columnNames = new String[]{"PolytomousKey_id","links_id","sortIndex"};
|
207
|
columnTypes = new String[]{"int","int","int"};
|
208
|
referencedTables = new String[]{"PolytomousKey","ExternalLink",null};
|
209
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
210
|
step.setPrimaryKeyParams("PolytomousKey_id,links_id", "REV,PolytomousKey_id,links_id");
|
211
|
|
212
|
//Reference_ExternalLink
|
213
|
stepName = "Create Reference_ExternalLink table";
|
214
|
includeCdmBaseAttributes = false;
|
215
|
tableName = "Reference_ExternalLink";
|
216
|
columnNames = new String[]{"Reference_id","links_id","sortIndex"};
|
217
|
columnTypes = new String[]{"int","int","int"};
|
218
|
referencedTables = new String[]{"Reference","ExternalLink",null};
|
219
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
220
|
step.setPrimaryKeyParams("Reference_id,links_id", "REV,Reference_id,links_id");
|
221
|
|
222
|
//SpecimenOrObservationBase_ExternalLink
|
223
|
stepName = "Create SpecimenOrObservationBase_ExternalLink table";
|
224
|
includeCdmBaseAttributes = false;
|
225
|
tableName = "SpecimenOrObservationBase_ExternalLink";
|
226
|
columnNames = new String[]{"SpecimenOrObservationBase_id","links_id","sortIndex"};
|
227
|
columnTypes = new String[]{"int","int","int"};
|
228
|
referencedTables = new String[]{"SpecimenOrObservationBase","ExternalLink",null};
|
229
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
230
|
step.setPrimaryKeyParams("SpecimenOrObservationBase_id,links_id", "REV,SpecimenOrObservationBase_id,links_id");
|
231
|
|
232
|
//TaxonBase_ExternalLink
|
233
|
stepName = "Create TaxonBase_ExternalLink table";
|
234
|
includeCdmBaseAttributes = false;
|
235
|
tableName = "TaxonBase_ExternalLink";
|
236
|
columnNames = new String[]{"TaxonBase_id","links_id","sortIndex"};
|
237
|
columnTypes = new String[]{"int","int","int"};
|
238
|
referencedTables = new String[]{"TaxonBase","ExternalLink",null};
|
239
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
240
|
step.setPrimaryKeyParams("TaxonBase_id,links_id", "REV,TaxonBase_id,links_id");
|
241
|
|
242
|
//TaxonName_ExternalLink
|
243
|
stepName = "Create TaxonName_ExternalLink table";
|
244
|
includeCdmBaseAttributes = false;
|
245
|
tableName = "TaxonName_ExternalLink";
|
246
|
columnNames = new String[]{"TaxonName_id","links_id","sortIndex"};
|
247
|
columnTypes = new String[]{"int","int","int"};
|
248
|
referencedTables = new String[]{"TaxonName","ExternalLink",null};
|
249
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
250
|
step.setPrimaryKeyParams("TaxonName_id,links_id", "REV,TaxonName_id,links_id");
|
251
|
|
252
|
//TermCollection_ExternalLink
|
253
|
stepName = "Create TermCollection_ExternalLink table";
|
254
|
includeCdmBaseAttributes = false;
|
255
|
tableName = "TermCollection_ExternalLink";
|
256
|
columnNames = new String[]{"TermCollection_id","links_id","sortIndex"};
|
257
|
columnTypes = new String[]{"int","int","int"};
|
258
|
referencedTables = new String[]{"TermCollection","ExternalLink",null};
|
259
|
step = TableCreator.NewInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT, includeCdmBaseAttributes);
|
260
|
step.setPrimaryKeyParams("TermCollection_id,links_id", "REV,TermCollection_id,links_id");
|
261
|
}
|
262
|
|
263
|
@Override
|
264
|
public ISchemaUpdater getPreviousUpdater() {
|
265
|
return SchemaUpdater_5150_5151.NewInstance();
|
266
|
}
|
267
|
|
268
|
@Override
|
269
|
public ISchemaUpdater getNextUpdater() {
|
270
|
return SchemaUpdater_5152_5180.NewInstance();
|
271
|
}
|
272
|
}
|