Revision c0248cde
Added by Andreas Müller over 7 years ago
cdmlib-print/src/test/java/eu/etaxonomy/cdm/print/PubTest.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2009 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
13 | 13 |
import java.sql.SQLException; |
14 | 14 |
import java.util.UUID; |
15 | 15 |
|
16 |
import org.junit.Assert; |
|
17 |
|
|
18 | 16 |
import org.apache.log4j.Logger; |
19 | 17 |
import org.jdom.Element; |
18 |
import org.junit.Assert; |
|
20 | 19 |
import org.springframework.core.io.ClassPathResource; |
21 | 20 |
import org.springframework.core.io.Resource; |
22 | 21 |
|
... | ... | |
28 | 27 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
29 | 28 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
30 | 29 |
import eu.etaxonomy.cdm.io.api.application.CdmIoApplicationController; |
31 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
|
32 | 30 |
import eu.etaxonomy.cdm.print.out.pdf.PdfOutputModule; |
33 | 31 |
import eu.etaxonomy.cdm.print.out.xml.XMLOutputModule; |
34 | 32 |
|
... | ... | |
38 | 36 |
* |
39 | 37 |
*/ |
40 | 38 |
public class PubTest { |
41 |
|
|
39 |
|
|
42 | 40 |
private static final Logger logger = Logger.getLogger(PubTest.class); |
43 | 41 |
|
44 |
private static PublishConfigurator configurator;
|
|
45 |
|
|
42 |
private static PublishConfigurator configurator; |
|
43 |
|
|
46 | 44 |
private static Publisher publisher; |
47 |
|
|
45 |
|
|
48 | 46 |
public static final String DEFAULT_PRINT_APPLICATION_CONTEXT_RESOURCE = "/eu/etaxonomy/cdm/defaultPrintApplicationContext.xml"; |
49 |
|
|
50 |
|
|
47 |
|
|
48 |
|
|
51 | 49 |
/** |
52 | 50 |
* @throws java.lang.Exception |
53 | 51 |
*/ |
54 | 52 |
public static void setUpBeforeClass() throws Exception { |
55 |
|
|
53 |
|
|
56 | 54 |
ICdmDataSource dataSource = customDataSource(); |
57 |
|
|
55 |
|
|
58 | 56 |
//Resource applicationContextResource, ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading, IProgressMonitor progressMonitor) |
59 | 57 |
IProgressMonitor progressMonitor = DefaultProgressMonitor.NewInstance(); |
60 |
|
|
58 |
|
|
61 | 59 |
//Connecting to a CDMDataSource |
62 | 60 |
///Resource resource = new ClassPathResource(CdmDefaultIOBase.DEFAULT_IO_APPLICATION_CONTEXT_RESOURCE); |
63 | 61 |
Resource resource = new ClassPathResource(DEFAULT_PRINT_APPLICATION_CONTEXT_RESOURCE); |
... | ... | |
65 | 63 |
//ICdmApplicationConfiguration app = CdmApplicationController.NewInstance(resource, dataSource, DbSchemaValidation.VALIDATE, false, progressMonitor); |
66 | 64 |
//configurator = PublishConfigurator.NewLocalInstance(CdmStore.getCurrentApplicationConfiguration());//from taxeditor GeneratePdfHandler |
67 | 65 |
configurator = PublishConfigurator.NewLocalInstance(app); |
68 |
|
|
66 |
|
|
69 | 67 |
IXMLEntityFactory factory = configurator.getFactory(); |
70 |
|
|
68 |
|
|
71 | 69 |
UUID taxonNodeUuid = UUID.fromString("a605e87e-113e-4ebd-ad97-f086b734b4da");//5168a18b-c0b1-44cc-80aa-7a5572fefe04 |
72 | 70 |
Element taxonNodeElement = factory.getTaxonNode(taxonNodeUuid); |
73 | 71 |
configurator.addSelectedTaxonNodeElements(taxonNodeElement); |
74 |
|
|
72 |
|
|
75 | 73 |
configurator.setDoPublishEntireBranches(false); |
76 |
|
|
74 |
|
|
77 | 75 |
configurator.addOutputModule(new PdfOutputModule()); |
78 | 76 |
configurator.addOutputModule(new XMLOutputModule()); |
79 |
|
|
80 |
|
|
77 |
|
|
78 |
|
|
81 | 79 |
//configurator.setWebserviceUrl("http://localhost:8080/"); |
82 |
|
|
80 |
|
|
83 | 81 |
// Element selectedTaxonNodeElement = new Element("TaxonNode"); |
84 |
//
|
|
82 |
// |
|
85 | 83 |
// configurator.addSelectedTaxonNodeElements(selectedTaxonNodeElement); |
86 |
|
|
84 |
|
|
87 | 85 |
configurator.setExportFolder(new File("/Users/nho/tmp/")); |
88 |
|
|
86 |
|
|
89 | 87 |
} |
90 |
|
|
88 |
|
|
91 | 89 |
private static ICdmDataSource customDataSource() { |
92 | 90 |
|
93 |
|
|
91 |
|
|
94 | 92 |
// pwd = AccountStore.readOrStorePassword(cdmServer, cdmDB, cdmUserName,pwd); |
95 | 93 |
String dataSourceName = CdmUtils.readInputLine("Database name: "); |
96 | 94 |
String username = CdmUtils.readInputLine("Username: "); |
97 | 95 |
String password = CdmUtils.readInputLine("Password: "); |
98 |
|
|
96 |
|
|
99 | 97 |
dataSourceName = (dataSourceName.equals("")) ? "cdm_test4" : dataSourceName; |
100 | 98 |
username = (username.equals("")) ? "ljm" : username; |
101 |
|
|
102 |
ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("160.45.63.201", "cdm_edit_flora_central_africa", 3306, "edit", password, NomenclaturalCode.ICNAFP);
|
|
103 |
//ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("127.0.0.1", dataSourceName, 3306, username, password, NomenclaturalCode.ICBN);
|
|
104 |
//ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("127.0.0.1", "cdm_edit_cichorieae", 3306, "ljm", password, NomenclaturalCode.ICBN);
|
|
105 |
//ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("160.45.63.201", "cdm_edit_cichorieae", 3306, "edit", password, NomenclaturalCode.ICBN);
|
|
99 |
|
|
100 |
ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("160.45.63.201", "cdm_edit_flora_central_africa", 3306, "edit", password); |
|
101 |
//ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("127.0.0.1", dataSourceName, 3306, username, password); |
|
102 |
//ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("127.0.0.1", "cdm_edit_cichorieae", 3306, "ljm", password); |
|
103 |
//ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("160.45.63.201", "cdm_edit_cichorieae", 3306, "edit", password); |
|
106 | 104 |
boolean connectionAvailable; |
107 | 105 |
try { |
108 | 106 |
connectionAvailable = dataSource.testConnection(); |
... | ... | |
124 | 122 |
* @param args |
125 | 123 |
*/ |
126 | 124 |
public static void main(String[] args) { |
127 |
|
|
125 |
|
|
128 | 126 |
PubTest pubTest = new PubTest(); |
129 | 127 |
try { |
130 | 128 |
pubTest.setUpBeforeClass(); |
Also available in: Unified diff
ref #3658 remove nomenclaturalCode from all datasource related classes