AutoAssociatePartFinderCreator Modification Example
Create and compile <WT_HOME>src\com\ptcts\autoassociate\CustomizedAutoAssociatePartFinderCreator.java with the following source.
The following is an example of customizing Auto Associate to override only the PTC behavior when creating a new part.
Create and compile the class in a company specific path. For example, <WT_HOME>src\com\acme\autoassociate\CustomizedAutoAssociatePartFinderCreator.java with the following source.
For more information about deploying the custom delegate, see: Using and Modifying the AutoAssociatePartFinderCreator Interface
package com.ptc.windchill.uwgm.common.autoassociate;
import java.lang.String;

import wt.epm.EPMAuthoringAppType;
import wt.epm.EPMDocument;
import wt.epm.modelitems.ModelItem;
import wt.epm.workspaces.EPMWorkspace;
import wt.part.WTPart;
import wt.pom.UniquenessException;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
import wt.vc.VersionControlException;

import wt.epm.EPMDocumentType;

import wt.org.WTOrganization;
import wt.part.PartType;
import wt.part.QuantityUnit;
import wt.part.Source;

import com.ptc.windchill.uwgm.common.associate.AssociatePartDescriptor;
import com.ptc.windchill.uwgm.common.autoassociate.AutoAssociatePartFinderCreator;
import com.ptc.windchill.uwgm.common.autoassociate.WTPartUtilities;
import com.ptc.windchill.uwgm.common.autoassociate.DefaultAutoAssociatePartFinderCreator;
import com.ptc.windchill.uwgm.common.util.PrintHelper;

/*
This class is provided for testing the case where customer could customize the implementation of AutoAssociatePartFinderCreator to not create Parts for CATIA V5 authored CAD DOcuments.
*/

public class CustomizedAutoAssociatePartFinderCreator extends DefaultAutoAssociatePartFinderCreator {

EPMAuthoringAppType catiaV5AuthApp = EPMAuthoringAppType.toEPMAuthoringAppType("CATIAV5");

@Override
public WTPart createNewWTPart(AssociatePartDescriptor partDescriptor)
throws WTException, WTPropertyVetoException, VersionControlException, UniquenessException {
System.out.println(
"Invoked CustomizedAutoAssociatePartFinderCreator extends DefaultAutoAssociatePartFinderCreator :: createNewWTPart() ");
EPMDocument epmDoc = partDescriptor.getSourceDoc();
// if epmdoc is authored by CATIAV5 do not create any new WTPart
if (epmDoc.getAuthoringApplication().equals(catiaV5AuthApp))
return null;

WTPart part = super.createNewWTPart(partDescriptor);
System.out.println("epmDoc is " + epmDoc);
System.out.println("New WTPart created is " + part);

return part;
}

@Override
public WTPart findOrCreateWTPart(EPMDocument doc, ModelItem modelItem, EPMWorkspace workspace)
throws WTException, WTPropertyVetoException, VersionControlException, UniquenessException {
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator :: findOrCreateWTPart(EPMDocument doc, ModelItem modelItem, EPMWorkspace workspace)");
return super.findOrCreateWTPart(doc, modelItem, workspace);
}

@Override
public WTPart findOrCreateWTPart(EPMDocument epmDoc, EPMWorkspace workspace)
throws WTException, WTPropertyVetoException, VersionControlException, UniquenessException {
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator :: findOrCreateWTPart(EPMDocument doc, EPMWorkspace workspace)");
return super.findOrCreateWTPart(epmDoc, workspace);
}
}
Was this helpful?