1 package eu
.etaxonomy
.cdm
.io
.xper
;
7 import org
.apache
.log4j
.Logger
;
9 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
10 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
11 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
12 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
13 import eu
.etaxonomy
.cdm
.model
.description
.WorkingSet
;
14 import fr_jussieu_snv_lis
.XPApp
;
15 import fr_jussieu_snv_lis
.Xper
;
16 import fr_jussieu_snv_lis
.utils
.Utils
;
18 public class TestAdapterCdmXper
{
19 private static final Logger logger
= Logger
.getLogger(TestAdapterCdmXper
.class);
21 CdmXperAdapter adapterCdmXper
;
26 private boolean startApplications() {
27 DbSchemaValidation dbSchemaValidation
= DbSchemaValidation
.VALIDATE
;
28 ICdmDataSource datasource
= CdmDestinations
.cdm_test_local_xper();
29 System
.out
.println("cdm start");
30 CdmApplicationController appCtr
= CdmApplicationController
.NewInstance(datasource
, dbSchemaValidation
);
31 System
.out
.println("cdm started :::");
33 List
<WorkingSet
> workingSets
= appCtr
.getWorkingSetService().list(null, 1, 0, null, null);
34 if (workingSets
.isEmpty()){
35 logger
.warn("There is no working set");
38 UUID uuidWorkingSet
= workingSets
.iterator().next().getUuid();
39 adapterCdmXper
= new CdmXperAdapter(appCtr
, uuidWorkingSet
);
44 Thread t
= new Thread() {
46 new Xper(adapterCdmXper
);
49 System
.out
.println("xper2 start");
51 while(!XPApp
.xperReady
){
54 System
.out
.println("xper2 started :::");
58 public void xperloadDataFromCdm(){
59 System
.out
.println("start load data");
60 // display a loading gif
61 Utils
.displayLoadingGif(true);
64 // create a new empty base and load data from CDM
65 if(XPApp
.cdmAdapter
!= null){
67 XPApp
.getMainframe().newBase("baseTest");
68 // specify that the current base is not new (needed to be able to add images)
69 XPApp
.isNewBase
= false;
70 // delete the variable create by default and update the frame
71 XPApp
.getCurrentBase().deleteVariable(XPApp
.getCurrentBase().getVariableAt(0));
72 XPApp
.getMainframe().displayNbVariable();
73 XPApp
.getMainframe().getControler().displayJifVarTree();
75 if (XPApp
.getCurrentBase() != null) {
76 // adaptaterCdmXper.createWorkingSet();
77 adapterCdmXper
.load();
79 XPApp
.getMainframe().displayNbVariable();
80 XPApp
.getMainframe().getControler().displayJifVarTree();
83 // undisplay a loading gif
84 Utils
.displayLoadingGif(false);
85 System
.out
.println("data loaded :::");
91 private void createThumbnailDirectory() {
92 // create a _thumbnail directory to store thumbnails
93 new File(System
.getProperty("user.dir") + Utils
.sep
+ "images" + Utils
.sep
+ "_thumbnails").mkdirs();
99 private void generateThumbnails() {
100 System
.out
.println("start generate thumbnails");
101 // generate all thumbnails (a loading gif is automatically displayed
102 XPApp
.generateThumbnailsFromURLImage(XPApp
.getCurrentBase().getAllResources());
103 System
.out
.println("stop generate thumbnails");
107 private void startPartialCdm() {
108 System
.out
.println("start load data");
109 // display a loading gif
110 // Utils.displayLoadingGif(true);
113 // create a new empty base and load data from CDM
114 if(XPApp
.cdmAdapter
!= null){
116 // XPApp.getMainframe().newBase("baseTest");
117 // specify that the current base is not new (needed to be able to add images), not really needed
118 XPApp
.isNewBase
= false;
120 XPApp
.getMainframe().displayNbVariable();
121 XPApp
.getMainframe().getControler().displayJifVarTree();
123 // if (XPApp.getCurrentBase() != null) {
124 //// adaptaterCdmXper.createWorkingSet();
125 // adapterCdmXper.load();
127 // XPApp.getMainframe().displayNbVariable();
128 // XPApp.getMainframe().getControler().displayJifVarTree();
131 // undisplay a loading gif
132 Utils
.displayLoadingGif(false);
133 System
.out
.println("data loaded :::");
141 public static void main(String
[] args
) {
142 System
.out
.println("start test");
144 TestAdapterCdmXper testAdapter
= new TestAdapterCdmXper();
145 boolean success
= testAdapter
.startApplications();
147 testAdapter
.createThumbnailDirectory();
148 if (args
.length
>= 1 && "-p".equals(args
[0]) ){
149 testAdapter
.startPartialCdm();
151 // load the data from CDM
152 testAdapter
.xperloadDataFromCdm();
153 // use the current directory as working directory for Xper2
154 XPApp
.getCurrentBase().setPathName(System
.getProperty("user.dir") + Utils
.sep
);
156 testAdapter
.generateThumbnails();