简体   繁体   中英

Fetch absolute or relative path using file object in IBM filenet

String mySQLString = "select * from document where documentTitle like '%test%' ";
SearchSQL sql = new SearchSQL(mySQLString);
IndependentObjectSet s = search.fetchObjects(sql, 10, null, true);
Document doc;
PageIterator iterator = s.pageIterator();
iterator.nextPage();

for (Object object : iterator.getCurrentPage()) {
    doc = (Document) object;
    Properties properties = doc.getProperties();
    //I am trying to get an absolute or relative path here for every document.
    // for eg: /objectstorename/foldername/filename like this.
}

I have tried searching propeties and class descriptions in document . but can't able to find the path. ?

I suggest you explore the "Creating DynamicReferentialContainmentRelationship Objects" section of FileNet documentation:

https://www.ibm.com/support/knowledgecenter/SSNW2F_5.5.0/com.ibm.p8.ce.dev.ce.doc/containment_procedures.htm#containment_procedures__fldr_creating_a_drcr

A FileNet Ddocument can be assigned to multiple Folders, so you can have several logical "Paths" for a given document.

At end, you should get something like "Folder.get_PathName() + DynamicReferentialContainmentRelationship.get_Name()" to display the full pathname.

As described by samples in FileNet documentation, a relationship object (eg DynamicReferentialContainmentRelationship) controls the relation of document/folder:

myRelationshipObject.set_Head(myDocument);

myRelationshipObject.set_Tail(myFolder);

Also, keep in mind that a FileNet Document can be also a "unfiled" document, so there is no actual "pathname" or folder "relationship" to be retrieved.

To do it all in one single query (as you are trying to do in your code) you can create a join with the ReferentialContainmentRelationship table. The property Head of this table points to the document, the property Tail points to the folder the document is filled in and the property ContainmentName is the name the document has in the folder. Use the following code to construct the document path:

SearchSQL searchSQL = new SearchSQL("SELECT R.ContainmentName, R.Tail, D.This FROM Document AS D WITH INCLUDESUBCLASSES INNER JOIN ReferentialContainmentRelationship AS R WITH INCLUDESUBCLASSES ON D.This = R.Head WHERE DocumentTitle like '%test%'");
SearchScope searchScope = new SearchScope(objectStore);
RepositoryRowSet objects = searchScope.fetchRows(searchSQL, null, null, null);
Iterator<RepositoryRow> iterator = objects.iterator();

while (iterator.hasNext()) {
    RepositoryRow repositoryRow = iterator.next();
    Properties properties = repositoryRow.getProperties();
    Folder folder = (Folder) properties.get("Tail").getEngineObjectValue();
    String containmentName = properties.get("ContainmentName").getStringValue();

    System.out.println(folder.get_PathName() + "/" + containmentName);
}

Paths constructed this way can also be used to fetch the object from the object store. The query code can be optimized by using a property filter as the third argument of the fetchRows() method. Don't know how this behaves if the document is filed in multiple folders.

tl;dr from FileNet Content Engine - Database Table for Physical path

Documents are stored among the directories at the leaf level using a hashing algorithm to evenly distribute files among these leaf directories.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM