Project

General

Profile

Revision 46366f19

ID46366f19ce798dd0f0c833473940e7e31ae2c8f7
Parent 8e9115f6
Child 94d72025

Added by Andreas Müller over 2 years ago

initialize CDM 4.9 schema update

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/CdmMetaData.java
59 59
	 * The last number represents the date of change.
60 60
	 */
61 61
//	private static final String dbSchemaVersion = "4.1.0.0.201607300000";
62
  private static final String dbSchemaVersion = "4.7.0.0.201710040000";
63

  
64
	/**
65
	 * The version number for the terms loaded by the termloader (csv-files)
66
	 * It is recommended to have the first two numbers equal to the CDM Library version number.
67
	 *
68
	 * But it is not obligatory as there may be cases when the library number changes but the
69
	 * schema version is not changing.
70
	 *
71
	 * The third should be incremented if the terms change in a way that is not compatible
72
	 * to the previous version (e.g. by changing the type of a term)
73
	 *
74
	 * The fourth number should be incremented when compatible term changes take place
75
	 * (e.g. when new terms were added)
76
	 *
77
	 * The last number represents the date of change.
78
	 */
79
	private static final String termsVersion = "4.1.0.0.201607300000";
80
//	private static final String termsVersion = "4.0.0.0.201604200000";
62
//  private static final String dbSchemaVersion = "4.7.0.0.201710040000";
63
     private static final String dbSchemaVersion = "4.9.0.0.20170710";
81 64

  
82 65

  
83 66
	/* END OF CONFUSION */
......
121 104
        List<CdmMetaData> result = new ArrayList<>();
122 105
        // schema version
123 106
        result.add(new CdmMetaData(CdmMetaDataPropertyName.DB_SCHEMA_VERSION, dbSchemaVersion));
124
        //term version
125
        result.add(new CdmMetaData(CdmMetaDataPropertyName.TERMS_VERSION, termsVersion));
126 107
        // database create time
127 108
        result.add(new CdmMetaData(CdmMetaDataPropertyName.DB_CREATE_DATE, new DateTime().toString()));
128 109
        result.add(new CdmMetaData(CdmMetaDataPropertyName.INSTANCE_ID, UUID.randomUUID().toString()));
......
173 154
			this.monitor = monitor;
174 155
		}
175 156

  
176
		/* (non-Javadoc)
177
		 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
178
		 */
179 157
		@Override
180 158
        public int compare(String version1, String version2) {
181 159
			int result = 0;
......
244 222
		return dbSchemaVersion;
245 223
	}
246 224

  
247
	public static String getTermsVersion() {
248
		return termsVersion;
249
	}
250

  
251
	public static boolean isTermsVersionCompatible(String version){
252
		return compareVersion(termsVersion, version, 3, null) == 0;
253
	}
254

  
255 225
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/CdmUpdater.java
17 17
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
18 18
import eu.etaxonomy.cdm.database.CdmDataSource;
19 19
import eu.etaxonomy.cdm.database.ICdmDataSource;
20
import eu.etaxonomy.cdm.database.update.v41_47.SchemaUpdater_41_47;
20
import eu.etaxonomy.cdm.database.update.v47_49.SchemaUpdater_47_49;
21 21
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
22 22

  
23 23
/**
......
74 74
     * @return
75 75
     */
76 76
    private ISchemaUpdater getCurrentSchemaUpdater() {
77
        return SchemaUpdater_41_47.NewInstance();
77
        return SchemaUpdater_47_49.NewInstance();
78 78
    }
79 79

  
80 80
    /**
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v41_47/SchemaUpdater_41_47.java
27 27
import eu.etaxonomy.cdm.database.update.TableNameChanger;
28 28
import eu.etaxonomy.cdm.database.update.UniqueIndexDropper;
29 29
import eu.etaxonomy.cdm.database.update.v40_41.SchemaUpdater_40_41;
30
import eu.etaxonomy.cdm.database.update.v47_49.SchemaUpdater_47_49;
30 31

  
31 32
/**
32 33
 * @author a.mueller
......
536 537

  
537 538
    @Override
538 539
	public ISchemaUpdater getNextUpdater() {
539
		return null;
540
		return SchemaUpdater_47_49.NewInstance() ;
540 541
	}
541 542

  
542 543
	@Override
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v47_49/SchemaUpdater_47_49.java
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
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)