Project

General

Profile

Revision 80cbc741

ID80cbc74164e5b37dbaa8e64d90126e745a9a05e3
Parent 3310d6a0
Child 80f29fef

Added by Andreas Müller 12 months ago

ref #7276 revert "make User.email a unique field"

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/User.java
51 51
@XmlType(name = "User", propOrder = {
52 52
    "username",
53 53
    "password",
54
    "salt",
55 54
    "emailAddress",
56 55
    "grantedAuthorities",
57 56
    "groups",
......
116 115
    @NotAudited
117 116
    protected String password;
118 117

  
119

  
120
    /**
121
     * The salt for password hashing.
122
     * @see https://dev.e-taxonomy.eu/redmine/issues/7210
123
     * @see https://code-bude.net/2015/03/30/grundlagen-sicheres-passwort-hashing-mit-salts/
124
     */
125
    @XmlElement(name = "Salt")
126
    @NotAudited
127
    protected String salt;
128

  
129 118
    @XmlElement(name = "EmailAddress")
130
    @Column(unique = true)
131 119
    protected String emailAddress;
132 120

  
133 121
    @XmlElementWrapper(name = "GrantedAuthorities")
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v47_49/SchemaUpdater_47_49.java
18 18
import eu.etaxonomy.cdm.database.update.ClassBaseTypeUpdater;
19 19
import eu.etaxonomy.cdm.database.update.ColumnAdder;
20 20
import eu.etaxonomy.cdm.database.update.ColumnNameChanger;
21
import eu.etaxonomy.cdm.database.update.ColumnTypeChanger;
22 21
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
23 22
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
24 23
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
25 24
import eu.etaxonomy.cdm.database.update.SimpleSchemaUpdaterStep;
26 25
import eu.etaxonomy.cdm.database.update.TableNameChanger;
27 26
import eu.etaxonomy.cdm.database.update.TermRepresentationUpdater;
28
import eu.etaxonomy.cdm.database.update.v33_34.UsernameConstraintUpdater;
29 27
import eu.etaxonomy.cdm.database.update.v41_47.SchemaUpdater_41_47;
30 28

  
31 29
/**
......
66 64

  
67 65
		List<ISchemaUpdaterStep> stepList = new ArrayList<>();
68 66

  
69
        //#6581 make nomenclatural reference and OriginalSource
70
        stepName = "Make nomenclatural reference and OriginalSource";
71
        tableName = "TaxonName";
72
        newColumnName = "nomenclaturalSource_id";
73
        String referencedTable = "OriginalSourceBase";
74
        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
75
        stepList.add(step);
76

  
77 67
		//#7109 nom. valid => nom. val.
78 68
		stepName = "nom valid => nom. val. (abbrevLabel)";
79 69
		UUID uuidTerm = UUID.fromString("bd036217-5499-4ccd-8f4c-72e06158db93");
......
104 94
        query = "UPDATE @@PermissionGroup@@ "
105 95
                + " SET uuid='1739df71-bf73-4dc6-8320-aaaf72cb555f', name='Admin' "
106 96
                + " WHERE  name='admin' or name='Admin'";
107
        step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
97
        tableName = "PermissionGroup";
98
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
108 99
        stepList.add(step);
109 100

  
110 101
        //#7405 Rename WorkingSet to DescriptiveDataSet
......
129 120
        oldTableName = "WorkingSet_TaxonNode";
130 121
        changeSingleWorkingSetTableName(stepList, oldTableName);
131 122

  
123
        stepName = "Update hibernate_sequences for WorkingSet renaming";
124
        query = " UPDATE hibernate_sequences "
125
                + " SET sequence_name = 'DescriptiveDataSet' "
126
                + " WHERE sequence_name = WorkingSet";
127
        step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
128
        stepList.add(step);
129

  
132 130
        //#2335 Make WorkingSet IdentifiableEntity
133 131
        stepName = "Make DescriptiveDataSet IdentifiableEntity";
134 132
        tableName = "DescriptiveDataSet";
......
148 146
        stepList.add(step);
149 147

  
150 148

  
151
        //#7238 rename lastName and firstName
152
        stepName = "rename lastName";
153
        tableName = "AgentBase";
154
        String oldColumnName = "lastname";
155
        newColumnName = "familyName";
156
        int size = 255;
157
        step = ColumnNameChanger.NewVarCharInstance(stepName, tableName, oldColumnName, newColumnName, size, INCLUDE_AUDIT);
158
        stepList.add(step);
159

  
160
        //... firstName
161
        stepName = "rename firstName";
162
        tableName = "AgentBase";
163
        oldColumnName = "firstname";
164
        newColumnName = "givenName";
165
        size = 255;
166
        step = ColumnNameChanger.NewVarCharInstance(stepName, tableName, oldColumnName, newColumnName, size, INCLUDE_AUDIT);
167
        stepList.add(step);
168

  
169
        //#7210 Add salt field for User
170
        stepName = "Add salt field for User";
171
        tableName = "UserAccount";
172
        newColumnName = "salt";
173
        step = ColumnAdder.NewStringInstance(stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
174
        stepList.add(step);
175

  
176
        //#6943 Add combination 'in'-author
177
        stepName = "Add combination 'in'-author";
178
        tableName = "TaxonName";
179
        newColumnName = "inCombinationAuthorship_id";
180
        referencedTable = "AgentBase";
181
        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
182
        stepList.add(step);
183

  
184
        //#6943 Add basionym 'in'-author
185
        stepName = "Add basionym 'in'-author";
186
        tableName = "TaxonName";
187
        newColumnName = "inBasionymAuthorship_id";
188
        referencedTable = "AgentBase";
189
        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
190
        stepList.add(step);
191

  
192
        //#6916 Link IntextReference to OriginalSource
193
        stepName = "Link IntextReference to OriginalSource";
194
        tableName = "IntextReference";
195
        newColumnName = "source_id";
196
        referencedTable = "OriginalSourceBase";
197
        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
198
        stepList.add(step);
199

  
200
        //#6720 Make individual count a string
201
        stepName = "Make individual count a string";
202
        tableName = "SpecimenOrObservationBase";
203
        String columnName = "individualCount";
204
        size = 255;
205
        step = ColumnTypeChanger.NewInt2StringInstance(stepName, tableName, columnName, size, INCLUDE_AUDIT, null, !NOT_NULL);
206
        stepList.add(step);
207

  
208
        updateSpecimenTypeDesignationStatusOrder(stepList);
209

  
210
        //#7144 Set Country area level
211
        stepName = "Set Country area level";
212
        query = " UPDATE @@DefinedTermBase@@ " +
213
                " SET level_id = ( SELECT id FROM (SELECT id FROM DefinedTermBase WHERE uuid = '79db63a4-1563-461e-8e41-48f5722feca4') as drv) " +
214
                " WHERE DTYPE = 'Country' ";
215
        step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
216
        stepList.add(step);
217

  
218

  
219

  
220
        //7276  Make User.emailAddress a unique field
221
        //TODO H2 / PostGreSQL / SQL Server
222
        //User.email unique
223
        stepName = "Update User.emailAdress unique index";
224
        tableName = "UserAccount";
225
        columnName = "emailAddress";
226
        step = UsernameConstraintUpdater.NewInstance(stepName, tableName, columnName);
227
        stepList.add(step);
228

  
229 149
        return stepList;
230 150
    }
231 151

  
232 152
    /**
233
     * @param stepList
234
     */
235
    private void updateSpecimenTypeDesignationStatusOrder(List<ISchemaUpdaterStep> stepList) {
236
        VocabularyOrderUpdater updater = VocabularyOrderUpdater.NewInstance(stepList);
237
        updater.add("a407dbc7-e60c-46ff-be11-eddf4c5a970d", 1);
238
        updater.add("05002d46-083e-4b27-8731-2e7c28a8825c", 2);
239
        updater.add("93ef8257-0a08-47bb-9b36-542417ae7560", 3);
240
        updater.add("7a1a8a53-78f4-4fc0-89f7-782e94992d08", 4);
241
        updater.add("f3b60bdb-4638-4ca9-a0c7-36e77d8459bb", 5);
242
        updater.add("052a5ff0-8e9a-4355-b24f-5e4bb6071f44", 6);
243
        updater.add("26e13359-8f77-4e40-a85a-56c01782fce0", 7);
244
        updater.add("7afc2f4f-f70a-4aa5-80a5-87764f746bde", 8);
245
        updater.add("989a2715-71d5-4fbe-aa9a-db9168353744", 9);
246
        updater.add("95b90696-e103-4bc0-b60b-c594983fb566", 10);
247
        updater.add("eb7df2e5-d9a7-479d-970c-c6f2b0a761d7", 11);
248
        updater.add("497137f3-b614-4183-8a22-97fcd6e2bdd8", 12);
249
        updater.add("7244bc51-14d8-41a6-9524-7dc5303bba29", 13);
250
        updater.add("0c39e2a5-2fe0-4d4f-819a-f609b5340339", 14);
251
        updater.add("01d91053-7004-4984-aa0d-9f4de59d6205", 15);
252
        updater.add("8d2fed1f-242e-4bcf-bbd7-e85133e479dc", 16);
253
        updater.add("49c96cae-6be6-401e-9b36-1bc12d9dc8f9", 17);
254
        updater.add("643513d0-32f5-46ba-840b-d9b9caf8160f", 18);
255
        updater.add("b7807acc-f559-474e-ad4a-e7a41e085e34", 19);
256
        updater.add("230fd762-b143-49de-ac2e-744bcc48a63b", 20);
257
        updater.add("7194020b-a326-4b47-9bfe-9f31a30aba7f", 21);
258
    }
259

  
260
    /**
261 153
     * @param #6368
262 154
     */
263 155
    private void changeSingleWorkingSetTableName(List<ISchemaUpdaterStep> stepList, String oldTableName) {
......
270 162
            stepName = "Rename " +  oldTableName + ".workingSet_id";
271 163
            String oldColumnName = "WorkingSet_id";
272 164
            String newColumnName = "DescriptiveDataSet_id";
273
            if ("WorkingSet_DescriptionBase".equals(oldTableName)){
274
                oldColumnName = "WorkingSets_id";
275
                newColumnName = "DescriptiveDataSets_id";
276
            }
277 165
            step = ColumnNameChanger.NewIntegerInstance(stepName, newTableName, oldColumnName, newColumnName, INCLUDE_AUDIT);
278 166
            stepList.add(step);
279 167
        }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)