Customizing Translation Creation Hook
Use the translation creation hook to customize the general attributes of translation objects created for a translation package. The translation creation hook is controlled by the xconf property com.ptc.tml.preparation.CustomTranslationCreationHook in the wt.properties file.
The steps to customize the translation creation hook are as follows:
1. Develop java code — Create a java class that extends the abstract class com.ptc.tml.preparation.CustomTranslationCreationHook and implements the desired behavior per your business requirement.
2. Register the customization — Add the com.ptc.tml.preparation.CustomTranslationCreationHook property to the codebase\wt.properties file. The value of the property should be the name of the class implemented in step 1.
3. Restart method server.
* 
It is not recommended to modify the CADNAME of a translation document.
Following is a sample code which adds the prefix ‘PTC’ to the Translation Number attribute of translation documents.
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);
}
}
}
Было ли это полезно?