高级自定义 > 业务逻辑自定义 > 包自定义 > 降级交付的自定义
降级交付的自定义
本节将介绍不同用例以及合并复制过程中所交换信息模型中的更改时所使用的相应操作。
用例:处理跨 Windchill 版本的元数据更改
如果最新 Windchill 版本的 DTD 中有更改,请执行以下操作:
1. 比较 DTD,以标识更改。
* 
DTD 文件的位置如下:
Windchill 11.1 M020Windchill\loadXMLFiles\standard11_1.dtd
2. 标识更改的 XSL 变换模式。有关方案和示例的详细信息,请参阅 XSL 变换方案
3. 更新发行版本特定 XSL 模板并检入各自源变型的相应文件夹。
4. 将其提取到位于 codebase\registry 中的发行版本特定文件夹。
* 
XSL 模板基于源 DTD 中定义的 DTD 元素结构而创建的。必须修改相应的 XSL。请勿更改包含项。
5. 创建降级交付以确保包括自定义对象。
有关详细信息,请参阅创建包
示例
属性 Attr1 已新添加到 Windchill 11.2.0.0 中的 WTPart DTD。在为 Windchill 11.1 M020 Attr1 创建降级交付期间,应将 Attr1 作为 XSL 更改的一部分进行筛选。您需要更新在 $(wt.codebase.location)\registry\XSLRepo\11.1.M020\WTPart.xsl 目录下的 WTPart.xsl 中检入的出厂设置。
WTPart.xsl 的所有其他内容必须按原样保留。只有 Attr1 副本必须使用 XSL 变换方案中提到的新 XSL 脚本替换。
用例:处理不支持的对象
如果某个对象不支持在特定 Windchill 发行版本中降级,则配置 xxx_filter.properties 文件以指定将在创建降级交付期间筛选或移除的对象元素,其中 XXX 是指应用程序开发人员的模块名称。
从降级交付中筛选对象
ELEMENT1 是在 Windchill 11.2.0.0 发行版本中添加的 wt.TestObject 对象的元素,但 Windchill 11.1 M020 不支持 wt.TestObject 。在 Windchill 11.2.0.0 中针对 Windchill 11.1 M020 创建降级交付前,在 xxx_filter.properties 中配置 tagsToFilter 特性以筛选 ELEMENT1xxx_filter.properties 文件位于 $(wt.codebase.location)\registry\transformationEngine\filter\11.1.M020\xxx_filter.properties
tagsToFilter=ELEMENT1
用例:处理不支持的可变类型
如果某个可变类型不支持在最新的 Windchill 发行版本中降级,则可添加具有 XPath 的变换筛选器以在降级时筛选可变类型。
从降级交付中筛选可变类型
要在降级到 Windchill 11.1 M020 时从 Windchill 11.2.0.0 筛选可变类型 org.rnd.ComputerPart,请添加包含 XPath 的变换筛选器,如下所示:
externalTypeId=WCTYPE|wt.part.WTPart|org.rnd.ComputerPart
变换 XPath 筛选器在以下位置进行配置:
$(wt.codebase.location)/registry/transformationEngine/filter/11.1.M020/xpath_filter.xml
<?xml version =”1.0" encoding="UTF-8" standalone="yes"?>
<AdvancedXpathFilter xmlns=”http://www.ptc.com/AdvancedXpathFilter”>
<xpathFilterGroup>
<xpath>//WTPart/externalTypeId==”WCTYPE|wt.part.WTPart|org.rnd.ComputerPart”</xpath>
</xpathFilterGroup>
</AdvancedXpathFilter>
基于 XPATH 的筛选器的性能注意事项
基于 XPATH 的筛选器需要基于选定的 XPATH 创建索引。这可防止降级进程中使用的 XMLDOCUMENT 表的插入和删除成本。要使用基于参数 XPATH 的索引功能,请从 Windchill shell 中执行以下步骤。
windchill wt.pds.tools.xdb.CreateIndex <dbUser> <dbPassword> [debug]
其中,
dbUser - 数据库架构用户
dbPassword - 数据库密码
debug - 在调试模式下运行的可选参数
如果此命令在无任何参数的情况下运行,则会显示使用消息。
* 
在离线模式下运行此工具。
针对系统预设 XPATH 筛选器和自定义筛选器运行此工具。
检查 XMLDocument 表上的索引以验证此工具。
此工具仅支持 Windchill 11.2.0.0 发行版本中的 Oracle 数据库。
检查 SQL 计划,即使用 XPATH 的查询,以验证 XPATH 筛选器中的 XDB 索引使用情况。
有关模式的详细信息,请参阅关于 XDB 索引的 Oracle 管理信息。
定义 XPath 筛选器的 AND 和 OR 条件
AND 条件:
创建 $(wt.codebase.location)\registry\transformationEngine\filter\11.1.M020\WTPart_xpath_filter.xml
<xpathFilterGroup></xpathFilterGroup> 中指定 Xpath 筛选条件
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AdvancedXpathFilter xmlns="http://www.ptc.com/AdvancedXpathFilter" >
<xpathFilterGroup>
<xpath>//WTPart/view="Design"</xpath>
<xpath>//WTPart/externalTypeId="WCTYPE|wt.part.WTPart|com.ptc.ptcnet.wt.part_type1"</xpath>
</xpathFilterGroup>
</AdvancedXpathFilter>
OR 条件:
创建 $(wt.codebase.location)\registry\transformationEngine\filter\11.1.M020\WTPart_xpath_filter.xml
在单独的 <xpathFilterGroup></xpathFilterGroup> 中指定单个 OR 条件
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AdvancedXpathFilter xmlns="http://www.ptc.com/AdvancedXpathFilter" >
<xpathFilterGroup>
<xpath>//WTPart/externalTypeId="WCTYPE|wt.part.WTPart|com.ptc.ptcnet.wt.part_type1"</xpath
</xpathFilterGroup>
<xpathFilterGroup>
<xpath>//WTDocument/ObjectID/localId =”wt.doc.WTDocument:200425”</xpath>
</xpathFilterGroup>
</AdvancedXpathFilter>
添加相关性筛选器
相关性筛选器是基于 Java 的筛选器,用于筛选任何对交换无效的依存对象集,如果其所需的任何对象通过 xpath 或基于特性的筛选器排除。
如果任何筛选 WTPart,此示例将显示正在筛选 WTPartUsageLink
XMLFilterEntry
默认情况下,对于所有根标记,默认 XML 筛选器条目会附带有关 localIdufid 的信息。但在查询时,usagelinkfilter 条目也必须包含其角色 A 和角色 B 信息。
示例
package com.ptc.transformation.filter.test;
import com.ptc.transformation.core.TransformationException;
import com.ptc.transformation.filter.DefaultXMLFilterEntry;
public class WTPartUsageLinkFilterEntry extends DefaultXMLFilterEntry {
public static final String USES_OBJECT_REFERENCE_UFID = "/uses/ObjectReference/ufid";
public static final String USED_BY_OBJECT_REFERENCE_UFID = "/usedBy/ObjectReference/ufid";
private static final long serialVersionUID = 1L;
@Override
public void initialize(String rootTag) throws TransformationException {
super.initialize(rootTag);
// Capture RoleA and RoleB also as part of filter entry
getIdentityEntries().put(getRootTag() + USED_BY_OBJECT_REFERENCE_UFID, null);
getIdentityEntries().put(getRootTag() + USES_OBJECT_REFERENCE_UFID, null);
}
}
这将覆盖初始化方法,以将更多的标记添加为标识键的一部分。
可通过 Windchill 服务委派工厂模式配置 WTPartUsageLinkFilter 条目,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Configuration SYSTEM "xconf.dtd">
<Configuration targetFile="codebase/service.properties">
<Service context="default" name="com.ptc.transformation.filter.DependencyFilter">
<Option cardinality="duplicate" requestor="java.lang.Object" selector="UsageLink" serviceClass="com.ptc.transformation.filter.test.UsageLinkFilter" />
</Service>
Service context="default" name="com.ptc.transformation.filter.XMLFilterEntry">
Option cardinality="duplicate" requestor="java.lang.Object" selector="WTPartUsageLink" serviceClass="com.ptc.transformation.filter.test.WTPartUsageLinkFilterEntry" />
/Service>
Service context="default" name="com.ptc.transformation.core.TransformationFilter">
Option serviceClass="com.ptc.windchill.transform.util.TestTransformationFilter" requestor="java.lang.Object" selector="xpath_filter" cardinality="duplicate" />
/Service>
</Configuration>
您可以在模块特定的服务配置中配置条目。
UsageLinkFilter
使用关系链接筛选器是示例相关性筛选器,用于在角色 B 中存在任何 WTPart 角色 A 或具有主 ufidWTPart 时筛选 WTPartUsageLink
示例
package com.ptc.transformation.filter.test;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.ptc.transformation.core.TransformationContext;
import com.ptc.transformation.core.TransformationException;
import com.ptc.transformation.filter.DefaultDependencyFilter;
import com.ptc.transformation.filter.DependencyFilterPriority;
import com.ptc.transformation.filter.FilterIdentityKey;
import com.ptc.transformation.filter.XMLFilterEntry;
import com.ptc.transformation.filter.XMLLookUpService;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
@FilterIdentityKey(keys = { "WTPart"})
public class UsageLinkFilter extends DefaultDependencyFilter {
public static final String ROOT_TAG = "WTPartUsageLink";
public static final String usedByPath = "WTPartUsageLink/usedBy/ObjectReference/ufid";
public static final String usesPath = "WTPartUsageLink/uses/ObjectReference/ufid";
@Override
public Collection<XMLFilterEntry> execute(Collection<XMLFilterEntry> inputEntries, TransformationContext context)
throws TransformationException {
Collection<XMLFilterEntry> usageLinkEntries = new HashSet<>();
Set<String> masterUfids = new HashSet<>();
Set<String> ufids = new HashSet<>();
for (XMLFilterEntry xmlFilterEntry : inputEntries) {
for (Map.Entry<String, String> entry : xmlFilterEntry.getIdentityEntries().entrySet()) {
String key = entry.getKey();
if (key.contains("/masterUfid")) {
masterUfids.add(entry.getValue());
}
if (key.contains("/ufid")) {
ufids.add(entry.getValue());
}
}
}
XMLLookUpService service = XMLLookUpService.getInstance(context);
Map<String, Collection<String>> filterEntries = new HashMap<>();
if (!ufids.isEmpty())
filterEntries.put(usedByPath, ufids);
if (!masterUfids.isEmpty())
filterEntries.put(usesPath, masterUfids);
try {
usageLinkEntries = service.getXMLFilterEntries(ROOT_TAG, filterEntries);
} catch (WTException | WTPropertyVetoException e) {
throw new TransformationException(e);
}
return usageLinkEntries;
}
@Override
public int getPriority() {
return DependencyFilterPriority.LINK_OBJECT_PRIORITY;
}
}
这将配置名为 FilterIdentityKey 的注释,如下所示:
package com.ptc.transformation.filter;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
@Retention(RUNTIME)
public @interface DependentOn {
FilterIdentityKey[] value() default {};
}
这将定义所需的依存标记及其处理所需的其他筛选器标识。在这种情况下,它需要 masterUfid 作为 Part filter identity 键的一部分,因此它会按如下所示进行注释:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Configuration SYSTEM "xconf.dtd">
<Configuration targetFile="codebase/service.properties">
<Service context="default" name="com.ptc.transformation.filter.DependencyFilter">
<Option cardinality="duplicate" requestor="java.lang.Object" selector="UsageLink" serviceClass="com.ptc.transformation.filter.test.UsageLinkFilter" />
</Service>
<Service context="default" name="com.ptc.transformation.filter.XMLFilterEntry">
<Option cardinality="duplicate" requestor="java.lang.Object" selector="WTPartUsageLink" serviceClass="com.ptc.transformation.filter.test.WTPartUsageLinkFilterEntry" />
</Service>
<Service context="default" name="com.ptc.transformation.core.TransformationFilter">
<Option serviceClass="com.ptc.windchill.transform.util.TestTransformationFilter" requestor="java.lang.Object" selector="xpath_filter" cardinality="duplicate" />
</Service>
</Configuration>
有关自定义相关性筛选器的详细信息,请参阅 Windchill 降级交付的相关性筛选器
处理筛选器配置
您可以在下列位置找到筛选器配置。
基于 Xpath 的筛选器更改 - $(wt.codebase.location)\registry\transformationEngine\filter\<releaseId>\xpath_filter.xml
移除基于元素名称的 XML 文件 - $(wt.codebase.location)\registry\transformationEngine\filter\11.1.M020\filter.properties
添加要移除的元素,值以逗号进行分隔。
处理变换期间的批处理大小
您可以使用在 $(wt.codebase)/wt.properties 中配置的特性 com.ptc.transformation.batchSize 来控制变换过程中所处理的 XML 数量的批处理大小。此特性用于控制在元素处理程序进程前、中、后处理的 XML 的内存 InputSource 处理。默认值为 10000。
此外,在 wt.properties 中配置以下特性,以指定要保留在内存中的缓存和 XML 文件数的批处理大小。特性文件位于 Windchill/codebase
com.ptc.transformation.dom.cache=100
com.ptc.transformation.batchSize=10000
您可以根据分配的堆栈值在这些特性中配置文件数。
这对您有帮助吗?