0

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

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

但我喜欢添加更多查找选项,以便我可以获取 Document with name 或 custom property 。我正在尝试这种搜索作为一种方法:

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 获取pathorid并获取此文档?有没有快速的方法?

4

2 回答 2

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

    }

现在只需进行少量更改,就可以使用它来获取任何具有属性的文档。

于 2014-10-30T12:00:53.747 回答
-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;
        }
    }
}
于 2017-08-29T19:04:13.650 回答