用于限制信息元素搜索条件的自定义挂接
使用挂接限制搜索条件的自定义只能由具备 Java 专业知识的 Windchill 管理员来执行。
可通过单击“插入现有的” > “插入现有信息元素”在服务结构中插入现有信息元素。“插入现有信息元素”窗口会随即打开,其中将列出基于指定搜索条件的所有信息元素。自定义挂接可用于限制搜索条件,以仅显示所需的信息元素。搜索条件基于挂接中指定的业务逻辑。
要实现此挂接,请在自定义服务类中扩展 com.ptc.arbortext.windchill.corestruct.server.ops.SIMCustomSearchCriteriaService java 类。执行以下步骤:
1. 在文本编辑器中打开 Windchill 主目录下的 site.xconf 文件,并以此 <Option serviceClass="YourCustomSearchServiceClassFullName" requestor="null" selector="null"/> 格式添加所需的服务类。例如:
<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. 使用 xconfmanager 实用程序传播您的更改。在 <Windchill>\bin 目录中,键入以下命令:
xconfmanager -pF
3. 重新启动方法服务器。
示例
以下是一个自定义代码示例,旨在限制搜索条件,以便仅显示处于已发布状态的信息元素的搜索结果。
/* 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");
}
}
}
这对您有帮助吗?