1 5 package org.exoplatform.portlets.monitor.session.component; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 9 import org.exoplatform.faces.core.component.model.SelectItem; 10 import org.exoplatform.faces.search.component.UISearchBar; 11 import org.exoplatform.faces.search.component.UISearcher; 12 import org.exoplatform.services.portal.log.Query; 13 18 public class UISessionLogManager extends UISearcher { 19 20 public UISessionLogManager() throws Exception { 21 setId("UISearcher") ; 22 setRendererType("ChildrenRenderer") ; 23 List options = new ArrayList () ; 24 options.add(new SelectItem("#{UISearchBar.label.search-all}", "")); 25 options.add(new SelectItem("#{UISearchBar.label.session-owner}", "sessionOwner")); 26 options.add(new SelectItem("#{UISearchBar.label.remote-user}","remoteUser")); 27 options.add(new SelectItem("#{UISearchBar.label.ip-address}", "ipAddress")); 28 options.add(new SelectItem("#{UISearchBar.label.client-type}", "clientName")); 29 UISearchBar uiBar = new UISearchBar(); 30 uiBar.setSearchOptions(options) ; 31 getChildren().add(uiBar) ; 32 addChild(UIListSessionLog.class) ; 33 addChild(UISearchLogForm.class).setRendered(false) ; 34 addChild(UIActionHistory.class).setRendered(false) ; 35 } 36 37 public void showAdvancedSearch() throws Exception { 38 setRenderedComponent(UISearchLogForm.class) ; 39 } 40 41 public void quickSearch(String term, List fields) throws Exception { 42 Query query = new Query() ; 43 if(term != null && term.length() > 0 && fields.size() == 1) { 44 String field = (String ) fields.get(0) ; 45 if("sessionOwner".equals(field)) query.setSessionOwner(term) ; 46 else if("remoteUser".equals(field))query.setRemoteUser(term) ; 47 else if("ipAddress".equals(field))query.setIPAddress(term) ; 48 else if("clientName".equals(field))query.setClientType(term) ; 49 } 50 UIListSessionLog uiList = 51 (UIListSessionLog) getChildComponentOfType(UIListSessionLog.class) ; 52 uiList.update(query) ; 53 setRenderedComponent(UIListSessionLog.class) ; 54 } 55 } | Popular Tags |