This topic describes how to use the <filters> element to narrow queries of the Query API service to specific portal communities.
In the previous topic, Viewing Portlet Usage, you built queries to see which portlets are being used on your portal. In this topic, you use filters to refine these queries.
The <filters> element describes a property, a value for that property, and an operator to perform a check to see if any given event belongs in the result set.
For more details on the <filters> element, see The <filters> Element.
For this example, you build on the final SOAP message from the previous topic:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Header/> <S:Body> <Q:executeResultSetQuery xmlns:Q="http://www.bea.com/analytics/AnalyticsQueryService"> <arg0> <eventName> {http://www.bea.com/analytics/ali}portletUses </eventName> <groups> <dimension>portlet</dimension> <property>name</property> </groups> </arg0> </Q:executeResultSetQuery> </S:Body> </S:Envelope>
This query returns the name of each portlet that has been used on the portal. Instead of all portlets, you want to see only the portlets that are accessed from the Analytics Console community. To do this, add the following <filters> element:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Header/> <S:Body> <Q:executeResultSetQuery xmlns:Q="http://www.bea.com/analytics/AnalyticsQueryService"> <arg0> <eventName> {http://www.bea.com/analytics/ali}portletUses </eventName> <groups> <dimension>portlet</dimension> <property>name</property> </groups> <filters xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <dimension>community</dimension> <property>name</property> <operator>1</operator> <values xsi:type="xs:string">Analytics Console</values> </filters> </arg0> </Q:executeResultSetQuery> </S:Body> </S:Envelope>
The <operator>1</operator> corresponds to the operator equals. For a list of all valid values for <operator>, see The <filters> Element.
The type of the <values> element must be defined. Because of this, we must include the XMLSchema and XMLSchema-instance namespaces.
When this SOAP message is sent with the example application, a list of the names of portlets that have been used in the Analytics Console community is output to the console. In a test environment, this was a list of six portlet names:
Analytics Query API Results: ---------------------------- Community Metrics Other Metrics Portlet Metrics Publisher Administration Report Summary Metrics
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Header/> <S:Body> <Q:executeResultSetQuery xmlns:Q="http://www.bea.com/analytics/AnalyticsQueryService"> <arg0> <eventName> {http://www.bea.com/analytics/ali}portletUses </eventName> <groups> <dimension>portlet</dimension> <property>name</property> </groups> <filters xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <dimension>community</dimension> <property>name</property> <operator>9</operator> <values xsi:type="xs:string">Analytics Console</values> <values xsi:type="xs:string">Publisher Community</values> </filters> </arg0> </Q:executeResultSetQuery> </S:Body> </S:Envelope>
When this SOAP message is sent with the example application, a list of the names of portlets that have been used in both the Publisher Community and Analytics Console communities is output to the console. In a test environment, this was a list of eight portlet names:
Analytics Query API Results: ---------------------------- Community Metrics FCC News Portlet Other Metrics Portlet Metrics Publisher Administration Publisher Community Directory Portlet Report Summary Metrics