javafilenet-p8filenetfilenet-content-engine

Fetch a Filenet document with Properties


I'm trying to do a test program deal with Filenet Documents. I know how to get a document Instance with Object Id or path like ,

doc  =  Factory.Document.fetchInstance(os,ID,null);
doc  =  Factory.Document.fetchInstance(os,path,null);

but I like to add more finding options so I can fetch, Document with name or a custom property . I am trying out this search as a approach to that:

String mySQLString = "SELECT * FROM DEMO WHERE DocumentTitle LIKE '"+prp+"'";
    SearchSQL sqlObject = new SearchSQL();
    sqlObject.setQueryString(mySQLString);

   // System.out.println(mySQLString);
    SearchScope searchScope = new SearchScope(os);
    RepositoryRowSet rowSet = searchScope.fetchRows(sqlObject, null, null, new Boolean(true));
    Iterator ppg = rowSet.iterator();

    if (ppg.hasNext()) {

            RepositoryRow rr = (RepositoryRow) ppg.next();
            System.err.println(rr.getProperties());
            Properties properties = rr.getProperties();

            String ID = properties.getStringValue("ID");
            System.out.println(ID);

    doc  =  Factory.Document.fetchInstance(os,ID,null);

But ID is not a Document property , it's a System property. How can I get the document? How can I get the path or id with a Search and fetch this document ? Is there a fast way ?


Solution

  • After few little changes I have made it work. Following is the code

        String mySQLString = "SELECT ID FROM Document WHERE DocumentTitle LIKE '"+prp+"'";
        SearchSQL sqlObject = new SearchSQL();
        sqlObject.setQueryString(mySQLString);
    
        SearchScope searchScope = new SearchScope(os);
        RepositoryRowSet rowSet = searchScope.fetchRows(sqlObject, null, null, new Boolean(true));
        Iterator ppg = rowSet.iterator();
    
        if (ppg.hasNext()) {
    
                RepositoryRow rr = (RepositoryRow) ppg.next();
                System.err.println(rr.getProperties());
                Properties properties = rr.getProperties();
    
                String ID = properties.getIdValue("ID").toString();
                System.out.println(ID);                
    
                doc  =  Factory.Document.fetchInstance(os,ID,null);
    
        }
    

    now with few changes this can be use to get any document with property.