使用“属性”获取Filenet文档

时间:2014-10-30 10:57:22

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

我正在尝试与Filenet Documents进行测试程序处理。我知道如何获取包含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属性。我怎样才能获得该文件?如何通过搜索获取​​pathid并获取此文档?有快速的方法吗?

2 个答案:

答案 0 :(得分:0)

经过一些小小的改变,我已经成功了。以下是代码

 if (type=="name"){
    String mySQLString = "SELECT ID FROM Document 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.getIdValue("ID").toString();
            System.out.println(ID);
           // System.out.println(properties.getIdValue(prp));


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

    }

现在只需要很少的更改就可以用来获取任何带有属性的文档。

答案 1 :(得分:-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;
        }
    }
}