AutoAssociatePartFinderCreator 修改範例
使用下列來源建立並編譯 <WT_HOME>src\com\ptcts\autoassociate\CustomizedAutoAssociatePartFinderCreator.java
以下是在建立新零件時自訂自動關聯以僅置換 PTC 行為的範例。
在公司特定路徑中建立及編譯類別。例如, 針對下列來源為 <WT_HOME>src\com\acme\autoassociate\CustomizedAutoAssociatePartFinderCreator.java
如需有關部署自訂委派的詳細資訊,請參閱:使用及修改 AutoAssociatePartFinderCreator 介面
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);
}
}
這是否有幫助?