Project

General

Profile

Revision 066c9dde

ID066c9dde83d31fbc6caa9219c774c9f03a65d429
Parent 741a4c05
Child 152fcd76

Added by Andreas Müller about 5 years ago

clean up and java doc

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/ColumnAdder.java
32 32

  
33 33
	private final String referencedTable;
34 34

  
35
	/**
36
	 * Add ForeignKey.
37
	 * @param referencedTable
38
	 * @return
39
	 */
35 40
	public static final ColumnAdder NewIntegerInstance(String stepName, String tableName, String newColumnName, boolean includeAudTable, boolean notNull, String referencedTable){
36 41
		return new ColumnAdder(stepName, tableName, newColumnName, "int", includeAudTable, null, notNull, referencedTable);
37 42
	}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/SchemaUpdaterBase.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
19 19

  
20 20
/**
21 21
 * Base class for updating a schema.
22
 * 
22
 *
23 23
 * @author a.mueller
24 24
 * @date 10.09.2010
25 25
 *
......
30 30

  
31 31
	public static boolean INCLUDE_AUDIT = true;
32 32
	protected static boolean INCLUDE_CDM_BASE = true;
33
	
33
	protected static boolean NOT_NULL = true;
34

  
34 35
//	private List<ISchemaUpdaterStep> list;
35
	
36

  
36 37

  
37 38
	protected abstract List<ISchemaUpdaterStep> getUpdaterList();
38 39

  
39
	
40

  
40 41
	protected SchemaUpdaterBase(String startSchemaVersion, String endSchemaVersion){
41 42
		this.startVersion = startSchemaVersion;
42 43
		this.targetVersion = endSchemaVersion;
......
51 52
			try {
52 53
				int n = datasource.executeUpdate(sqlUpdateSchemaVersion);
53 54
				return n > 0;
54
				
55

  
55 56
			} catch (Exception e) {
56 57
				monitor.warning("Error when trying to set new schemaversion: ", e);
57 58
				throw new SQLException(e);
......
62 63
	protected String getCurrentVersion(ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType) throws SQLException {
63 64
		int intSchemaVersion = 0;
64 65
		String sqlSchemaVersion = caseType.replaceTableNames( "SELECT value FROM @@CdmMetaData@@ WHERE propertyname = " +  intSchemaVersion);
65
		
66

  
66 67
		try {
67 68
			String value = (String)datasource.getSingleValue(sqlSchemaVersion);
68 69
			return value;
......
72 73
		}
73 74
	}
74 75

  
75
	
76

  
76 77
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/SimpleSchemaUpdaterStep.java
38 38
// *************************** FACTORY ********************************/
39 39

  
40 40
	/**
41
	 * Deprecated method
41 42
	 * @deprecated use  {@link #NewNonAuditedInstance(String, String)},
42 43
	 * {@link #NewAuditedInstance(String, String, boolean, String)},
43 44
	 * or {@link #NewExplicitAuditedInstance(String, String, String)} instead
......
47 48
		return new SimpleSchemaUpdaterStep(stepName, defaultQuery, false, null, null);
48 49
	}
49 50

  
51
	/**
52
     * Simple schema updater with update query only for non_AUD tables.
53
	 *
54
	 * @param stepName step name
55
	 * @param defaultQuery the query
56
	 * @param adapt preliminary
57
	 * @return
58
	 */
50 59
	public static SimpleSchemaUpdaterStep NewNonAuditedInstance(String stepName, String defaultQuery, int adapt){
51 60
		return new SimpleSchemaUpdaterStep(stepName, defaultQuery, false, null, null);
52 61
	}
53 62

  
54 63
	/**
55
	 * @param stepName Step name
64
	 * Simple schema updater with update query for AUD and non_AUD tables.
65
     *
66
     * @param stepName Step name
56 67
	 * @param defaultQuery query
57 68
	 * @param nonAuditedTableName the name of the non audited table. E.g. TaxonNameBase
58 69
	 *     (while TaxonNameBase_AUD is the audited table
......
64 75
		return new SimpleSchemaUpdaterStep(stepName, defaultQuery, audit, nonAuditedTableName, null);
65 76
	}
66 77

  
78
	/**
79
	 * Simple schema updater with an explicit query for AUD table.
80
	 * @param stepName step name
81
	 * @param defaultQuery the non_AUD update query
82
	 * @param defaultQueryForAuditedTables the AUD update query
83
	 * @param adapt preliminary
84
	 * @return
85
	 */
67 86
	public static SimpleSchemaUpdaterStep NewExplicitAuditedInstance(String stepName, String defaultQuery, String defaultQueryForAuditedTables, int adapt){
68 87
		boolean audit = StringUtils.isNotBlank(defaultQueryForAuditedTables);
69 88
		return new SimpleSchemaUpdaterStep(stepName, defaultQuery, audit, null, defaultQueryForAuditedTables);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)