4
4
import java .util .ArrayList ;
5
5
import java .util .Arrays ;
6
6
import java .util .HashMap ;
7
+ import java .util .HashSet ;
7
8
import java .util .List ;
8
9
import java .util .Map ;
9
10
import java .util .Objects ;
26
27
import com .vaadin .ui .Layout ;
27
28
import com .vaadin .ui .TabSheet ;
28
29
import com .vaadin .ui .VerticalLayout ;
30
+ import ch .ethz .sis .openbis .generic .asapi .v3 .dto .experiment .Experiment ;
31
+ import ch .ethz .sis .openbis .generic .asapi .v3 .dto .project .Project ;
29
32
import com .vaadin .ui .Button .ClickEvent ;
30
33
import com .vaadin .ui .Button .ClickListener ;
31
- import ch .systemsx .cisd .openbis .generic .shared .api .v1 .dto .Experiment ;
32
- import ch .systemsx .cisd .openbis .generic .shared .api .v1 .dto .Project ;
33
34
import life .qbic .datamodel .persons .Affiliation ;
34
35
import life .qbic .datamodel .persons .CollaboratorWithResponsibility ;
35
36
import life .qbic .datamodel .persons .Person ;
@@ -213,19 +214,25 @@ private void initTabs() {
213
214
}
214
215
Map <String , ProjectInfo > userProjects = new HashMap <String , ProjectInfo >();
215
216
216
- List <Project > openbisProjects = new ArrayList <Project >();
217
+ List <Project > openbisProjectsForUser = new ArrayList <Project >();
218
+ Set <String > spaces = new HashSet <>(openbis .getUserSpaces (userID ));
217
219
218
- openbisProjects = openbis .getOpenbisInfoService ()
219
- .listProjectsOnBehalfOfUser (openbis .getSessionToken (), userID );
220
+ List <Project > allOpenbisProjects = openbis .listProjects ();
221
+ for (Project p : allOpenbisProjects ) {
222
+ String space = p .getSpace ().getCode ();
223
+ if (spaces .contains (space )) {
224
+ openbisProjectsForUser .add (p );
225
+ }
226
+ }
220
227
221
228
Map <String , ProjectInfo > dbProjects = dbControl .getProjectMap ();
222
- for (Project p : openbisProjects ) {
229
+ for (Project p : openbisProjectsForUser ) {
223
230
String desc = Objects .toString (p .getDescription (), "" );
224
231
desc = desc .replaceAll ("\n +" , ". " );
225
- String projectID = p .getIdentifier ();
232
+ String projectID = p .getIdentifier (). getIdentifier () ;
226
233
String code = p .getCode ();
227
234
if (dbProjects .get (projectID ) == null )
228
- userProjects .put (projectID , new ProjectInfo (p .getSpaceCode (), code , desc , "" , -1 ));
235
+ userProjects .put (projectID , new ProjectInfo (p .getSpace (). getCode (), code , desc , "" , -1 ));
229
236
else {
230
237
ProjectInfo info = dbProjects .get (projectID );
231
238
info .setDescription (desc );
@@ -253,8 +260,7 @@ private Map<String, Integer> fillMaxInputLengthMap() {
253
260
res .putAll (dbControl .getColsMaxLengthsForTable ("persons" ));
254
261
res .putAll (dbControl .getColsMaxLengthsForTable ("organizations" ));
255
262
} catch (SQLException e ) {
256
- // TODO Auto-generated catch block
257
- e .printStackTrace ();
263
+ logger .error (e .toString ());
258
264
}
259
265
return res ;
260
266
}
@@ -271,8 +277,8 @@ private boolean canUsePortlet() {
271
277
}
272
278
}
273
279
} catch (Exception e ) {
274
- e .printStackTrace ();
275
280
logger .error ("Could not fetch user groups. User won't be able to use portlet." );
281
+ logger .error (e .toString ());
276
282
}
277
283
return false ;
278
284
}
@@ -292,8 +298,8 @@ private boolean isAdmin() {
292
298
}
293
299
}
294
300
} catch (Exception e ) {
295
- e .printStackTrace ();
296
301
logger .error ("Could not fetch user groups. User won't be able to use portlet." );
302
+ logger .error (e .toString ());
297
303
}
298
304
return false ;
299
305
}
@@ -361,9 +367,9 @@ public void valueChange(ValueChangeEvent event) {
361
367
dbControl .getCollaboratorsOfProject (project );
362
368
// get openbis experiments and type
363
369
Map <String , String > existingExps = new HashMap <String , String >();
364
- for (Experiment e : openbis .getExperimentsForProject2 (project )) {
365
- String type = expTypeCodeTranslation .get (e .getExperimentTypeCode ());
366
- String id = e .getIdentifier ();
370
+ for (Experiment e : openbis .getExperimentsOfProjectByCode (project )) {
371
+ String type = expTypeCodeTranslation .get (e .getType (). getCode ());
372
+ String id = e .getIdentifier (). getIdentifier () ;
367
373
if (type != null )
368
374
existingExps .put (id , type );
369
375
}
@@ -613,8 +619,7 @@ private void successfulCommit() {
613
619
try {
614
620
Thread .sleep (1000 );
615
621
} catch (InterruptedException e ) {
616
- // TODO Auto-generated catch block
617
- e .printStackTrace ();
622
+ logger .error (e .toString ());
618
623
}
619
624
initTabs ();
620
625
}
0 commit comments