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.v505_508;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.database.update.ColumnAdder;
|
18
|
import eu.etaxonomy.cdm.database.update.ColumnNameChanger;
|
19
|
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
|
20
|
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
|
21
|
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
|
22
|
import eu.etaxonomy.cdm.database.update.TableCreator;
|
23
|
|
24
|
/**
|
25
|
* @author a.mueller
|
26
|
* @date 02.08.2019
|
27
|
*/
|
28
|
public class SchemaUpdater_58_581 extends SchemaUpdaterBase {
|
29
|
|
30
|
@SuppressWarnings("unused")
|
31
|
private static final Logger logger = LogManager.getLogger(SchemaUpdater_58_581.class);
|
32
|
|
33
|
private static final String endSchemaVersion = "5.8.1.0.20190813";
|
34
|
private static final String startSchemaVersion = "5.8.0.0.201906020";
|
35
|
|
36
|
// ********************** FACTORY METHOD *************************************
|
37
|
|
38
|
public static SchemaUpdater_58_581 NewInstance() {
|
39
|
return new SchemaUpdater_58_581();
|
40
|
}
|
41
|
|
42
|
/**
|
43
|
* @param startSchemaVersion
|
44
|
* @param endSchemaVersion
|
45
|
*/
|
46
|
protected SchemaUpdater_58_581() {
|
47
|
super(startSchemaVersion, endSchemaVersion);
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
protected List<ISchemaUpdaterStep> getUpdaterList() {
|
52
|
|
53
|
String stepName;
|
54
|
String tableName;
|
55
|
String newColumnName;
|
56
|
String oldColumnName;
|
57
|
|
58
|
List<ISchemaUpdaterStep> stepList = new ArrayList<>();
|
59
|
|
60
|
//#8429
|
61
|
stepName = "Rename DeterminationEvent.setOfReferences";
|
62
|
tableName = "DeterminationEvent_Reference";
|
63
|
oldColumnName = "setOfReferences_id";
|
64
|
newColumnName = "references_id";
|
65
|
ColumnNameChanger.NewIntegerInstance(stepList, stepName, tableName,
|
66
|
oldColumnName, newColumnName, INCLUDE_AUDIT);
|
67
|
|
68
|
//7099 Make CdmAuthority a persistable class - create 'Authority' table
|
69
|
stepName = "Create Authority table ";
|
70
|
tableName = "Authority";
|
71
|
String[] columnNames = new String[]{"DTYPE", "operations", "permissionClass",
|
72
|
"property", "targetUuid", "role"};
|
73
|
String[] columnTypes = new String[]{"string_255","string_255","string_255","string_255",
|
74
|
"string_36","string_255"};
|
75
|
String[] referencedTables = new String[]{null, null, null, null, null, null};
|
76
|
TableCreator.NewNonVersionableInstance(stepList, stepName, tableName,
|
77
|
columnNames, columnTypes, referencedTables);
|
78
|
|
79
|
//7099 Make CdmAuthority a persistable class - create PermissionGroup_Authority table
|
80
|
stepName = "Create PermissionGroup_Authority table ";
|
81
|
tableName = "PermissionGroup_Authority";
|
82
|
columnNames = new String[]{"Group_id", "authorities_id"};
|
83
|
columnTypes = new String[]{"int","int"};
|
84
|
referencedTables = new String[]{"PermissionGroup", "Authority"};
|
85
|
TableCreator.NewNonVersionableInstance(stepList, stepName, tableName,
|
86
|
columnNames, columnTypes, referencedTables);
|
87
|
|
88
|
//7099 Make CdmAuthority a persistable class - create UserAccount_Authority table
|
89
|
stepName = "Create UserAccount_Authority table ";
|
90
|
tableName = "UserAccount_Authority";
|
91
|
columnNames = new String[]{"User_id", "authorities_id"};
|
92
|
columnTypes = new String[]{"int","int"};
|
93
|
referencedTables = new String[]{"UserAccount", "Authority"};
|
94
|
TableCreator.NewNonVersionableInstance(stepList, stepName, tableName,
|
95
|
columnNames, columnTypes, referencedTables);
|
96
|
|
97
|
//#8442
|
98
|
addExternalDataHandler(stepList, "DefinedTermBase");
|
99
|
|
100
|
//#8442
|
101
|
addExternalDataHandler(stepList, "TermCollection");
|
102
|
|
103
|
//#8442 / #6663
|
104
|
stepName = "Add importMethod to Reference";
|
105
|
tableName = "Reference";
|
106
|
newColumnName = "importMethod";
|
107
|
int length = 30;
|
108
|
ColumnAdder.NewStringInstance(stepList, stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
|
109
|
|
110
|
//
|
111
|
UsernameRegexAdapter.NewInstance(stepList);
|
112
|
|
113
|
return stepList;
|
114
|
}
|
115
|
|
116
|
/**
|
117
|
* @param stepList
|
118
|
* @param string
|
119
|
*/
|
120
|
private void addExternalDataHandler(List<ISchemaUpdaterStep> stepList, String tableName) {
|
121
|
//Add "lastRetrieved"
|
122
|
String stepName = "Add 'lastRetrieved' to " + tableName;
|
123
|
String newColumnName = "lastRetrieved";
|
124
|
ColumnAdder.NewDateTimeInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL);
|
125
|
|
126
|
stepName = "Add externalId to DefinedTermBase";
|
127
|
newColumnName = "externalId";
|
128
|
int length = 255;
|
129
|
ColumnAdder.NewStringInstance(stepList, stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
|
130
|
|
131
|
stepName = "Add externalLink to DefinedTermBase";
|
132
|
newColumnName = "externalLink";
|
133
|
ColumnAdder.NewClobInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT);
|
134
|
|
135
|
stepName = "Add authorityType to DefinedTermBase";
|
136
|
newColumnName = "authorityType";
|
137
|
length = 10;
|
138
|
ColumnAdder.NewStringInstance(stepList, stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
|
139
|
|
140
|
stepName = "Add importMethod to DefinedTermBase";
|
141
|
newColumnName = "importMethod";
|
142
|
length = 30;
|
143
|
ColumnAdder.NewStringInstance(stepList, stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
|
144
|
}
|
145
|
|
146
|
@Override
|
147
|
public ISchemaUpdater getPreviousUpdater() {
|
148
|
return SchemaUpdater_55_58.NewInstance();
|
149
|
}
|
150
|
}
|