PageIterator (Paging) (FileNet Content Engine API)
Provides paging functionality for sets of independent objects and repository rows.
Sets of independent objects and repository rows are divided into pages;each page is a number of collection elements (objects or rows) that represent a subset of the collection elements. You can iterate a page at a time instead of one object or row at a time.
As an example, if a page is defined as 10 elements, and the collection has a total of 22 elements, the first paging operation returns a page containing 10 elements, the second page returns the next 10 elements, and the third page returns the last 2 elements. This page iteration is especially useful for interactive applications that display a page of information at a time.
//Searching Documents with Paging concept in FileNet Content Engine
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ClassDescriptionSet;
import com.filenet.api.collection.DocumentSet;
import com.filenet.api.collection.PageIterator;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Document;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.meta.ClassDescription;
import com.filenet.api.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.util.UserContext;
public class ceUtil {
public static void main(String[] args) {
ceUtil obj = new ceUtil();
obj.FetchCEObjects(obj.getCEConnection());
}
public Connection getCEConnection() {
Connection conn = null;
try {
String ceURI = "http://localhost:9080/wsi/FNCEWS40MTOM/";
String userName = "username";
String password = "password!";
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName,
password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
} catch (Exception e1) {
e1.printStackTrace();
}
System.out.println("CE Connection" + conn);
return conn;
}
public void FetchCEDocs(Connection conn) {
try {
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain,"OS NAME", null);
String folder= "/TestEform";
SearchScope search = new SearchScope(objStore);
String sql1 = "Select * from docClass where Creator='p8admin'";
SearchSQL searchSQL= new SearchSQL(sql1);
DocumentSet documents = (DocumentSet) search.fetchObjects(searchSQL,Integer.valueOf("50"),null, Boolean.valueOf(true));
//Without Paging Concept
Document doc;
Iterator DocIt= documents.iterator();
while (DocIt.hasNext())
{
doc = (Document)DocIt.next();
System.out.println("document="+doc.get_Name());
}
// With Paging Concept
PageIterator pageIter= documents.pageIterator();
pageIter.getPageSize();pageIter.setPageSize(5);
int pageCount= 0;
while (pageIter.nextPage() == true)
{
pageCount++;
int elementCount= pageIter.getElementCount();
System.out.println("Element Count = "+elementCount);
Object[] pageObjects= pageIter.getCurrentPage();
for (int index=0; index<pageObjects.length;index++)
{
Document document = (Document)pageObjects[index];
System.out.println("document= "+ document.get_Name());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Provides paging functionality for sets of independent objects and repository rows.
Sets of independent objects and repository rows are divided into pages;each page is a number of collection elements (objects or rows) that represent a subset of the collection elements. You can iterate a page at a time instead of one object or row at a time.
As an example, if a page is defined as 10 elements, and the collection has a total of 22 elements, the first paging operation returns a page containing 10 elements, the second page returns the next 10 elements, and the third page returns the last 2 elements. This page iteration is especially useful for interactive applications that display a page of information at a time.
//Searching Documents with Paging concept in FileNet Content Engine
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ClassDescriptionSet;
import com.filenet.api.collection.DocumentSet;
import com.filenet.api.collection.PageIterator;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Document;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.meta.ClassDescription;
import com.filenet.api.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.util.UserContext;
public class ceUtil {
public static void main(String[] args) {
ceUtil obj = new ceUtil();
obj.FetchCEObjects(obj.getCEConnection());
}
public Connection getCEConnection() {
Connection conn = null;
try {
String ceURI = "http://localhost:9080/wsi/FNCEWS40MTOM/";
String userName = "username";
String password = "password!";
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName,
password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
} catch (Exception e1) {
e1.printStackTrace();
}
System.out.println("CE Connection" + conn);
return conn;
}
public void FetchCEDocs(Connection conn) {
try {
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain,"OS NAME", null);
String folder= "/TestEform";
SearchScope search = new SearchScope(objStore);
String sql1 = "Select * from docClass where Creator='p8admin'";
SearchSQL searchSQL= new SearchSQL(sql1);
DocumentSet documents = (DocumentSet) search.fetchObjects(searchSQL,Integer.valueOf("50"),null, Boolean.valueOf(true));
//Without Paging Concept
Document doc;
Iterator DocIt= documents.iterator();
while (DocIt.hasNext())
{
doc = (Document)DocIt.next();
System.out.println("document="+doc.get_Name());
}
// With Paging Concept
PageIterator pageIter= documents.pageIterator();
pageIter.getPageSize();pageIter.setPageSize(5);
int pageCount= 0;
while (pageIter.nextPage() == true)
{
pageCount++;
int elementCount= pageIter.getElementCount();
System.out.println("Element Count = "+elementCount);
Object[] pageObjects= pageIter.getCurrentPage();
for (int index=0; index<pageObjects.length;index++)
{
Document document = (Document)pageObjects[index];
System.out.println("document= "+ document.get_Name());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment