From 0dda697045681c556cbcd3191c4868c5a29ba585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radovan=20Tom=C3=A1=C5=A1ik?= Date: Fri, 21 Oct 2022 15:26:07 +0200 Subject: [PATCH] Updated counting of Queries (#154) * added setQueryCount() * dummy data fix * typo fix * get actual count of queries for the owner * query counting upgrade * remove ordering * researcher query count * updated queryCounting for researcher * cleanup --- .../control/owner/OwnerQueriesBean.java | 33 ++-- .../control/owner/OwnerQueriesDetailBean.java | 55 +++--- .../researcher/ResearcherQueriesBean.java | 156 +----------------- .../ResearcherQueriesDetailBean.java | 61 ++++--- .../bbmri/negotiator/db/util/DbUtil.java | 99 ++++++++--- src/main/resources/sql/dummyData.sql | 22 +-- 6 files changed, 164 insertions(+), 262 deletions(-) diff --git a/src/main/java/de/samply/bbmri/negotiator/control/owner/OwnerQueriesBean.java b/src/main/java/de/samply/bbmri/negotiator/control/owner/OwnerQueriesBean.java index 37d2cf4d..3a323dba 100644 --- a/src/main/java/de/samply/bbmri/negotiator/control/owner/OwnerQueriesBean.java +++ b/src/main/java/de/samply/bbmri/negotiator/control/owner/OwnerQueriesBean.java @@ -27,16 +27,6 @@ package de.samply.bbmri.negotiator.control.owner; -import java.io.Serializable; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.*; - -import javax.annotation.PostConstruct; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ManagedProperty; -import javax.faces.bean.ViewScoped; - import de.samply.bbmri.negotiator.Config; import de.samply.bbmri.negotiator.ConfigFactory; import de.samply.bbmri.negotiator.control.SessionBean; @@ -44,13 +34,21 @@ import de.samply.bbmri.negotiator.db.util.DbUtil; import de.samply.bbmri.negotiator.jooq.enums.Flag; import de.samply.bbmri.negotiator.model.OwnerQueryStatsDTO; -import de.samply.bbmri.negotiator.model.QueryStatsDTO; import org.jooq.Record; import org.jooq.Result; import org.primefaces.model.FilterMeta; import org.primefaces.model.LazyDataModel; import org.primefaces.model.SortOrder; +import javax.annotation.PostConstruct; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.ViewScoped; +import java.io.Serializable; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.*; + /** * Manages the query view for owners */ @@ -65,8 +63,7 @@ public class OwnerQueriesBean implements Serializable { // TODO: set the chunk size static for now, but this should be adopted to display according to the maximum page size private static final int CHUNK_SIZE = 5; - // Number of all queries for this researcher - // TODO: check if this can be removed + private int queryCount; // lazy data model to hold the researcher queries private LazyDataModel lazyDataModel; @@ -90,7 +87,7 @@ public class OwnerQueriesBean implements Serializable { */ @PostConstruct public void init() { - this.getQueryCount(); + countQueriesForOwner(); this.lazyDataModel = new LazyDataModel() { @@ -248,9 +245,13 @@ private List loadLatestOwnerQueryStatsDTO( int offset, int s * Load the number of queries "("SELECT COUNT(*) from ..." * @return int numQueries */ - public void getQueryCount() { + public int getQueryCount() { + return this.queryCount; + } + + public void countQueriesForOwner() { try( Config config = ConfigFactory.get()) { - this.queryCount = DbUtil.getOwnerQueriesCount(config, userBean.getUserId(), getFilterTerms()); + this.queryCount = DbUtil.countOwnerQueries(config, userBean.getUserId(), getFilterTerms(), flagFilter, isTestRequest); } catch (SQLException e) { System.err.println("ERROR: OwnerQueriesBean::getQueryCount()"); e.printStackTrace(); 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 6750c0d1..a2624ae7 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 @@ -26,32 +26,8 @@ package de.samply.bbmri.negotiator.control.owner; -import java.io.*; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.Collection; -import java.util.stream.Collectors; - -import javax.annotation.PostConstruct; -import javax.faces.application.FacesMessage; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ManagedProperty; -import javax.faces.bean.ViewScoped; -import javax.faces.context.FacesContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.Part; - import com.fasterxml.jackson.databind.ObjectMapper; import com.openhtmltopdf.pdfboxout.PdfRendererBuilder; -import org.apache.pdfbox.multipdf.PDFMergerUtility; -import org.apache.pdfbox.io.MemoryUsageSetting; import de.samply.bbmri.negotiator.Config; import de.samply.bbmri.negotiator.ConfigFactory; import de.samply.bbmri.negotiator.FileUtil; @@ -68,10 +44,14 @@ import de.samply.bbmri.negotiator.model.*; import de.samply.bbmri.negotiator.rest.RestApplication; import de.samply.bbmri.negotiator.rest.dto.QueryDTO; -import eu.bbmri.eric.csit.service.negotiator.lifecycle.CollectionLifeCycleStatus; import de.samply.bbmri.negotiator.util.DataCache; +import eu.bbmri.eric.csit.service.negotiator.lifecycle.CollectionLifeCycleStatus; import eu.bbmri.eric.csit.service.negotiator.lifecycle.RequestLifeCycleStatus; import eu.bbmri.eric.csit.service.negotiator.lifecycle.util.LifeCycleRequestStatusStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.pdfbox.io.MemoryUsageSetting; +import org.apache.pdfbox.multipdf.PDFMergerUtility; import org.jooq.Record; import org.jooq.Result; import org.json.simple.JSONArray; @@ -81,8 +61,27 @@ import org.jsoup.Jsoup; import org.jsoup.helper.W3CDom; import org.jsoup.nodes.Document; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; + +import javax.annotation.PostConstruct; +import javax.faces.application.FacesMessage; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.ViewScoped; +import javax.faces.context.FacesContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.Part; +import java.io.*; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.*; +import java.util.stream.Collectors; /** * Manages the query detail view for owners @@ -220,7 +219,7 @@ public void init() { /** * set the number of queries to be used in the page display */ - this.NumQueries = DbUtil.getQueryStatsDTOsCount(config, userBean.getUserId(), getFilterTerms()); + this.NumQueries = DbUtil.countQueriesForResearcher(config, userBean.getUserId(), getFilterTerms()); } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/main/java/de/samply/bbmri/negotiator/control/researcher/ResearcherQueriesBean.java b/src/main/java/de/samply/bbmri/negotiator/control/researcher/ResearcherQueriesBean.java index f50e5a95..94332c46 100644 --- a/src/main/java/de/samply/bbmri/negotiator/control/researcher/ResearcherQueriesBean.java +++ b/src/main/java/de/samply/bbmri/negotiator/control/researcher/ResearcherQueriesBean.java @@ -37,7 +37,6 @@ import de.samply.bbmri.negotiator.model.QueryStatsDTO; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; import org.jooq.Record; import org.jooq.Result; import org.primefaces.model.FilterMeta; @@ -70,8 +69,6 @@ public class ResearcherQueriesBean implements Serializable { // TODO: set the chunk size static for now, but this should be adopted to display according to the maximum page size private static final int CHUNK_SIZE = 5; - // Number of all queries for this researcher - // TODO: check if this can be removed private int queryCount; // lazy data model to hold the researcher queries private LazyDataModel lazyDataModel; @@ -105,8 +102,7 @@ public class ResearcherQueriesBean implements Serializable { */ @PostConstruct public void init() { - // this.queryCount = 10; // set to the count from JOOQ - this.getQueryCount(); + countQueries(); this.lazyDataModel = new LazyDataModel() { @@ -199,163 +195,25 @@ private List loadLatestQueryStatsDTO( int offset, int size) { return queries; } - public List loadLatestQueriesOffset( int offset, int size) { - List queries = new List() { - @Override - public int size() { - return 0; - } - - @Override - public boolean isEmpty() { - return false; - } - - @Override - public boolean contains(Object o) { - return false; - } - - @NotNull - @Override - public Iterator iterator() { - return null; - } - @NotNull - @Override - public Object[] toArray() { - return new Object[0]; - } - - @NotNull - @Override - public T[] toArray(@NotNull T[] ts) { - return null; - } - - @Override - public boolean add(Query query) { - return false; - } - - @Override - public boolean remove(Object o) { - return false; - } - - @Override - public boolean containsAll(@NotNull Collection collection) { - return false; - } - - @Override - public boolean addAll(@NotNull Collection collection) { - return false; - } - - @Override - public boolean addAll(int i, @NotNull Collection collection) { - return false; - } - - @Override - public boolean removeAll(@NotNull Collection collection) { - return false; - } - - @Override - public boolean retainAll(@NotNull Collection collection) { - return false; - } - - @Override - public void clear() { - - } - - @Override - public Query get(int i) { - return null; - } - - @Override - public Query set(int i, Query query) { - return null; - } - - @Override - public void add(int i, Query query) { - - } - - @Override - public Query remove(int i) { - return null; - } - - @Override - public int indexOf(Object o) { - return 0; - } - - @Override - public int lastIndexOf(Object o) { - return 0; - } - - @NotNull - @Override - public ListIterator listIterator() { - return null; - } - - @NotNull - @Override - public ListIterator listIterator(int i) { - return null; - } - - @NotNull - @Override - public List subList(int i, int i1) { - return null; - } - }; - List queriesStatusDTO = loadLatestQueryStatsDTO( offset, size); - - for ( QueryStatsDTO qso : queriesStatusDTO) { - queries.add( qso.getQuery()); - } - return queries; - } /** * Load the number of queries "("SELECT COUNT(*) from ..." * @return int numQueries */ - public void getQueryCount() { + public void countQueries() { try( Config config = ConfigFactory.get()) { - this.queryCount = DbUtil.getQueryStatsDTOsCount(config, userBean.getUserId(), getFilterTerms()); + this.queryCount = DbUtil.countQueriesForResearcher(config, userBean.getUserId(), getFilterTerms()); } catch (SQLException e) { System.err.println("ERROR: ResearcherQueriesBean::getQueryCount()"); e.printStackTrace(); } } -// public List getQueries() { -// try(Config config = ConfigFactory.get()) { -// queries = DbUtil.getQueryStatsDTOs(config, userBean.getUserId(), getFilterTerms()); -// -// for (int i = 0; i < queries.size(); ++i) { -// getPrivateNegotiationCountAndTime(i); -// getUnreadQueryLifecycleChangesCountAndTime(i); -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } -// return queries; -// } + public int getQueryCount() { + return this.queryCount; + } + public void getPrivateNegotiationCountAndTime(int index){ try(Config config = ConfigFactory.get()) { 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 4e03ed11..6a082459 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 @@ -26,55 +26,50 @@ package de.samply.bbmri.negotiator.control.researcher; -import java.io.*; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.time.LocalDateTime; -import java.util.*; - -import javax.annotation.PostConstruct; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ManagedProperty; -import javax.faces.bean.ViewScoped; -import javax.faces.context.ExternalContext; -import javax.faces.context.FacesContext; -import javax.servlet.http.HttpServletResponse; - +import com.fasterxml.jackson.databind.ObjectMapper; import com.openhtmltopdf.pdfboxout.PdfRendererBuilder; import de.samply.bbmri.negotiator.*; import de.samply.bbmri.negotiator.config.Negotiator; +import de.samply.bbmri.negotiator.control.SessionBean; +import de.samply.bbmri.negotiator.control.UserBean; import de.samply.bbmri.negotiator.control.component.FileUploadBean; +import de.samply.bbmri.negotiator.db.util.DbUtil; import de.samply.bbmri.negotiator.jooq.tables.pojos.Person; +import de.samply.bbmri.negotiator.jooq.tables.pojos.Query; import de.samply.bbmri.negotiator.model.*; -import eu.bbmri.eric.csit.service.negotiator.lifecycle.CollectionLifeCycleStatus; +import de.samply.bbmri.negotiator.rest.RestApplication; +import de.samply.bbmri.negotiator.rest.dto.QueryDTO; import de.samply.bbmri.negotiator.util.DataCache; import de.samply.bbmri.negotiator.util.ObjectToJson; +import eu.bbmri.eric.csit.service.negotiator.lifecycle.CollectionLifeCycleStatus; import eu.bbmri.eric.csit.service.negotiator.lifecycle.RequestLifeCycleStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.pdfbox.io.MemoryUsageSetting; import org.apache.pdfbox.multipdf.PDFMergerUtility; import org.jooq.Record; import org.jooq.Result; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import de.samply.bbmri.negotiator.control.SessionBean; -import de.samply.bbmri.negotiator.control.UserBean; -import de.samply.bbmri.negotiator.db.util.DbUtil; -import de.samply.bbmri.negotiator.jooq.tables.pojos.Query; -import de.samply.bbmri.negotiator.rest.RestApplication; -import de.samply.bbmri.negotiator.rest.dto.QueryDTO; import org.jsoup.Jsoup; import org.jsoup.helper.W3CDom; import org.jsoup.nodes.Document; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.primefaces.model.FilterMeta; import org.primefaces.model.LazyDataModel; -import org.primefaces.model.SortOrder; + +import javax.annotation.PostConstruct; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.ViewScoped; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.*; /** * Manages the query detail view for owners @@ -215,7 +210,7 @@ public void init() { /** * set the number of queries to be used in the page display */ - this.NumQueries = DbUtil.getQueryStatsDTOsCount(config, userBean.getUserId(), getFilterTerms()); + this.NumQueries = DbUtil.countQueriesForResearcher(config, userBean.getUserId(), getFilterTerms()); } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/main/java/de/samply/bbmri/negotiator/db/util/DbUtil.java b/src/main/java/de/samply/bbmri/negotiator/db/util/DbUtil.java index 8e81a663..09641693 100644 --- a/src/main/java/de/samply/bbmri/negotiator/db/util/DbUtil.java +++ b/src/main/java/de/samply/bbmri/negotiator/db/util/DbUtil.java @@ -720,12 +720,11 @@ public static List getQueryStatsDTOsAtOffset(Config config, int u * @param filters filters to be applierd * @return integer number of queries */ - public static int getQueryStatsDTOsCount(Config config, int userId, Set filters) { -// Person commentAuthor = Tables.PERSON.as("comment_author"); + public static int countQueriesForResearcher(Config config, int userId, Set filters) { + Person commentAuthor = Tables.PERSON.as("comment_author"); Condition condition = Tables.QUERY.RESEARCHER_ID.eq(userId); -/* if(filters != null && filters.size() > 0) { Condition titleCondition = DSL.trueCondition(); Condition textCondition = DSL.trueCondition(); @@ -739,19 +738,20 @@ public static int getQueryStatsDTOsCount(Config config, int userId, Set } condition = condition.and(titleCondition.or(textCondition).or(nameCondition)); } -*/ - // TODO: check if we really need to get the actual number here, - // or if we just can work with a high enough estimated number and save the cost of doing the count on the database - // int queryCount = 1000; - int queryCount = config.dsl() - .selectCount() + return config.dsl() + .fetchCount(DSL + .select(getFields(Tables.QUERY, "query")) + .select(getFields(Tables.PERSON, "person")) .from(Tables.QUERY) - .where(condition) - .fetchOne(0, int.class); + .join(Tables.PERSON, JoinType.LEFT_OUTER_JOIN).on(Tables.PERSON.ID.eq(Tables.QUERY.RESEARCHER_ID)) + .leftOuterJoin(Tables.REQUEST_STATUS) + .on(Tables.REQUEST_STATUS.QUERY_ID.eq(Tables.QUERY.ID) + .and(Tables.REQUEST_STATUS.STATUS.eq("abandoned"))) + .where(condition).and(Tables.REQUEST_STATUS.STATUS.isNull()) + .groupBy(Tables.QUERY.ID, Tables.PERSON.ID)); + - logger.debug("queryCount: "+ queryCount); - return queryCount; } /** * Returns a list of queries for a particular owner, filtered by a search term if such is provided @@ -878,7 +878,7 @@ public static List getOwnerQueriesAtOffset(Config config, in condition = condition.and(Tables.QUERY.NEGOTIATION_STARTED_TIME.isNotNull()); Table requestStatusTableStart = Tables.REQUEST_STATUS.as("request_status_table_start"); - Table requestStatusTableAbandon = Tables.REQUEST_STATUS.as("reque_ststatus_table_abandon"); + Table requestStatusTableAbandon = Tables.REQUEST_STATUS.as("request_status_table_abandon"); Result fetch = config.dsl() .select(getFields(Tables.QUERY, "query")) @@ -928,6 +928,8 @@ public static List getOwnerQueriesAtOffset(Config config, in .offset(offset) .limit(size) .fetch(); + logger.info(userId); + logger.info(fetch.toString()); return MappingListDbUtil.mapRecordResultOwnerQueryStatsDTOList(fetch); } @@ -939,27 +941,78 @@ public static List getOwnerQueriesAtOffset(Config config, in * @param filters search term for title and text * @return */ - public static int getOwnerQueriesCount(Config config, int userId, Set filters) { + public static int countOwnerQueries(Config config, int userId, Set filters, Flag flag, Boolean isTestRequest) { Person queryAuthor = Tables.PERSON.as("query_author"); Condition condition = Tables.PERSON_COLLECTION.PERSON_ID.eq(userId); - // We need to get the actual query count, otherwise the More button will not go away on the page - // so no use to work with a high enough estimated number and save the cost of doing the count on the database - int queryCount = config.dsl() - .selectCount() + if(filters != null && filters.size() > 0) { + Condition titleCondition = DSL.trueCondition(); + Condition textCondition = DSL.trueCondition(); + Condition nameCondition = DSL.trueCondition(); + + for(String filter : filters) { + titleCondition = titleCondition.and(Tables.QUERY.TITLE.likeIgnoreCase("%" + filter.replace("%", "!%") + "%", '!')); + textCondition = textCondition.and(Tables.QUERY.TEXT.likeIgnoreCase("%" + filter.replace("%", "!%") + "%", '!')); + nameCondition = nameCondition.and(queryAuthor.AUTH_NAME.likeIgnoreCase("%" + filter.replace("%", "!%") + "%", '!')); + } + condition = condition.and(titleCondition.or(textCondition).or(nameCondition)); + } + + if (flag != null && flag != Flag.UNFLAGGED) { + condition = condition.and(Tables.FLAGGED_QUERY.FLAG.eq(flag)); + } else { + /** + * Ignored queries are never selected unless the user is in the ignored folder + */ + condition = condition.and(Tables.FLAGGED_QUERY.FLAG.ne(Flag.IGNORED).or(Tables.FLAGGED_QUERY.FLAG.isNull())); + } + + condition = condition.and(Tables.QUERY.NEGOTIATION_STARTED_TIME.isNotNull()); + + Table requestStatusTableStart = Tables.REQUEST_STATUS.as("request_status_table_start"); + Table requestStatusTableAbandon = Tables.REQUEST_STATUS.as("request_status_table_abandon"); + + int fetch = config.dsl().fetchCount(DSL + .select(getFields(Tables.QUERY, "query")) + .select(getFields(queryAuthor, "person")) + .select(DSL.decode().when(Tables.FLAGGED_QUERY.FLAG.isNull(), Flag.UNFLAGGED) + .otherwise(Tables.FLAGGED_QUERY.FLAG).as("flag")) .from(Tables.QUERY) + .join(Tables.QUERY_COLLECTION, JoinType.JOIN) .on(Tables.QUERY.ID.eq(Tables.QUERY_COLLECTION.QUERY_ID)) + .join(Tables.COLLECTION, JoinType.JOIN) .on(Tables.COLLECTION.ID.eq(Tables.QUERY_COLLECTION.COLLECTION_ID)) + .join(Tables.PERSON_COLLECTION, JoinType.JOIN) .on(Tables.PERSON_COLLECTION.COLLECTION_ID.eq(Tables.COLLECTION.ID)) - .where(condition) - .fetchOne(0, int.class); - logger.debug("queryCount: "+ queryCount); - return queryCount; + .join(queryAuthor, JoinType.LEFT_OUTER_JOIN) + .on(Tables.QUERY.RESEARCHER_ID.eq(queryAuthor.ID)) + + + .join(Tables.FLAGGED_QUERY, JoinType.LEFT_OUTER_JOIN) + .on(Tables.QUERY.ID.eq(Tables.FLAGGED_QUERY.QUERY_ID).and(Tables.FLAGGED_QUERY.PERSON_ID.eq(Tables.PERSON_COLLECTION.PERSON_ID))) + + .join(requestStatusTableStart, JoinType.JOIN) + .on(Tables.QUERY.ID.eq(requestStatusTableStart.field(Tables.REQUEST_STATUS.QUERY_ID)) + .and(requestStatusTableStart.field(Tables.REQUEST_STATUS.STATUS).eq("started"))) + + .join(requestStatusTableAbandon, JoinType.LEFT_OUTER_JOIN) + .on(Tables.QUERY.ID.eq(requestStatusTableAbandon.field(Tables.REQUEST_STATUS.QUERY_ID)) + .and(requestStatusTableAbandon.field(Tables.REQUEST_STATUS.STATUS).eq("abandoned"))) + + + .where(condition).and(requestStatusTableAbandon.field(Tables.REQUEST_STATUS.STATUS).isNull()) + .and(Tables.QUERY.TEST_REQUEST.eq(isTestRequest)) + .groupBy(Tables.QUERY.ID, queryAuthor.ID, Tables.FLAGGED_QUERY.PERSON_ID, Tables.FLAGGED_QUERY.QUERY_ID) + ); + logger.info(userId); + logger.info(fetch); + + return fetch; } /** diff --git a/src/main/resources/sql/dummyData.sql b/src/main/resources/sql/dummyData.sql index 96245ed3..35295b06 100644 --- a/src/main/resources/sql/dummyData.sql +++ b/src/main/resources/sql/dummyData.sql @@ -43,18 +43,14 @@ INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (7, 'https://auth-dev.mitro.dkfz.de/users/2', 'Max Ataian', 'm.ataian@dkfz.de', NULL); INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (8, 'https://auth-dev.mitro.dkfz.de/users/19', 'Saher Maqsood', 's.maqsood@dkfz.de', NULL); INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (9, 'https://auth-dev.mitro.dkfz.de/users/24', 'Polina Litvak', 'p.litvak@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (10, 'usertest-biobanker1', 'Biobank test user 1', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (11, 'usertest-biobanker2', 'Biobank test user 2', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (12, 'usertest-biobanker3', 'Biobank test user 3', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (13, 'usertest-biobanker4', 'Biobank test user 4', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (14, 'usertest-biobanker5', 'Biobank test user 5', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (15, 'usertest-owner1', 'Researcher test user 1', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (16, 'usertest-owner2', 'Researcher test user 2', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (17, 'usertest-owner3', 'Researcher test user 3', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (18, 'usertest-owner4', 'Researcher test user 4', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (19, 'usertest-owner5', 'Researcher test user 5', 'r.proynova@dkfz.de', NULL); -INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image, is_admin) VALUES (20, 'admin001','BBMRI ADMIN', 'admin@negotiator', NULL, TRUE); -ALTER SEQUENCE person_id_seq RESTART WITH 21; +INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (10, 'biobanker-000', 'Biobank test user 1', 'r.proynova@dkfz.de', NULL); +INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (11, 'biobanker-001', 'Biobank test user 2', 'r.proynova@dkfz.de', NULL); +INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (12, 'biobanker-002', 'Biobank test user 3', 'r.proynova@dkfz.de', NULL); +INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (13, 'biobanker-003', 'Biobank test user 4', 'r.proynova@dkfz.de', NULL); +INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (14, 'biobanker-004', 'Biobank test user 5', 'r.proynova@dkfz.de', NULL); +INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image) VALUES (15, 'researcher-001', 'Researcher test user 1', 'r.proynova@dkfz.de', NULL); +INSERT INTO person(id, auth_subject, auth_name, auth_email, person_image, is_admin) VALUES (20, 'admin-001','BBMRI ADMIN', 'admin@negotiator', NULL, TRUE); +INSERT INTO person(id, auth_subject, auth_name, auth_email, is_admin, organization) VALUES (19, 'national-node-001', 'National Node', 'nn@localhost', false, 'BBMRI.eu');ALTER SEQUENCE person_id_seq RESTART WITH 21; INSERT INTO person_collection (person_id, collection_id) VALUES (1, 1); INSERT INTO person_collection (person_id, collection_id) VALUES (2, 2); @@ -189,4 +185,4 @@ INSERT INTO json_query (json_text) VALUES ( } ], "URL": "https://does-not-exist.com" }' -); \ No newline at end of file +);