Programatically how to retrive the objects present in the workspace
I am trying to retrieve the WTParts / EPMdocument from the workspace, it was throwing error it was saying that the query is wromng.
help me to retrieve the objects from the workspace.
this is my code.
This is my workspace id iam passing :
private static String WorkspaceNumber = "OR:wt.epm.workspaces.EPMWorkspace:1150900;
From this method iam getting the workspace:
private static EPMWorkspace getWorkspaceById(String WorkspaceNumber ) {
try {
wt.fc.ReferenceFactory referenceFactory = new wt.fc.ReferenceFactory();
wt.fc.WTReference wtReference = referenceFactory.getReference(workspaceId);
return (EPMWorkspace) wtReference.getObject(); // Returns the workspace object
} catch (Exception e) {
System.err.println("Error fetching workspace by ID: " + workspaceId);
e.printStackTrace();
return null; // Return null if workspace cannot be fetched
}
}
This is the method i used to retrive objects present in the workspace
private static List<EPMDocument> getEPMDocumentsInWorkspace(EPMWorkspace workspace) throws WTException {
List<EPMDocument> epmDocuments = new ArrayList<>();
QuerySpec query = new QuerySpec(EPMDocument.class);
query.appendWhere(new SearchCondition(EPMDocument.class, "thePersistInfo.theObjectIdentifier.id", SearchCondition.EQUAL, workspace.getPersistInfo().getObjectIdentifier().getId()), null);
QueryResult results = PersistenceHelper.manager.find(query);
System.out.println("results: "+results.size());
while (results.hasMoreElements()) {
Persistable per = (Persistable) results.nextElement();
System.out.println("per "+per.toString());
if(per instanceof EPMDocument) {
epmDocuments.add((EPMDocument) per);
}
}
return epmDocuments;
}

