How to retrieve all objects(WTpart,document,epm) from a Particular context?
I need to get all the objects including WTPart,WTDocument,EPMDocument from a particular context.Any give me some code or API for this to do.
Thanks
I need to get all the objects including WTPart,WTDocument,EPMDocument from a particular context.Any give me some code or API for this to do.
Thanks
HI Vigneshwaran,
Don't know whether It's a efficient way or not.But it works in `10.1
package ext.customization;
import wt.doc.WTDocument;
import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.part.WTPart;
import wt.pdmlink.PDMLinkProduct;
import wt.pds.StatementSpec;
import wt.query.CompositeQuerySpec;
import wt.query.QueryException;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.util.WTException;
public class ObjectFromContainer {
public static void main(String[] args) {
try{
CompositeQuerySpec cqs = new CompositeQuerySpec();
cqs.addComponent(statementspecGenerator(WTPart.class,"<product name>"));
cqs.addComponent(statementspecGenerator(WTDocument.class,"<product name>"));
QueryResult queryResult2 = PersistenceHelper.manager.find((StatementSpec)cqs);
System.out.println(queryResult2.size());
}
catch(QueryException e)
{
e.printStackTrace();
} catch (WTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static StatementSpec statementspecGenerator(Class c,String contName) throws QueryException
{
QuerySpec queryspec = new QuerySpec(c);
queryspec.setAdvancedQueryEnabled(true);
int contIndex = queryspec.appendClassList(PDMLinkProduct.class,false);
SearchCondition sc1 = new SearchCondition(c, "containerReference.key.id",PDMLinkProduct.class, wt.util.WTAttributeNameIfc.ID_NAME);
queryspec.appendWhere(sc1, new int[] { 0, contIndex });
queryspec.appendAnd();
SearchCondition scSWPart = new SearchCondition(PDMLinkProduct.class ,"containerInfo.name",SearchCondition.EQUAL,contName,true);
queryspec.appendWhere(scSWPart, new int[] { contIndex });
//QueryResult queryResult = PersistenceHelper.manager.find((StatementSpec)queryspec);
return (StatementSpec)queryspec;
}
}
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.