FileNet:FileNet 文件夹中的文档总数
FileNet: Count of total documents in a FileNet Folder
我正在处理一个 FileNet 项目,我需要在该项目中显示名为 Others 的文件夹中的文档数。我可以通过 CE API 轻松完成,但我需要知道此信息存储在 FileNet DB 中的何处。
我可以从名为 DocVersion
的 table 获取文档计数,文件夹信息存储在 Container
table。我需要的是这样的查询:
SELECT COUNT(*) FROM DOCVERSION D, CONTAINER C WHERE --container name is 'Others'
非常感谢任何帮助。
我没有在应用程序中尝试过代码,但它会像..
SELECT count (*) as Row_Count
FROM Container c, DocVersion d
WHERE c.object_id = d.object_class_id
AND c.name = 'Others'
希望这对您的想法有所帮助。
你是对的。文档放在 DocVersion 中,文件夹放在 Container table 中。但是 link 文档和文件夹之间的关系 table.
如果你使用 FileNet API 你可以尝试使用下一个 FN 查询
Select d.Id from Document d
where d.This INFOLDER '/bla/bla/bla'
或 INSUBFOLDER
运算符。在下一步中,您将需要计算结果集。
如果想直接从数据库中获取信息,可以尝试使用下一个查询。
select count(r.Object_Id) from DocVersion d, Container c, Relationship r
where r.Head_Id = c.Object_Id
and d.Object_Id = r.Tail_Id --// you can exclude this if in the Folder filed only documents and not custom objects.
and c.Object_Id = {folder-id} --// or use c.Name = 'Other' - you can't use PathName field in DB query.
这些是获取特定文件夹中文档总数的正确查询...
db2 "select count(*) from OSDBUSER.Relationship r, OSDBUSER.Container c, OSDBUSER.DOCVERSION d where r.Tail_Id = c.Object_Id and r.Head_Id = d.Object_Id and c.name = 'Error'"
在此查询中,'Error' 是用于统计文档的文件夹的名称....
感谢您的咨询,我已经试过了。您的查询中存在一个问题。您在错误的方向上使用了 head_id 和 tail_id。正确的查询应该如下所示。
select count(r.Object_Id)
from DocVersion d, Container c, Relationship r
where r.Tail_Id = c.Object_Id and d.Object_Id = r.Head_Id --// you can exclude this if in the Folder filed only documents and not custom objects.
and c.Object_Id = {folder-id} --// or use c.Name = 'Other' - you can't use PathName field in DB query.
这里有一些直接数据库查询(不是ACCE/FEM SQL)查找未归档文档的更多示例,但可以更改为查找特定文件夹中归档的对象。 (将 where rel.Head_id IS NULL
更改为您的文件夹)
已在 MS SQL 上测试并 运行。
--Count by Doc Class
SELECT Doc.object_class_id, count(distinct Doc.version_series_id) as '# Docs' , ClassDef.symbolic_name as ClassName
FROM DocVersion doc
LEFT JOIN Relationship rel ON doc.object_id = rel.Head_id
INNER JOIN ClassDefinition ClassDef ON doc.object_class_id = ClassDef.[object_id]
where rel.Head_id IS NULL and doc.is_current=1
group by Doc.object_class_id, ClassDef.symbolic_name
order by '# Docs' desc
--by creator
SELECT Doc.creator, count(distinct Doc.version_series_id) as '# Docs'
FROM DocVersion doc
LEFT JOIN Relationship rel ON doc.object_id = rel.Head_id
where rel.Head_id IS NULL and doc.is_current=1
group by Doc.creator
order by '# Docs' desc
--list Of Docs
SELECT Doc.creator, doc.create_date, doc.u32_documenttitle , doc.modify_date ,doc.modify_user , ClassDef.symbolic_name as ClassName
FROM DocVersion doc
LEFT JOIN Relationship rel ON doc.object_id = rel.Head_id
INNER JOIN ClassDefinition ClassDef ON doc.object_class_id = ClassDef.[object_id]
where rel.Head_id IS NULL and doc.is_current=1
order by Doc.create_date
希望对您有所帮助。
public void countobjectsinAllOS() {
Connection conn = Factory.Connection.getConnection(ConfigInfo.CE_URI);
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
Iterator<ObjectStoreSet> it = domain.get_ObjectStores().iterator();
int countofos = 0;
while (it.hasNext()) {
ObjectStore os = (ObjectStore)it.next();
String osname = os.get_DisplayName();
System.out.println("Working on Object Store " +osname);
countofos++;
countObjectsInAnOS(osname);
}
System.out.println("\n\n");
//System.out.println("Number of Object Stores found in doamin >>\t" + domain.get_Name() + "\t<< is " + countofos);
}
public void countObjectsInAnOS(String OSName) {
Connection conn = Factory.Connection.getConnection(ConfigInfo.CE_URI);
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, OSName, null);
// Create a SearchSQL instance and specify the SQL statement (using the
// helper methods).
SearchSQL sqlObject = new SearchSQL();
sqlObject.setSelectList("*");
//sqlObject.setMaxRecords(10);
sqlObject.setWhereClause("f.This INSUBFOLDER '/'");
sqlObject.setFromClauseInitialValue("Folder", "f", false);
domain.get_ObjectStores();
// Uncomment below lines for Documents
// sqlObject.setSelectList("d.DocumentTitle, d.Id");
// sqlObject.setMaxRecords(20);
// sqlObject.setFromClauseInitialValue("Document", "d", false);
// Check the SQL statement.
//Uncomment to see the SQL
//System.out.println("SQL: " + sqlObject.toString());
// Create a SearchScope instance. (Assumes you have the object store
// object.)
Boolean continuable = new Boolean(true);
// Set the page size (Long) to use for a page of query result data. This value is passed
// in the pageSize parameter. If null, this defaults to the value of
// ServerCacheConfiguration.QueryPageDefaultSize.
Integer myPageSize = new Integer(10);
// Specify a property filter to use for the filter parameter, if needed.
// This can be null if you are not filtering properties.
// PropertyFilter myFilter = new PropertyFilter();
// int myFilterLevel = 1;
// myFilter.setMaxRecursion(myFilterLevel);
// myFilter.addIncludeType(new FilterElement(null, null, null, FilteredPropertyType.ANY, null));
// Set the (Boolean) value for the continuable parameter. This indicates
// whether to iterate requests for subsequent pages of result data when the end of the
// first page of results is reached. If null or false, only a single page of results is
// returned.
// Execute the fetchObjects method using the specified parameters.
//IndependentObjectSet myObjects = search.fetchObjects(sqlObject, myPageSize, myFilter, continuable);
SearchScope searchScope = new SearchScope(os);
RepositoryRowSet rowSet = searchScope.fetchRows(sqlObject, myPageSize, null, continuable);
long count = 0;
Iterator<RepositoryRow> it = rowSet.iterator();
while (it.hasNext()) {
it.next();
count++;
}
//System.out.println("Total number of Documents >>\t\t" + count + "\n\n");
System.out.println("Total number of Folders >>\t\t" + count + "\n\n");
}
我正在处理一个 FileNet 项目,我需要在该项目中显示名为 Others 的文件夹中的文档数。我可以通过 CE API 轻松完成,但我需要知道此信息存储在 FileNet DB 中的何处。
我可以从名为 DocVersion
的 table 获取文档计数,文件夹信息存储在 Container
table。我需要的是这样的查询:
SELECT COUNT(*) FROM DOCVERSION D, CONTAINER C WHERE --container name is 'Others'
非常感谢任何帮助。
我没有在应用程序中尝试过代码,但它会像..
SELECT count (*) as Row_Count
FROM Container c, DocVersion d
WHERE c.object_id = d.object_class_id
AND c.name = 'Others'
希望这对您的想法有所帮助。
你是对的。文档放在 DocVersion 中,文件夹放在 Container table 中。但是 link 文档和文件夹之间的关系 table.
如果你使用 FileNet API 你可以尝试使用下一个 FN 查询
Select d.Id from Document d
where d.This INFOLDER '/bla/bla/bla'
或 INSUBFOLDER
运算符。在下一步中,您将需要计算结果集。
如果想直接从数据库中获取信息,可以尝试使用下一个查询。
select count(r.Object_Id) from DocVersion d, Container c, Relationship r
where r.Head_Id = c.Object_Id
and d.Object_Id = r.Tail_Id --// you can exclude this if in the Folder filed only documents and not custom objects.
and c.Object_Id = {folder-id} --// or use c.Name = 'Other' - you can't use PathName field in DB query.
这些是获取特定文件夹中文档总数的正确查询...
db2 "select count(*) from OSDBUSER.Relationship r, OSDBUSER.Container c, OSDBUSER.DOCVERSION d where r.Tail_Id = c.Object_Id and r.Head_Id = d.Object_Id and c.name = 'Error'"
在此查询中,'Error' 是用于统计文档的文件夹的名称....
感谢您的咨询,我已经试过了。您的查询中存在一个问题。您在错误的方向上使用了 head_id 和 tail_id。正确的查询应该如下所示。
select count(r.Object_Id)
from DocVersion d, Container c, Relationship r
where r.Tail_Id = c.Object_Id and d.Object_Id = r.Head_Id --// you can exclude this if in the Folder filed only documents and not custom objects.
and c.Object_Id = {folder-id} --// or use c.Name = 'Other' - you can't use PathName field in DB query.
这里有一些直接数据库查询(不是ACCE/FEM SQL)查找未归档文档的更多示例,但可以更改为查找特定文件夹中归档的对象。 (将 where rel.Head_id IS NULL
更改为您的文件夹)
已在 MS SQL 上测试并 运行。
--Count by Doc Class
SELECT Doc.object_class_id, count(distinct Doc.version_series_id) as '# Docs' , ClassDef.symbolic_name as ClassName
FROM DocVersion doc
LEFT JOIN Relationship rel ON doc.object_id = rel.Head_id
INNER JOIN ClassDefinition ClassDef ON doc.object_class_id = ClassDef.[object_id]
where rel.Head_id IS NULL and doc.is_current=1
group by Doc.object_class_id, ClassDef.symbolic_name
order by '# Docs' desc
--by creator
SELECT Doc.creator, count(distinct Doc.version_series_id) as '# Docs'
FROM DocVersion doc
LEFT JOIN Relationship rel ON doc.object_id = rel.Head_id
where rel.Head_id IS NULL and doc.is_current=1
group by Doc.creator
order by '# Docs' desc
--list Of Docs
SELECT Doc.creator, doc.create_date, doc.u32_documenttitle , doc.modify_date ,doc.modify_user , ClassDef.symbolic_name as ClassName
FROM DocVersion doc
LEFT JOIN Relationship rel ON doc.object_id = rel.Head_id
INNER JOIN ClassDefinition ClassDef ON doc.object_class_id = ClassDef.[object_id]
where rel.Head_id IS NULL and doc.is_current=1
order by Doc.create_date
希望对您有所帮助。
public void countobjectsinAllOS() {
Connection conn = Factory.Connection.getConnection(ConfigInfo.CE_URI);
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
Iterator<ObjectStoreSet> it = domain.get_ObjectStores().iterator();
int countofos = 0;
while (it.hasNext()) {
ObjectStore os = (ObjectStore)it.next();
String osname = os.get_DisplayName();
System.out.println("Working on Object Store " +osname);
countofos++;
countObjectsInAnOS(osname);
}
System.out.println("\n\n");
//System.out.println("Number of Object Stores found in doamin >>\t" + domain.get_Name() + "\t<< is " + countofos);
}
public void countObjectsInAnOS(String OSName) {
Connection conn = Factory.Connection.getConnection(ConfigInfo.CE_URI);
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, OSName, null);
// Create a SearchSQL instance and specify the SQL statement (using the
// helper methods).
SearchSQL sqlObject = new SearchSQL();
sqlObject.setSelectList("*");
//sqlObject.setMaxRecords(10);
sqlObject.setWhereClause("f.This INSUBFOLDER '/'");
sqlObject.setFromClauseInitialValue("Folder", "f", false);
domain.get_ObjectStores();
// Uncomment below lines for Documents
// sqlObject.setSelectList("d.DocumentTitle, d.Id");
// sqlObject.setMaxRecords(20);
// sqlObject.setFromClauseInitialValue("Document", "d", false);
// Check the SQL statement.
//Uncomment to see the SQL
//System.out.println("SQL: " + sqlObject.toString());
// Create a SearchScope instance. (Assumes you have the object store
// object.)
Boolean continuable = new Boolean(true);
// Set the page size (Long) to use for a page of query result data. This value is passed
// in the pageSize parameter. If null, this defaults to the value of
// ServerCacheConfiguration.QueryPageDefaultSize.
Integer myPageSize = new Integer(10);
// Specify a property filter to use for the filter parameter, if needed.
// This can be null if you are not filtering properties.
// PropertyFilter myFilter = new PropertyFilter();
// int myFilterLevel = 1;
// myFilter.setMaxRecursion(myFilterLevel);
// myFilter.addIncludeType(new FilterElement(null, null, null, FilteredPropertyType.ANY, null));
// Set the (Boolean) value for the continuable parameter. This indicates
// whether to iterate requests for subsequent pages of result data when the end of the
// first page of results is reached. If null or false, only a single page of results is
// returned.
// Execute the fetchObjects method using the specified parameters.
//IndependentObjectSet myObjects = search.fetchObjects(sqlObject, myPageSize, myFilter, continuable);
SearchScope searchScope = new SearchScope(os);
RepositoryRowSet rowSet = searchScope.fetchRows(sqlObject, myPageSize, null, continuable);
long count = 0;
Iterator<RepositoryRow> it = rowSet.iterator();
while (it.hasNext()) {
it.next();
count++;
}
//System.out.println("Total number of Documents >>\t\t" + count + "\n\n");
System.out.println("Total number of Folders >>\t\t" + count + "\n\n");
}