Получить документ Filenet со свойствами
Я пытаюсь заключить тестовую программу с документами Filenet. Я знаю, как получить экземпляр документа с Object Id
или же path
лайк,
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. Как я могу получить документ? Как я могу получить path
или же id
с поиском и получить этот документ? Есть ли быстрый способ?
2 ответа
Решение
После нескольких небольших изменений я заставил это работать. Ниже приведен код
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);
}
теперь с небольшими изменениями это можно использовать для получения любого документа со свойством.
Вы можете перебирать все документы. Взгляните на это:
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;
}
}
}