From: <fm...@rh...> - 2008-12-01 23:55:24
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [2156] RHQ-1048 - Pulled EventComposite from DB and displayed in history page</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>2156</dd> <dt>Author</dt> <dd>fmatar</dd> <dt>Date</dt> <dd>2008-12-01 17:55:20 -0600 (Mon, 01 Dec 2008)</dd> </dl> <h3>Log Message</h3> <pre>RHQ-1048 - Pulled EventComposite from DB and displayed in history page</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguicommonpagingPageControlViewjava">rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguieventEventHistoryUIBeanjava">rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseguiportalwarsrcmainwebapprhqresourceeventshistoryxhtml">rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/events/history.xhtml</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguicommonpagingPageControlViewjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java (2155 => 2156)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java 2008-12-01 21:17:55 UTC (rev 2155) +++ rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java 2008-12-01 23:55:20 UTC (rev 2156) </span><span class="lines">@@ -50,6 +50,7 @@ </span><span class="cx"> import org.rhq.enterprise.gui.definition.group.GroupDefinitionUIBean; import org.rhq.enterprise.gui.definition.group.ListGroupDefinitionsUIBean; import org.rhq.enterprise.gui.discovery.AutoDiscoveryQueueUIBean; </span><span class="add">+import org.rhq.enterprise.gui.event.EventHistoryUIBean; </span><span class="cx"> import org.rhq.enterprise.gui.ha.AffinityGroupSubscribedAgentsUIBean; import org.rhq.enterprise.gui.ha.AffinityGroupSubscribedServersUIBean; import org.rhq.enterprise.gui.ha.AffinityGroupUnsubscribedAgentsUIBean; </span><span class="lines">@@ -229,7 +230,9 @@ </span><span class="cx"> /** */ ResourceMeasuremntScheduleList(ListResourceMeasurementScheduleUIBean.class, true), /** */ </span><span class="rem">- ResourceGroupMeasuremntScheduleList(ListResourceGroupMeasurementScheduleUIBean.class, true); </span><span class="add">+ ResourceGroupMeasuremntScheduleList(ListResourceGroupMeasurementScheduleUIBean.class, true), + /** */ + EventsHistoryList(EventHistoryUIBean.class); </span><span class="cx"> private Class<? extends PagedDataTableUIBean> beanClass; private boolean showAll = false;; </span></pre></div> <a id="rhqtrunkmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguieventEventHistoryUIBeanjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java (2155 => 2156)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java 2008-12-01 21:17:55 UTC (rev 2155) +++ rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java 2008-12-01 23:55:20 UTC (rev 2156) </span><span class="lines">@@ -18,20 +18,37 @@ </span><span class="cx"> */ package org.rhq.enterprise.gui.event; </span><span class="add">+import java.util.Map; + +import javax.faces.model.DataModel; + </span><span class="cx"> import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; </span><span class="add">+import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.event.EventSeverity; </span><span class="cx"> import org.rhq.core.domain.event.composite.EventComposite; </span><span class="add">+import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.util.PageControl; </span><span class="cx"> import org.rhq.core.domain.util.PageList; </span><span class="rem">-import org.rhq.enterprise.gui.alert.ListAlertHistoryUIBean; </span><span class="add">+import org.rhq.core.gui.util.FacesContextUtility; +import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean; +import org.rhq.enterprise.gui.common.paging.PageControlView; +import org.rhq.enterprise.gui.common.paging.PagedListDataModel; +import org.rhq.enterprise.gui.legacy.ParamConstants; +import org.rhq.enterprise.gui.legacy.WebUser; +import org.rhq.enterprise.gui.legacy.util.MonitorUtils; +import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; +import org.rhq.enterprise.server.event.EventManagerLocal; +import org.rhq.enterprise.server.util.LookupUtil; </span><span class="cx"> </span><span class="rem">-public class EventHistoryUIBean { - private static final Log log = LogFactory.getLog(ListAlertHistoryUIBean.class); </span><span class="add">+public class EventHistoryUIBean extends PagedDataTableUIBean { + private static final Log log = LogFactory.getLog(EventHistoryUIBean.class); </span><span class="cx"> public static final String MANAGED_BEAN_NAME = "EventHistoryUIBean"; private int id; </span><span class="rem">- private String sevFilter; </span><span class="add">+ private EventSeverity sevFilter; </span><span class="cx"> private String sourceFilter; private String searchString; private PageList<EventComposite> events; </span><span class="lines">@@ -44,11 +61,11 @@ </span><span class="cx"> this.id = id; } </span><span class="rem">- public String getSevFilter() { </span><span class="add">+ public EventSeverity getSevFilter() { </span><span class="cx"> return sevFilter; } </span><span class="rem">- public void setSevFilter(String sevFilter) { </span><span class="add">+ public void setSevFilter(EventSeverity sevFilter) { </span><span class="cx"> this.sevFilter = sevFilter; } </span><span class="lines">@@ -76,4 +93,46 @@ </span><span class="cx"> this.events = events; } </span><span class="add">+ @Override + public DataModel getDataModel() { + if (dataModel == null) { + dataModel = new ListEventsHistoryDataModel(PageControlView.EventsHistoryList, MANAGED_BEAN_NAME); + } + return dataModel; + } + + private class ListEventsHistoryDataModel extends PagedListDataModel<EventComposite> { + public ListEventsHistoryDataModel(PageControlView view, String beanName) { + super(view, beanName); + } + + @Override + public PageList<EventComposite> fetchPage(PageControl pc) { + Resource requestResource = EnterpriseFacesContextUtility.getResourceIfExists(); + EventManagerLocal manager = LookupUtil.getEventManager(); + Subject subject = EnterpriseFacesContextUtility.getSubject(); + Resource resource = EnterpriseFacesContextUtility.getResource(); + + WebUser user = EnterpriseFacesContextUtility.getWebUser(); + + Map pref = user.getPreferences().getMetricRangePreference(true); + long begin = (Long) pref.get(MonitorUtils.BEGIN); + long end = (Long) pref.get(MonitorUtils.END); + Integer lastN = (Integer) pref.get(MonitorUtils.LASTN); + + int resourceId = FacesContextUtility.getRequiredRequestParameter(ParamConstants.RESOURCE_ID_PARAM, + Integer.class); + int eventId = -1; + try { + eventId = FacesContextUtility.getRequiredRequestParameter("eventId", Integer.class); + } catch (IllegalStateException isex) { + eventId = -1; + } + PageList<EventComposite> results = null; + + results = manager.getEvents(subject, new int[] { requestResource.getId() }, begin, end, sevFilter, eventId, + getSourceFilter(), searchString, pc); + return results; + } + } </span><span class="cx"> } </span></pre></div> <a id="rhqtrunkmodulesenterpriseguiportalwarsrcmainwebapprhqresourceeventshistoryxhtml"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/events/history.xhtml (2155 => 2156)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/events/history.xhtml 2008-12-01 21:17:55 UTC (rev 2155) +++ rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/events/history.xhtml 2008-12-01 23:55:20 UTC (rev 2156) </span><span class="lines">@@ -47,6 +47,47 @@ </span><span class="cx"> <h:inputText value="#{EventHistoryUIBean.searchString}" /> </rich:panel> </span><span class="add">+ <ui:param name="eventHistoryDataModel" value="#{EventHistoryUIBean.dataModel}"/> + + + <rich:dataTable binding="#{EventHistoryUIBean.dataTable}" + id="eventHistoryDataTable" + rows="10" + value="#{eventHistoryDataModel}" + var="item" + width="100%" + headerClass="tableRowHeader" + footerClass="on-pager-footer"> + + <rich:column> + <f:facet name="header"> + <h:outputText styleClass="headerText" value="Severity" /> + </f:facet> + <h:outputText value="#{item.severity}" /> + </rich:column> + + <rich:column> + <f:facet name="header"> + <h:outputText styleClass="headerText" value="Source" /> + </f:facet> + <h:outputText value="#{item.sourceLocation}" /> + </rich:column> + + <rich:column> + <f:facet name="header"> + <h:outputText styleClass="headerText" value="Detail" /> + </f:facet> + <h:outputText value="#{item.eventDetail}" /> + </rich:column> + + <rich:column> + <f:facet name="header"> + <h:outputText styleClass="headerText" value="Time occurred" /> + </f:facet> + <h:outputText value="#{item.timestamp}" /> + </rich:column> + + </rich:dataTable> </span><span class="cx"> </h:form> </ui:define> </span> </pre> </div> </div> </body> </html> |