Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Fix to add userID for selected queries; add queries for owners withou…
Browse files Browse the repository at this point in the history
…t queryID to allow acting on behalf of Biobank;
  • Loading branch information
konradlang committed Feb 1, 2023
1 parent 3e421de commit 1363a29
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,22 @@ public String initialize() {
* Get the selected(clicked on) query from the list of queries for the owner
*/
// TODO: implement loading of the selected query and setting the comments
selectedQuery = DbUtil.getSelectedQuery( config, queryId);
selectedQuery = DbUtil.getSelectedQueryForUserId( config, queryId, userBean.getUserId());
//selectedQuery = DbUtil.getSelectedQuery( config, queryId);

// TODO: Get the query for type ownerQueryStatsDTO
//setCommentCountAndUreadCommentCount(ownerQueryStatsDTO);
/**
* Get the selected(clicked on) query from the list of queries for the owner

// Get the selected(clicked on) query from the list of queries for the owner
// Needs to be optimized!

for(OwnerQueryStatsDTO ownerQueryStatsDTO : getQueries()) {
if(ownerQueryStatsDTO.getQuery().getId() == queryId) {
selectedQuery = ownerQueryStatsDTO.getQuery();
setCommentCountAndUreadCommentCount(ownerQueryStatsDTO);
}
}
*/


if(selectedQuery != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ public String loadSelectedQueryDetails() {
* Get the selected(clicked on) query from the list of queries for the owner
*/
// TODO: implement loading of the selected query and setting the comments
selectedQuery = DbUtil.getSelectedQuery( config, queryId);
selectedQuery = DbUtil.getSelectedQueryForUserId( config, queryId, userBean.getUserId());
//selectedQuery = DbUtil.getSelectedQuery( config, queryId);
logger.debug("loadSelectedQueryDetails-17: " + LocalDateTime.now());
/*
for (QueryStatsDTO query : getQueries()) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/de/samply/bbmri/negotiator/db/util/DbUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,22 @@ public static de.samply.bbmri.negotiator.jooq.tables.pojos.Query getSelectedQuer
//.fetchOne( Tables.QUERY.as(fetchedQuery));
//.getResult();
}

/**
* Get the JSON query from the database for a specific userID.
* @param config JOOQ configuration
* @param queryId the query ID
* @param userId the user ID for this query
* @return JSON string
*/
public static de.samply.bbmri.negotiator.jooq.tables.pojos.Query getSelectedQueryForUserId( Config config, Integer queryId, int userId) {
Condition condition = Tables.QUERY.RESEARCHER_ID.eq(userId);

return (de.samply.bbmri.negotiator.jooq.tables.pojos.Query) config.dsl().selectFrom(Tables.QUERY)
.where(condition).and(Tables.QUERY.ID.eq(queryId))
.fetchOneInto( de.samply.bbmri.negotiator.jooq.tables.pojos.Query.class);
}

/**
* Get the JSON query from the database.
* @param config JOOQ configuration
Expand Down

0 comments on commit 1363a29

Please sign in to comment.