Filewriter-call

From GreenVulcano Wiki
Revision as of 11:47, 8 February 2012 by Anonymous (talk) (How To)
Jump to: navigation, search

Definition

Use this plug-in if you want to write the contain of a Buffer object into a file present or not in the local file system. The target file will be overwritten if it is already present.

GreenVulcano® ESB provides two different tools, GV Console® and VulCon®, to configure this plug-ins in GVServices.

VulCon / GV Console Configuration

This plug-in writes into a local filesystem file.

Complete file path is the concatenation of targetPath attribute, with the fileName attribute. Both of them can contain placeholders, that are expanded at plugin call time.


Attributes targetPath and fileName are subject to these constraints:

  • attribute targetPath is overridden by GVFW_DIRECTORY property, if present in current GVBuffer. If property is not defined in GVBuffer, the targetPath attribute in the configuration is used. In both cases, the value of this attribute can be a placeholder, resolved at plugin call time, and the result of the expansion, must result in an absolute pathname, otherwise an exception is thrown.
    An exception is also thrown if neither the property nor the attribute in configuration are set.
  • attribute fileName is overridden by GVFW_FILE_NAME property, if present in current GVBuffer. If property is not defined in GVBuffer, the fileName attribute in the configuration is used. In both cases, the value of this attribute can be a placeholder, resolved at plugin call time, and the result of the expansion, combined with the previous attribute, must result in an existent resource in the local filesystem otherwise an exception is thrown.
    An exception is also thrown if neither the property nor the attribute in configuration are set.

The filewriter-call element is used by: Channel and routed-call. It has the following attributes:

Attribute Type Description
type fixed This attribute must assume the value call.
class fixed This attribute must assume the value it.greenvulcano.gvesb.virtual.file.reader.FileWriter.
name required Operation name. Used in the Flow section to associate workflow nodes to VCL operations.
targetPath required This value can be static or dynamic, containing placeholders that could be replaced at plugin call time. This is a default value, and is used if the property GVFW_DIRECTORY is not defined in the current GVBuffer.
fileName required This value can be static or dynamic, containing placeholders that could be replaced at plugin call time. This is a default value, and is used if the property GVFW_FILE_NAME is not defined in the current GVBuffer.

and does not have sub-elements.

How To

Suppose you want to create an Excel report file in the ${{gv.app.home}}/log folder. Right-clicking on Channel, insert after, FileWriter-call, a new element FileWriter-call will be created. Clicking above, on the Properties view, you can set its attributes like this:

Filewriter_call attributes
  • Class and type are passed by default.
  • Name, in this example, takes the value WriteReportFile
  • file-name will be setted as Report.xls

The respective part of the GVCore.xml file becomes:

<System id-system="GVESB" system-activation="on">
    <Channel id-channel="TEST_CHANNEL">    
        ----       
        <filewriter-call class="it.greenvulcano.gvesb.virtual.file.writer.FileWriter"
             fileName="Report.xls"
             name="WriteReportFile"
             targetPath="${{gv.app.home}}/log" type="call"/>                                     
    </Channel>
</System>

associated to the Service TestBirt.

<Service group-name="DEFAULT_GRP" id-service="TestBirt" service-activation="on" statistics="off">
    <Operation name="RequestReply" operation-activation="on" out-check-type="sys-svc-id" type="operation">
         <Participant id-channel="TEST_CHANNEL" id-system="GVESB"/>
         <Flow first-node="generate" point-x="20" point-y="150">
              <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
                    dump-in-out="false" id="generate" id-system="GVESB" input="input"
                    next-node-id="write" op-type="call" operation-name="TestBirt" output="report"
                    point-x="172" point-y="143" type="flow-node"/>
              <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
                    dump-in-out="false" id="write" id-system="GVESB" input="report" next-node-id="end" op-type="call"
                    operation-name="WriteReportFile" output="output" point-x="363" point-y="143" type="flow-node"/>
              <GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode" end-business-process="yes" id="end" op-type="end"
                    output="output" point-x="563" point-y="154" type="flow-node">
                   <ChangeGVBuffer clear-data="true"/>
             </GVEndNode>
         </Flow>
   </Operation>
</Service>
  • The first operation node, GVOperationNode: TestBirt defines the information needed for generating a BIRT report which be saved in report GVBuffer output.
  • The second Operation Node GVOperationNode : write receives report GVBUFFER as input and calls the operation filewriter-call : WriteReportFile which save its contain as an Excel file named Report.xls into path ${{gv.app.home}}/log (see placeholders).
  • The third node, GVEndNode : end, finishes the flow.