Project

General

Profile

Revision b66167fa

IDb66167fa0bd3de643ec91830b5a5ec1cdb03af65
Parent c0b73e71
Child 4179f687

Added by Andreas Müller over 2 years ago

ref #6529, ref #6258 improve MN TableCreator and missing ForeignKey handling (add index instead)

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/ClassBaseTypeUpdater.java
26 26
	@SuppressWarnings("unused")
27 27
	private static final Logger logger = Logger.getLogger(TableCreator.class);
28 28

  
29
	private static final boolean SORT_INDEX = true;
30

  
31 29
	private final boolean includeIdentifiableEntity;
32 30
	private final boolean includeAnnotatableEntity;
33 31
	protected List<ISchemaUpdaterStep> mnTablesStepList = new ArrayList<>();
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/IndexAdder.java
37 37

  
38 38
// ********************** FACTORY ****************************************/
39 39

  
40
	public static final IndexAdder NewInstance(String stepName, String tableName, String columnName, Integer length){
41
		return new IndexAdder(stepName, tableName, columnName, length);
40
	public static final IndexAdder NewStringInstance(String stepName, String tableName, String columnName, Integer length){
41
		return new IndexAdder(stepName, tableName, columnName, length == null ? 255 : length);
42 42
	}
43 43

  
44
    public static final IndexAdder NewIntegerInstance(String stepName, String tableName, String columnName){
45
        return new IndexAdder(stepName, tableName, columnName, null);
46
    }
47

  
44 48
// **************************** CONSTRUCTOR *********************************/
45 49

  
46 50
	protected IndexAdder(String stepName, String tableName, String columnName, Integer length) {
47 51
		super(stepName);
48 52
		this.tableName = tableName;
49 53
		this.columnName = columnName;
50
		this.length = length == null ? 255 : length;
54
		this.length = length;
51 55
	}
52 56

  
53 57

  
......
78 82
			String updateQuery;
79 83
			if (type.equals(DatabaseTypeEnum.MySQL)){
80 84
				//Maybe MySQL also works with the below syntax. Did not check yet.
81
				updateQuery = "ALTER TABLE @@"+ tableName + "@@ ADD INDEX " + constraintName + " ("+columnName+"("+length+"));";
85
				updateQuery = "ALTER TABLE @@"+ tableName + "@@ ADD INDEX " + constraintName + " ("+columnName+ makeLength()+");";
82 86
			}else if (type.equals(DatabaseTypeEnum.H2) || type.equals(DatabaseTypeEnum.PostgreSQL) || type.equals(DatabaseTypeEnum.SqlServer2005)){
83 87
				updateQuery = "CREATE INDEX " + constraintName + " ON "+tableName+"(" + columnName + ")";
84 88
			}else{
......
89 93
			return updateQuery;
90 94
	}
91 95

  
92
	private boolean removeExistingConstraint(ICdmDataSource datasource, CaseType caseType) {
96
	/**
97
     * @param length2
98
     * @return
99
     */
100
    private String makeLength() {
101
        if (length != null){
102
            return "(" + length + ")";
103
        }else{
104
            return "";
105
        }
106
    }
107

  
108
    private boolean removeExistingConstraint(ICdmDataSource datasource, CaseType caseType) {
93 109
		try {
94 110
			DatabaseTypeEnum type = datasource.getDatabaseType();
95 111
			String indexName = "_UniqueKey";
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/MnTableCreator.java
6 6
import java.util.ArrayList;
7 7
import java.util.Arrays;
8 8
import java.util.List;
9

  
10
import org.apache.commons.lang.StringUtils;
9
import java.util.Map;
11 10

  
12 11
/**
13 12
 * Creates an MN table
......
18 17

  
19 18
	private String firstTableName;
20 19
	private String firstTableAlias;
20
    private String firstColumnName;
21 21
	private String secondTableName;
22 22
	private String secondTableAlias;
23
	//is a sort index column needed.
24
	private boolean hasSortIndex;
25
	//is the key of the MN table including the FK to the second table?
26
	private boolean secondTableInKey;
27

  
28
	public static MnTableCreator NewMnInstance(String stepName, String firstTableName, String secondTableName, boolean includeAudTable){
29
		MnTableCreator result = new MnTableCreator(stepName, firstTableName, null, secondTableName, null, new String[]{}, new String[]{}, null, null, includeAudTable, false, true, false, false, false);
23
    private String secondColumnName;
24
	//is the MN table used for a list, if yes, a sortIndex column is needed
25
    //and the and the sortindex column needs to be in the key instead of second table column.
26
	private boolean isList;
27
	private boolean is1toM;
28

  
29
	public static MnTableCreator NewMnInstance(String stepName, String firstTableName, String secondTableName, boolean includeAudTable, boolean isList, boolean is1toM){
30
		MnTableCreator result = new MnTableCreator(stepName, firstTableName, null, null, secondTableName, null, null, new String[]{}, new String[]{}, null, null, includeAudTable, isList, is1toM, false, false, false);
30 31
		return result;
31 32
	}
32 33

  
33
	public static MnTableCreator NewMnInstance(String stepName, String firstTableName, String firstTableAlias, String secondTableName, String secondTableAlias, boolean includeAudTable, boolean hasSortIndex, boolean secondTableInKey){
34
		MnTableCreator result = new MnTableCreator(stepName, firstTableName, firstTableAlias, secondTableName, secondTableAlias, new String[]{}, new String[]{}, null, null, includeAudTable, hasSortIndex, secondTableInKey, false, false, false);
34
	/**
35
	 *
36
	 * @param stepName The step name
37
	 * @param firstTableName The name of the first table
38
	 * @param firstTableAlias The alias for the first table as used in the MN table name
39
	 * @param secondTableName The name of the second table
40
	 * @param secondTableAlias The alias for the second table as used in the MN table name
41
	 * @param attributeName The name of the attribute pointing to the second table (this is used for the column name for the
42
	 * column pointing to the second table)
43
	 * @param includeAudTable <code>true</code> if also the Audit (_AUD) table should be created
44
	 * @param hasSortIndex by default <code>false</code> but true for {@link Map maps} (or maybe user defined MN-tables)
45
	 * @param secondTableInKey should the column that links to the second table also be in the key? This is by default
46
	 * <code>true</code> but for {@link List lists} should be <code>false</code>.
47
	 * @return
48
	 */
49
	public static MnTableCreator NewMnInstance(String stepName, String firstTableName, String firstTableAlias, String secondTableName, String secondTableAlias, String attributeName,
50
	        boolean includeAudTable, boolean isList, boolean is1toM){
51
		MnTableCreator result = new MnTableCreator(stepName, firstTableName, firstTableAlias, null, secondTableName, secondTableAlias, attributeName,
52
		        new String[]{}, new String[]{}, null, null,
53
		        includeAudTable, isList, is1toM, false, false, false);
35 54
		return result;
36 55
	}
37 56

  
57
// ****************************** CONSTRUCTOR *********************************/
38 58

  
39
	protected MnTableCreator(String stepName, String firstTableName, String firstTableAlias, String secondTableName, String secondTableAlias, String[] columnNames, String[] columnTypes,
40
			List<Object> defaultValues, List<Boolean> isNull, boolean includeAudTable, boolean hasSortIndex, boolean secondTableInKey, boolean includeCdmBaseAttributes,boolean includeAnnotatableEntity, boolean includeIdentifiableEntity) {
41
		super(stepName, firstTableName + "_" + secondTableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), defaultValues, isNull,	new ArrayList<String>(), includeAudTable, includeCdmBaseAttributes, includeAnnotatableEntity, includeIdentifiableEntity, false);
59
	protected MnTableCreator(String stepName, String firstTableName, String firstTableAlias, String firstColumnName, String secondTableName, String secondTableAlias, String secondColumnName,
60
	        String[] columnNames, String[] columnTypes, List<Object> defaultValues, List<Boolean> isNull,
61
	        boolean includeAudTable, boolean isList, boolean is1toM,
62
	        boolean includeCdmBaseAttributes, boolean includeAnnotatableEntity, boolean includeIdentifiableEntity) {
63
		super(stepName, makeAlias(firstTableName, firstTableAlias) + "_" + makeAlias(secondTableName, secondTableAlias),
64
		        Arrays.asList(columnNames), Arrays.asList(columnTypes), defaultValues,
65
		        isNull,	new ArrayList<>(), includeAudTable,
66
		        includeCdmBaseAttributes, includeAnnotatableEntity, includeIdentifiableEntity, false);
42 67
		this.firstTableName = firstTableName;
43 68
		this.secondTableName = secondTableName;
44
		this.firstTableAlias = (firstTableAlias != null )? firstTableAlias : firstTableName ;
45
		this.secondTableAlias = (secondTableAlias !=  null)? secondTableAlias : secondTableName ;
46
		this.hasSortIndex = hasSortIndex;
47
		this.secondTableInKey = secondTableInKey;
69
		this.firstTableAlias = makeAlias(firstTableName, firstTableAlias) ;
70
		this.secondTableAlias = makeAlias(secondTableName, secondTableAlias) ;
71
		this.firstColumnName = (firstColumnName !=  null) ? firstColumnName : this.firstTableAlias;
72
        this.secondColumnName = (secondColumnName !=  null) ? secondColumnName : this.secondTableAlias;
73
        this.isList = isList;
74
        this.is1toM = is1toM;
48 75
		addMyColumns();
49 76
	}
50 77

  
78
    /**
79
     * @param secondTableName
80
     * @param secondTableAlias
81
     * @return
82
     */
83
    private static String makeAlias(String tableName, String alias) {
84
        return (alias !=  null) ? alias : tableName;
85
    }
86

  
51 87

  
52 88
	protected void addMyColumns(){
53
		this.columnAdders.add(ColumnAdder.NewIntegerInstance(stepName, tableName, getFirstIdColumn(), false, true, this.firstTableName));
54
		this.columnAdders.add(ColumnAdder.NewIntegerInstance(stepName, tableName, getSecondIdColumn(), false, true, this.secondTableName));
55
		if (this.hasSortIndex){
89
	    ColumnAdder firstColAdder = ColumnAdder.NewIntegerInstance(stepName, tableName, getFirstIdColumn(), false, true, this.firstTableName);
90
		this.columnAdders.add(firstColAdder);
91
		ColumnAdder secondColAdder = ColumnAdder.NewIntegerInstance(stepName, tableName, getSecondIdColumn(), false, true, this.secondTableName);
92
//		secondColAdder.addIndex(tableName+"_"+getSecondIdColumn(), null);
93
		this.columnAdders.add(secondColAdder);
94
		if (this.isList){
56 95
			this.columnAdders.add(ColumnAdder.NewIntegerInstance(stepName, tableName, "sortIndex", false, true, null));
57 96
		}
58

  
59 97
	}
60 98

  
61 99
	@Override
......
63 101
		String result = "";
64 102
		if (! isAudit){
65 103
			result = getFirstIdColumn() + ",";
66
			result += secondTableInKey ? getSecondIdColumn() + "," : "";
67
			result += hasSortIndex ? "sortIndex," : "";
104
			result += (isList ? "sortIndex" : getSecondIdColumn());
68 105
		}else{
69 106
			result = "REV, " + primaryKey(false);
70
			result += (!secondTableInKey) ? ","+getSecondIdColumn() + "," : "";
107
			//for AUDIT also the second table column is in PK
108
			result += (isList) ? ","+getSecondIdColumn() : "";
71 109
		}
72
		result = StringUtils.chomp(result.trim(), ",");
73 110
		return result;
74 111
	}
75 112

  
76 113
	@Override
77 114
    protected String unique(boolean isAudit){
78
		if (! isAudit){
115
		if (! isAudit && is1toM){
79 116
			return getSecondIdColumn();
80 117
		}else{
81 118
			return null;
......
83 120
	}
84 121

  
85 122
	private String getFirstIdColumn(){
86
		return this.firstTableAlias + "_id";
123
		return this.firstColumnName + "_id";
87 124
	}
88 125

  
89 126
	private String getSecondIdColumn(){
90
		String result = this.secondTableAlias.toLowerCase();
127
		String result = this.secondColumnName.toLowerCase();
91 128

  
92
		if (this.secondTableAlias.equalsIgnoreCase(this.secondTableName) ){
129
		if (this.secondColumnName.equalsIgnoreCase(this.secondTableName) ){
93 130
			if (! result.endsWith("s")){
94 131
				result += "s";
95 132
			}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/SchemaUpdaterBase.java
27 27
	@SuppressWarnings("unused")
28 28
	private static final Logger logger = Logger.getLogger(SchemaUpdaterBase.class);
29 29

  
30
	public static boolean INCLUDE_AUDIT = true;
31
	protected static boolean INCLUDE_CDM_BASE = true;
32
	protected static boolean NOT_NULL = true;
30
	public static final boolean INCLUDE_AUDIT = true;
31
	protected static final boolean INCLUDE_CDM_BASE = true;
32
	protected static final boolean NOT_NULL = true;
33
	protected static final boolean IS_LIST = true;
34
	protected static final boolean IS_1_TO_M = true;
35
	protected static final boolean IS_M_TO_M = false;
36

  
33 37

  
34 38
//	private List<ISchemaUpdaterStep> list;
35 39

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/TableCreator.java
8 8
*/
9 9
package eu.etaxonomy.cdm.database.update;
10 10

  
11
import java.sql.SQLException;
12 11
import java.util.ArrayList;
13 12
import java.util.Arrays;
14 13
import java.util.List;
......
29 28
public class TableCreator extends AuditedSchemaUpdaterStepBase<TableCreator> {
30 29
	private static final Logger logger = Logger.getLogger(TableCreator.class);
31 30

  
32
	private static final boolean SORT_INDEX = true;
31
	private static final boolean IS_LIST = true;
32
	private static final boolean IS_1_TO_M = true;
33
	private static final boolean IS_M_TO_M = false;
34

  
33 35

  
34 36
	private final List<String> columnNames;
35 37
	private final List<String> columnTypes;
......
157 159
			//annotations
158 160
			stepName= "Add @tableName annotations";
159 161
			stepName = stepName.replace("@tableName", tableName);
160
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, "Annotation", SchemaUpdaterBase.INCLUDE_AUDIT);
162
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, "Annotation", SchemaUpdaterBase.INCLUDE_AUDIT, !IS_LIST, IS_1_TO_M);
161 163
			mnTablesStepList.add(tableCreator);
162 164

  
163 165
			//marker
164 166
			stepName= "Add @tableName marker";
165 167
			stepName = stepName.replace("@tableName", tableName);
166
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, "Marker", SchemaUpdaterBase.INCLUDE_AUDIT);
168
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, "Marker", SchemaUpdaterBase.INCLUDE_AUDIT, !IS_LIST, IS_1_TO_M);
167 169
			mnTablesStepList.add(tableCreator);
168

  
169 170
		}
170 171

  
171 172
		if (includeIdentifiable){
......
173 174
			//credits
174 175
			stepName= "Add @tableName credits";
175 176
			stepName = stepName.replace("@tableName", tableName);
176
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, null, "Credit", null, SchemaUpdaterBase.INCLUDE_AUDIT, SORT_INDEX, false);
177
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, null, "Credit", null, null, SchemaUpdaterBase.INCLUDE_AUDIT, IS_LIST, IS_1_TO_M);
177 178
			mnTablesStepList.add(tableCreator);
178 179

  
179

  
180 180
			//identifier
181 181
			stepName= "Add @tableName identifiers";
182 182
			stepName = stepName.replace("@tableName", tableName);
183
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, null, "Identifier", null, SchemaUpdaterBase.INCLUDE_AUDIT, SORT_INDEX, false);
183
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, null, "Identifier", null, null, SchemaUpdaterBase.INCLUDE_AUDIT, IS_LIST, IS_1_TO_M);
184 184
			mnTablesStepList.add(tableCreator);
185 185

  
186

  
187 186
			//extensions
188 187
			stepName= "Add @tableName extensions";
189 188
			stepName = stepName.replace("@tableName", tableName);
190
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, "Extension", SchemaUpdaterBase.INCLUDE_AUDIT);
189
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, "Extension", SchemaUpdaterBase.INCLUDE_AUDIT, !IS_LIST, IS_1_TO_M);
191 190
			mnTablesStepList.add(tableCreator);
