Revision cc0b954b
Added by Andreas Müller about 2 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/TableCreator.java | ||
---|---|---|
39 | 39 |
private final boolean includeCdmBaseAttributes; |
40 | 40 |
private final boolean includeIdentifiableEntity; |
41 | 41 |
private final boolean includeAnnotatableEntity; |
42 |
private final boolean includeSingleSourcedEntity; |
|
42 | 43 |
private boolean includeEventBase; |
43 | 44 |
private final boolean excludeVersionableAttributes; |
44 | 45 |
protected List<ColumnAdder> columnAdders = new ArrayList<>(); |
... | ... | |
50 | 51 |
|
51 | 52 |
|
52 | 53 |
public static final TableCreator NewInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, List<String> columnNames, List<String> columnTypes, boolean includeAudTable, boolean includeCdmBaseAttributes){ |
53 |
return new TableCreator(stepList, stepName, tableName, columnNames, columnTypes, null, null, null, includeAudTable, includeCdmBaseAttributes, false, false, false); |
|
54 |
return new TableCreator(stepList, stepName, tableName, columnNames, columnTypes, null, null, null, includeAudTable, includeCdmBaseAttributes, false, false, false, false);
|
|
54 | 55 |
} |
55 | 56 |
|
56 | 57 |
public static final TableCreator NewInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable, boolean includeCdmBaseAttributes){ |
57 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, includeCdmBaseAttributes, false, false, false); |
|
58 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, includeCdmBaseAttributes, false, false, false, false);
|
|
58 | 59 |
} |
59 | 60 |
|
60 | 61 |
public static final TableCreator NewAuditedCdmBaseInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables){ |
61 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), true, true, false, false, true); |
|
62 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), true, true, false, false, true, false);
|
|
62 | 63 |
} |
63 | 64 |
|
64 | 65 |
public static final TableCreator NewNonVersionableInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables){ |
65 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), false, true, false, false, true); |
|
66 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), false, true, false, false, true, false);
|
|
66 | 67 |
} |
67 | 68 |
|
68 | 69 |
public static final TableCreator NewVersionableInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
69 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, false, false, false); |
|
70 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, false, false, false, false);
|
|
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
public static final TableCreator NewAnnotatableInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
73 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false); |
|
74 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false, false); |
|
75 |
} |
|
76 |
|
|
77 |
public static final TableCreator NewSingleSourcedInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
|
78 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false, true); |
|
74 | 79 |
} |
75 | 80 |
|
76 | 81 |
public static final TableCreator NewEventInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
77 |
TableCreator result = new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false); |
|
82 |
TableCreator result = new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false, false);
|
|
78 | 83 |
result.includeEventBase = true; |
79 | 84 |
return result; |
80 | 85 |
} |
81 | 86 |
|
82 | 87 |
public static final TableCreator NewIdentifiableInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
83 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, true, false); |
|
88 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, true, false, false);
|
|
84 | 89 |
} |
85 | 90 |
|
86 | 91 |
protected TableCreator(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, List<String> columnNames, List<String> columnTypes, List<Object> defaultValues, List<Boolean> isNotNull, List<String> referencedTables, |
87 |
boolean includeAudTable, boolean includeCdmBaseAttributes, boolean includeAnnotatableEntity, boolean includeIdentifiableEntity, boolean excludeVersionableAttributes) { |
|
92 |
boolean includeAudTable, boolean includeCdmBaseAttributes, boolean includeAnnotatableEntity, boolean includeIdentifiableEntity, boolean excludeVersionableAttributes, boolean includeSingleSourcedEntity) {
|
|
88 | 93 |
super(stepList, stepName, tableName, includeAudTable); |
89 | 94 |
this.columnNames = columnNames; |
90 | 95 |
this.columnTypes = columnTypes; |
... | ... | |
95 | 100 |
this.includeAnnotatableEntity = includeAnnotatableEntity; |
96 | 101 |
this.includeIdentifiableEntity = includeIdentifiableEntity; |
97 | 102 |
this.excludeVersionableAttributes = excludeVersionableAttributes; |
103 |
this.includeSingleSourcedEntity = includeSingleSourcedEntity; |
|
98 | 104 |
makeColumnAdders(); |
99 | 105 |
makeMnTables(mnTablesStepList, this.tableName, this.includeAnnotatableEntity, this.includeIdentifiableEntity); |
100 | 106 |
} |
... | ... | |
220 | 226 |
if (this.includeIdentifiableEntity){ |
221 | 227 |
updateQuery += "lsid_authority varchar(255), lsid_lsid varchar(255), lsid_namespace varchar(255), lsid_object varchar(255), lsid_revision varchar(255), protectedtitlecache bit not null, titleCache varchar(255),"; |
222 | 228 |
} |
229 |
if (this.includeSingleSourcedEntity){ |
|
230 |
updateQuery += "source_id integer, "; |
|
231 |
} |
|
223 | 232 |
//specific columns |
224 | 233 |
updateQuery += getColumnsSql(tableName, datasource, monitor); |
225 | 234 |
|
... | ... | |
302 | 311 |
makeForeignKey(tableName, datasource, monitor, attribute, |
303 | 312 |
referencedTable, caseType, result); |
304 | 313 |
} |
314 |
if (this.includeSingleSourcedEntity){ |
|
315 |
//source |
|
316 |
String attribute = "source_id"; |
|
317 |
String referencedTable = "OriginalSourceBase"; |
|
318 |
makeForeignKey(tableName, datasource, monitor, attribute, |
|
319 |
referencedTable, caseType, result); |
|
320 |
} |
|
321 |
|
|
305 | 322 |
for (ColumnAdder adder : this.columnAdders){ |
306 | 323 |
if (adder.getReferencedTable() != null){ |
307 | 324 |
makeForeignKey(tableName, datasource, monitor, adder.getNewColumnName(), |
Also available in: Unified diff
ref #2506 model change and update script for occurrence status