Example of getting the total amount of document instances

Source: Internet
Author: User

When using the filenet API to obtain the total number of doucmnt instances, you must note that the root folder (/) is obtained, and whether the document in the unfileddocument is useful must be considered. For example, in a Zhy project, the document under unfileddocument is stored with the file management platform, but it stores the email attachments archived in notes. Simple query operations are as follows:Code(Note the use of pageiterator ).

 

Public int querytotal (ObjectStore OS, string doctype) {string SQL = "select ID from" + doctype + "d with includesubclasses where D. this insubfolder '/' "; searchsql = new searchsql (SQL); searchscope scope = new searchscope (OS); propertyfilter filter = new propertyfilter (); filterelement ele = new filterelement (null, "ID", null); filter. addincludeproperty (Ele); repositoryrowset rows = scope. fetchrows (searchsql, null, filter, null); iterator iter = rows. iterator (); int COUNT = 0; while (ITER. hasnext () {ITER. next (); count ++;} return count;} public int queryrangeamount (ObjectStore OS, string doctype, date startdate, date enddate) {string SQL = "select ID from" + doctype + "d with your desubclasses where (D. this insubfolder '/') and "+ propertynames. date_created + "> =" + dateformat (startdate) + "and" + propertynames. date_created + "<" + dateformat (enddate); searchsql = new searchsql (SQL); searchscope scope = new searchscope (OS); propertyfilter filter = new propertyfilter (); filterelement ele = new filterelement (null, "ID", null); filter. addincludeproperty (Ele); repositoryrowset rows = scope. fetchrows (searchsql, null, filter, null); iterator iter = rows. iterator (); int COUNT = 0; while (ITER. hasnext () {ITER. next (); count ++;} return count;} private string dateformat (date) {simpledateformat SDF = new simpledateformat ("yyyymmdd"); string datestr = SDF. format (date); SDF = new simpledateformat ("hhmmss"); datestr = datestr + "T" + SDF. format (date) + "Z"; return datestr;} public void testquerytotalbydoctype () {string SQL = "select ID from companydoc d with includesubclasses where D. this insubfolder '/' "; searchsql = new searchsql (SQL); searchscope scope = new searchscope (OS); propertyfilter filter = new propertyfilter (); filterelement ele = new filterelement (null, "ID", null); filter. addincludeproperty (Ele); repositoryrowset rows = scope. fetchrows (searchsql, 1000, filter, true); iterator iter = rows. iterator (); int COUNT = 0; pageiterator = rows. pageiterator (); While (pageiterator. nextpage () {COUNT = count + pageiterator. getelementcount ();} logger.info ("count is:" + count );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.