2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.test
.function
;
12 import java
.io
.IOException
;
13 import java
.util
.HashSet
;
16 import java
.util
.UUID
;
18 import javax
.servlet
.http
.HttpServletResponse
;
20 import org
.apache
.log4j
.Logger
;
21 import org
.springframework
.web
.servlet
.ModelAndView
;
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
;
38 public class TestScriptRemote
{
40 @SuppressWarnings("unused")
41 private static final Logger logger
= Logger
.getLogger(TestScriptPersistence
.class);
44 private void testNewConfigControler(){
46 DbSchemaValidation schema
= DbSchemaValidation
.VALIDATE
;
51 ICdmDataSource dataSource
;
53 // List<CdmPersistentDataSource> lsDataSources = CdmPersistentDataSource.getAllDataSources();
54 // System.out.println(lsDataSources);
55 // dataSource = lsDataSources.get(1);
57 // DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
59 // server = "localhost";
60 // database = "cdm_bupleurum";
61 //// database = "cdm_production_edaphobase";
63 // dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
65 // server = "160.45.63.171";
66 // database = "cdm_production_flora_malesiana_prospective";
68 // dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
70 server
= "test.e-taxonomy.eu";
71 database
= "cdm_rem_conf_am";
73 dataSource
= CdmDataSource
.NewMySqlInstance(server
, database
, username
, AccountStore
.readOrStorePassword(server
, database
, username
, null));
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));
82 // server = "BGBM-PESISQL";
83 // database = "cdm36";
85 // username = "cdmupdater";
86 // dataSource = CdmDataSource.NewSqlServer2012Instance(server, database, port, username, AccountStore.readOrStorePassword(server, database, username, null));
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";
93 // dataSource = CdmDataSource.NewH2EmbeddedInstance("cdm", username, "", path);
95 // dataSource = CdmDataSource.NewH2EmbeddedInstance(database, username, "sa");
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));
103 CdmApplicationController appCtr
= CdmRemoteApplicationController
.NewRemoteInstance(dataSource
, schema
);
107 } catch (IOException e
) {
108 // TODO Auto-generated catch block
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);
122 private void doTemporary(CdmApplicationController appCtr
) throws IOException
{
126 private void doGetDistributionInfo(CdmApplicationController appCtr
) throws IOException
{
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
;
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
);
147 System
.out
.println("Start TestScript");
148 testNewConfigControler();
149 //testDatabaseChange();
151 System
.out
.println("\nEnd TestScript");
154 public static void main(String
[] args
) {
155 TestScriptRemote cc
= new TestScriptRemote();