2424import java .util .HashMap ;
2525import java .util .List ;
2626import java .util .Map ;
27+ import java .util .Objects ;
2728
2829import org .apache .logging .log4j .LogManager ;
2930import org .apache .logging .log4j .Logger ;
@@ -62,7 +63,7 @@ public class ProjectView extends VerticalLayout {
6263 private Button downloadProjectInfo ;
6364 private FileDownloader tsvDL ;
6465
65- private Table projectPersons ;
66+ private Table experimentPersons ;
6667 private Button submitPersons ;
6768 private Map <String , CollaboratorWithResponsibility > experimentMap ;
6869
@@ -98,15 +99,15 @@ public ProjectView(Map<String, ProjectInfo> projectMap, Map<String, Integer> per
9899 addComponent (downloadProjectInfo );
99100 initProjectInfos ();
100101
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 );
110111
111112 submitPersons = new Button ("Submit Experiment" );
112113 addComponent (submitPersons );
@@ -212,15 +213,21 @@ public void initProjectInfos() {
212213 private String createTSV (String subProject , Person PI , Person contact , Person manager )
213214 throws FileNotFoundException , UnsupportedEncodingException {
214215
215- String secondaryName = projectMap .get (subProject ).getSecondaryName ();
216+ ProjectInfo proj = projectMap .get (subProject );
217+ String secondaryName = proj .getSecondaryName ();
216218 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 ));
224231
225232 addPersonInfos (data , PI );
226233 addPersonInfos (data , contact );
@@ -230,39 +237,50 @@ private String createTSV(String subProject, Person PI, Person contact, Person ma
230237 for (CollaboratorWithResponsibility col : experimentMap .values ()) {
231238 String name = col .getPerson ();
232239 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" );
235242 data .add (name );
236243 data .add (col .getRole ());
237244 }
238245 }
239246
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 ) );
242249
243250 return headerLine + "\n " + dataLine + "\n " ;
244251 }
245252
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+
246260 private void addPersonInfos (List <String > data , Person p ) {
247261 if (p != null ) {
248262 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 ));
254269 } else {
255270 data .add ("" );
256271 data .add ("" );
257272 data .add ("" );
273+ data .add ("" );
274+ data .add ("" );
275+ data .add ("" );
258276 }
259277 }
260278
261279 private String getFullName (Person person ) {
262280 return person .getFirstName () + " " + person .getLastName ();
263281 }
264282
265- private String generatePersonAdress (Person person ) {
283+ private String generatePersonAddress (Person person ) {
266284 Affiliation af = person .getAffiliations ().get (0 );
267285 StringBuilder b = new StringBuilder (af .getStreet ());
268286 b .append (" " );
@@ -367,13 +385,13 @@ public FilterTable getProjectTable() {
367385 }
368386
369387 public Table getCollaboratorTable () {
370- return projectPersons ;
388+ return experimentPersons ;
371389 }
372390
373391 public void setCollaboratorsOfProject (List <CollaboratorWithResponsibility > collaborators ) {
374392 experimentMap = new HashMap <String , CollaboratorWithResponsibility >();
375- projectPersons .removeAllItems ();
376- projectPersons .setVisible (false );
393+ experimentPersons .removeAllItems ();
394+ experimentPersons .setVisible (false );
377395
378396 for (CollaboratorWithResponsibility c : collaborators ) {
379397 String code = c .getOpenbisCode ();
@@ -387,17 +405,17 @@ public void setCollaboratorsOfProject(List<CollaboratorWithResponsibility> colla
387405 row .add (persons );
388406 row .add (c .getOpenbisCode ());
389407 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 );
392410 }
393411
394412 // sort ascending by Experiment ID
395413 Object [] properties = {"Experiment" };
396414 boolean [] ordering = {true };
397- projectPersons .sort (properties , ordering );
415+ experimentPersons .sort (properties , ordering );
398416
399- projectPersons .sort ();
400- projectPersons .setPageLength (collaborators .size ());
417+ experimentPersons .sort ();
418+ experimentPersons .setPageLength (collaborators .size ());
401419 }
402420
403421 /**
@@ -406,9 +424,10 @@ public void setCollaboratorsOfProject(List<CollaboratorWithResponsibility> colla
406424 */
407425 public List <CollaboratorWithResponsibility > getNewResponsibilities () {
408426 List <CollaboratorWithResponsibility > res = new ArrayList <CollaboratorWithResponsibility >();
409- for (Object code : projectPersons .getItemIds ()) {
427+ logger .debug ("ids: " + experimentPersons .getItemIds ());
428+ for (Object code : experimentPersons .getItemIds ()) {
410429 ComboBox personBox =
411- (ComboBox ) projectPersons .getItem (code ).getItemProperty ("Name" ).getValue ();
430+ (ComboBox ) experimentPersons .getItem (code ).getItemProperty ("Name" ).getValue ();
412431 String name = "" ;
413432 if (personBox .getValue () != null )
414433 name = personBox .getValue ().toString ();
@@ -434,6 +453,12 @@ public void updateChangedInfo(ProjectInfo info) {
434453 projectTable .sort (new Object [] {"Sub-Project" }, new boolean [] {true });
435454 }
436455
456+ public void handleProjectDeselect () {
457+ projectInfoLayout .setVisible (false );
458+ downloadProjectInfo .setVisible (false );
459+ experimentPersons .setVisible (false );
460+ }
461+
437462 public void handleProjectValueChange (Object item , Person PI , Person contact , Person manager ) {
438463 projectInfoLayout .setVisible (false );
439464 downloadProjectInfo .setVisible (false );
@@ -450,10 +475,8 @@ public void handleProjectValueChange(Object item, Person PI, Person contact, Per
450475 armDownloadButton (item , PI , contact , manager );
451476 downloadProjectInfo .setVisible (true );
452477 } catch (FileNotFoundException e ) {
453- // TODO Auto-generated catch block
454478 e .printStackTrace ();
455479 } catch (UnsupportedEncodingException e ) {
456- // TODO Auto-generated catch block
457480 e .printStackTrace ();
458481 }
459482 projectInfoLayout .setVisible (true );
0 commit comments