To query for documents in the ALI Knowledge Directory from a remote application, use the IDocumentManager interface in the IDK.
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