24
24
import java .util .HashMap ;
25
25
import java .util .List ;
26
26
import java .util .Map ;
27
+ import java .util .Objects ;
27
28
28
29
import org .apache .logging .log4j .LogManager ;
29
30
import org .apache .logging .log4j .Logger ;
@@ -62,7 +63,7 @@ public class ProjectView extends VerticalLayout {
62
63
private Button downloadProjectInfo ;
63
64
private FileDownloader tsvDL ;
64
65
65
- private Table projectPersons ;
66
+ private Table experimentPersons ;
66
67
private Button submitPersons ;
67
68
private Map <String , CollaboratorWithResponsibility > experimentMap ;
68
69
@@ -98,15 +99,15 @@ public ProjectView(Map<String, ProjectInfo> projectMap, Map<String, Integer> per
98
99
addComponent (downloadProjectInfo );
99
100
initProjectInfos ();
100
101
101
- projectPersons = new Table ("Experiment Collaborators (optional)" );
102
- projectPersons .setVisible (false );
103
- projectPersons .setStyleName (ValoTheme .TABLE_SMALL );
104
- projectPersons .addContainerProperty ("Name" , ComboBox .class , null );
105
- projectPersons .addContainerProperty ("Experiment" , String .class , null );
106
- projectPersons .addContainerProperty ("Responsibility" , String .class , null );
107
- projectPersons .setColumnWidth ("Responsibility" , 150 );
108
- projectPersons .setPageLength (1 );
109
- addComponent (projectPersons );
102
+ experimentPersons = new Table ("Experiment Collaborators (optional)" );
103
+ experimentPersons .setVisible (false );
104
+ experimentPersons .setStyleName (ValoTheme .TABLE_SMALL );
105
+ experimentPersons .addContainerProperty ("Name" , ComboBox .class , null );
106
+ experimentPersons .addContainerProperty ("Experiment" , String .class , null );
107
+ experimentPersons .addContainerProperty ("Responsibility" , String .class , null );
108
+ experimentPersons .setColumnWidth ("Responsibility" , 150 );
109
+ experimentPersons .setPageLength (1 );
110
+ addComponent (experimentPersons );
110
111
111
112
submitPersons = new Button ("Submit Experiment" );
112
113
addComponent (submitPersons );
@@ -212,15 +213,21 @@ public void initProjectInfos() {
212
213
private String createTSV (String subProject , Person PI , Person contact , Person manager )
213
214
throws FileNotFoundException , UnsupportedEncodingException {
214
215
215
- String secondaryName = projectMap .get (subProject ).getSecondaryName ();
216
+ ProjectInfo proj = projectMap .get (subProject );
217
+ String secondaryName = proj .getSecondaryName ();
216
218
secondaryName = secondaryName == null ? "" : secondaryName ;
217
- String space = projectMap .get (subProject ).getSpace ();
218
-
219
- List <String > header = new ArrayList <>(
220
- Arrays .asList ("Sub-Project" , "Short Title" , "Project" , "Principal Investigator" ,
221
- "PI Affiliation" , "PI Adress" , "Contact Person" , "Contact Affiliation" ,
222
- "Contact Adress" , "Project Manager" , "Manager Affiliation" , "Manager Adress" ));
223
- List <String > data = new ArrayList <>(Arrays .asList (subProject , secondaryName , space ));
219
+ String space = proj .getSpace ();
220
+ String description = proj .getDescription ();
221
+ System .out .println (description );
222
+
223
+ List <String > summaryHeader =
224
+ new ArrayList <>(Arrays .asList ("Sub-Project" , "Short Title" , "Description" , "Project" ,
225
+ "Principal Investigator" , "PI E-Mail" , "PI Group" , "PI Institute" , "PI Organization" ,
226
+ "PI Address" , "Contact Person" , "Contact E-Mail" , "Contact Group" , "Contact Institute" ,
227
+ "Contact Organization" , "Contact Address" , "Project Manager" , "Manager E-Mail" ,
228
+ "Manager Group" , "Manager Institute" , "Manager Organization" , "Manager Address" ));
229
+ List <String > data =
230
+ new ArrayList <>(Arrays .asList (subProject , secondaryName , description , space ));
224
231
225
232
addPersonInfos (data , PI );
226
233
addPersonInfos (data , contact );
@@ -230,39 +237,50 @@ private String createTSV(String subProject, Person PI, Person contact, Person ma
230
237
for (CollaboratorWithResponsibility col : experimentMap .values ()) {
231
238
String name = col .getPerson ();
232
239
if (name != null && !name .isEmpty ()) {
233
- header .add (col .getOpenbisCode () + " Experiment Collaborator" );
234
- header .add (col .getOpenbisCode () + " Experiment Role" );
240
+ summaryHeader .add (col .getOpenbisCode () + " Experiment Collaborator" );
241
+ summaryHeader .add (col .getOpenbisCode () + " Experiment Role" );
235
242
data .add (name );
236
243
data .add (col .getRole ());
237
244
}
238
245
}
239
246
240
- String headerLine = String .join ("\t " , header );
241
- String dataLine = String .join ("\t " , data );
247
+ String headerLine = String .join ("\t " , summaryHeader );
248
+ String dataLine = replaceSpecialSymbols ( String .join ("\t " , data ) );
242
249
243
250
return headerLine + "\n " + dataLine + "\n " ;
244
251
}
245
252
253
+ private String replaceSpecialSymbols (String string ) {
254
+ string = string .replace ("ß" , "ss" );
255
+ string = string .replace ("ä" , "ae" ).replace ("ü" , "ue" ).replace ("ö" , "oe" );
256
+ string = string .replace ("Ä" , "Ae" ).replace ("Ü" , "Ue" ).replace ("Ö" , "Oe" );
257
+ return string ;
258
+ }
259
+
246
260
private void addPersonInfos (List <String > data , Person p ) {
247
261
if (p != null ) {
248
262
data .add (getFullName (p ));
249
- String affi = p .getAffiliations ().get (0 ).getGroupName ();
250
- if (affi != null ) {
251
- data .add (affi );
252
- }
253
- data .add (generatePersonAdress (p ));
263
+ data .add (p .getEmail ());
264
+ Affiliation affi = p .getAffiliations ().get (0 );
265
+ data .add (Objects .toString (affi .getGroupName (), "" ));
266
+ data .add (Objects .toString (affi .getInstitute (), "" ));
267
+ data .add (Objects .toString (affi .getOrganization (), "" ));
268
+ data .add (generatePersonAddress (p ));
254
269
} else {
255
270
data .add ("" );
256
271
data .add ("" );
257
272
data .add ("" );
273
+ data .add ("" );
274
+ data .add ("" );
275
+ data .add ("" );
258
276
}
259
277
}
260
278
261
279
private String getFullName (Person person ) {
262
280
return person .getFirstName () + " " + person .getLastName ();
263
281
}
264
282
265
- private String generatePersonAdress (Person person ) {
283
+ private String generatePersonAddress (Person person ) {
266
284
Affiliation af = person .getAffiliations ().get (0 );
267
285
StringBuilder b = new StringBuilder (af .getStreet ());
268
286
b .append (" " );
@@ -367,13 +385,13 @@ public FilterTable getProjectTable() {
367
385
}
368
386
369
387
public Table getCollaboratorTable () {
370
- return projectPersons ;
388
+ return experimentPersons ;
371
389
}
372
390
373
391
public void setCollaboratorsOfProject (List <CollaboratorWithResponsibility > collaborators ) {
374
392
experimentMap = new HashMap <String , CollaboratorWithResponsibility >();
375
- projectPersons .removeAllItems ();
376
- projectPersons .setVisible (false );
393
+ experimentPersons .removeAllItems ();
394
+ experimentPersons .setVisible (false );
377
395
378
396
for (CollaboratorWithResponsibility c : collaborators ) {
379
397
String code = c .getOpenbisCode ();
@@ -387,17 +405,17 @@ public void setCollaboratorsOfProject(List<CollaboratorWithResponsibility> colla
387
405
row .add (persons );
388
406
row .add (c .getOpenbisCode ());
389
407
row .add (c .getOpenbisType ());
390
- projectPersons .addItem (row .toArray (new Object [row .size ()]), code );
391
- projectPersons .setVisible (true );
408
+ experimentPersons .addItem (row .toArray (new Object [row .size ()]), code );
409
+ experimentPersons .setVisible (true );
392
410
}
393
411
394
412
// sort ascending by Experiment ID
395
413
Object [] properties = {"Experiment" };
396
414
boolean [] ordering = {true };
397
- projectPersons .sort (properties , ordering );
415
+ experimentPersons .sort (properties , ordering );
398
416
399
- projectPersons .sort ();
400
- projectPersons .setPageLength (collaborators .size ());
417
+ experimentPersons .sort ();
418
+ experimentPersons .setPageLength (collaborators .size ());
401
419
}
402
420
403
421
/**
@@ -406,9 +424,10 @@ public void setCollaboratorsOfProject(List<CollaboratorWithResponsibility> colla
406
424
*/
407
425
public List <CollaboratorWithResponsibility > getNewResponsibilities () {
408
426
List <CollaboratorWithResponsibility > res = new ArrayList <CollaboratorWithResponsibility >();
409
- for (Object code : projectPersons .getItemIds ()) {
427
+ logger .debug ("ids: " + experimentPersons .getItemIds ());
428
+ for (Object code : experimentPersons .getItemIds ()) {
410
429
ComboBox personBox =
411
- (ComboBox ) projectPersons .getItem (code ).getItemProperty ("Name" ).getValue ();
430
+ (ComboBox ) experimentPersons .getItem (code ).getItemProperty ("Name" ).getValue ();
412
431
String name = "" ;
413
432
if (personBox .getValue () != null )
414
433
name = personBox .getValue ().toString ();
@@ -434,6 +453,12 @@ public void updateChangedInfo(ProjectInfo info) {
434
453
projectTable .sort (new Object [] {"Sub-Project" }, new boolean [] {true });
435
454
}
436
455
456
+ public void handleProjectDeselect () {
457
+ projectInfoLayout .setVisible (false );
458
+ downloadProjectInfo .setVisible (false );
459
+ experimentPersons .setVisible (false );
460
+ }
461
+
437
462
public void handleProjectValueChange (Object item , Person PI , Person contact , Person manager ) {
438
463
projectInfoLayout .setVisible (false );
439
464
downloadProjectInfo .setVisible (false );
@@ -450,10 +475,8 @@ public void handleProjectValueChange(Object item, Person PI, Person contact, Per
450
475
armDownloadButton (item , PI , contact , manager );
451
476
downloadProjectInfo .setVisible (true );
452
477
} catch (FileNotFoundException e ) {
453
- // TODO Auto-generated catch block
454
478
e .printStackTrace ();
455
479
} catch (UnsupportedEncodingException e ) {
456
- // TODO Auto-generated catch block
457
480
e .printStackTrace ();
458
481
}
459
482
projectInfoLayout .setVisible (true );
0 commit comments