Class ODFDOMFindReplaceAdapter

java.lang.Object
org.imixs.workflow.odf.ODFDOMFindReplaceAdapter
All Implemented Interfaces:
org.imixs.workflow.Adapter, org.imixs.workflow.SignalAdapter

public class ODFDOMFindReplaceAdapter extends Object implements org.imixs.workflow.SignalAdapter
This ODFDOMFindReplaceAdapter can be used to find and replace text fragements in a Open Document Format (ODF) documents (e.g. .odt, .ods).

The adapter can be configured by the event workflow result:

 
 
	<odf-update>
		<filename>file1.odf</filename>
		<replace>
			<key>\[contract\.start\]</key>
			<value><itemvalue>contract.start</itemvalue></value>
		</replace>
	</odf-update>

	OLD 
      <odf-update name=
        "filename">PLA Membership Agreement-<itemvalue>numsequencenumber</itemvalue>.odt</odf-update>
        <odf-update name="findreplace">
               <find>[company.name]</find>
               <replace><itemvalue>company.name</itemvalue></replace>
        </odf-update>
        <odf-update name="findreplace">
               <find>[company.country]</find>
               <replace><itemvalue>company.country</itemvalue></replace>
        </odf-update>
        <odf-update name="findreplace">
               <find>[contract.startdate]</find>
               <replace><itemvalue format=
        "EEE, MMM d, yyyy">contract.start</itemvalue></replace>
       </odf-update>
   
 
Version:
2.0
Author:
rsoika
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.imixs.workflow.ItemCollection
    execute(org.imixs.workflow.ItemCollection workitem, org.imixs.workflow.ItemCollection event)
    This method computes the findreplace configuration and updates an attachments form type .docx
    org.odftoolkit.odfdom.doc.OdfDocument
    loadODFDocument(org.imixs.workflow.FileData fileData)
     
    void
    updateFileData(org.imixs.workflow.FileData fileData, org.imixs.workflow.ItemCollection workitem, List<String> replaceDevList)
    This helper method updates the content of a given FileData object with a replaceDevList
    void
    updateODFDocument(org.odftoolkit.odfdom.doc.OdfDocument odfDoc, org.imixs.workflow.ItemCollection workitem, List<String> replaceDevList)
    Updates a ODF Document.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ODFDOMFindReplaceAdapter

      public ODFDOMFindReplaceAdapter()
  • Method Details

    • execute

      public org.imixs.workflow.ItemCollection execute(org.imixs.workflow.ItemCollection workitem, org.imixs.workflow.ItemCollection event) throws org.imixs.workflow.exceptions.AdapterException, org.imixs.workflow.exceptions.PluginException
      This method computes the findreplace configuration and updates an attachments form type .docx
      Specified by:
      execute in interface org.imixs.workflow.Adapter
      Throws:
      org.imixs.workflow.exceptions.PluginException
      org.imixs.workflow.exceptions.AdapterException
    • updateFileData

      public void updateFileData(org.imixs.workflow.FileData fileData, org.imixs.workflow.ItemCollection workitem, List<String> replaceDevList) throws org.imixs.workflow.exceptions.PluginException
      This helper method updates the content of a given FileData object with a replaceDevList

      The method verifies if the content of the file need to be loaded from the snapshot

      Parameters:
      fileData - - the fileData object containing the text or calc file
      replaceDevList - - list of text markers or cell positions to be replaced
      Throws:
      IOException
      org.imixs.workflow.exceptions.PluginException
    • loadODFDocument

      public org.odftoolkit.odfdom.doc.OdfDocument loadODFDocument(org.imixs.workflow.FileData fileData) throws org.imixs.workflow.exceptions.PluginException
      Throws:
      org.imixs.workflow.exceptions.PluginException
    • updateODFDocument

      public void updateODFDocument(org.odftoolkit.odfdom.doc.OdfDocument odfDoc, org.imixs.workflow.ItemCollection workitem, List<String> replaceDevList) throws org.imixs.workflow.exceptions.PluginException, org.odftoolkit.odfdom.incubator.search.InvalidNavigationException
      Updates a ODF Document. TextWriter and Calc are supported. The method can be overwritten by subclasses to add additional logic
      Parameters:
      odfDoc -
      workitem -
      replaceDevList -
      Throws:
      org.imixs.workflow.exceptions.PluginException
      org.odftoolkit.odfdom.incubator.search.InvalidNavigationException