package com.dokoll.solutions.inc.search; /** * Created from copy: 2012.08.25.9.14.PM * SearchNSFJavaBean * Read View data into Xpage (JavaBean Search Feature) */ //load import for Domino classes import lotus.domino.*; import lotus.domino.local.Database; import lotus.domino.local.Document; //import for JavaServer Faces classes import javax.faces.context.FacesContext; /** * @author Dököll Solutions, Inc. * @version 2012.08.25.9.14.PM * */ // begin class public class SearchNSFJavaBean extends AgentBase { //declare Search Criteria variables private String UserID; private String RoleID; private String SearchText; //declare variables for page security loads private String ViewAccess; private String AddAccess; private String UpdateAccess; private String DeleteAccess; private DateTime DateCreated; /** * @return the dateCreated */ public DateTime getDateCreated() { return DateCreated; } /** * @param dateCreated the dateCreated to set */ public void setDateCreated(DateTime dateCreated) { DateCreated = dateCreated; } /** * @return the viewAccess */ public String getViewAccess() { return ViewAccess; } /** * @param viewAccess the viewAccess to set */ public void setViewAccess(String viewAccess) { ViewAccess = viewAccess; } /** * @return the addAccess */ public String getAddAccess() { return AddAccess; } /** * @param addAccess the addAccess to set */ public void setAddAccess(String addAccess) { AddAccess = addAccess; } /** * @return the updateAccess */ public String getUpdateAccess() { return UpdateAccess; } /** * @param updateAccess the updateAccess to set */ public void setUpdateAccess(String updateAccess) { UpdateAccess = updateAccess; } /** * @return the deleteAccess */ public String getDeleteAccess() { return DeleteAccess; } /** * @param deleteAccess the deleteAccess to set */ public void setDeleteAccess(String deleteAccess) { DeleteAccess = deleteAccess; } /** * @return the userID */ public String getUserID() { return UserID; } /** * @param userID the userID to set */ public void setUserID(String userID) { UserID = userID; } /** * @return the roleID */ public String getRoleID() { return RoleID; } /** * @param roleID the roleID to set */ public void setRoleID(String roleID) { RoleID = roleID; } /** * @return the searchText */ public String getSearchText() { return SearchText; } /** * @param searchText the searchText to set */ public void setSearchText(String searchText) { SearchText = searchText; } // open method, this actually runs the whole App public void doSearchNSFDocs() { // let's add a try catch here, to grab errors near the end try { // Declare Variables, one to hold Documents/ and page through results with the other Document doc; //BEGIN DEBUG Database database = (Database) FacesContext.getCurrentInstance() .getApplication().getVariableResolver().resolveVariable( FacesContext.getCurrentInstance(), "database"); System.out.println("Database Obtained..." + database); // Find the view in question View view = database.getView("SecurityAccessView"); System.out.println("View Obtained..." + view); //initialize search through collection ViewEntryCollection vec = view.getAllEntriesByKey(SearchText, true);// System.out.println("Collection Obtained..." + vec); doc = (Document) view.getFirstDocument(); System.out.println("Doc Obtained..." + doc); System.out.println("Loading to Xpage..."); // process the document in the View while (vec != null) { //Load security document to Xpapes form UserID = doc.getItemValueString("UserID"); RoleID = doc.getItemValueString("RoleID"); ViewAccess = doc.getItemValueString("ViewAccess"); AddAccess = doc.getItemValueString("AddAccess"); UpdateAccess = doc.getItemValueString("UpdateAccess"); DeleteAccess = doc.getItemValueString("DeleteAccess"); DateCreated = doc.getCreated(); System.out.println("Loaded to Xpage..."); //... //load to debug console for testing purposes System.out.println("Searching UserID "+SearchText); System.out.println("Found UserID "+ UserID); System.out.println("Created @ "+ DateCreated); //... //recycle to free up mem doc.recycle(); //... //this is necessary to avoid NullPointer //We do not expect another instance of that userID return; } } catch (Exception e) { e.printStackTrace(); } } }