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.io.IOException;
|
13
|
import java.util.HashSet;
|
14
|
import java.util.Map;
|
15
|
import java.util.Set;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import javax.servlet.http.HttpServletResponse;
|
19
|
|
20
|
import org.apache.log4j.Logger;
|
21
|
import org.springframework.web.servlet.ModelAndView;
|
22
|
|
23
|
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
|
24
|
import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO.InfoPart;
|
25
|
import eu.etaxonomy.cdm.config.AccountStore;
|
26
|
import eu.etaxonomy.cdm.database.CdmDataSource;
|
27
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
28
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
29
|
import eu.etaxonomy.cdm.ext.geo.CondensedDistributionRecipe;
|
30
|
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
|
31
|
import eu.etaxonomy.cdm.remote.controller.DescriptionListController;
|
32
|
import eu.etaxonomy.cdm.remote.io.application.CdmRemoteApplicationController;
|
33
|
|
34
|
/**
|
35
|
* @author a.mueller
|
36
|
* @since 08.11.2021
|
37
|
*/
|
38
|
public class TestScriptRemote {
|
39
|
|
40
|
@SuppressWarnings("unused")
|
41
|
private static final Logger logger = Logger.getLogger(TestScriptPersistence.class);
|
42
|
|
43
|
|
44
|
private void testNewConfigControler(){
|
45
|
|
46
|
DbSchemaValidation schema = DbSchemaValidation.VALIDATE;
|
47
|
|
48
|
String server;
|
49
|
String database;
|
50
|
String username;
|
51
|
ICdmDataSource dataSource;
|
52
|
|
53
|
// List<CdmPersistentDataSource> lsDataSources = CdmPersistentDataSource.getAllDataSources();
|
54
|
// System.out.println(lsDataSources);
|
55
|
// dataSource = lsDataSources.get(1);
|
56
|
|
57
|
// DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
|
58
|
|
59
|
// server = "localhost";
|
60
|
// database = "cdm_bupleurum";
|
61
|
//// database = "cdm_production_edaphobase";
|
62
|
// username = "edit";
|
63
|
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
64
|
|
65
|
// server = "160.45.63.171";
|
66
|
// database = "cdm_production_flora_malesiana_prospective";
|
67
|
// username = "edit";
|
68
|
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
69
|
|
70
|
server = "test.e-taxonomy.eu";
|
71
|
database = "cdm_rem_conf_am";
|
72
|
username = "edit";
|
73
|
dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
74
|
|
75
|
// String server = "localhost";
|
76
|
// String database = "testCDM";
|
77
|
// String username = "postgres";
|
78
|
// dataSource = CdmDataSource.NewInstance(DatabaseTypeEnum.PostgreSQL, server, database, DatabaseTypeEnum.PostgreSQL.getDefaultPort(), username, AccountStore.readOrStorePassword(server, database, username, null));
|
79
|
|
80
|
|
81
|
// //SQLServer
|
82
|
// server = "BGBM-PESISQL";
|
83
|
// database = "cdm36";
|
84
|
// int port = 1433;
|
85
|
// username = "cdmupdater";
|
86
|
// dataSource = CdmDataSource.NewSqlServer2012Instance(server, database, port, username, AccountStore.readOrStorePassword(server, database, username, null));
|
87
|
//
|
88
|
// //H2
|
89
|
// String path = "C:\\Users\\a.mueller\\.cdmLibrary\\writableResources\\h2\\LocalH2";
|
90
|
//// String path = "C:\\Users\\pesiimport\\.cdmLibrary\\writableResources\\h2\\LocalH2";
|
91
|
//// String path = "C:\\Users\\a.mueller\\eclipse\\svn\\cdmlib-trunk\\cdmlib-remote-webapp\\src\\test\\resources\\h2";
|
92
|
// username = "sa";
|
93
|
// dataSource = CdmDataSource.NewH2EmbeddedInstance("cdm", username, "", path);
|
94
|
|
95
|
// dataSource = CdmDataSource.NewH2EmbeddedInstance(database, username, "sa");
|
96
|
|
97
|
|
98
|
// server = "160.45.63.201";
|
99
|
// database = "cdm_integration_cichorieae";
|
100
|
// username = "edit";
|
101
|
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
102
|
|
103
|
CdmApplicationController appCtr = CdmRemoteApplicationController.NewRemoteInstance(dataSource, schema);
|
104
|
|
105
|
try {
|
106
|
doTemporary(appCtr);
|
107
|
} catch (IOException e) {
|
108
|
// TODO Auto-generated catch block
|
109
|
e.printStackTrace();
|
110
|
}
|
111
|
|
112
|
// List<UuidAndTitleCache<TaxonBase>> list = appCtr.getTaxonService().getUuidAndTitleCache(null, 10, "Abies alba%");
|
113
|
// System.out.println(list);
|
114
|
// appCtr.getOccurrenceService().findRootUnitDTOs(UUID.fromString("2debf5ee-cb57-40bc-af89-173d1d17cefe"));
|
115
|
// aggregateDDS(appCtr);
|
116
|
// aggregateDistribution(appCtr);
|
117
|
|
118
|
appCtr.close();
|
119
|
System.exit(0);
|
120
|
}
|
121
|
|
122
|
private void doTemporary(CdmApplicationController appCtr) throws IOException {
|
123
|
|
124
|
}
|
125
|
|
126
|
private void doGetDistributionInfo(CdmApplicationController appCtr) throws IOException {
|
127
|
|
128
|
UUID descUUID = UUID.fromString("2debf5ee-cb57-40bc-af89-173d1d17cefe");
|
129
|
Set<InfoPart> parts = new HashSet<>();
|
130
|
parts.add(InfoPart.tree);
|
131
|
parts.add(InfoPart.mapUriParams);
|
132
|
Set<NamedAreaLevel> omitLevels = new HashSet<>();
|
133
|
NamedAreaLevel areaLevel = (NamedAreaLevel)appCtr.getTermService().find(UUID.fromString("38efa5fd-d7f0-451c-9de9-e6cce41e2225"));
|
134
|
omitLevels.add(areaLevel);
|
135
|
HttpServletResponse response = null;
|
136
|
DescriptionListController descriptionListController = (DescriptionListController) appCtr.getBean("descriptionListController");
|
137
|
CondensedDistributionRecipe recipe = CondensedDistributionRecipe.EuroPlusMed;
|
138
|
|
139
|
ModelAndView mav = descriptionListController.doGetDistributionInfo(descUUID, parts, false, false, null,
|
140
|
omitLevels, null, null, recipe, null, response );
|
141
|
Map<String, Object> model = mav.getModel();
|
142
|
System.out.println(model);
|
143
|
|
144
|
}
|
145
|
|
146
|
private void test(){
|
147
|
System.out.println("Start TestScript");
|
148
|
testNewConfigControler();
|
149
|
//testDatabaseChange();
|
150
|
|
151
|
System.out.println("\nEnd TestScript");
|
152
|
}
|
153
|
|
154
|
public static void main(String[] args) {
|
155
|
TestScriptRemote cc = new TestScriptRemote();
|
156
|
cc.test();
|
157
|
}
|
158
|
|
159
|
}
|