3

I had gotten the code to work to search for folders and retrieve properties. Ref: Search folder hierarchy in FileNet for a particular folder

I am trying to retrieve the class name of the folder object so as to differentiate between different types of docs that will get stored in custom folders.

I iterated thru the Properties collection, but the name of the class isn't a property.

String sqlStatement = "SELECT * FROM [Folder] WHERE ([FolderName] LIKE '%MyFolder%')";
SearchSQL sqlObject = new SearchSQL(sqlStatement);
RepositoryRowSet rowSet = searchScope.fetchRows(sqlObject, null, null, new Boolean(true));
Iterator iter = myRows.iterator();
while (iter.hasNext()) {
    RepositoryRow row = (RepositoryRow) iter.next();
    String folderID = row.getProperties().getIdValue("ID").toString();
}

I tried row.getClass() but that just returns: RepositoryRowImpl

Hussain Akbar
  • 646
  • 8
  • 25
  • From any object, we write obj.getClass().getName() provides class name, in this case, what are you expecting ? Are you expecting a Folder object and its class name ? – Sambit May 19 '19 at 18:27
  • Yes, I was expecting "Folder" or "MyCustomFolder" as the name. – Hussain Akbar May 21 '19 at 11:04

1 Answers1

6

If you use the * in your SELECT clause then the repository row object will contain all the properties of the object. This will also include a property called This. This property is a reference to the object that is returned. Therefore you can use the following code to fetch the class of the folder:

EngineObject eo = row.getProperties().getEngineObjectValue("This");
String className = eo.getClassName();

Instead of the * you can also explicitly select This. In that case your query will be like this:

String sqlStatement = "SELECT This,Id FROM [Folder] WHERE ([FolderName] LIKE '%MyFolder%')";

This will limit the amount of data that is fetched from the server.

Ricardo
  • 401
  • 3
  • 4
  • Ofcourse. Agreed. I only use * during testing. I tried this: ClassDescription objClassDesc = (ClassDescription) rrRow.getProperties().getObjectValue("ClassDescription"); String className = objClassDesc.get_Name(); This also gives me the expected class name of the folder. Which is the recommended / faster method? – Hussain Akbar May 21 '19 at 11:05
  • 1
    The Class Description is in another table then the Folder object. So this gives you a overhead from a query perspective. Besides the name of the class, the Class Description object comes filed with a lot of other information your are not interested in, giving you an overhead from the data perspective. – Ricardo May 23 '19 at 05:41
  • BTW, I tried accessing DB/2 databases directly using the CLI. Can't find this, or any other table. Where are the tables in DB/2? – Hussain Akbar May 26 '19 at 17:42
  • @Ricardo That does not mean there is no additional round-trip associated with `getEngineObjectValue("This")`. I am pretty sure there is. But this should be specifically examined. Unfortunately, CE API makes a lot of implicit round-trips behind the scene. – ᄂ ᄀ Jul 03 '19 at 19:28