From 61edd20e43adad0ce4b305ac3cb6be563f21de7b Mon Sep 17 00:00:00 2001 From: Konrad Lang <110096044+konradlang@users.noreply.github.com> Date: Fri, 21 Oct 2022 15:47:43 +0200 Subject: [PATCH] Replaced personList and creation of DIVs with personListString and creation of DIVs in Java to speed up DOM creation. (#151) Check during creation of personList required, as some user data seems to be valid but not set leading to NullPointerExceptions. This could be avoided with a data cleanup; --- .../control/owner/OwnerQueriesDetailBean.java | 44 ++++++++++++++++++- .../ResearcherQueriesDetailBean.java | 41 ++++++++++++++++- src/main/webapp/owner/detail.xhtml | 6 +++ src/main/webapp/researcher/detail.xhtml | 6 +++ 4 files changed, 93 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/samply/bbmri/negotiator/control/owner/OwnerQueriesDetailBean.java b/src/main/java/de/samply/bbmri/negotiator/control/owner/OwnerQueriesDetailBean.java index a2624ae7..b1673218 100644 --- a/src/main/java/de/samply/bbmri/negotiator/control/owner/OwnerQueriesDetailBean.java +++ b/src/main/java/de/samply/bbmri/negotiator/control/owner/OwnerQueriesDetailBean.java @@ -171,7 +171,12 @@ public class OwnerQueriesDetailBean implements Serializable { private int unreadQueryCount = 0; + @Deprecated private List personList; + /** + * String to hold contact persons in DIVs + */ + private String personStringDIVsForRequest = ""; private final HashMap> sortedCollections = new HashMap<>(); @@ -325,7 +330,10 @@ public String initialize() { } } - setPersonListForRequest(config, selectedQuery.getId()); + // setPersonListForRequest(config, selectedQuery.getId()); + // Set the PersonDIVsString - setPersonListForRequest is deprecated once this works + setPersonStringDIVsForRequest(config, selectedQuery.getId()); + /* * Initialize Lifecycle Status @@ -345,6 +353,7 @@ public String initialize() { return null; } + @Deprecated private void setPersonListForRequest(Config config, Integer queryId) { personList = DbUtil.getPersonsContactsForRequest(config, queryId); } @@ -1088,10 +1097,41 @@ public void setUnreadPrivateNegotiationCount(int unreadPrivateNegotiationCount) this.unreadPrivateNegotiationCount = unreadPrivateNegotiationCount; } + /** + * Set the contact persons in a String with DIVs to speed up the DOM creation + * + * @param config + * @param queryId + */ + private void setPersonStringDIVsForRequest( Config config, Integer queryId) { + // ensure the personStringDIVsForRequest is empty + personStringDIVsForRequest = new String(""); + + // get the personList from the database + personList = DbUtil.getPersonsContactsForRequest(config, queryId); + + logger.debug ( "personStringDIVsForRequest: " + personStringDIVsForRequest); + for( de.samply.bbmri.negotiator.jooq.tables.pojos.Person person : personList) { + if( person.getAuthName() != null) { + personStringDIVsForRequest = personStringDIVsForRequest.concat("
"); + personStringDIVsForRequest = personStringDIVsForRequest.concat(person.getAuthName()); + personStringDIVsForRequest = personStringDIVsForRequest.concat("
"); + } + } + + } + /** + * Returns the previously set person list as DIVs to speed up DOM creation + * @return + */ + public String getPersonStringDIVsForRequest() { + return personStringDIVsForRequest; + } + @Deprecated public List getPersonList() { return personList; } - + @Deprecated public void setPersonList(List personList) { this.personList = personList; } diff --git a/src/main/java/de/samply/bbmri/negotiator/control/researcher/ResearcherQueriesDetailBean.java b/src/main/java/de/samply/bbmri/negotiator/control/researcher/ResearcherQueriesDetailBean.java index 6a082459..4d0d6d7c 100644 --- a/src/main/java/de/samply/bbmri/negotiator/control/researcher/ResearcherQueriesDetailBean.java +++ b/src/main/java/de/samply/bbmri/negotiator/control/researcher/ResearcherQueriesDetailBean.java @@ -187,8 +187,13 @@ public int getNumQueries() { private int unreadCommentCount = 0; private int privateNegotiationCount; private int unreadPrivateNegotiationCount = 0; + @Deprecated private List personList; + /** + * String to hold contact persons in DIVs + */ + private String personStringDIVsForRequest = ""; private int unreadQueryCount = 0; /** * Lifecycle Collection Data (Form, Structure) @@ -304,8 +309,9 @@ public String loadSelectedQueryDetails() { logger.debug("loadSelectedQueryDetails-21: " + LocalDateTime.now()); } logger.debug("loadSelectedQueryDetails-21.1-setPersonListForRequest: " + LocalDateTime.now()); - // This will be set once the button is hit ... - //setPersonListForRequest(config, selectedQuery.getId()); + // setPersonListForRequest(config, selectedQuery.getId()); + // Set the PersonDIVsString - setPersonListForRequest is deprecated once this works + setPersonStringDIVsForRequest(config, selectedQuery.getId()); logger.debug("loadSelectedQueryDetails-22: " + LocalDateTime.now()); /* * Initialize Lifecycle Status @@ -333,6 +339,37 @@ public String loadSelectedQueryDetails() { return null; } + /** + * Set the contact persons in a String with DIVs to speed up the DOM creation + * + * @param config + * @param queryId + */ + private void setPersonStringDIVsForRequest( Config config, Integer queryId) { + // ensure the personStringDIVsForRequest is empty + personStringDIVsForRequest = new String(""); + + // get the personList from the database + personList = DbUtil.getPersonsContactsForRequest(config, queryId); + + for( de.samply.bbmri.negotiator.jooq.tables.pojos.Person person : personList) { + if( person.getAuthName() != null) { + personStringDIVsForRequest = personStringDIVsForRequest.concat("
"); + personStringDIVsForRequest = personStringDIVsForRequest.concat(person.getAuthName()); + personStringDIVsForRequest = personStringDIVsForRequest.concat("
"); + } + } + } + + /** + * Returns the previously set person list as DIVs to speed up DOM creation + * @return + */ + private String getPersonStringDIVsForRequest() { + return personStringDIVsForRequest; + } + + @Deprecated private void setPersonListForRequest(Config config, Integer queryId) { personList = DbUtil.getPersonsContactsForRequest(config, queryId); } diff --git a/src/main/webapp/owner/detail.xhtml b/src/main/webapp/owner/detail.xhtml index 734f9eaf..568aca54 100644 --- a/src/main/webapp/owner/detail.xhtml +++ b/src/main/webapp/owner/detail.xhtml @@ -413,10 +413,16 @@
+ + +
diff --git a/src/main/webapp/researcher/detail.xhtml b/src/main/webapp/researcher/detail.xhtml index 7ee1afde..5a005328 100644 --- a/src/main/webapp/researcher/detail.xhtml +++ b/src/main/webapp/researcher/detail.xhtml @@ -532,10 +532,16 @@
+ + #{researcherQueriesDetailBean.getPersonStringDIVsForRequest()} +