Project

General

Profile

Revision 4b1a00be

ID4b1a00be90ffaddfbd0b795427c1ad9418c3f0ec
Parent 2a933a18
Child b3340748

Added by Andreas Müller about 1 year ago

ref #6794 update script for name changes in FeatureNode and TermVocabulary

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/ColumnAdder.java
62 62
		return new ColumnAdder(stepName, tableName, newColumnName, "nvarchar(255)", includeAudTable, null, false, null);
63 63
	}
64 64

  
65
    public static final ColumnAdder NewDTYPEInstance(String stepName, String tableName, String defaultValue, boolean includeAudTable){
66
        return new ColumnAdder(stepName, tableName, "DTYPE", "nvarchar(31)", includeAudTable, defaultValue, true, null);
67
    }
68

  
65 69
	public static final ColumnAdder NewStringInstance(String stepName, String tableName, String newColumnName, int length, boolean includeAudTable){
66 70
		return new ColumnAdder(stepName, tableName, newColumnName, "nvarchar("+length+")", includeAudTable, null, false, null);
67 71
	}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v50_55/SchemaUpdater_55_551.java
15 15
import org.apache.log4j.Logger;
16 16

  
17 17
import eu.etaxonomy.cdm.common.UTF8;
18
import eu.etaxonomy.cdm.database.update.ColumnAdder;
19
import eu.etaxonomy.cdm.database.update.ColumnNameChanger;
18 20
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
19 21
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
20 22
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
21 23
import eu.etaxonomy.cdm.database.update.SimpleSchemaUpdaterStep;
24
import eu.etaxonomy.cdm.database.update.TableNameChanger;
22 25

  
23 26
/**
24 27
/**
......
60 63
		List<ISchemaUpdaterStep> stepList = new ArrayList<>();
61 64

  
62 65

  
63
//		//#6699 delete term version
64
//		//just in case not fixed before yet
65
//		stepName = "Delete term version";
66
//		query = "DELETE FROM @@CdmMetaData@@ WHERE propertyName = 'TERM_VERSION'";
67
//		step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
68
//        stepList.add(step);
66

  
69 67

  
70 68

  
71 69
        //TODO remove proparte and partial columns
72 70

  
73 71
		updateConceptRelationshipSymbolsAgain(stepList);
74 72

  
73

  
74
       //#6794 rename FeatureNode to TermRelation
75
       stepName = "rename FeatureNode to TermRelation";
76
       String oldName = "FeatureNode";
77
       String newName = "TermRelation";
78
       boolean includeDtype = false;
79
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
80
       stepList.add(step);
81

  
82
       //#6794 add DTYPE to TermRelation
83
       stepName = "add DTYPE to TermRelation";
84
       tableName = "TermRelation";
85
       step = ColumnAdder.NewDTYPEInstance(stepName, tableName, "TermTreeNode", INCLUDE_AUDIT) ;
86
       stepList.add(step);
87

  
88
       //#6794 change featuretree_id to termtree_id
89
       stepName = "change featuretree_id to termtree_id";
90
       tableName = "TermRelation";
91
       String oldColumnName = "featureTree_id";
92
       newColumnName = "termTree_id";
93
       step = ColumnNameChanger.NewIntegerInstance(stepName, tableName, oldColumnName, newColumnName, INCLUDE_AUDIT);
94
       stepList.add(step);
95

  
96
       //#6794 change featuretree_id to termtree_id
97
       stepName = "change feature_id to term_id";
98
       tableName = "TermRelation";
99
       oldColumnName = "feature_id";
100
       newColumnName = "term_id";
101
       step = ColumnNameChanger.NewIntegerInstance(stepName, tableName, oldColumnName, newColumnName, INCLUDE_AUDIT);
102
       stepList.add(step);
103

  
104
       //#6794 rename FeatureNode_DefinedTermBase_InapplicableIf to TermTreeNode_DefinedTermBase_InapplicableIf
105
       stepName = "rename FeatureNode_DefinedTermBase_InapplicableIf to TermTreeNode_DefinedTermBase_InapplicableIf";
106
       oldName = "FeatureNode_DefinedTermBase_InapplicableIf";
107
       newName = "TermTreeNode_DefinedTermBase_InapplicableIf";
108
       includeDtype = false;
109
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
110
       stepList.add(step);
111

  
112
       //#6794 change FeatureNode_id to TermTreeNode_id in TermTreeNode_DefinedTermBase_InapplicableIf
113
       stepName = "change FeatureNode_id to TermTreeNode_id in TermTreeNode_DefinedTermBase_InapplicableIf";
114
       tableName = "TermTreeNode_DefinedTermBase_InapplicableIf";
115
       oldColumnName = "FeatureNode_id";
116
       newColumnName = "TermTreeNode_id";
117
       step = ColumnNameChanger.NewIntegerInstance(stepName, tableName, oldColumnName, newColumnName, INCLUDE_AUDIT);
118
       stepList.add(step);
119

  
120
       //#6794 rename FeatureNode_DefinedTermBase_OnlyApplicable to TermTreeNode_DefinedTermBase_OnlyApplicable
121
       stepName = "rename FeatureNode_DefinedTermBase_InapplicableIf to TermTreeNode_DefinedTermBase_InapplicableIf";
122
       oldName = "FeatureNode_DefinedTermBase_OnlyApplicable";
123
       newName = "TermTreeNode_DefinedTermBase_OnlyApplicable";
124
       includeDtype = false;
125
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
126
       stepList.add(step);
127

  
128
       //#6794 change FeatureNode_id to TermTreeNode_id in TermTreeNode_DefinedTermBase_OnlyApplicable
129
       stepName = "change FeatureNode_id to TermTreeNode_id in TermTreeNode_DefinedTermBase_OnlyApplicable";
130
       tableName = "TermTreeNode_DefinedTermBase_OnlyApplicable";
131
       oldColumnName = "FeatureNode_id";
132
       newColumnName = "TermTreeNode_id";
133
       step = ColumnNameChanger.NewIntegerInstance(stepName, tableName, oldColumnName, newColumnName, INCLUDE_AUDIT);
134
       stepList.add(step);
135

  
136
       //#6794 rename TermVocabulary to TermCollection
137
       stepName = "rename TermVocabulary to TermCollection";
138
       oldName = "TermVocabulary";
139
       newName = "TermCollection";
140
       includeDtype = false;
141
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
142
       stepList.add(step);
143

  
144
       //#6794 rename TermVocabulary_Annotation to TermCollection_Annotation
145
       stepName = "rename TermVocabulary_Annotation to TermCollection_Annotation";
146
       oldName = "TermVocabulary_Annotation";
147
       newName = "TermCollection_Annotation";
148
       includeDtype = false;
149
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
150
       stepList.add(step);
151

  
152
       //#6794 rename TermVocabulary_Credit to TermCollection_Credit
153
       stepName = "rename TermVocabulary_Credit to TermCollection_Credit";
154
       oldName = "TermVocabulary_Credit";
155
       newName = "TermCollection_Credit";
156
       includeDtype = false;
157
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
158
       stepList.add(step);
159

  
160
       //#6794 rename TermVocabulary_Extension to TermCollection_Extension
161
       stepName = "rename TermVocabulary_Extension to TermCollection_Extension";
162
       oldName = "TermVocabulary_Extension";
163
       newName = "TermCollection_Extension";
164
       includeDtype = false;
165
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
166
       stepList.add(step);
167

  
168
       //#6794 rename TermVocabulary_Identifier to TermCollection_Identifier
169
       stepName = "rename TermVocabulary_Identifier to TermCollection_Identifier";
170
       oldName = "TermVocabulary_Identifier";
171
       newName = "TermCollection_Identifier";
172
       includeDtype = false;
173
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
174
       stepList.add(step);
175

  
176
       //#6794 rename TermVocabulary_Marker to TermCollection_Marker
177
       stepName = "rename TermVocabulary_Marker to TermCollection_Marker";
178
       oldName = "TermVocabulary_Marker";
179
       newName = "TermCollection_Marker";
180
       includeDtype = false;
181
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
182
       stepList.add(step);
183

  
184
       //#6794 rename TermVocabulary_OriginalSourceBase to TermCollection_OriginalSourceBase
185
       stepName = "rename TermVocabulary_OriginalSourceBase to TermCollection_OriginalSourceBase";
186
       oldName = "TermVocabulary_OriginalSourceBase";
187
       newName = "TermCollection_OriginalSourceBase";
188
       includeDtype = false;
189
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
190
       stepList.add(step);
191

  
192
       //#6794 rename TermVocabulary_Representation to TermCollection_Representation
193
       stepName = "rename TermVocabulary_Representation to TermCollection_Representation";
194
       oldName = "TermVocabulary_Representation";
195
       newName = "TermCollection_Representation";
196
       includeDtype = false;
197
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
198
       stepList.add(step);
199

  
200
       //#6794 rename TermVocabulary_RightsInfo to TermCollection_RightsInfo
201
       stepName = "rename TermVocabulary_RightsInfo to TermCollection_RightsInfo";
202
       oldName = "TermVocabulary_RightsInfo";
203
       newName = "TermCollection_RightsInfo";
204
       includeDtype = false;
205
       step = TableNameChanger.NewInstance(stepName, oldName, newName, INCLUDE_AUDIT, includeDtype);
206
       stepList.add(step);
207

  
208

  
209

  
75 210
        return stepList;
76 211

  
77 212
	}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)