將自訂連結轉換為彈性變更連結
如果您有自訂變更物件或連結,則必須遵循下列額外步驟將其轉換為彈性變更物件︰
更新變更流程連結 - 只有在您擁有包含其他屬性的自訂變更連結時,才需要執行。
建立自訂就緒委派 - 只有在所提供的就緒委派不能滿足您的需求時,才需要執行。

更新變更流程連結
如果自訂連結具有任何其他屬性,則無法將其轉換為變更流程連結。
您可使用 AddColumns 公用程式達成此目標。如需詳細資訊,請參閱 Running the AddColumns Tool
有關具有其他屬性之自訂連結的範例,請參閱下一節。

自訂連結類型的轉換器委派
此委派可讓您從自訂舊有連結更新具有任何唯一值的變更流程連結。欲註冊新委派,請參閱 Properties and Property Files
Windchill 提供下列連結轉換器委派註冊︰
<!-- Delegates for converting legacy change link to flexible links. -->
<Service context="default" name="wt.change2.flexible.FlexibleChangeLinkConverterDelegate">
<Option selector="wt.change2.FormalizedBy" cardinality="singleton"
serviceClass="wt.change2.flexible.DefaultFlexibleChangeLinkConverterDelegate"
requestor="null"/>
<Option selector="wt.change2.AddressedBy2" cardinality="singleton"
serviceClass="wt.change2.flexible.DefaultFlexibleChangeLinkConverterDelegate"
requestor="null"/>
</Service>
在下列範例中,自訂舊有連結上還有一個屬性必須新增至變更流程連結。此範例假設您已執行 AddColumns 公用程式。
委派會從自訂舊有連結擷取屬性,並將其新增至變更流程連結︰
package com.myCompany;
public class CustomLinkConverterDelegate extends FlexibleChangeLinkConverterDelegate {
@Override
public void postStoreUpdate(WTValuedMap legacyToFlexibleLinkMap) throws WTException {
Locale locale = SessionHelper.getLocale();
//Go through individual legacy links
for(Object obj: legacyToFlexibleLinkMap.entrySet()){
WTValuedEntry entry = (WTValuedEntry) obj;
ObjectReference legacyLinkRef = (ObjectReference) entry.getKey();
ObjectReference changeProcessRef = (ObjectReference) entry.getValue();

//Get value of custom attribute
CustomFormalizedBy formalizedBy = (CustomFormalizedBy) legacyLinkRef.getObject();
String customLinkValue = formalizedBy.getValue().toString();

//Set value of attribute on Change Process Link
ChangeProcessLink changeProcessLink = (ChangeProcessLink) changeProcessRef.getObject();
PersistableAdapter perAdapter = new PersistableAdapter(changeProcessLink,null,locale,new UpdateOperationIdentifier());
perAdapter.load("CustomLinkValue");
perAdapter.set("CustomLinkValue",customLinkValue);
perAdapter.apply();
try {
changeProcessLink.getPersistInfo().setVerified(true);
} catch (WTPropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
PersistenceHelper.manager.modify(changeProcessLink);
}
}
}
CustomLinkConverterDelegate 類別的註冊過程如下︰
<Service context="default" name="wt.change2.flexible.FlexibleChangeLinkConverterDelegate">
<Option selector="wt.change2.FormalizedBy" cardinality="singleton"
serviceClass="com.myCompany.CustomLinkConverterDelegate"
requestor="null"/>
</Service>

自訂連結類型轉換器規則檔
必須針對系統中的每個自訂連結建立自訂連結轉換器規則檔。
例如,com.myCompany.CustomFormalizedBy 的連結轉換器規則檔的位置和名稱如下︰
<Windchill>/codebase/wt/change2/flexible/LinkConverterRule.com.myCompany.CustomFormalizedBy.csv
如需詳細資訊,請參閱配置連結轉換規則

自訂就緒委派
就緒委派可根據您的需求決定變更物件是否已準備就緒,可以轉換。
Windchill 提供下列預設委派︰
WorkflowReadinessDelegate
ResolutionDateReadinessDelegate
TerminalStateReadinessDelegate
AdministrativeLockReadinessDelegate
* 
TerminalStateReadinessDelegate 未預設註冊。如需詳細資訊,請參閱變更管理物件的終止狀態管理
預設就緒委派可決定變更物件是否已準備就緒,可以轉換。如果物件通過一次評估,就會將物件視為已準備就緒,可以轉換,而無論它的另一個就緒委派是否失敗。
欲針對變更物件類型變更此行為,請對 ReadinessInfo 物件呼叫下列 API︰setShouldContinueProcessing()。如果此 API 設定為 false,則當物件標記為未準備就緒而無法轉換時,公用程式會停止檢查其他委派。
Windchill 提供下列服務用於配置就緒委派︰
wt.change2.flexible.FlexibleChangeItemReadinessDelegate.convertLinks
wt.change2.flexible.FlexibleChangeItemReadinessDelegate.convertReplicatedLinks
每個委派必須使用大於零的具唯一性 selector 整數值進行註冊。當註冊兩個或多個就緒委派時,會以選取器值增加的順序使用這些委派。
wt.change2.flexible.FlexibleChangeItemReadinessDelegate.convertLinks 服務會首先呼叫 AdministrativeLockReadinessDelegate 以檢查變更物件是否已被管理員鎖定。如果已鎖定,則委派會傳回包含下列值的 ReadinessInfo 物件︰
isReady 旗標設定為 False
shouldContinueProcessing 旗標設定為 False
目前已被管理員鎖定的物件處理進行進一步的就緒檢查會被阻止。
如果物件未鎖定,則會呼叫 ResolutionDateReadinessDelegate 來確定變更物件是否準備好進行轉換。如果尚未準備好,則會呼叫 WorkflowReadinessDelegate
wt.change2.flexible.FlexibleChangeItemReadinessDelegate.convertReplicatedLinks 服務不會呼叫 AdministrativeLockReadinessDelegate
下列範例提供用於現成就緒委派的組態:
<!-- Delegates for computing readiness state for converting legacy change items.
The selector attribute must be unique and must be an integer because the delegates
are called in a particular order which is based on the selector value. -->
<Service context="default" name="wt.change2.flexible.FlexibleChangeItemReadinessDelegate.convertLinks">
<Option serviceClass="wt.change2.flexible.AdministrativeLockReadinessDelegate"
selector="10"
requestor="wt.change2.FlexibleChangeItem"
cardinality="singleton"/>
<Option serviceClass="wt.change2.flexible.ResolutionDateReadinessDelegate"
selector="20"
requestor="wt.change2.FlexibleChangeItem"
cardinality="singleton"/>
<Option serviceClass="wt.change2.flexible.WorkflowReadinessDelegate"
selector="30"
requestor="wt.change2.FlexibleChangeItem"
cardinality="singleton"/>
</Service>
<Service context="default" name="wt.change2.flexible.FlexibleChangeItemReadinessDelegate.convertReplicatedLinks">
<Option serviceClass="wt.change2.flexible.ResolutionDateReadinessDelegate"
selector="10"
requestor="wt.change2.FlexibleChangeItem"
cardinality="singleton"/>
<Option serviceClass="wt.change2.flexible.WorkflowReadinessDelegate"
selector="20"
requestor="wt.change2.FlexibleChangeItem"
cardinality="singleton"/>
</Service>
欲註冊新委派,請參閱內容與內容檔
下列範例委派說明了兩個動作︰
檢查變更物件是否處於「實行」狀態。
如果物件處於錯誤狀態,則會略過其他任何委派。
package com.myCompany;
public class CustomReadinessDelegate extends FlexibleChangeItemReadinessDelegate {

protected static final String CUSTOM_RESOURCE = CustomConverterResource.class.getName();
private static final Logger logger = Logger.getLogger(CustomReadinessDelegate.class.getName());
@Override
public WTKeyedMap determineReadiness(WTCollection changeItems) throws WTException {
WTKeyedMap changeItemToReadinessMap = new WTKeyedHashMap();
Map<FlexibleChangeItem, Boolean> shouldContinueMap = new HashMap<FlexibleChangeItem, Boolean>();
for (Object object : changeItems) {
ObjectReference changeItemRef = (ObjectReference) object;
ChangeRequest2Custom changeItem = (ChangeRequest2Custom) changeItemRef.getObject();
ReadinessInfo readinessInfo = null;
WTMessage reasonMsg;
boolean isReady = true;
boolean shouldContinue = true;
if (((VersionableChangeItem) changeItem).getState().getState() != State.toState("IMPLEMENTATION")) {
reasonMsg = new WTMessage(CUSTOM_RESOURCE, CustomConverterResource.INCORRECT_STATE,
new Object[] { FlexibleChangeConverterHelper.getDisplayIdentity(changeItem) });
isReady = false;
shouldContinue = false;
} else {
reasonMsg = new WTMessage(CUSTOM_RESOURCE, CustomConverterResource.CORRECT_STATE,
new Object[] { FlexibleChangeConverterHelper.getDisplayIdentity(changeItem) });
}
readinessInfo = new ReadinessInfo(isReady, changeItemRef, reasonMsg);
readinessInfo.setShouldContinueProcessing(shouldContinue);
changeItemToReadinessMap.put(changeItem, readinessInfo);
}
return changeItemToReadinessMap;
}
}
欲在現成委派之前執行 CustomReadinessDelegate,請使用較小的 selector 值進行註冊︰
<Service context="default" name="wt.change2.flexible.FlexibleChangeItemReadinessDelegate">
<Option serviceClass=" com.myCompany.CustomReadinessDelegate"
selector="5"
requestor="wt.change2.FlexibleChangeItem"
cardinality="singleton"/>
</Service>
這是否有幫助?