44import java .util .ArrayList ;
55import java .util .Arrays ;
66import java .util .HashMap ;
7+ import java .util .HashSet ;
78import java .util .List ;
89import java .util .Map ;
910import java .util .Objects ;
2627import com .vaadin .ui .Layout ;
2728import com .vaadin .ui .TabSheet ;
2829import 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 ;
2932import com .vaadin .ui .Button .ClickEvent ;
3033import 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 ;
3334import life .qbic .datamodel .persons .Affiliation ;
3435import life .qbic .datamodel .persons .CollaboratorWithResponsibility ;
3536import life .qbic .datamodel .persons .Person ;
@@ -213,19 +214,25 @@ private void initTabs() {
213214 }
214215 Map <String , ProjectInfo > userProjects = new HashMap <String , ProjectInfo >();
215216
216- List <Project > openbisProjects = new ArrayList <Project >();
217+ List <Project > openbisProjectsForUser = new ArrayList <Project >();
218+ Set <String > spaces = new HashSet <>(openbis .getUserSpaces (userID ));
217219
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+ }
220227
221228 Map <String , ProjectInfo > dbProjects = dbControl .getProjectMap ();
222- for (Project p : openbisProjects ) {
229+ for (Project p : openbisProjectsForUser ) {
223230 String desc = Objects .toString (p .getDescription (), "" );
224231 desc = desc .replaceAll ("\n +" , ". " );
225- String projectID = p .getIdentifier ();
232+ String projectID = p .getIdentifier (). getIdentifier () ;
226233 String code = p .getCode ();
227234 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 ));
229236 else {
230237 ProjectInfo info = dbProjects .get (projectID );
231238 info .setDescription (desc );
@@ -253,8 +260,7 @@ private Map<String, Integer> fillMaxInputLengthMap() {
253260 res .putAll (dbControl .getColsMaxLengthsForTable ("persons" ));
254261 res .putAll (dbControl .getColsMaxLengthsForTable ("organizations" ));
255262 } catch (SQLException e ) {
256- // TODO Auto-generated catch block
257- e .printStackTrace ();
263+ logger .error (e .toString ());
258264 }
259265 return res ;
260266 }
@@ -271,8 +277,8 @@ private boolean canUsePortlet() {
271277 }
272278 }
273279 } catch (Exception e ) {
274- e .printStackTrace ();
275280 logger .error ("Could not fetch user groups. User won't be able to use portlet." );
281+ logger .error (e .toString ());
276282 }
277283 return false ;
278284 }
@@ -292,8 +298,8 @@ private boolean isAdmin() {
292298 }
293299 }
294300 } catch (Exception e ) {
295- e .printStackTrace ();
296301 logger .error ("Could not fetch user groups. User won't be able to use portlet." );
302+ logger .error (e .toString ());
297303 }
298304 return false ;
299305 }
@@ -361,9 +367,9 @@ public void valueChange(ValueChangeEvent event) {
361367 dbControl .getCollaboratorsOfProject (project );
362368 // get openbis experiments and type
363369 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 () ;
367373 if (type != null )
368374 existingExps .put (id , type );
369375 }
@@ -613,8 +619,7 @@ private void successfulCommit() {
613619 try {
614620 Thread .sleep (1000 );
615621 } catch (InterruptedException e ) {
616- // TODO Auto-generated catch block
617- e .printStackTrace ();
622+ logger .error (e .toString ());
618623 }
619624 initTabs ();
620625 }
0 commit comments