Custom Hook to Restrict Search Criteria for Information Elements
The customization to restrict search criteria by using the hook can be performed only by a Windchill+ administrator with Java expertise.
You can insert an existing information element in a service structure by clicking > .The Insert Existing Information Element window opens, listing all the information element based on the specified search criteria. The custom hook can be used to limit the search criteria to display only the required information elements. The search criteria are based on the business logic specified in the hook.
To implement this hook, extend the com.ptc.arbortext.windchill.corestruct.server.ops.SIMCustomSearchCriteriaService java class in the custom service class. Perform these steps:
1. Create a custom xconf file and add the required service class in this format <Option serviceClass="YourCustomSearchServiceClassFullName" requestor="null" selector="null"/>. For example:
<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>
Sample
The following is an example of the custom code to restrict the search criteria to display search results for information elements in released state only.
/* 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");
}
}
}