AquaLogic User Interaction Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Querying Existing Collaboration Discussions Using IDK Remote APIs

To query Collaboration discussions and messages from a remote application, use the IDiscussionManager interface in the IDK.

The PRC Collaboration API allows you to query existing collaboration discussions and messages. Results can be filtered in a variety of ways.
  • To query for existing discussions in a project, use IDiscussionManager.queryDiscussions using the project instance.
  • To query for existing messages in a discussion, use IDiscussionManager.queryDiscussionMessages using the discussion instance.
  • To query for existing messages in a project, use IDiscussionManager.queryDiscussionMessages using the project instance.
For any of these queries, the IDiscussionFilter/IDiscussionMessageFilter interfaces allow you to set the following search options:
Maximum Results Sets the maximum number of results returned. The default is to return all results.
Order-By Fields and Sort Order Messages only. Sets the fields to be displayed with an order-by functionality, and sets the sort order (ascending or descending). The following fields support the order-by option: created, most recent, last modified, project, replies, and owner.
Security Enables or disables the security filter that applies security to the result set with respect to the user that submitted the query. If the filter is enabled, the query result will only include objects for which the querying user has appropriate permission. The default is false (disabled); all objects matching the query criteria will be returned.
Result Filter: Status Messages only. Limits queries by status (approved or unapproved).
Result Filter: Moderator Type Messages only. Limits queries to those discussions for which the current user is a moderator, or extends the search to all discussions.
To query for discussions and messages, follow the steps below.
  1. Create a PRC session. For details, see Initiating a PRC Session to Use IDK Remote APIs.
  2. Get the project or discussion ID and retrieve the associated object.
  3. Create a new method to query for discussions or messages.
  4. Get the Discussion Manager.
  5. Create a query filter and execute the query as shown in the code samples below.

Java

...

//perform the search
IDiscussionManager discussionManager = getDiscussionManager(request, response);
IDiscussionMessageFilter discussionMessageFilter = discussionManager.createDiscussionMessageFilter();

//disable security checking on the returned objects against the user who performs this query,
//so that all objects will be returned
messageFilter.setRestoreSecurity(false);

//hard-code the max results to 10; setting to 0 will return all results
discussionMessageFilter.setMaximumResults(10);

//search for ALL messages; other options include searching for APPROVED or UNAPPROVED messages
messageFilter.setMessageStatusType(DiscussionMessageStatusFilterType.ALL);

//optionally, set the query orders
//example below sorts returned messages by CREATED date in descending order
DiscussionMessageQueryOrder messageQueryOrder = new DiscussionMessageQueryOrder(DiscussionMessageAttribute.CREATED, false);
messageFilter.setQueryOrders(new DiscussionMessageQueryOrder(messageQueryOrder));

