【问题标题】:Fetch a Filenet document with Properties获取具有属性的 Filenet 文档
【发布时间】:2014-10-30 10:57:21
【问题描述】:

我正在尝试做一个处理 Filenet 文档的测试程序。我知道如何获取带有Object Idpath 之类的文档实例,

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

但我喜欢添加更多查找选项,以便获取, 具有名称或自定义属性的文档。我正在尝试这种搜索作为一种方法:

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);

但 ID 不是 Document 属性,它是 System 属性。我怎样才能得到文件?如何通过 Search 获取 pathid 并获取此文档?有没有快速的方法?

【问题讨论】:

    标签: java filenet-p8 filenet filenet-content-engine


    【解决方案1】:

    经过一些小改动后,我让它工作了。以下是代码

        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);
    
        }
    

    现在只需进行少量更改,即可用于获取任何具有属性的文档。

    【讨论】:

    • 请注意,还有 searchScope.fetchObjects,它会立即为您提供 Document 对象。将它与“select *”结合使用以填充文档的属性。这减少了对额外 fetchInstance(往返)的需求
    【解决方案2】:

    您可以遍历所有文档。看看这个:

    public void iterateThruAllDocs(ObjectStore os, String foldername) {
        Folder folder = Factory.Folder.fetchInstance(os, foldername, null);
        Document doc = Factory.Document.getInstance(os, null, foldername);
    
        DocumentSet docset = folder.get_ContainedDocuments();
        Iterator<DocumentSet> docitr = docset.iterator();
    
        while (docitr.hasNext()) {
    
            doc = (Document) docitr.next();
            String mydocid = doc.get_Id().toString();
            Document mydoc = Factory.Document.fetchInstance(os, mydocid, null);
            AccessPermissionList apl = mydoc.get_Permissions();
            Iterator ite = apl.iterator();
            while (ite.hasNext()) {
                Properties documentProperties = doc.getProperties();
                String DateCreated = documentProperties.getDateTimeValue("DateCreated").toString();
                String DateLastModified = documentProperties.getDateTimeValue("DateLastModified").toString();
                Permission permission = (Permission) ite.next();
                String docTitle = doc.getProperties().getStringValue("DocumentTitle");
                System.out.println("Document Title for document with DocumentID \"" + mydoc.get_Id() + "\" is \"" + docTitle + "\"");
                //String someprop = documentProperties.getStringValue("someprop");
                System.out.println("Document was Created on  :: " + DateCreated);
                System.out.println("Document was Last Modified on :: " + DateLastModified);
                System.out.println("Grantee Name :: " + permission.get_GranteeName());
                //if (permission.get_GranteeName().equals(groupname/username)) {
                //permission.set_GranteeName("groupname/username");
                //  System.out.println("Security REMOVED for document....");
                //mydoc.save(RefreshMode.REFRESH);
                // Go Nuts on Documents Here......
                break;
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-07
      • 1970-01-01
      • 1970-01-01
      • 2017-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多