Revision 0a59dd14
Added by Andreas Müller almost 3 years ago
cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/CdmUtilsTest.java | ||
---|---|---|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.common; |
11 | 10 |
|
12 | 11 |
import static org.junit.Assert.assertNotNull; |
... | ... | |
17 | 16 |
|
18 | 17 |
import org.apache.log4j.Level; |
19 | 18 |
import org.apache.log4j.Logger; |
20 |
import org.junit.After; |
|
21 | 19 |
import org.junit.Assert; |
22 |
import org.junit.Before; |
|
23 | 20 |
import org.junit.Test; |
24 | 21 |
|
25 | 22 |
/** |
26 | 23 |
* @author a.mueller |
27 | 24 |
* @since 22.01.2008 |
28 |
* |
|
29 | 25 |
*/ |
30 | 26 |
public class CdmUtilsTest { |
31 |
private static final Logger logger = Logger.getLogger(CdmUtilsTest.class); |
|
32 |
|
|
33 |
|
|
34 |
@Before |
|
35 |
public void setUp() throws Exception { |
|
36 |
} |
|
37 | 27 |
|
38 |
@After |
|
39 |
public void tearDown() throws Exception { |
|
40 |
} |
|
28 |
private static final Logger logger = Logger.getLogger(CdmUtilsTest.class); |
|
41 | 29 |
|
42 | 30 |
/************************** TESTS ****************************************/ |
43 | 31 |
|
... | ... | |
83 | 71 |
str1 = "An y eer"; |
84 | 72 |
str2 = "A nyfffe er"; |
85 | 73 |
Assert.assertFalse(CdmUtils.equalsIgnoreWS(str1, str2)); |
86 |
|
|
87 | 74 |
} |
88 | 75 |
|
89 | 76 |
@Test |
... | ... | |
102 | 89 |
Assert.assertEquals(".*\\Qabc\\E.*", regEx); |
103 | 90 |
Assert.assertTrue("abc".matches(regEx)); |
104 | 91 |
Assert.assertTrue("a80/(--e*wabc?äe".matches(regEx)); |
105 |
|
|
106 | 92 |
} |
107 | 93 |
|
108 | 94 |
/** |
... | ... | |
145 | 131 |
Assert.assertEquals("Str1;Str3", CdmUtils.concat(";", str1, "", str3)); |
146 | 132 |
Assert.assertEquals("Str1; ;Str3", CdmUtils.concat(";", str1, " ", str3)); |
147 | 133 |
} |
148 |
|
|
149 |
} |
|
134 |
} |
cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/function/TestSomething.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.common.function; |
|
10 |
|
|
11 |
/** |
|
12 |
* @author a.mueller |
|
13 |
* @since 07.06.2021 |
|
14 |
*/ |
|
15 |
public class TestSomething { |
|
16 |
|
|
17 |
public static void main(String[] args){ |
|
18 |
try{ |
|
19 |
throw new RuntimeException(); |
|
20 |
}catch(Exception e){ |
|
21 |
for (StackTraceElement ste: e.getStackTrace()){ |
|
22 |
System.out.println(ste.getClassName()); |
|
23 |
System.out.println(ste.getMethodName()); |
|
24 |
System.out.println(e.getMessage()); |
|
25 |
System.out.println(e.getClass().getCanonicalName()); |
|
26 |
} |
|
27 |
System.out.println(e.getStackTrace()); |
|
28 |
} |
|
29 |
} |
|
30 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java | ||
---|---|---|
302 | 302 |
this.protectedNomenclaturalTitleCache = protectedNomenclaturalTitleCache; |
303 | 303 |
} |
304 | 304 |
|
305 |
|
|
306 | 305 |
@Override |
307 | 306 |
//@Transient //TODO a.kohlbecker remove?? |
308 | 307 |
public String getTitleCache() { |
... | ... | |
348 | 347 |
public boolean isHasMoreMembers() { |
349 | 348 |
return hasMoreMembers; |
350 | 349 |
} |
351 |
|
|
352 | 350 |
public void setHasMoreMembers(boolean hasMoreMembers) { |
353 | 351 |
this.hasMoreMembers = hasMoreMembers; |
354 | 352 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/TeamOrPersonBase.java | ||
---|---|---|
114 | 114 |
return result; |
115 | 115 |
} |
116 | 116 |
|
117 |
@Transient |
|
117 |
@Transient
|
|
118 | 118 |
public String getFullTitle() { |
119 | 119 |
@SuppressWarnings("unchecked") |
120 | 120 |
T agent = (T)this; |
... | ... | |
136 | 136 |
} |
137 | 137 |
|
138 | 138 |
@Override |
139 |
public TeamOrPersonBase clone() throws CloneNotSupportedException { |
|
140 |
@SuppressWarnings("rawtypes") |
|
141 |
TeamOrPersonBase<?> result = (TeamOrPersonBase)super.clone(); |
|
139 |
public TeamOrPersonBase<T> clone() throws CloneNotSupportedException { |
|
140 |
TeamOrPersonBase<T> result = (TeamOrPersonBase<T>)super.clone(); |
|
142 | 141 |
|
143 | 142 |
//nothing to do: collectorTitle, nomenclaturalTitle; |
144 | 143 |
return result; |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v523_524/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_524; |
|
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/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-services/src/main/java/eu/etaxonomy/cdm/api/service/IOccurrenceService.java | ||
---|---|---|
681 | 681 |
* derivative has more than one original. (see https://dev.e-taxonomy.eu/redmine/issues/9253) |
682 | 682 |
* |
683 | 683 |
* @param derivedUnitDTO |
684 |
* The DerivedUnitDTO to start the search from. |
|
684 |
* The DerivedUnitDTO to start the search from.
|
|
685 | 685 |
* @param alreadyCollectedSpecimen |
686 |
* A map to hold all originals that have been sees during the recursive walk. |
|
686 |
* A map to hold all originals that have been sees during the recursive walk.
|
|
687 | 687 |
* @return |
688 |
* The collection of all Field Units that are accessible from the derivative from where the search was started. |
|
688 |
* The collection of all Field Units that are accessible from the derivative from where the search was started.
|
|
689 | 689 |
*/ |
690 | 690 |
public Collection<SpecimenOrObservationBaseDTO> findRootUnitDTOs(UUID unitUUID); |
691 | 691 |
|
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/Datasource.java | ||
---|---|---|
79 | 79 |
username = "edit"; |
80 | 80 |
dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null)); |
81 | 81 |
|
82 |
// String server = "160.45.63.171";
|
|
83 |
// String database = "cdm_production_xxx";
|
|
84 |
// String username = "edit";
|
|
82 |
// server = "160.45.63.171"; |
|
83 |
// database = "cdm_production_flora_malesiana_prospective";
|
|
84 |
// username = "edit"; |
|
85 | 85 |
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null)); |
86 | 86 |
|
87 | 87 |
|
... | ... | |
118 | 118 |
// username = "edit"; |
119 | 119 |
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null)); |
120 | 120 |
|
121 |
|
|
122 |
// try { |
|
123 |
// CdmUpdater updater = new CdmUpdater(); |
|
124 |
// if (schema == DbSchemaValidation.VALIDATE){ |
|
125 |
// updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance()); |
|
126 |
// } |
|
127 |
// } catch (Exception e) { |
|
128 |
// e.printStackTrace(); |
|
129 |
// } |
|
130 |
|
|
131 | 121 |
//CdmPersistentDataSource.save(dataSource.getName(), dataSource); |
132 | 122 |
CdmApplicationController appCtr; |
133 | 123 |
appCtr = CdmApplicationController.NewInstance(dataSource, schema); |
134 | 124 |
|
135 |
//// TransactionStatus tx = appCtr.startTransaction(true); |
|
136 |
//// |
|
137 |
//// DescriptiveDataSet dataset = appCtr.getDescriptiveDataSetService().find(10); |
|
138 |
//// PolytomousKeyGeneratorConfigurator config = new PolytomousKeyGeneratorConfigurator(); |
|
139 |
//// config.setDataSet(dataset); |
|
140 |
//// config.setDebug(true); |
|
141 |
//// PolytomousKey key = new PolytomousKeyGenerator().invoke(config); |
|
142 |
////// appCtr.getPolytomousKeyService().save(key); |
|
143 |
//// key.print(System.out); |
|
144 |
// System.out.println(key.getUuid()); |
|
145 |
// |
|
146 |
// appCtr.commitTransaction(tx); |
|
147 |
|
|
148 |
// testGroupedTaxa(appCtr); |
|
149 |
|
|
125 |
appCtr.getOccurrenceService().findRootUnitDTOs(UUID.fromString("2debf5ee-cb57-40bc-af89-173d1d17cefe")); |
|
150 | 126 |
|
151 |
// int n = appCtr.getAgentService().count(null); |
|
152 |
// logger.warn("End adding " + n + " persons"); |
|
153 |
|
|
154 |
// appCtr.getCommonService().createFullSampleData(); |
|
155 |
|
|
156 |
// ValidationManager valMan = (ValidationManager)appCtr.getBean("validationManager"); |
|
157 |
// valMan.registerValidationListeners(); |
|
158 |
|
|
159 |
// State state = State.NewInstance(); |
|
160 |
// Taxon taxon = Taxon.NewInstance(null, null); |
|
161 |
// TaxonDescription desc = TaxonDescription.NewInstance(taxon); |
|
162 |
//// CategoricalData catData = CategoricalData.NewInstance(state, Feature.HABITAT()); |
|
163 |
// QuantitativeData quantData = QuantitativeData.NewInstance(Feature.ANATOMY()); |
|
164 |
// StatisticalMeasurementValue statisticalValue = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.AVERAGE(), 2); |
|
165 |
// quantData.addStatisticalValue(statisticalValue); |
|
166 |
// desc.addElement(quantData); |
|
167 |
|
|
168 |
// appCtr.getTermService().saveOrUpdate(state); |
|
169 |
// |
|
170 |
// appCtr.getTaxonService().save(taxon); |
|
171 | 127 |
|
172 |
// insertSomeData(appCtr); |
|
173 |
// deleteHighLevelNode(appCtr); //->problem with Duplicate Key in Classification_TaxonNode |
|
174 | 128 |
appCtr.close(); |
175 | 129 |
System.exit(0); |
176 | 130 |
} |
Also available in: Unified diff
cleanup