Skip to content

Commit

Permalink
#3614 - proof of concept of dropping prime faces table over Raman's c…
Browse files Browse the repository at this point in the history
…ustom query
  • Loading branch information
sekmiller committed Jun 5, 2017
1 parent 91fe835 commit 13f7ca5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/main/java/edu/harvard/iq/dataverse/UserServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ public List<Object[]> getUserList(String searchTerm, String sortKey, Integer res
qstr += " u.affiliation, u.superuser,";
qstr += " u.position, u.modificationtime";
qstr += " FROM authenticateduser u";
qstr += " WHERE ";
qstr += getSharedSearchClause();
qstr += getSharedSearchClause(searchTerm);
qstr += " ORDER BY u.useridentifier";
qstr += " LIMIT " + resultLimit;
qstr += " OFFSET " + offset;
Expand All @@ -190,12 +189,16 @@ public List<Object[]> getUserList(String searchTerm, String sortKey, Integer res
* @param searchTerm
* @return
*/
private String getSharedSearchClause(){
private String getSharedSearchClause(String searchTerm){
if (searchTerm.isEmpty()){
return "";
}


String searchClause = " u.useridentifier ILIKE #searchTerm";
searchClause += " OR u.firstname ILIKE #searchTerm";
searchClause += " OR u.lastname ILIKE #searchTerm";
searchClause += " OR u.email ILIKE #searchTerm";
String searchClause = "WHERE u.useridentifier LIKE '%" + searchTerm +"%'";
searchClause += " OR u.firstname LIKE '%" + searchTerm +"%'";
searchClause += " OR u.lastname LIKE '%" + searchTerm +"%'";
searchClause += " OR u.email LIKE '%" + searchTerm +"%'";

return searchClause;
}
Expand All @@ -213,8 +216,7 @@ public Long getUserCount(String searchTerm) {

String qstr = "SELECT count(u.id)";
qstr += " FROM authenticateduser u";
qstr += " WHERE ";
qstr += getSharedSearchClause();
qstr += getSharedSearchClause(searchTerm);
qstr += ";";

Query nativeQuery = em.createNativeQuery(qstr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.harvard.iq.dataverse.api.Admin;
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import java.util.List;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.view.ViewScoped;
Expand All @@ -18,6 +19,16 @@ public class DashboardUsersPage implements java.io.Serializable {

private static final Logger logger = Logger.getLogger(DashboardUsersPage.class.getCanonicalName());
private AuthenticatedUser authUser = null;

private List<Object[]> userList = null;

public List<Object[]> getUserList() {
return userService.getUserList("", null, Integer.SIZE, Integer.SIZE);
}

public void setUserList(List<Object[]> userList) {
this.userList = userList;
}

@EJB
AuthenticationServiceBean authenticationService;
Expand All @@ -34,6 +45,7 @@ public String init() {

if ((session.getUser() != null) && (session.getUser().isAuthenticated()) && (session.getUser().isSuperuser())) {
authUser = (AuthenticatedUser) session.getUser();
userList = userService.getUserList("", null, Integer.SIZE, Integer.SIZE);
} else {
return permissionsWrapper.notAuthorized();
// redirect to login OR give some type ‘you must be logged in message'
Expand Down
20 changes: 19 additions & 1 deletion src/main/webapp/dashboard-users.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,25 @@
});
</script>
</ui:fragment>

<p:dataTable value="#{DashboardUsersPage.userList}" var="user">
<p:column headerText="Id">
<h:outputText value="#{user[0]}" />
</p:column>

<p:column headerText="Year">
<h:outputText value="#{user[1]}" />
</p:column>

<p:column headerText="Brand">
<h:outputText value="#{user[2]}" />
</p:column>

<p:column headerText="Color">
<h:outputText value="#{user[3]}" />
</p:column>


</p:dataTable>
</ui:define>
</ui:composition>
</h:body>
Expand Down

0 comments on commit 13f7ca5

Please sign in to comment.