5
5
import java .util .HashMap ;
6
6
import java .util .List ;
7
7
import java .util .Map ;
8
+ import java .util .Objects ;
8
9
import java .util .Set ;
9
10
10
11
import org .apache .commons .lang3 .StringUtils ;
@@ -66,7 +67,7 @@ public class UserDBPortletUI extends QBiCPortletUI {
66
67
private Map <String , Integer > affiMap ;
67
68
private Map <String , Integer > personMap ;
68
69
private Map <String , ProjectInfo > projectMap ;
69
-
70
+
70
71
private TabSheet options ;
71
72
72
73
private ConfigurationManager manager ;
@@ -86,9 +87,10 @@ protected Layout getPortletContent(final VaadinRequest request) {
86
87
87
88
String userID = "" ;
88
89
boolean success = true ;
90
+ manager = ConfigurationManagerFactory .getInstance ();
91
+
89
92
if (PortalUtils .isLiferayPortlet ()) {
90
93
// read in the configuration file
91
- manager = ConfigurationManagerFactory .getInstance ();
92
94
93
95
logger .info ("User DB portlet is running on Liferay and user is logged in." );
94
96
userID = PortalUtils .getUser ().getScreenName ();
@@ -107,6 +109,7 @@ protected Layout getPortletContent(final VaadinRequest request) {
107
109
// establish connection to the OpenBIS API
108
110
try {
109
111
logger .debug ("trying to connect to openbis" );
112
+
110
113
this .openbis = new OpenBisClient (manager .getDataSourceUser (), manager .getDataSourcePassword (),
111
114
manager .getDataSourceUrl ());
112
115
this .openbis .login ();
@@ -129,7 +132,7 @@ protected Layout getPortletContent(final VaadinRequest request) {
129
132
dbControl = new DBManager (config );
130
133
131
134
initTabs ();
132
-
135
+
133
136
layout .addComponent (options );
134
137
return layout ;
135
138
}
@@ -214,12 +217,18 @@ private void initTabs() {
214
217
215
218
Map <String , ProjectInfo > allProjects = dbControl .getProjectMap ();
216
219
for (Project p : openbisProjects ) {
220
+ String desc = Objects .toString (p .getDescription (), "" );
221
+ desc = desc .replace ("\n " , ";" );
217
222
String projectID = p .getIdentifier ();
218
223
String code = p .getCode ();
219
224
if (allProjects .get (projectID ) == null )
220
- userProjects .put (projectID , new ProjectInfo (p .getSpaceCode (), code , "" , "" , -1 ));
221
- else
222
- userProjects .put (projectID , allProjects .get (projectID ));
225
+ userProjects .put (projectID , new ProjectInfo (p .getSpaceCode (), code , desc , "" , -1 ));
226
+ else {
227
+ ProjectInfo info = allProjects .get (projectID );
228
+ info .setDescription (desc );
229
+ userProjects .put (projectID , info );
230
+ }
231
+
223
232
}
224
233
225
234
projectMap = new HashMap <>();
@@ -360,17 +369,19 @@ public void valueChange(ValueChangeEvent event) {
360
369
collaborators .add (c );
361
370
}
362
371
projects .setCollaboratorsOfProject (collaborators );
363
- }
364
-
365
- Person investigator = getPersonOrNull (projectMap .get (item ).getInvestigator ());
366
- Person manager = getPersonOrNull (projectMap .get (item ).getManager ());
367
- Person contact = getPersonOrNull (projectMap .get (item ).getContact ());
368
372
369
- projects .handleProjectValueChange (item , investigator , contact , manager );
373
+ Person investigator = getPersonOrNull (projectMap .get (item ).getInvestigator ());
374
+ Person manager = getPersonOrNull (projectMap .get (item ).getManager ());
375
+ Person contact = getPersonOrNull (projectMap .get (item ).getContact ());
376
+
377
+ projects .handleProjectValueChange (item , investigator , contact , manager );
378
+ } else {
379
+ projects .handleProjectDeselect ();
380
+ }
370
381
}
371
382
372
383
private Person getPersonOrNull (String name ) {
373
- if (personMap .get (name )!= null ) {
384
+ if (personMap .get (name ) != null ) {
374
385
return dbControl .getPersonWithAffiliations (personMap .get (name )).get (0 );
375
386
}
376
387
return null ;
0 commit comments