Skip to main content
12-Amethyst
January 7, 2025
Question

Programatically how to retrive the objects present in the workspace

  • January 7, 2025
  • 1 reply
  • 1685 views

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;

}

1 reply

18-Opal
January 7, 2025

d_graham_0-1736286291482.png

 

d_graham_2-1736286373596.png

 

 

12-Amethyst
January 8, 2025

Hello,

 

In my scenario, I have multiple EPMDocuments Assembly  within a workspace that are checked out (e.g., 123.SLDASM). Iwant to retrieve all these EPMDocuments that are checked out, and then check them in programmatically.

 

Regards

Raikar

HelesicPetr
22-Sapphire II
22-Sapphire II
January 15, 2025

Hi @RaikarRaghu 

It would be nice to see full stack error 

PetrH