AutoAssociatePartFinderCreator の修正例
以下のソースを使用して、<WT ホーム>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);
}
}
これは役に立ちましたか?