Revision 5ab2bdcf
Added by Andreas Müller over 1 year ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/SingleTermRemover.java | ||
---|---|---|
30 | 30 |
public class SingleTermRemover |
31 | 31 |
extends SchemaUpdaterStepBase{ |
32 | 32 |
|
33 |
private String uuidTerm ; |
|
34 |
private List<String> checkUsedQueries = new ArrayList<>(); |
|
35 |
private boolean isAudit = false; |
|
36 |
|
|
37 | 33 |
@SuppressWarnings("unused") |
38 | 34 |
private static final Logger logger = Logger.getLogger(SingleTermRemover.class); |
39 | 35 |
|
36 |
// **************************** FACTORY METHODS ********************************/ |
|
37 |
|
|
40 | 38 |
public static final SingleTermRemover NewInstance(List<ISchemaUpdaterStep> stepList, String stepName, |
41 | 39 |
String uuidTerm, List<String> checkUsedQueries, int adapt){ |
42 | 40 |
return new SingleTermRemover(stepList, stepName, uuidTerm, checkUsedQueries, false); |
... | ... | |
66 | 64 |
return new SingleTermRemover(stepList, stepName, uuidTerm, checkUsedQueries, true); |
67 | 65 |
} |
68 | 66 |
|
67 |
// *************************** VARIABLES *****************************************/ |
|
68 |
|
|
69 |
private String uuidTerm ; |
|
70 |
private List<String> checkUsedQueries = new ArrayList<>(); |
|
71 |
private boolean isAudit = false; |
|
72 |
|
|
73 |
// ***************************** CONSTRUCTOR ***************************************/ |
|
74 |
|
|
69 | 75 |
private SingleTermRemover(List<ISchemaUpdaterStep> stepList, String stepName, String uuidTerm, |
70 | 76 |
List<String> checkUsedQueries, boolean isAudit) { |
71 | 77 |
super(stepList, stepName); |
... | ... | |
74 | 80 |
this.isAudit = isAudit; |
75 | 81 |
} |
76 | 82 |
|
83 |
// ******************************* METHODS *************************************************/ |
|
84 |
|
|
77 | 85 |
@Override |
78 | 86 |
public void invoke(ICdmDataSource datasource, IProgressMonitor monitor, |
79 | 87 |
CaseType caseType, SchemaUpdateResult result) throws SQLException { |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/SingleTermUpdater.java | ||
---|---|---|
26 | 26 |
* Creates a new term if a term with the same given uuid does not exist yet |
27 | 27 |
* @author a.mueller |
28 | 28 |
* @since 10.09.2010 |
29 |
* |
|
30 | 29 |
*/ |
31 | 30 |
public class SingleTermUpdater extends SchemaUpdaterStepBase { |
31 |
|
|
32 | 32 |
@SuppressWarnings("unused") |
33 | 33 |
private static final Logger logger = Logger.getLogger(SingleTermUpdater.class); |
34 | 34 |
|
35 |
/** |
|
36 |
* @Deprecated use {@link #NewInstance(String, TermType, UUID, String, String, String, String, UUID, UUID, boolean, UUID)} instead |
|
37 |
*/ |
|
38 |
@Deprecated |
|
39 |
public static final SingleTermUpdater NewInstance(List<ISchemaUpdaterStep> stepList, String stepName, UUID uuidTerm, String description, String label, String abbrev, String dtype, UUID uuidVocabulary, UUID uuidLanguage, boolean isOrdered, UUID uuidAfterTerm){ |
|
40 |
return new SingleTermUpdater(stepList, stepName, null, uuidTerm, null, null, description, label, abbrev, null, null, null, dtype, uuidVocabulary, uuidLanguage, isOrdered, uuidAfterTerm); |
|
41 |
} |
|
35 |
// **************************** FACTORY METHODS ********************************/ |
|
42 | 36 |
|
43 | 37 |
public static final SingleTermUpdater NewInstance(List<ISchemaUpdaterStep> stepList, String stepName, TermType termType, UUID uuidTerm, String idInVocabulary, String symbol, |
44 | 38 |
String description, String label, String abbrev, String dtype, UUID uuidVocabulary, UUID uuidLanguage, boolean isOrdered, UUID uuidAfterTerm){ |
... | ... | |
46 | 40 |
description, label, abbrev, null, null, null, dtype, uuidVocabulary, uuidLanguage, isOrdered, uuidAfterTerm); |
47 | 41 |
} |
48 | 42 |
|
49 |
public static final SingleTermUpdater NewReverseInstance(List<ISchemaUpdaterStep> stepList, String stepName, TermType termType, UUID uuidTerm, String idInVocabulary, String symbol,
|
|
50 |
String description, String label, String abbrev, String reverseDescription, String reverseLabel, String reverseAbbrev,
|
|
51 |
String dtype, UUID uuidVocabulary, UUID uuidLanguage, boolean isOrdered, UUID uuidAfterTerm){
|
|
52 |
return new SingleTermUpdater(stepList, stepName, termType, uuidTerm, idInVocabulary,symbol,
|
|
53 |
description, label, abbrev, reverseDescription, reverseLabel, reverseAbbrev,
|
|
54 |
dtype, uuidVocabulary, uuidLanguage, isOrdered, uuidAfterTerm);
|
|
55 |
}
|
|
43 |
public static final SingleTermUpdater NewReverseInstance(List<ISchemaUpdaterStep> stepList, String stepName, TermType termType, UUID uuidTerm, String idInVocabulary, String symbol,
|
|
44 |
String description, String label, String abbrev, String reverseDescription, String reverseLabel, String reverseAbbrev, |
|
45 |
String dtype, UUID uuidVocabulary, UUID uuidLanguage, boolean isOrdered, UUID uuidAfterTerm){ |
|
46 |
return new SingleTermUpdater(stepList, stepName, termType, uuidTerm, idInVocabulary,symbol, |
|
47 |
description, label, abbrev, reverseDescription, reverseLabel, reverseAbbrev, |
|
48 |
dtype, uuidVocabulary, uuidLanguage, isOrdered, uuidAfterTerm); |
|
49 |
} |
|
56 | 50 |
|
51 |
// *************************** VARIABLES *****************************************/ |
|
57 | 52 |
|
58 | 53 |
private final UUID uuidTerm ; |
59 | 54 |
private final String description; |
... | ... | |
74 | 69 |
private boolean transitive = false; |
75 | 70 |
private String symbol; |
76 | 71 |
|
77 |
|
|
72 |
// ***************************** CONSTRUCTOR ***************************************/ |
|
78 | 73 |
|
79 | 74 |
private SingleTermUpdater(List<ISchemaUpdaterStep> stepList, String stepName, TermType termType, UUID uuidTerm, String idInVocabulary, String symbol, |
80 | 75 |
String description, String label, String abbrev, String reverseDescription, String reverseLabel, String reverseAbbrev, |
... | ... | |
97 | 92 |
this.reverseAbbrev = reverseAbbrev; |
98 | 93 |
} |
99 | 94 |
|
95 |
// ******************************* METHODS *************************************************/ |
|
96 |
|
|
100 | 97 |
@Override |
101 | 98 |
public void invoke(ICdmDataSource datasource, IProgressMonitor monitor, |
102 | 99 |
CaseType caseType, SchemaUpdateResult result) throws SQLException { |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/TermRepresentationAdder.java | ||
---|---|---|
59 | 59 |
this.isReverse = isReverse; |
60 | 60 |
} |
61 | 61 |
|
62 |
|
|
63 |
|
|
64 | 62 |
@Override |
65 | 63 |
public void invoke(ICdmDataSource datasource, IProgressMonitor monitor, |
66 | 64 |
CaseType caseType, SchemaUpdateResult result) throws SQLException{ |
... | ... | |
123 | 121 |
return; |
124 | 122 |
} |
125 | 123 |
|
126 |
/** |
|
127 |
* @param datasource |
|
128 |
* @param monitor |
|
129 |
* @param langId |
|
130 |
* @param caseType |
|
131 |
* @return |
|
132 |
* @throws SQLException |
|
133 |
*/ |
|
134 | 124 |
private Integer getRepresentationId(ICdmDataSource datasource, |
135 | 125 |
IProgressMonitor monitor, Integer langId, CaseType caseType) throws SQLException { |
136 | 126 |
//representation |
... | ... | |
156 | 146 |
} |
157 | 147 |
return repId; |
158 | 148 |
} |
159 |
|
|
160 |
} |
|
149 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/VocabularyCreator.java | ||
---|---|---|
24 | 24 |
/** |
25 | 25 |
* @author a.mueller |
26 | 26 |
* @since 10.09.2010 |
27 |
* |
|
28 | 27 |
*/ |
29 | 28 |
public class VocabularyCreator extends SchemaUpdaterStepBase { |
29 |
|
|
30 | 30 |
@SuppressWarnings("unused") |
31 | 31 |
private static final Logger logger = Logger.getLogger(VocabularyCreator.class); |
32 | 32 |
|
... | ... | |
38 | 38 |
} |
39 | 39 |
|
40 | 40 |
// *************************** VARIABLES *****************************************/ |
41 |
|
|
41 | 42 |
private UUID uuidVocabulary; |
42 | 43 |
private String description; |
43 | 44 |
private String label; |
... | ... | |
75 | 76 |
return; |
76 | 77 |
} |
77 | 78 |
|
78 |
|
|
79 | 79 |
//vocId |
80 | 80 |
Integer vocId; |
81 | 81 |
String sqlMaxId = " SELECT max(id)+1 as maxId FROM " + caseType.transformTo("TermVocabulary"); |
... | ... | |
89 | 89 |
return; |
90 | 90 |
} |
91 | 91 |
|
92 |
|
|
93 | 92 |
String id = Integer.toString(vocId); |
94 | 93 |
String created = getNowString(); |
95 | 94 |
String dtype; |
... | ... | |
147 | 146 |
return; |
148 | 147 |
} |
149 | 148 |
|
150 |
|
|
151 |
|
|
152 | 149 |
private String nullSafeString(String abbrev) { |
153 | 150 |
if (abbrev == null){ |
154 | 151 |
return "NULL"; |
... | ... | |
161 | 158 |
String stepName = "Create new vocabulary '"+ label + "'"; |
162 | 159 |
return stepName; |
163 | 160 |
} |
164 |
|
|
165 |
} |
|
161 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v40_50/ProParteSynonymUpdater.java | ||
---|---|---|
157 | 157 |
|
158 | 158 |
|
159 | 159 |
private void invokeSingle(boolean isPartial, int typeId, ICdmDataSource datasource, IProgressMonitor monitor, |
160 |
CaseType caseType, SchemaUpdateResult result) throws SQLException {
|
|
160 |
CaseType caseType, SchemaUpdateResult result){ |
|
161 | 161 |
|
162 | 162 |
try { |
163 | 163 |
//get maxId from taxonRelationship |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v523_525/VocabularyTreeCreator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2021 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.database.update.v523_525; |
|
10 |
|
|
11 |
import java.sql.SQLException; |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
|
16 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
17 |
import eu.etaxonomy.cdm.database.update.CaseType; |
|
18 |
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep; |
|
19 |
import eu.etaxonomy.cdm.database.update.SchemaUpdateResult; |
|
20 |
import eu.etaxonomy.cdm.database.update.SchemaUpdaterStepBase; |
|
21 |
|
|
22 |
/** |
|
23 |
* #6794 |
|
24 |
* @author a.mueller |
|
25 |
* @since 22.04.2021 |
|
26 |
*/ |
|
27 |
public class VocabularyTreeCreator extends SchemaUpdaterStepBase { |
|
28 |
|
|
29 |
protected VocabularyTreeCreator(List<ISchemaUpdaterStep> stepList, String stepName) { |
|
30 |
super(stepList, stepName); |
|
31 |
} |
|
32 |
@Override |
|
33 |
public List<ISchemaUpdaterStep> getInnerSteps() { |
|
34 |
List<ISchemaUpdaterStep> result = new ArrayList<>(); |
|
35 |
|
|
36 |
return result; |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public void invoke(ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType, |
|
41 |
SchemaUpdateResult result) throws SQLException { |
|
42 |
|
|
43 |
//before this the tree (or graph) attribute needs to be added to TermVocabulary |
|
44 |
|
|
45 |
//Create tree |
|
46 |
//Set ordered flag |
|
47 |
//set flat flag depending on existing terms |
|
48 |
//getTermsOrdered |
|
49 |
//for each Term |
|
50 |
//addToTree |
|
51 |
//TODO decide on kindOf vs. partOf |
|
52 |
//do the same for hierarchical terms |
|
53 |
//add tree to vocabulary |
|
54 |
|
|
55 |
//TODO how to handle AUD data |
|
56 |
|
|
57 |
// boolean includeAudit = true; |
|
58 |
// int osbId = getMaxId1(datasource, "OriginalSourceBase", includeAudit, monitor, caseType, result); |
|
59 |
// |
|
60 |
// String sql = "SELECT * " |
|
61 |
// + " FROM "+caseType.transformTo(tableName)+" t " |
|
62 |
// + " WHERE t."+this.citationsIdAttr+" IS NOT NULL OR t."+this.detailAttr+" IS NOT NULL "; |
|
63 |
// |
|
64 |
// ResultSet rs = datasource.executeQuery(sql); |
|
65 |
// while(rs.next()){ |
|
66 |
// int tnId = rs.getInt("id"); |
|
67 |
// Integer citationId = nullSafeInt(rs, citationsIdAttr); |
|
68 |
// Integer createdById = nullSafeInt(rs, "createdBy_id"); |
|
69 |
// String detail = rs.getString(detailAttr); |
|
70 |
// |
|
71 |
// sql = "INSERT INTO @@OriginalSourceBase@@ (DTYPE, sourceType, uuid, id, citation_id, citationMicroReference, createdBy_id, created, "+sourcedAttr+")" |
|
72 |
// + " VALUES ('"+dtype+"', '"+sourceType+"','"+UUID.randomUUID()+"'," + osbId + ", " + citationId + "," + nullSafeParam(detail) + "," + createdById + ",'" + this.getNowString() + "',"+tnId+")"; |
|
73 |
// datasource.executeUpdate(caseType.replaceTableNames(sql)); |
|
74 |
// |
|
75 |
// osbId++; |
|
76 |
// } |
|
77 |
} |
|
78 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v529_53x/VocabularyTreeCreator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2021 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.database.update.v529_53x; |
|
10 |
|
|
11 |
import java.sql.SQLException; |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
|
16 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
17 |
import eu.etaxonomy.cdm.database.update.CaseType; |
|
18 |
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep; |
|
19 |
import eu.etaxonomy.cdm.database.update.SchemaUpdateResult; |
|
20 |
import eu.etaxonomy.cdm.database.update.SchemaUpdaterStepBase; |
|
21 |
|
|
22 |
/** |
|
23 |
* #6794 |
|
24 |
* @author a.mueller |
|
25 |
* @since 22.04.2021 |
|
26 |
*/ |
|
27 |
public class VocabularyTreeCreator extends SchemaUpdaterStepBase { |
|
28 |
|
|
29 |
protected VocabularyTreeCreator(List<ISchemaUpdaterStep> stepList, String stepName) { |
|
30 |
super(stepList, stepName); |
|
31 |
} |
|
32 |
@Override |
|
33 |
public List<ISchemaUpdaterStep> getInnerSteps() { |
|
34 |
List<ISchemaUpdaterStep> result = new ArrayList<>(); |
|
35 |
|
|
36 |
return result; |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public void invoke(ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType, |
|
41 |
SchemaUpdateResult result) throws SQLException { |
|
42 |
|
|
43 |
//before this the tree (or graph) attribute needs to be added to TermVocabulary |
|
44 |
|
|
45 |
//Create tree |
|
46 |
//Set ordered flag |
|
47 |
//set flat flag depending on existing terms |
|
48 |
//getTermsOrdered |
|
49 |
//for each Term |
|
50 |
//addToTree |
|
51 |
//TODO decide on kindOf vs. partOf |
|
52 |
//do the same for hierarchical terms |
|
53 |
//add tree to vocabulary |
|
54 |
|
|
55 |
//TODO how to handle AUD data |
|
56 |
|
|
57 |
// boolean includeAudit = true; |
|
58 |
// int osbId = getMaxId1(datasource, "OriginalSourceBase", includeAudit, monitor, caseType, result); |
|
59 |
// |
|
60 |
// String sql = "SELECT * " |
|
61 |
// + " FROM "+caseType.transformTo(tableName)+" t " |
|
62 |
// + " WHERE t."+this.citationsIdAttr+" IS NOT NULL OR t."+this.detailAttr+" IS NOT NULL "; |
|
63 |
// |
|
64 |
// ResultSet rs = datasource.executeQuery(sql); |
|
65 |
// while(rs.next()){ |
|
66 |
// int tnId = rs.getInt("id"); |
|
67 |
// Integer citationId = nullSafeInt(rs, citationsIdAttr); |
|
68 |
// Integer createdById = nullSafeInt(rs, "createdBy_id"); |
|
69 |
// String detail = rs.getString(detailAttr); |
|
70 |
// |
|
71 |
// sql = "INSERT INTO @@OriginalSourceBase@@ (DTYPE, sourceType, uuid, id, citation_id, citationMicroReference, createdBy_id, created, "+sourcedAttr+")" |
|
72 |
// + " VALUES ('"+dtype+"', '"+sourceType+"','"+UUID.randomUUID()+"'," + osbId + ", " + citationId + "," + nullSafeParam(detail) + "," + createdById + ",'" + this.getNowString() + "',"+tnId+")"; |
|
73 |
// datasource.executeUpdate(caseType.replaceTableNames(sql)); |
|
74 |
// |
|
75 |
// osbId++; |
|
76 |
// } |
|
77 |
} |
|
78 |
} |
Also available in: Unified diff
cleanup