1 package eu
.etaxonomy
.cdm
.io
.xper
;
5 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
6 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
7 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
8 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
9 import eu
.etaxonomy
.cdm
.io
.xper
.AdaptaterCdmXper
;
10 import fr_jussieu_snv_lis
.XPApp
;
11 import fr_jussieu_snv_lis
.Xper
;
12 import fr_jussieu_snv_lis
.edition
.XPDisplay
;
13 import fr_jussieu_snv_lis
.utils
.Utils
;
15 public class TestAdapterCdmXper
{
17 AdaptaterCdmXper adapterCdmXper
;
22 private void startApplications() {
23 DbSchemaValidation dbSchemaValidation
= DbSchemaValidation
.VALIDATE
;
24 ICdmDataSource datasource
= CdmDestinations
.cdm_test_local_xper();
25 System
.out
.println("cdm start");
26 CdmApplicationController appCtr
= CdmApplicationController
.NewInstance(datasource
, dbSchemaValidation
);
27 System
.out
.println("cdm started :::");
29 adapterCdmXper
= new AdaptaterCdmXper(appCtr
);
31 Thread t
= new Thread() {
33 new Xper(adapterCdmXper
);
36 System
.out
.println("xper2 start");
38 while(!XPApp
.xperReady
){
41 System
.out
.println("xper2 started :::");
44 public void xperloadDataFromCdm(){
45 System
.out
.println("start load data");
46 // display a loading gif
47 Utils
.displayLoadingGif(true);
50 // create a new empty base and load data from CDM
51 if(XPApp
.cdmAdapter
!= null){
53 XPApp
.getMainframe().newBase("baseTest");
54 // specify that the current base is not new (needed to be able to add images)
55 XPApp
.isNewBase
= false;
56 // delete the variable create by default and update the frame
57 XPApp
.getCurrentBase().deleteVariable(XPApp
.getMainframe().getControler().getBase().getVariableAt(0));
58 XPApp
.getMainframe().displayNbVariable();
59 XPApp
.getMainframe().getControler().displayJifVarTree();
61 if (XPApp
.getCurrentBase() != null) {
62 // adaptaterCdmXper.createWorkingSet();
63 adapterCdmXper
.load();
65 XPApp
.getMainframe().displayNbVariable();
66 XPApp
.getMainframe().getControler().displayJifVarTree();
69 // undisplay a loading gif
70 Utils
.displayLoadingGif(false);
71 System
.out
.println("data loaded :::");
77 private void createThumbnailDirectory() {
78 // create a _thumbnail directory to store thumbnails
79 new File(System
.getProperty("user.dir") + Utils
.sep
+ "images" + Utils
.sep
+ "_thumbnails").mkdirs();
85 private void generateThumbnails() {
86 System
.out
.println("start generate thumbnails");
87 // generate all thumbnails (a loading gif is automatically displayed
88 XPApp
.generateThumbnailsFromURLImage(XPApp
.getCurrentBase().getAllResources());
89 System
.out
.println("stop generate thumbnails");
93 private void startPartialCdm() {
94 // TODO Auto-generated method stub
101 public static void main(String
[] args
) {
102 System
.out
.println("start test");
104 TestAdapterCdmXper testAdapter
= new TestAdapterCdmXper();
105 testAdapter
.startApplications();
106 testAdapter
.createThumbnailDirectory();
107 if (args
.length
>= 1 && "-p".equals(args
[0]) ){
108 testAdapter
.startPartialCdm();
110 // load the data from CDM
111 testAdapter
.xperloadDataFromCdm();
112 // use the current directory as working directory for Xper2
113 XPApp
.getCurrentBase().setPathName(System
.getProperty("user.dir") + Utils
.sep
);
115 testAdapter
.generateThumbnails();