The PTC Community is on temporary read only status in preparation for moving our community to a new platform. Learn more here
Version: Windchill 11.2
Use Case: I want to remove the content link association between a WTPart and EPMDocument via API , basically my requirement is to remove all the association of cad for perticular part and break the link not deleted the object in actual but remove it from a perticular part and break the link and till now I've successfully been able to remove owner link but I'm not able to find any related API to remove the content link so if you know anything about it please let me know.
Description:
I want to remove the content link association between a WTPart and EPMDocument via API , basically my requirement is to remove all the association of cad for perticular part and break the link not deleted the object in actual but remove it from a perticular part and break the link and till now I've successfully been able to remove owner link but I'm not able to find any related API to remove the content link so if you know anything about it please let me know.
Hi guy,
There is no content link object exists in OOTB Windchill 11 installation.
But for content you could use:
EPMDocument businessObject =null;
businessObject = (EPMDocument) wt.content.ContentHelper.service.getContents(businessObject);
Vector<?> ads = wt.content.ContentHelper.getApplicationData(businessObject);
wt.content.ApplicationData appData;
String desc;
for (int i = 0; i < ads.size(); i++) {
appData = (wt.content.ApplicationData) ads.elementAt(i);
desc = appData.getDescription();
if (FormatHelper.hasContent(desc) && (desc.indexOf("CONTENT") == 0 || desc.indexOf("IMAGE") == 0)) {
wt.content.ContentServerHelper.service.deleteContent(businessObject, appData);
}
}
Hi @SS_14439466,
Use the following API to delete the content link.
PersistenceServerHelper.manager.remove(new WTHashSet(epmDescribeLink));
For Content CAD associations, there is no dedicated API to directly “remove the content link.” In Windchill, these associations are stored as EPMDescribeLink (passive links), not as EPMBuildRule.
The recommended approach is to retrieve and delete the link objects themselves. From the WTPart side, you can obtain the Content associations using: PersistenceHelper.manager.navigate( partWC, EPMDescribeLink.DESCRIBED_BY_ROLE, EPMDescribeLink.class, false )
(Note: the false parameter is required to return the link objects instead of only the associated CAD documents.)
You can then delete each EPMDescribeLink using: PersistenceHelper.manager.delete(link)
This is typically done on a checked-out working copy of the part, followed by a check-in, as illustrated in the Knowledge Base examples.
You can do:
QueryResult qr = PersistenceHelper.manager.navigate( partWC, EPMDescribeLink.DESCRIBED_BY_ROLE, EPMDescribeLink.class, false);
while (qr.hasMoreElements()) {
PersistenceHelper.manager.delete(qr.nextElement());
}
If you also need to remove Owner / Image / other active associations, these are stored as EPMBuildRule links and can be handled in a similar way using: EPMBuildRule.BUILD_SOURCE_ROLE
For more details, please refer to the following PTC articles:
Hi @SS_14439466
Just add a point.
The EPMBuildRole has a parameter buildType and it is the type link
there are several int values and each value refers to the the type link
createLinkType = EPMBuildRule.BUILD_ATTRIBUTES; //Contributing Content Link
epmBuildRule.getBuildType()
Detailed explanation
https://www.ptc.com/en/support/article/CS125790
PetrH
Hi @SS_14439466,
I wanted to see if you got the help you needed.
If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation.
Thanks,
Anurag
removing association will remove the link on the next iteration the link will not be deleted from existing version .
you have to use unsupported way (SQL )
Hi @Fadel
Or, you can use following methods 😄 sure the createEPMBuildRuleAssociationLinks is also not supported but you can use it 😄
StructureServiceUtility.createEPMBuildRuleAssociationLinks(listToDeleteEPMBuildRule, new Map[0]);
PersistenceServerHelper.manager.remove(new WTHashSet(listToDeleteEPMBuildRule));
PetrH
@HelesicPetr nice to hear from you again.
I try to avoid sharing unsupported stuff as it may cause data corruption (especially in the new releases 13.1+ ),I have seen some edowns caused by unsupported APIs and later we struggled with providing healing scripts to fix data:-)
