自訂翻譯建立勾點
可使用翻譯建立勾點來自訂針對翻譯封裝建立之翻譯物件的一般屬性。翻譯建立勾點由 wt.properties 檔案中的 xconf 內容 com.ptc.tml.preparation.CustomTranslationCreationHook 控制。
自訂翻譯建立勾點的步驟如下:
1. 開發 java 程式碼 - 根據您企業的需求建立延伸抽象類別 com.ptc.tml.preparation.CustomTranslationCreationHook 與實行所需行為的 java 類別。
2. 註冊自訂 - 在 <customizationRootDirectory>/configurations/xconf/ custom.site.xconf 位置建立包含下列內容之適當值的 xconf 檔案:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configuration
SYSTEM "xconf.dtd">
<Configuration xmlns:xlink="http://www.w3.org/1999/xlink">
<Property name="com.ptc.tml.preparation.CustomTranslationCreationHook"
overridable="true"
targetFile="codebase/wt.properties"
value=<"className>"/>
</Configuration>
內容的值應該是在步驟 1 中實行的類別名稱。
以下是將字首 'PTC' 新增至翻譯文件之「翻譯編號」屬性的範例程式碼。
package com.ptc.tml.preparation.sample;
import java.util.List;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
import com.ptc.tml.preparation.CustomTranslationCreationHook;
/** Example implementation of CustomTranslationCreationHook that customizes translation objects by prepending "PTC"
* to each translation object's Number. This is enabled by adding
* 'com.ptc.tml.preparation.CustomTranslationCreationHook=com.ptc.tml.preparation.sample.PrefixCustomTranslationObjectCreationHook'
* to wt.properties. */
public class PrefixCustomTranslationObjectCreationHook extends CustomTranslationCreationHook {
@Override
protected void customize(List<EPMDocumentCopyInfo> documentCopies) throws WTException, WTPropertyVetoException {
for (EPMDocumentCopyInfo info : documentCopies) {
final String initialNumber = info.getTarget().getNumber();
info.getTarget().setNumber("PTC" + initialNumber);
}
}
}