1
|
/**
|
2
|
* Copyright (C) 2009 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
|
|
10
|
package eu.etaxonomy.cdm.test.function;
|
11
|
|
12
|
import java.util.HashSet;
|
13
|
import java.util.List;
|
14
|
import java.util.Set;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import javax.servlet.http.HttpServletRequest;
|
18
|
import javax.servlet.http.HttpServletResponse;
|
19
|
import javax.servlet.http.HttpServletResponseWrapper;
|
20
|
|
21
|
import org.apache.log4j.Logger;
|
22
|
import org.springframework.core.io.ClassPathResource;
|
23
|
|
24
|
import eu.etaxonomy.cdm.api.application.CdmApplicationDefaultController;
|
25
|
import eu.etaxonomy.cdm.api.service.DistributionTree;
|
26
|
import eu.etaxonomy.cdm.common.AccountStore;
|
27
|
import eu.etaxonomy.cdm.database.CdmDataSource;
|
28
|
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
|
29
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
30
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
31
|
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
|
32
|
import eu.etaxonomy.cdm.remote.controller.DescriptionPortalController;
|
33
|
import eu.etaxonomy.cdm.remote.editor.UuidList;
|
34
|
|
35
|
/**
|
36
|
* This class is meant for generic cdmlib-remote testing during development and to try things out.
|
37
|
* It is not a test class to be run in unit or integration tests.
|
38
|
* It may be adapted as required,
|
39
|
* but please do not destroy the overall structure.
|
40
|
*
|
41
|
* TODO not yet fully ready as the remote beans are not yet loaded.
|
42
|
* We need a specific applicationContext
|
43
|
*
|
44
|
* @author a.mueller
|
45
|
*
|
46
|
*/
|
47
|
public class GenericRemoteTester {
|
48
|
private static final Logger logger = Logger.getLogger(GenericRemoteTester.class);
|
49
|
|
50
|
|
51
|
private void testNewConfigControler(){
|
52
|
List<CdmPersistentDataSource> lsDataSources = CdmPersistentDataSource.getAllDataSources();
|
53
|
DbSchemaValidation schema = DbSchemaValidation.VALIDATE;
|
54
|
System.out.println(lsDataSources);
|
55
|
ICdmDataSource dataSource;
|
56
|
|
57
|
dataSource = lsDataSources.get(1);
|
58
|
// DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
|
59
|
|
60
|
String server = "localhost";
|
61
|
String database = "cdm_test";
|
62
|
// String database = "test";
|
63
|
String username = "edit";
|
64
|
dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
65
|
|
66
|
// //H2
|
67
|
// username = "sa";
|
68
|
// dataSource = CdmDataSource.NewH2EmbeddedInstance(database, username, "sa", NomenclaturalCode.ICNAFP);
|
69
|
|
70
|
String resourceStr = "/eu/etaxonomy/cdm/remote.xml";
|
71
|
ClassPathResource applicationContextResource = new ClassPathResource(resourceStr);
|
72
|
CdmApplicationDefaultController appCtr = CdmApplicationDefaultController.NewInstance(applicationContextResource, dataSource, schema, false);
|
73
|
|
74
|
// insertSomeData(appCtr);
|
75
|
// deleteHighLevelNode(appCtr); //->problem with Duplicate Key in Classification_TaxonNode
|
76
|
testDistributionTree(appCtr);
|
77
|
|
78
|
appCtr.close();
|
79
|
}
|
80
|
|
81
|
private void testDistributionTree(CdmApplicationDefaultController appCtr) {
|
82
|
DescriptionPortalController ctl = (DescriptionPortalController)appCtr.getBean("descriptionPortalController");
|
83
|
HttpServletRequest request = null;
|
84
|
HttpServletResponse response = new HttpServletResponseWrapper(null);
|
85
|
Set<NamedAreaLevel> levels = new HashSet<NamedAreaLevel>();
|
86
|
NamedAreaLevel areaLevel = (NamedAreaLevel)appCtr.getTermService().find(UUID.fromString("38efa5fd-d7f0-451c-9de9-e6cce41e2225"));
|
87
|
levels.add(areaLevel);
|
88
|
UuidList descriptionUuidList = new UuidList();
|
89
|
descriptionUuidList.add(UUID.fromString("c0e05d0c-1a80-4f2e-b051-ed9fd625d740"));
|
90
|
|
91
|
boolean subAreaPreference = false;
|
92
|
boolean statusOrderPreference = false;
|
93
|
DistributionTree tree = ctl.doGetOrderedDistributionsB(
|
94
|
descriptionUuidList,
|
95
|
subAreaPreference ,
|
96
|
statusOrderPreference,
|
97
|
null,
|
98
|
levels, request, response);
|
99
|
tree.toString();
|
100
|
}
|
101
|
|
102
|
|
103
|
private void test(){
|
104
|
System.out.println("Start Test");
|
105
|
testNewConfigControler();
|
106
|
System.out.println("\nEnd Test");
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* @param args
|
111
|
*/
|
112
|
public static void main(String[] args) {
|
113
|
GenericRemoteTester cc = new GenericRemoteTester();
|
114
|
cc.test();
|
115
|
}
|
116
|
|
117
|
}
|