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 fr_jussieu_snv_lis
.XPApp
;
10 import fr_jussieu_snv_lis
.Xper
;
11 import fr_jussieu_snv_lis
.utils
.Utils
;
13 public class TestAdapterCdmXper
{
15 AdaptaterCdmXper adapterCdmXper
;
20 private void startApplications() {
21 DbSchemaValidation dbSchemaValidation
= DbSchemaValidation
.VALIDATE
;
22 ICdmDataSource datasource
= CdmDestinations
.cdm_test_local_xper();
23 System
.out
.println("cdm start");
24 CdmApplicationController appCtr
= CdmApplicationController
.NewInstance(datasource
, dbSchemaValidation
);
25 System
.out
.println("cdm started :::");
27 adapterCdmXper
= new AdaptaterCdmXper(appCtr
);
29 Thread t
= new Thread() {
31 new Xper(adapterCdmXper
);
34 System
.out
.println("xper2 start");
36 while(!XPApp
.xperReady
){
39 System
.out
.println("xper2 started :::");
42 public void xperloadDataFromCdm(){
43 System
.out
.println("start load data");
44 // display a loading gif
45 Utils
.displayLoadingGif(true);
48 // create a new empty base and load data from CDM
49 if(XPApp
.cdmAdapter
!= null){
51 XPApp
.getMainframe().newBase("baseTest");
52 // specify that the current base is not new (needed to be able to add images)
53 XPApp
.isNewBase
= false;
54 // delete the variable create by default and update the frame
55 XPApp
.getCurrentBase().deleteVariable(XPApp
.getCurrentBase().getVariableAt(0));
56 XPApp
.getMainframe().displayNbVariable();
57 XPApp
.getMainframe().getControler().displayJifVarTree();
59 if (XPApp
.getCurrentBase() != null) {
60 // adaptaterCdmXper.createWorkingSet();
61 adapterCdmXper
.load();
63 XPApp
.getMainframe().displayNbVariable();
64 XPApp
.getMainframe().getControler().displayJifVarTree();
67 // undisplay a loading gif
68 Utils
.displayLoadingGif(false);
69 System
.out
.println("data loaded :::");
75 private void createThumbnailDirectory() {
76 // create a _thumbnail directory to store thumbnails
77 new File(System
.getProperty("user.dir") + Utils
.sep
+ "images" + Utils
.sep
+ "_thumbnails").mkdirs();
83 private void generateThumbnails() {
84 System
.out
.println("start generate thumbnails");
85 // generate all thumbnails (a loading gif is automatically displayed
86 XPApp
.generateThumbnailsFromURLImage(XPApp
.getCurrentBase().getAllResources());
87 System
.out
.println("stop generate thumbnails");
91 private void startPartialCdm() {
92 System
.out
.println("start load data");
93 // display a loading gif
94 // Utils.displayLoadingGif(true);
97 // create a new empty base and load data from CDM
98 if(XPApp
.cdmAdapter
!= null){
100 // XPApp.getMainframe().newBase("baseTest");
101 // specify that the current base is not new (needed to be able to add images), not really needed
102 XPApp
.isNewBase
= false;
104 XPApp
.getMainframe().displayNbVariable();
105 XPApp
.getMainframe().getControler().displayJifVarTree();
107 if (XPApp
.getCurrentBase() != null) {
108 // adaptaterCdmXper.createWorkingSet();
109 adapterCdmXper
.load();
111 XPApp
.getMainframe().displayNbVariable();
112 XPApp
.getMainframe().getControler().displayJifVarTree();
115 // undisplay a loading gif
116 Utils
.displayLoadingGif(false);
117 System
.out
.println("data loaded :::");
125 public static void main(String
[] args
) {
126 System
.out
.println("start test");
128 TestAdapterCdmXper testAdapter
= new TestAdapterCdmXper();
129 testAdapter
.startApplications();
130 testAdapter
.createThumbnailDirectory();
131 if (args
.length
>= 1 && "-p".equals(args
[0]) ){
132 testAdapter
.startPartialCdm();
134 // load the data from CDM
135 testAdapter
.xperloadDataFromCdm();
136 // use the current directory as working directory for Xper2
137 XPApp
.getCurrentBase().setPathName(System
.getProperty("user.dir") + Utils
.sep
);
139 testAdapter
.generateThumbnails();