Search CE Object using SearchSQL (Content Engine API)
package createdoc_api;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ContentElementList;
import com.filenet.api.collection.RepositoryRowSet;
import com.filenet.api.constants.AutoClassify;
import com.filenet.api.constants.AutoUniqueName;
import com.filenet.api.constants.CheckinType;
import com.filenet.api.constants.ClassNames;
import com.filenet.api.constants.DefineSecurityParentage;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.core.Connection;
import com.filenet.api.core.ContentTransfer;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Document;
import com.filenet.api.core.Factory;
import com.filenet.api.core.Folder;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.core.ReferentialContainmentRelationship;
import com.filenet.api.property.Properties;
import com.filenet.api.query.RepositoryRow;
import com.filenet.api.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.util.Id;
import com.filenet.api.util.UserContext;
public class sql_query {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
String uri = "http://ecmdemo1.ecm.ibm.local:9080/wsi/FNCEWS40MTOM/";
String username = "P8admin";
String password = "filenet";
String v_id = null;
// Make connection.
Connection conn = Factory.Connection.getConnection(uri);
Subject subject = UserContext.createSubject(conn, username, password, null);
UserContext.get().pushSubject(subject);
try
{
// Get default domain.
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
System.out.println("Domain: " + domain.get_Name());
// Get object stores for domain.
// ObjectStoreSet osSet = domain.get_ObjectStores();
/// ObjectStore store;
//Iterator osIter = osSet.iterator();
//while (osIter.hasNext())
///{
// store = (ObjectStore) osIter.next();
// System.out.println("Object store: " + store.get_Name());
// }
System.out.println("Connection to Content Platform Engine successful");
// Create a document instance.
ObjectStore os = Factory.ObjectStore.getInstance(domain, "CMTOS");
String searchQ = "SELECT ID FROM CmAcmCaseFolder WHERE LP_ID_link = 2";
SearchSQL sqlObject = new SearchSQL(searchQ);
SearchScope searchScope = new SearchScope(os);
// Execute the fetchRows method using the specified parameters.
RepositoryRowSet myRows = searchScope.fetchRows(sqlObject, null, null, new Boolean(true));
// You can then iterate through the collection of rows to access the properties.
int rowCount = 0;
Iterator iter = myRows.iterator();
while (iter.hasNext())
{
RepositoryRow row = (RepositoryRow) iter.next();
// String docTitle = row.getProperties().get("DocumentTitle").getStringValue();
Id docId = row.getProperties().get("Id").getIdValue();
v_id=docId.toString();
rowCount++;
System.out.print(" row " + rowCount + ":");
System.out.print(" Id=" + docId.toString());
//if (docTitle != null)
//{
// System.out.print(" DocumentTitle=" + docTitle);
// }
// System.out.println();
}
}
finally
{
UserContext.get().popSubject();
}
System.out.println("a"+ v_id);
}
}
Không có nhận xét nào:
Đăng nhận xét