cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Translate the entire conversation x

Content link

SS_14439466
2-Explorer

Content link

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.

3 REPLIES 3

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));

Imad_A
13-Aquamarine
(To:SS_14439466)

 

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:

Announcements
Top Tags