//execute the search and print out the results
IDiscussionMessage[] discussionMessages = discussionManager.queryDiscussionMessages(project,
discussionMessageFilter);
if (discussionMessages.length > 0)
{
	%>
	<tr>
		<td colspan="2">
		Search Results
		</td>
	</tr>
	<tr>
		<td>
		Discussion Message Name- Link to Discussion Message
		</td>
		<td>
		Discussion ID
		</td>
	</tr>
	<%
	for (int i = 0; i < discussionMessages.length; i++)
	{
		IDiscussionMessage discussionMessage = discussionMessages[i];
		int id = discussionMessage.getID();
		name = discussionMessage.getSubject();
		String url = discussionMessage.getDetailsURL();
		%>
	<tr>
		<td>
		<%out.print("<a href=\"" + url + "\">" + name + "</a>");%>
		</td>
		<td>
		<%out.print(id);%>
		</td>
	</tr>

...

.NET (C#)

...

//get the project ID out of session- this should never be null as it is added in the page load event
Plumtree.Remote.PRC.Collaboration.Project.IProject project = (Plumtree.Remote.PRC.Collaboration.Project.IProject)
Session[SESSION_PROJECT_KEY];

//perform the search
Plumtree.Remote.PRC.Collaboration.Discussion.IDiscussionManager discussionManager = GetDiscussionManager(Request, Response);
Plumtree.Remote.PRC.Collaboration.Discussion.IDiscussionMessageFilter discussionMessageFilter = discussionManager.CreateDiscussionMessageFilter();

//disable security checking on the returned objects against the user who performs this query,
//so that all objects will be returned
messageFilter.RestoreSecurity = false;

//hard-code the max results to 10
discussionMessageFilter.MaximumResults = 10;

//search for ALL messages; other options include searching for Approved or Unapproved messages
messageFilter.MessageStatusType = DiscussionMessageStatusFilterTypes.All;

//optionally, set the query orders
//example below sorts returned messages by CREATED date in descending order
DiscussionMessageQueryOrder messageQueryOrder = new DiscussionMessageQueryOrder(DiscussionMessageAttributes.Created, false);
messageFilter.setQueryOrders(new DiscussionMessageQueryOrder(messageQueryOrder));

//execute the search and print out the results
Plumtree.Remote.PRC.Collaboration.Discussion.IDiscussionMessage[] discussionMessages
= discussionManager.QueryDiscussionMessages(project, discussionMessageFilter);
if (discussionMessages.Length > 0)
{
	%>
	<tr>
		<td colspan="2">
		Search Results
		</td>
	</tr>
	<tr>
		<td>
		Discussion Message Name- Link to Discussion Message
		</td>
		<td>
		Discussion ID
		</td>
	</tr>
	<%
	for (int i = 0; i < discussionMessages.Length; i++)
	{
		Plumtree.Remote.PRC.Collaboration.Discussion.IDiscussionMessage discussionMessage = discussionMessages[i];
		int id = discussionMessage.ID;
		String name = discussionMessage.Subject;
		String url = discussionMessage.DetailsURL;
		%>
		<tr>
			<td>
			<%Response.Write("<a href=\"" + url + "\">" + name + "</a>");%>
			</td>
			<td>
			<%Response.Write(id);%>
			</td>
		</tr>
		<%
	}
}
else
{
	Response.Write("No discussion messages found.");
}
...

.NET (VB)

...

'get the project ID out of session- this should never be Nothing as it is added in the page load event
dim project as Plumtree.Remote.PRC.Collaboration.Project.IProject = CType(Session.Item(SESSION_PROJECT_KEY),Plumtree.Remote.PRC.Collaboration.Project.IProject)

'perform the search
dim discussionManager as Plumtree.Remote.PRC.Collaboration.Discussion.IDiscussionManager = GetDiscussionManager(Request, Response)
dim discussionMessageFilter as Plumtree.Remote.PRC.Collaboration.Discussion.IDiscussionMessageFilter = discussionManager.CreateDiscussionMessageFilter()

//disable security checking on the returned objects against the user who performs this query,
//so that all objects will be returned
messageFilter.RestoreSecurity = false

'hard-code the max results to 10; setting to 0 will return all messages
discussionMessageFilter.MaximumResults = 10

//search for ALL messages; other options include searching for Approved, or Unapproved messages
messageFilter.MessageStatusType = DiscussionMessageStatusFilterTypes.All

'optionally, set the query orders
'example below sorts returned messages by CREATED date in descending order
DiscussionMessageQueryOrder messageQueryOrder = new DiscussionMessageQueryOrder(DiscussionMessageAttributes.Created, false)
messageFilter.setQueryOrders(new DiscussionMessageQueryOrder(messageQueryOrder))
 
'execute the search and print out the results
dim discussionMessages() as Plumtree.Remote.PRC.Collaboration.Discussion.IDiscussionMessage
= discussionManager.QueryDiscussionMessages(project, discussionMessageFilter)
if discussionMessages.Length > 0 then
	%>
	<tr>
		<td colspan="2">
		Search Results
		</td>
	</tr>
	<tr>
		<td>
		Discussion Message Name- Link to Discussion Message
		</td>
		<td>
		Discussion Message ID
		</td>
	</tr>
	<%
	dim i as Integer
	for i = 0 to discussionMessages.Length -1
		dim discussionMessage as Plumtree.Remote.PRC.Collaboration.Discussion.IDiscussionMessage = discussionMessages(i)
		dim id as Integer = discussionMessage.ID
		dim name as String = discussionMessage.Subject
		dim url as String = discussionMessage.DetailsURL
		%>
		<tr>
			<td>
			<%Response.Write("<a href=""" & url & """>" & name & "</a>") %>
			</td>
			<td>
			<%Response.Write(CStr(id)) %>
			</td>
		</tr>
		<%
	next
else
	Response.Write("No discussion messages found.")
end if
...

  Back to Top      Previous Next