Programatically how to retrive the objects present in the workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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;
}
- Labels:
-
API
-
EPM
-
General Customization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
Any solution you have to retrieve the available objects in the workspace. you know any API please share it.
Regards
Raikar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Why are you ignoring Petr's question? We're trying to help you, which is not always easy. Print a stack trace or describe exactly what's not working. The best approach is to always include the Windchill version.
I’m guessing your code is working, and you’re able to retrieve the assemblies, but you’re unable to check them back in. Is that the case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
Yes, I am unable to check in the CAD assemblies. i found the API to retrieve the available EPMDocuments from the workspace(CS244949).but I not able to check-in from the workspace.
Regards
Raikar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @RaikarRaghu
@BjoernRueegg is right. Why do you not share any errors?
I can say, that the query definition is wrong because you search for EPMDocument but you provide the Workspace ID so it can not work at all..
btw Windchill has a helper for Workspace, and it can retrieve the objects from workspace
PS> EPMWorkspaceHelper
PetrH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
Yes, Thank you.
I found the article regarding to this, I think it will work on this.
WTSet objsInWS = EPMWorkspaceHelper.manager.getObjectsInWorkspace(workspace, EPMDocument.getClass());
Iterator iterator = objsInWS.iterator();
while (iterator.hasNext()) {
EPMDocument keyobj = (EPMDocument)((ObjectReference)iterator.next()).getObject();
}
Regards
Raikar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
It was showing the assembly is already check-in.
error log.
available object in workspace
This is the code I am using to do checkin:
workingepm = (EPMDocument) WorkInProgressHelper.service.workingCopyOf(epmDocument);
checkincollection.put(workingepm,null);
// Now we proceed with the check-in operation using the provided API
if (!checkincollection.isEmpty()) {
workspace = getWorkspaceById(WorkspaceNumber);
if (workspace != null) {
// Call the checkin method from EPMWorkspaceHelper
EPMWorkspaceHelper.manager.checkin(workspace, checkincollection, null, null, null);
System.out.println("Documents successfully checked in.");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
hi @RaikarRaghu
The error log should contains also all the stack-trace info with java row numbers. Thanks that I can find the problematic place and look what should be there.
btw if the system tell you that the object is already checked-in that means that you have wrong collection or you work with commonspace version instead of the working modified object in the workspace.
PetrH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
Yes, actually it was taking the EPMDocument from the common space which is original copy. now I figured out.
Thank you.
Regards
Raghavendra