merge-update from trunk
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / database / update / v33_34 / SchemaUpdater_331_34.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.cdm.database.update.v33_34;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 import org.apache.log4j.Logger;
17
18 import eu.etaxonomy.cdm.database.update.ColumnAdder;
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.SimpleSchemaUpdaterStep;
23 import eu.etaxonomy.cdm.database.update.v31_33.SchemaUpdater_33_331;
24
25 /**
26 * @author a.mueller
27 * @created Jan 14, 2014
28 */
29 public class SchemaUpdater_331_34 extends SchemaUpdaterBase {
30
31 @SuppressWarnings("unused")
32 private static final Logger logger = Logger.getLogger(SchemaUpdater_331_34.class);
33 private static final String startSchemaVersion = "3.3.1.0.201401140000";
34 private static final String endSchemaVersion = "3.4.0.0.201407010000";
35
36 // ********************** FACTORY METHOD
37 // *******************************************
38
39 public static SchemaUpdater_331_34 NewInstance() {
40 return new SchemaUpdater_331_34();
41 }
42
43 /**
44 * @param startSchemaVersion
45 * @param endSchemaVersion
46 */
47 protected SchemaUpdater_331_34() {
48 super(startSchemaVersion, endSchemaVersion);
49 }
50
51 @Override
52 protected List<ISchemaUpdaterStep> getUpdaterList() {
53
54 String stepName;
55 String tableName;
56 ISchemaUpdaterStep step;
57 String columnName;
58
59 List<ISchemaUpdaterStep> stepList = new ArrayList<ISchemaUpdaterStep>();
60
61 //TODO test and PostGreSQL / SQL Server
62 //UserAccount unique
63 stepName = "Update User unique indexes";
64 tableName = "UserAccount";
65 columnName = "username";
66 step = UsernameConstraintUpdater.NewInstance(stepName, tableName, columnName);
67 stepList.add(step);
68
69 //TODO test and PostGreSQL / SQL Server
70 //PermissionGroup unique
71 stepName = "Update Group unique indexes";
72 tableName = "PermissionGroup";
73 columnName = "name";
74 step = UsernameConstraintUpdater.NewInstance(stepName, tableName, columnName);
75 stepList.add(step);
76
77 //TODO test and PostGreSQL / SQL Server
78 //GrantedAuthority unique
79 stepName = "Update User unique indexes";
80 tableName = "GrantedAuthorityImpl";
81 columnName = "authority";
82 step = UsernameConstraintUpdater.NewInstance(stepName, tableName, columnName);
83 stepList.add(step);
84
85 //TODO test
86 stepName = "Add label column to derived unit";
87 tableName = "SpecimenOrObservationBase";
88 columnName = "originalLabelInfo";
89 step = ColumnAdder.NewClobInstance(stepName, tableName, columnName, INCLUDE_AUDIT);
90 stepList.add(step);
91
92
93 //TODO test
94 //set default value to true where required
95 stepName = "Set publish to true if null";
96 String query = " UPDATE @@TaxonBase@@ " +
97 " SET publish = @TRUE@ " +
98 " WHERE DTYPE IN ('Synonym') AND publish IS NULL ";
99 step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, "TaxonBase", 99);
100 stepList.add(step);
101
102
103 return stepList;
104
105 }
106
107 @Override
108 public ISchemaUpdater getNextUpdater() {
109 return null;
110 }
111
112 @Override
113 public ISchemaUpdater getPreviousUpdater() {
114 return SchemaUpdater_33_331.NewInstance();
115 }
116
117 }