1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.test.function;
|
11
|
|
12
|
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
|
13
|
import eu.etaxonomy.cdm.api.validation.ValidationManager;
|
14
|
import eu.etaxonomy.cdm.common.AccountStore;
|
15
|
import eu.etaxonomy.cdm.database.CdmDataSource;
|
16
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
17
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
18
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
19
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
20
|
|
21
|
/**
|
22
|
* @author a.mueller
|
23
|
* @date 23.01.2015
|
24
|
*
|
25
|
*/
|
26
|
public class TestValidationManager {
|
27
|
|
28
|
|
29
|
public void testMe(){
|
30
|
DbSchemaValidation schema = DbSchemaValidation.CREATE;
|
31
|
|
32
|
|
33
|
String path = "C:\\Users\\a.mueller\\.cdmLibrary\\writableResources\\h2\\testValidation2";
|
34
|
String username = "sa";
|
35
|
CdmDataSource dataSource = CdmDataSource.NewH2EmbeddedInstance("validationTest", username, "", path, NomenclaturalCode.ICNAFP);
|
36
|
// dataSource = getMySQLDatasource(schema);
|
37
|
|
38
|
|
39
|
//CdmPersistentDataSource.save(dataSource.getName(), dataSource);
|
40
|
CdmApplicationController appCtr;
|
41
|
appCtr = CdmApplicationController.NewInstance(dataSource,schema);
|
42
|
// appCtr.getCommonService().createFullSampleData();
|
43
|
|
44
|
ValidationManager valMan = (ValidationManager)appCtr.getBean("validationManager");
|
45
|
valMan.registerValidationListeners();
|
46
|
|
47
|
Reference<?> ref = ReferenceFactory.newDatabase();
|
48
|
ref.setIsbn("1234");
|
49
|
appCtr.getReferenceService().save(ref);
|
50
|
|
51
|
|
52
|
// insertSomeData(appCtr);
|
53
|
// deleteHighLevelNode(appCtr); //->problem with Duplicate Key in Classification_TaxonNode
|
54
|
|
55
|
appCtr.close();
|
56
|
|
57
|
|
58
|
}
|
59
|
|
60
|
private CdmDataSource getMySQLDatasource (DbSchemaValidation schema){
|
61
|
String server = "localhost";
|
62
|
String database = (schema == DbSchemaValidation.VALIDATE ? "AM_test" : "AM_test");
|
63
|
String username = "edit";
|
64
|
CdmDataSource dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
65
|
return dataSource;
|
66
|
}
|
67
|
|
68
|
/**
|
69
|
* @param args
|
70
|
*/
|
71
|
public static void main(String[] args) {
|
72
|
TestValidationManager cc = new TestValidationManager();
|
73
|
cc.testMe();
|
74
|
}
|
75
|
}
|