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 boolean result
= false;
28 DbSchemaValidation dbSchemaValidation
= DbSchemaValidation
.VALIDATE
;
29 ICdmDataSource datasource
= CdmDestinations
.cdm_test_local_xper();
30 System
.out
.println("cdm start");
31 CdmApplicationController appCtr
= CdmApplicationController
.NewInstance(datasource
, dbSchemaValidation
);
32 System
.out
.println("cdm started :::");
34 List
<WorkingSet
> workingSets
= appCtr
.getWorkingSetService().list(null, 1, 0, null, null);
35 if (workingSets
.isEmpty()){
36 logger
.warn("There is no working set");
39 UUID uuidWorkingSet
= workingSets
.iterator().next().getUuid();
41 adapterCdmXper
= (CdmXperAdapter
)appCtr
.getBean("cdmXperAdapter");
42 // adapterCdmXper = new CdmXperAdapter(appCtr, uuidWorkingSet);
43 result
= adapterCdmXper
.startXper(uuidWorkingSet
);
50 public void xperloadDataFromCdm(){
51 System
.out
.println("start load data");
52 // display a loading gif
53 Utils
.displayLoadingGif(true);
56 // create a new empty base and load data from CDM
57 if(XPApp
.cdmAdapter
!= null){
59 XPApp
.getMainframe().newBase("baseTest");
60 // specify that the current base is not new (needed to be able to add images)
61 XPApp
.isNewBase
= false;
62 // delete the variable create by default and update the frame
63 XPApp
.getCurrentBase().deleteVariable(XPApp
.getCurrentBase().getVariableAt(0));
64 XPApp
.getMainframe().displayNbVariable();
65 XPApp
.getMainframe().getControler().displayJifVarTree();
67 if (XPApp
.getCurrentBase() != null) {
68 // adaptaterCdmXper.createWorkingSet();
69 adapterCdmXper
.load();
71 XPApp
.getMainframe().displayNbVariable();
72 XPApp
.getMainframe().getControler().displayJifVarTree();
75 // undisplay a loading gif
76 Utils
.displayLoadingGif(false);
77 System
.out
.println("data loaded :::");
83 private void createThumbnailDirectory() {
84 // create a _thumbnail directory to store thumbnails
85 new File(System
.getProperty("user.dir") + Utils
.sep
+ "images" + Utils
.sep
+ "_thumbnails").mkdirs();
91 private void generateThumbnails() {
92 System
.out
.println("start generate thumbnails");
93 // generate all thumbnails (a loading gif is automatically displayed
94 XPApp
.generateThumbnailsFromURLImage(XPApp
.getCurrentBase().getAllResources());
95 System
.out
.println("stop generate thumbnails");
99 private void startPartialCdm() {
100 System
.out
.println("start load data");
101 // display a loading gif
102 // Utils.displayLoadingGif(true);
105 // create a new empty base and load data from CDM
106 if(XPApp
.cdmAdapter
!= null){
108 // XPApp.getMainframe().newBase("baseTest");
109 // specify that the current base is not new (needed to be able to add images), not really needed
110 XPApp
.isNewBase
= false;
112 XPApp
.getMainframe().displayNbVariable();
113 XPApp
.getMainframe().getControler().displayJifVarTree();
115 // if (XPApp.getCurrentBase() != null) {
116 //// adaptaterCdmXper.createWorkingSet();
117 // adapterCdmXper.load();
119 // XPApp.getMainframe().displayNbVariable();
120 // XPApp.getMainframe().getControler().displayJifVarTree();
123 // undisplay a loading gif
124 Utils
.displayLoadingGif(false);
125 System
.out
.println("data loaded :::");
133 public static void main(String
[] args
) {
134 System
.out
.println("start test adapter");
136 TestAdapterCdmXper testAdapter
= new TestAdapterCdmXper();
137 boolean success
= testAdapter
.startApplications();
138 while(!XPApp
.xperReady
){
141 } catch (InterruptedException e
) {
145 System
.out
.println("xper2 started :::");
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();
159 System
.out
.println("end test adapter with errors");
163 System
.out
.println("end test adapter");