Hook personnalisé pour limiter les critères de recherche des éléments d'information
La personnalisation permettant de limiter les critères de recherche à l'aide du hook ne peut être effectuée que par un administrateur Windchill+ familiarisé avec Java.
Vous pouvez insérer un élément d'information existant dans une structure de service à l'aide de l'action Insérer existant > Insérer l'élément d'information existant. La fenêtre Insérer l'élément d'information existant qui s'affiche répertorie tous les éléments d'information correspondant aux critères de recherche spécifiés. Le hook personnalisé peut être utilisé pour limiter les critères de recherche afin d'afficher uniquement les éléments d'information requis. Les critères de recherche sont basés sur la logique métier spécifiée dans le hook.
Pour implémenter ce hook, étendez la classe Java com.ptc.arbortext.windchill.corestruct.server.ops.SIMCustomSearchCriteriaService dans la classe de service personnalisée. Procédez comme suit :
1. Créez un fichier personnalisé xconf et ajoutez la classe de service requise au format <Option serviceClass="YourCustomSearchServiceClassFullName" requestor="null" selector="null"/>. Par exemple :
<Service name="com.ptc.arbortext.windchill.corestruct.server.ops.SIMCustomSearchCriteriaService" targetFile="codebase/service.properties">
<Option serviceClass="com.ptc.arbortext.windchill.corestruct.server.ops.CustomASPSSearchService" requestor="null" selector="null"/>
</Service>
2. Organisez et déployez les modifications à l'aide de CCD. Pour plus d'informations, consultez la rubrique Définition des valeurs de propriétés et propagation de vos modifications. Pour plus d'informations sur la création d'une structure de fichier modulaire pour Windchill+, consultez l'exemple suivant : Installing or Enabling Configurable Links with New Custom Subtyped Configurable Links Example.
Exemple
Vous trouverez ci-dessous un exemple de code personnalisé permettant de limiter les critères de recherche pour afficher uniquement les résultats de la recherche d'éléments d'information à l'état Officiel.
/* bcwti
*
* Copyright (c) 2021 PTC, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of PTC
* and is subject to the terms of a software license agreement.
* You shall not disclose such confidential information and shall use it
* only in accordance with the terms of the license agreement.
*
* ecwti
*/

package com.ptc.arbortext.windchill.corestruct.server.ops;

import com.ptc.arbortext.windchill.corestruct.client.ops.ASPSFindOperation.ASPSFindOperationParams;

import wt.fc.ObjectIdentifier;
import wt.fc.ObjectReference;
import wt.fc.Persistable;
import wt.inf.container.WTContained;
import wt.util.WTException;

public class CustomASPSSearchService implements SIMCustomSearchCriteriaService {
private static final long serialVersionUID = 1L;

@Override
public void updateSearchCriteria(ASPSFindOperationParams fop) throws WTException {
Persistable contextObject = ObjectReference.newObjectReference(ObjectIdentifier.newObjectIdentifier(fop.getRootIdentifier().getStringIdentifer())).getObject();
if (contextObject != null && contextObject instanceof WTContained) {
fop.getSearchCriteriaList().get(0).set("state.state", "RELEASED");
}
}
}
Est-ce que cela a été utile ?