Exemple de modification de l'interface AutoAssociatePartFinderCreator
Créez et compilez <WT_HOME>src\com\ptcts\autoassociate\CustomizedAutoAssociatePartFinderCreator.java avec la source suivante.
Voici un exemple de personnalisation de la fonction Association automatique visant à ne remplacer le comportement PTC que lors de la création d'un nouvel article.
Créez et compilez la classe dans un chemin propre à l'entreprise. Par exemple, <WT_HOME>src\com\acme\autoassociate\CustomizedAutoAssociatePartFinderCreator.java avec la source suivante.
Pour plus d'informations sur le déploiement du délégué personnalisé, consultez la rubrique Utilisation et modification de l'interface 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);
}
}
Est-ce que cela a été utile ?