192 191

  
193 192
			//OriginalSourceBase
194 193
			stepName= "Add @tableName sources";
195 194
			stepName = stepName.replace("@tableName", tableName);
196
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, null, "OriginalSourceBase", "sources", SchemaUpdaterBase.INCLUDE_AUDIT, false, true);
195
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, null, "OriginalSourceBase", null, "sources", SchemaUpdaterBase.INCLUDE_AUDIT, ! IS_LIST, IS_1_TO_M);
197 196
			mnTablesStepList.add(tableCreator);
198 197

  
199 198
			//Rights
200 199
			stepName= "Add @tableName rights";
201 200
			stepName = stepName.replace("@tableName", tableName);
202
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, "Rights", SchemaUpdaterBase.INCLUDE_AUDIT);
201
			tableCreator = MnTableCreator.NewMnInstance(stepName, tableName, "Rights", SchemaUpdaterBase.INCLUDE_AUDIT, !IS_LIST, IS_M_TO_M);
203 202
			mnTablesStepList.add(tableCreator);
204 203
		}
205 204
	}
......
281 280
	}
282 281

  
283 282

  
284
	private boolean createForeignKeys(String tableName, boolean isAudit, ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType) throws SQLException {
283
	private boolean createForeignKeys(String tableName, boolean isAudit, ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType) {
285 284
		boolean result = true;
286 285
		if (includeCdmBaseAttributes){
287 286
			//updatedBy
......
317 316
		return result;
318 317
	}
319 318

  
320
	public static boolean makeForeignKey(String tableName, ICdmDataSource datasource, IProgressMonitor monitor, String attribute, String referencedTable, CaseType caseType) throws SQLException {
319

  
320
    public static boolean makeForeignKey(String tableName, ICdmDataSource datasource, IProgressMonitor monitor, String attribute, String referencedTable, CaseType caseType) {
321 321
		boolean result = true;
322 322

  
323 323
		referencedTable = caseType.transformTo(referencedTable);
324 324

  
325
        String idSuffix = "_id";
326
        if (isRevAttribute(attribute) || attribute.endsWith(idSuffix)){
327
            idSuffix = "";
328
        }
329
        String columnName =  attribute + idSuffix;
330

  
325 331
		if (supportsForeignKeys(datasource, monitor, tableName, referencedTable)){
326 332
			String index = "FK@tableName_@attribute";
327 333
			index = index.replace("@tableName", tableName);
328 334
			index = index.replace("@attribute", attribute);
329 335

  
330
			String idSuffix = "_id";
331
			if (isRevAttribute(attribute) || attribute.endsWith(idSuffix)){
332
				idSuffix = "";
333
			}
336

  
334 337
			//OLD - don't remember why we used ADD INDEX here
335 338
//			String updateQuery = "ALTER TABLE @tableName ADD INDEX @index (@attribute), ADD FOREIGN KEY (@attribute) REFERENCES @referencedTable (@id)";
336 339
			String updateQuery = "ALTER TABLE @tableName ADD @constraintName FOREIGN KEY (@attribute) REFERENCES @referencedTable (@id)";
337 340
			updateQuery = updateQuery.replace("@tableName", tableName);
338 341
//			updateQuery = updateQuery.replace("@index", index);
339
			updateQuery = updateQuery.replace("@attribute", attribute + idSuffix);
342
			updateQuery = updateQuery.replace("@attribute", columnName);
340 343
			updateQuery = updateQuery.replace("@referencedTable", referencedTable);
341 344
			if (datasource.getDatabaseType().equals(DatabaseTypeEnum.MySQL)){
342 345
				updateQuery = updateQuery.replace("@constraintName", "CONSTRAINT " + index);
......
360 363
			}
361 364
			return result;
362 365
		}else{
363
			return true;
366
		    //create only index
367
			IndexAdder indexAdder = IndexAdder.NewIntegerInstance("Add index instead of Foreign Key", tableName, columnName);
368
			try {
369
                indexAdder.invoke(datasource, monitor, caseType);
370
            } catch (Exception e) {
371
                String message = "Problem when creating index instead of Foreign Key for " + tableName +"." + columnName +": " + e.getMessage();
372
                monitor.warning(message);
373
                logger.warn(message, e);
374
                return true;   //we do not interrupt update if only index generation did not work
375
            }
376
		    return result;
364 377
		}
365

  
366 378
	}
367 379

  
368 380
	/**
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v25_30/SchemaUpdater_25_30.java
100 100

  
101 101
		//covered taxa
102 102
		stepName= "Add polytomous key covered taxa";
103
		tableCreator = MnTableCreator.NewMnInstance(stepName, "PolytomousKey", null, "TaxonBase", "coveredtaxa", SchemaUpdaterBase.INCLUDE_AUDIT, false, true);
103
		tableCreator = MnTableCreator.NewMnInstance(stepName, "PolytomousKey", null, "TaxonBase", null, "coveredtaxa", SchemaUpdaterBase.INCLUDE_AUDIT, false, false);
104 104
		stepList.add(tableCreator);
105 105

  
106 106
		//Polytomous key node
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v31_33/SchemaUpdater_31_33.java
686 686
		String firstTable = "Amplification";
687 687
		String secondTable = "SingleRead";
688 688
		step = MnTableCreator
689
				.NewMnInstance(stepName, firstTable, null, secondTable, null,
690
						SchemaUpdaterBase.INCLUDE_AUDIT, false, true);
689
				.NewMnInstance(stepName, firstTable, null, secondTable, null, null,
690
						SchemaUpdaterBase.INCLUDE_AUDIT, !IS_LIST, IS_1_TO_M);
691 691
		stepList.add(step);
692 692

  
693 693
		// sequence - single reads #3360
......
695 695
		firstTable = "Sequence";
696 696
		secondTable = "SingleRead";
697 697
		step = MnTableCreator
698
				.NewMnInstance(stepName, firstTable, null, secondTable, null,
699
						SchemaUpdaterBase.INCLUDE_AUDIT, false, true);
698
				.NewMnInstance(stepName, firstTable, null, secondTable, null, null,
699
						SchemaUpdaterBase.INCLUDE_AUDIT, !IS_LIST, IS_1_TO_M);
700 700
		stepList.add(step);
701 701

  
702 702
		// sequence - barcode #3360
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v40_41/SchemaUpdater_40_41.java
276 276
        stepName = "Add identityCache index";
277 277
        tableName = "SpecimenOrObservationBase";
278 278
        newColumnName = "identityCache";
279
        step = IndexAdder.NewInstance(stepName, tableName, newColumnName, null);
279
        step = IndexAdder.NewStringInstance(stepName, tableName, newColumnName, null);
280 280
        stepList.add(step);
281 281

  
282 282
        stepName = "Add protectedIdentityCache";
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v41_47/SchemaUpdater_41_47.java
78 78
        //subtree filter
79 79
        stepName= "Add geo filter MN table to WorkingSet";
80 80
        String firstTableName = "WorkingSet";
81
        String secondTableName = "NamedArea";
82
        String secondTableAlias = "geoFilter";
83
        boolean hasSortIndex = false;
84
        boolean secondTableInKey = true;
85
        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, INCLUDE_AUDIT, hasSortIndex, secondTableInKey);
81
        String secondTableAlias = "NamedArea";
82
        String secondTableName = "DefinedTermBase";
83
        String attributeName = "geoFilter";
84
        boolean isList = ! IS_LIST;
85
        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
86 86
        stepList.add(step);
87 87

  
88 88
        //subtree filter
89 89
        stepName= "Add subtree filter MN table to WorkingSet";
90 90
        firstTableName = "WorkingSet";
91 91
        secondTableName = "TaxonNode";
92
        secondTableAlias = "taxonSubtreeFilter";
93
        hasSortIndex = false;
94
        secondTableInKey = true;
95
        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, INCLUDE_AUDIT, hasSortIndex, secondTableInKey);
92
        secondTableAlias = null;
93
        attributeName = "taxonSubtreeFilter";
94
        isList = ! IS_LIST;
95
        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
96 96
        stepList.add(step);
97 97

  
98 98
        //#6258
......
111 111
        stepName= "Add blockedBy_id to Registration";
112 112
        firstTableName = "Registration";
113 113
        secondTableName = "Registration";
114
        secondTableAlias = "blockedBy";
115
        hasSortIndex = false;
116
        secondTableInKey = true;
117
        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, INCLUDE_AUDIT, hasSortIndex, secondTableInKey);
114
        attributeName = "blockedBy";
115
        isList = ! IS_LIST;
116
        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, null, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
118 117
        stepList.add(step);
119 118

  
120 119
        //add type designations
121 120
        stepName= "Add type designations to Registration";
122 121
        firstTableName = "Registration";
123 122
        secondTableName = "TypeDesignationBase";
124
        secondTableAlias = "typeDesignations";
125
        hasSortIndex = false;
126
        secondTableInKey = true;
127
        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, INCLUDE_AUDIT, hasSortIndex, secondTableInKey);
123
        attributeName = "typeDesignations";
124
        isList = false;
125
        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, null, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
128 126
        stepList.add(step);
129 127

  
130 128
        //#5258

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)