IBM FileNet P8, Version 5.2.1            

Querying for Tagged Documents

The following Java™ and C# examples query for all documents that have a specified tag. The code prints document and tag property values from the result set.

Java Example

// Create a SearchSQL instance and specify the SQL statement (using the helper methods).
SearchSQL sqlObject = new SearchSQL();
sqlObject.setSelectList("T1.DocumentTitle, T2.ClbDocumentMajorVersion, T2.ClbDocumentMinorVersion, T2.ClbTagValue");
sqlObject.setFromClauseInitialValue("Document", "T1", true); // include subclasses
sqlObject.setFromClauseAdditionalJoin(JoinOperator.INNER, "ClbTag","T2", "T1.VersionSeries",
   JoinComparison.EQUAL,"T2.ClbTaggedVersionSeries", false);
sqlObject.setWhereClause("T2.ClbTagValue='loantemplate'");
sqlObject.setDistinct(); // suppress redundant rows
        
// Create a SearchScope instance. (Assumes you have the object store object.)
SearchScope search = new SearchScope(os);

// Execute the fetchRows method using the specified parameters.
Boolean continuable = new Boolean(true);
RepositoryRowSet myRows = search.fetchRows(sqlObject, null, null, continuable);

// Iterate the collection of rows to access the properties.
Iterator iter = myRows.iterator();
while (iter.hasNext()) 
{
    RepositoryRow row = (RepositoryRow) iter.next();
    // Print properties from the result set.
    System.out.print("\nDocumentTitle: " + row.getProperties().get("DocumentTitle").getStringValue() +
        "\nTag Value: " + row.getProperties().get("ClbTagValue").getStringValue() +
        "\nMajorVersion: " + row.getProperties().get("ClbDocumentMajorVersion").getInteger32Value() +
        "\nMinorVersion: " + row.getProperties().get("ClbDocumentMinorVersion").getInteger32Value() );
}

C# Example

// Create a SearchSQL instance and specify the SQL statement (using the helper methods).
SearchSQL sqlObject = new SearchSQL();
sqlObject.SetSelectList("T1.DocumentTitle, T2.ClbDocumentMajorVersion, T2.ClbDocumentMinorVersion, T2.ClbTagValue");
sqlObject.SetFromClauseInitialValue("Document", "T1", true); // include subclasses
sqlObject.SetFromClauseAdditionalJoin(JoinOperator.INNER, "ClbTag","T2", "T1.VersionSeries",
   JoinComparison.EQUAL,"T2.ClbTaggedVersionSeries", false);
sqlObject.SetWhereClause("T2.ClbTagValue='loantemplate'");
sqlObject.SetDistinct(); // suppress redundant rows

// Create a SearchScope instance. (Assumes you have the object store object.)
SearchScope search = new SearchScope(os);

// Execute the fetchRows method using the specified parameters.
bool continuable = true;
IRepositoryRowSet myRows = search.FetchRows(sqlObject, null, null, continuable);

// Iterate the collection of rows to access the properties.
foreach(IRepositoryRow row in myRows)
{
     // Print properties from the result set.
     System.Console.WriteLine("\nDocumentTitle: " + row.Properties.GetProperty("DocumentTitle").GetStringValue() +
         "\nTag Value: " + row.Properties.GetProperty("ClbTagValue").GetStringValue() +
         "\nMajorVersion: " + row.Properties.GetProperty("ClbDocumentMajorVersion").GetInteger32Value() +
         "\nMinorVersion: " + row.Properties.GetProperty("ClbDocumentMinorVersion").GetInteger32Value() );
}


Last updated: October 2015
socialCollab_tags_snip2.htm

© Copyright IBM Corporation 2015.