1 package eu
.etaxonomy
.cdm
.app
.references
;
4 import java
.net
.URISyntaxException
;
6 import org
.apache
.log4j
.Logger
;
8 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
9 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
10 import eu
.etaxonomy
.cdm
.app
.util
.TestDatabase
;
11 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
12 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
13 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
14 import eu
.etaxonomy
.cdm
.io
.reference
.endnote
.in
.EndnoteImportConfigurator
;
16 public class EndNoteImportActivator
{
17 /* SerializeFrom DB **/
18 //private static final ICdmDataSource cdmSource = CdmDestinations.localH2Diptera();
19 private static final ICdmDataSource cdmDestination
= CdmDestinations
.localH2Diptera();
22 private static String importFileNameString
= "file:/C:/EndNoteTest.xml";
27 private static final Logger logger
= Logger
.getLogger(EndNoteImportActivator
.class);
30 public static String
chooseFile(String
[] args
) {
33 for (String dest
: args
){
34 if (dest
.endsWith(".xml")){
41 private void invokeImport(String importFileParamString
, ICdmDataSource destination
) {
44 importFileName
= new URI(importFileNameString
);
45 EndnoteImportConfigurator endNoteImportConfigurator
;
46 if (importFileParamString
!=null && destination
!= null){
47 URI importFileParam
= new URI(importFileParamString
);
48 endNoteImportConfigurator
= EndnoteImportConfigurator
.NewInstance(importFileParam
, destination
);
49 }else if (destination
!= null){
50 endNoteImportConfigurator
= EndnoteImportConfigurator
.NewInstance(importFileName
, destination
);
51 } else if (importFileParamString
!=null ){
52 URI importFileParam
= new URI(importFileParamString
);
53 endNoteImportConfigurator
= EndnoteImportConfigurator
.NewInstance(importFileParam
, cdmDestination
);
55 endNoteImportConfigurator
= EndnoteImportConfigurator
.NewInstance(importFileName
, cdmDestination
);
58 CdmDefaultImport
<EndnoteImportConfigurator
> endNoteImport
=
59 new CdmDefaultImport
<EndnoteImportConfigurator
>();
63 logger
.debug("Invoking Jaxb import");
65 endNoteImport
.invoke(endNoteImportConfigurator
, destination
, true);
66 } catch (URISyntaxException e
) {
75 private CdmApplicationController
initDb(ICdmDataSource db
) {
78 CdmApplicationController appCtrInit
= null;
80 appCtrInit
= TestDatabase
.initDb(db
, DbSchemaValidation
.VALIDATE
, true);
86 // Load test data to DB
87 private void loadTestData(CdmApplicationController appCtrInit
) {
89 TestDatabase
.loadTestData("", appCtrInit
);
96 public static void main(String
[] args
) {
98 EndNoteImportActivator sc
= new EndNoteImportActivator();
99 ICdmDataSource destination
= CdmDestinations
.chooseDestination(args
) != null ? CdmDestinations
.chooseDestination(args
) : cdmDestination
;
100 String file
= chooseFile(args
)!= null ?
chooseFile(args
) : importFileNameString
;
101 CdmApplicationController appCtr
= null;
102 appCtr
= sc
.initDb(destination
);
103 //sc.loadTestData(appCtr);
105 sc
.invokeImport(file
, destination
);