Servigistics InService 發佈與載入 > 其他資訊 > TAL 自訂 > 將 CGM 圖像轉換為 SVG
  
將 CGM 圖像轉換為 SVG
欲將 CGM 圖形轉換為 SVG,您必須有 CGM 到 SVG 轉換器。轉換會在「發佈以預覽」任務執行時發生。
轉換器會作為外掛程式安裝在 Publisher 伺服器上。請遵循下列步驟來實行轉換器︰
1. 在自訂內容組態檔案中定義名為 CustomCGMtoSVGConverter 的元件。
組態檔案必須位於 INSERVICE_CONFIG/System/Config 目錄中。您可以使用該處的現有檔案,例如 customizedContext_3.conf.xml,但建議您建立新檔案。檔案必須命名為 customizedContext_X.conf.xml,其中 X 是任意數字。雖然元件可以位於多個檔案中,但系統一律會使用編號最高的檔案中的元件。
您可以在此元件中配置轉換器特定內容。這些內容可透過以下方法供元件類別存取︰
public void configure(IConfiguration conf) throws ConfigurationException {
在組態檔案中宣告的組態參數,可使用在 IConfiguration 介面 (存在於封裝路徑為 com/enigma/sdk/framework/configurationFramework.jar 檔案中) 中定義的各種方法存取。
2. 延伸位於 SCEImageConverter.jar 檔案中的類別 com.enigma.imageConverter.ImageConverter,來針對 CGM 到 SVG 轉換器建立 Java 類別 (例如 CustomCGMtoSVGConverter)。
3. 使用三個「字串」參數 (例如 input folderoutput folderoutput format) 建立名為 convertCGMToSVG 的方法。
此方法應將存在於輸入資料夾中的 CGM 圖像轉換為 SVG 圖像,並將其放在輸出資料夾中。
4. 重新定義 execute(Map variables, String method) 方法。
如果方法名稱為 convertCGMToSVG,則您可以從變數對應擷取下列參數︰
//input folder
String input = (String) variables.get("input");
//output folder
String output = (String) variables.get("output");
//output format
String outputFormat = (String) variables.get("outputFormat")
接下來,使用上述參數呼叫在步驟 2 中定義的方法。預期會將存在於輸入資料夾中的 CGM 檔案轉換為 SVG 檔案,並放在輸出資料夾中。
5. 更新圖像轉換的載入特定流程。
6. 更新在 CGMtoSVGConverterSubFlow_PD.xml 子流程 ConvertCGMToSVGNode 節點中使用的 CGM 到 SVG 轉換器元件與方法名稱。
元件與方法名稱必須與在步驟 2 和 4 中定義的相同。應在建立於步驟 1 的自訂類別中定義要呼叫的方法。
在您實行轉換器之後,請遵循下列步驟自訂 CGM 到 SVG 處理:
1. 在位於 INSERVICE_CONFIG/System/Config 目錄中的 customizedContext_3.conf.xml 檔案中,新增下列內容:
<Component Name="CustomCGMToSVGConvertor">
<Creation Type="JavaObject">
<!-- class name with package -->
<Class>com.custom.imageConverter.CustomCGMToSVGConvertor</Class>
</Creation>
<Config>
<!-- Pass various configuration parameters for converter into the Component -->
<!-- User can define attributes as
<attribute1>value</attribute1>
<attribute2>value</attribute2>
-->
</Config>
</Component>
2. 更新位於 INSERVICE_CONFIG/System/Config/Flows/ContentManager 目錄中的 contentManagerFlow_PD.xml 檔案,以包括下列預先處理節點:
<start-state name="start">
<transition to="runConvertImagesSubFlow"/>
</start-state>
<!-- Normalize sources -->
<node name="runCMPublishNormalizeSubFlow">
<action class="com.enigma.workflowengine.handlers.FlowActionHandler" config-type="handler">
<processDefinitionPath>${enigma.config.home}/System/Config/Flows/ContentManager/
cmPublishNormalizeFlow_PD.xml</processDefinitionPath>
</action>
<transition name="failure" to="End"/>
<transition name="success" to="runConvertImagesSubFlow"/>
<transition name="reenter" to="runCMPublishNormalizeSubFlow"/>
</node>
<node name="runConvertImagesSubFlow">
<action class="com.enigma.workflowengine.handlers.FlowActionHandler" config-type="handler">
<processDefinitionPath>${enigma.config.home}/System/Config/Flows/ContentManager/
convertImagesFlow_PD.xml</processDefinitionPath>
<monitoringName>Run Convert Images Flow</monitoringName>
</action>
<transition name="failure" to="End"/>
<transition name="success" to="runCheckGlobalDiskSpaceFlow"/>
<transition name="reenter" to="runConvertImagesSubFlow"/>
</node>
<node name="runCheckGlobalDiskSpaceFlow">
<action class="com.enigma.workflowengine.handlers.FlowActionHandler" config-type="handler">
<processDefinitionPath>${enigma.config.home}/System/Config/Flows/ContentManager/
checkGlobalDiskSpaceFlow_PD.xml</processDefinitionPath>
<monitoringName>Check Disk Space</monitoringName>
</action>
<transition name="failure" to="End"/>
<transition name="success" to="runHandlePDFLinksFlow"/>
<transition name="reenter" to="runCheckGlobalDiskSpaceFlow"/>
</node>

<!-- Setup profile path.
<node name="getProfilePath">
<action class="com.enigma.workflowengine.handlers.ProcessActionHandler" config-type="handler">
<contextName>ContentManager.Application.BusinessLogic</contextName>
<componentName>PacketDeployer</componentName>
<methodName>getProfilePath</methodName>
<profileName>${profile_name}</profileName>
<monitoringName>Retrieve Profile Path</monitoringName>
</action>
<transition name="failure" to="End"/>
<transition name="success" to="runHandlePDFLinksFlow"/>
<transition name="reenter" to="getProfilePath"/>
</node>
-->
<node name="runHandlePDFLinksFlow">
<action class="com.enigma.workflowengine.handlers.FlowActionHandler" config-type="handler">
<processDefinitionPath>${enigma.config.home}/System/Config/Flows/ContentManager/
handlePDFLinksFlow_PD.xml</processDefinitionPath>
<monitoringName>Handle PDF Links</monitoringName>
</action>
<transition name="failure" to="End"/>
<transition name="success" to="TypeOfCMScriptDecision"/>
<transition name="reenter" to="runHandlePDFLinksFlow"/>
</node>
<decision name="TypeOfCMScriptDecision">
<transition name="failure" to="End"/>
<transition name="CreateCMScriptFlow" to="runCreateCMScriptFlow">
<condition expression="#{S1000D_publication != 'true'}" />
</transition>
<transition name="CreateCMScriptForS1000DFlow" to="runCreateCMScriptForS1000DFlow">
<condition expression="#{S1000D_publication == 'true'}" />
</transition>
</decision>

<node name="runCreateCMScriptFlow">
<action class="com.enigma.workflowengine.handlers.FlowActionHandler" config-type="handler">
<processDefinitionPath>${enigma.config.home}/System/Config/Flows/ContentManager/
createCMScriptFlow_PD.xml</processDefinitionPath>
<monitoringName>Create Script</monitoringName>
</action>
<transition name="failure" to="End"/>
<transition name="success" to="extractFeedIds"/>
<transition name="reenter" to="runCreateCMScriptFlow"/>
</node>

<node name="runCreateCMScriptForS1000DFlow">
<action class="com.enigma.workflowengine.handlers.FlowActionHandler" config-type="handler">
<processDefinitionPath>${enigma.config.home}/System/Config/Flows/ContentManager/
createCMScriptFlowForS1000D_PD.xml</processDefinitionPath>
<monitoringName>Create Script For S1000D</monitoringName>
</action>
<transition name="failure" to="End"/>
<transition name="success" to="extractFeedIds"/>
<transition name="reenter" to="runCreateCMScriptForS1000DFlow"/>
</node>
<!-- Copy contents before this node -->
<node name="extractFeedIds">
3. 將新內容新增至位於 INSERVICE_CONFIG/System/Config/Flows/ContentManager 目錄中的 convertCGMToSVGFlow_PD.xml 檔案。
欲執行此操作,請先為檔案此部份中的最後兩行新增註解︰
<node name="ConvertCGMToSVGNode">
<action class="com.enigma.workflowengine.handlers.ProcessActionHandler" config-type="handler">
<contextName>DataProcess.Application.BusinessLogic</contextName>
<componentName>CGMToSVGConverter</componentName>
<methodName>doConvertViaPTCTool</methodName>
接下來,在註解行下新增下列內容︰
<componentName>CustomCGMToSVGConvertor</componentName>
<methodName>convertCGMToSVG</methodName>
4. 編譯 CustomCGMToSVGConvertor.java 檔案,並複製位於 INSERVICE_HOME/InS_SW/SW/System/WildFly/modules/system/layers/base/com/ptc/e3c/main/SCEImageConverter.jar/com/ptc/sce/imageConverter 目錄中的 CustomCGMToSVGConvertor.class 檔案。
完成組態後,在「將 CGM 轉換為 SVG」選項設定為「真」的情況下,執行 Transform and Load with Collection 任務或 Transform and Load CSV Data 任務,以轉換圖形: