Oracle WebCenter Interaction Web Service Development Guide

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

Querying Documents in the Directory Using Oracle WebCenter Interaction Development Kit (IDK) Remote APIs

To query for documents in the portal Directory from a remote application, use the IDocumentManager interface in the Oracle WebCenter Interaction Development Kit (IDK).

To query for documents, follow the steps below. You can also query documents using the PRC Search API; for details, see Querying Objects Using the Oracle WebCenter Interaction Development Kit (IDK) Remote Search API.
  1. Create a session with the portal. For details, see Initiating a PRC Session to Use Oracle WebCenter Interaction Development Kit (IDK) Remote APIs.
  2. Retrieve an IDocumentManager object by calling IRemoteSession.getDocumentManager.
  3. Execute the query, as shown in the sample code below.
    1. Create a new method to print out information about new documents in a folder.
    2. Create a query within the specified folder. There are two ways to retrieve a KD folder ID: (1) Use the PRC search API to perform a search for document folder objects, or (2) Let the user select a folder by using a pt:treeLink tag with classID = 17. (There is no Object Manager for document folders.) For details on tags, see con_tags.html.
    3. Set up a query filter with the appropriate parameters.
    4. Execute the query.
    5. Loop through the results and print out document details.
This example demonstrates how to query for documents matching specific criteria (new documents) within a specific folder.

Java

public static void printNewDocumentDetails(IDocumentManager documentManager, int
folderID, int daysOld) throws PortalException, RemoteException
{
 IDocumentQuery documentQuery = documentManager.createQuery(folderID);

 // Set up a filter to query only documents up to the specified age
 GregorianCalendar createdAge = new GregorianCalendar();
 createdAge.add(Calendar.DATE, -daysOld);
 QueryFilter ageFilter = new DateQueryFilter(ObjectProperty.Created, Operator.GreaterThan, createdAge.getTime());
 documentQuery.setFilters(new QueryFilter[]{ageFilter});

 IObjectQuery queryResults = documentQuery.execute();

 for (int i = 0; i < queryResults.getRowCount(); i++)
 {
  IObjectQueryRow document = queryResults.getRow(i); 
  //Print out standard properties
  System.out.println("Document: " + document.getName());
  System.out.println("Created: " + document.getCreated());
  System.out.println("Description" + document.getDescription());
  //Print out a Document-specific property
  System.out.println("Located at URL: " + document.getStringValue(DocumentProperty.URL));
 }
}

.NET (C#)

public static void PrintNewDocumentDetails(IDocumentManager documentManager, int
folderID, int daysOld)
{
 IDocumentQuery documentQuery = documentManager.CreateQuery(folderID);

 // Set up a filter to query only documents up to the specified age
 DateTime createdAge = DateTime().AddDays(-daysOld);
 QueryFilter ageFilter = new DateQueryFilter(ObjectProperty.Created, Operator.GreaterThan, createdAge);
 documentQuery.SetFilters(new QueryFilter[]{ageFilter});

 IObjectQuery queryResults = documentQuery.Execute();

 for (int i = 0; i < queryResults.GetRowCount(); i++)
 {
  IObjectQueryRow document = queryResults.GetRow(i); 
  //Print out standard properties
  Console.WriteLine("Document: " + document.GetName());
  Console.WriteLine("Created: " + document.GetCreated());
  Console.WriteLine("Description" + document.GetDescription());
  //Print out a Document-specific property
  Console.WriteLine("Located at URL: " + document.GetStringValue(DocumentProperty.URL));
 }
}

.NET (VB)

Public Shared SubPrintNewDocumentDetails (ByVal documentManager As IDocumentManager,
ByVal folderID As Integer, ByVal daysOld As Integer)

 Dim documentQuery As IDocumentQuery = documentManager.CreateQuery(folderID)

 ' Set up a filter to query only documents up to the specified age
 Dim createdAge As DateTime = New DateTime().AddDays(-daysOld)
 Dim ageFilter As QueryFilter = New DateQueryFilter(ObjectProperty.Created, Operator.GreaterThan,createdAge)
 Dim ageFilters() As QueryFilter = {ageFilter} 'Put the filter into an array 

 documentQuery.SetFilters(ageFilters)

 Dim queryResults As IObjectQuery = documentQuery.Execute()
 Dim i As Integer

 For i = 0 To queryResults.GetRowCount -1 
Dim document As IObjectQueryRow = queryResults.GetRow(i)
'Print out standard properties 
Console.WriteLine("Document: " + document.GetName())
Console.WriteLine("Created: " + document.GetCreated())
Console.WriteLine("Description: " + document.GetDescription())
'Print out a Document-specific property
Console.WriteLine("Located at URL:"+ document.GetStringValue(DocumentProperty.URL))
 Next

EndSub

  Back to Top      Previous Next