Difference between revisions of "Filewriter-call"

From GreenVulcano Wiki
Jump to: navigation, search
({{VULCON}} / {{GVCONSOLE}} Configuration)
({{VULCON}} / {{GVCONSOLE}} Configuration)
 
(3 intermediate revisions by the same user not shown)
Line 29: Line 29:
 
|-
 
|-
 
| 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]].
 
| 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]].
 +
|-
 +
| append || optional || If true, the data are appended at the end of an existing file
 +
|-
 +
| appendEOL || optional || If true, then the attribute defines the EOL chars to append at the end of the input data. Default to nothing.
 
|}
 
|}
  
Line 35: Line 39:
 
==How To==
 
==How To==
  
Suppose you want to create a file present in the <nowiki>${{gv.app.home}}</nowiki>/TEST/TESTFS/TestXML/output 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. [[File:VULCONFilewriter_call.jpg|thumb|Filewriter_call attributes]]  
+
Suppose you want to create an Excel report file in the <nowiki>${{gv.app.home}}</nowiki>/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: [[File:VULCONFilewriter_call.jpg|thumb|Filewriter_call attributes]]  
 
 
''Class'' and ''type'' are passed by default. Name, in this example, takes the value ''writeFile'', and ''file-name'' is passed as a parameter through the property ''FILE_NAME'' (see [[placeholders]]).
 
  
 +
* ''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:
 
The respective part of the GVCore.xml file becomes:
Line 44: Line 49:
 
<syntaxhighlight lang="XML">
 
<syntaxhighlight lang="XML">
 
<System id-system="GVESB" system-activation="on">
 
<System id-system="GVESB" system-activation="on">
     <Channel id-channel="TEST_CHANNEL_FILE">     
+
     <Channel id-channel="TEST_CHANNEL">     
 
         ----       
 
         ----       
         <filereader-call class="it.greenvulcano.gvesb.virtual.file.reader.FileWriter"
+
         <filewriter-call class="it.greenvulcano.gvesb.virtual.file.writer.FileWriter"
            fileName="ognl{{property[&apos;FILE_NAME&apos;]}}"
+
            fileName="Report.xls"
            name="writeFile"
+
            name="WriteReportFile"
            srcPath="${{gv.app.home}}/TEST/TESTFS/TestXML/output"
+
            targetPath="${{gv.app.home}}/log" type="call"/>                                     
            type="call"/>                                     
 
 
     </Channel>
 
     </Channel>
 
</System>
 
</System>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
associated to the Service ''ValidateRemoteSingleXMLFile''.
+
associated to the Service ''TestBirt''.
  
 
<syntaxhighlight lang="XML">
 
<syntaxhighlight lang="XML">
<Service group-name="DEFAULT_GRP" id-service="ValidateRemoteSingleXMLFile" service-activation="on" statistics="off">
+
<Service group-name="DEFAULT_GRP" id-service="TestBirt" service-activation="on" statistics="off">
  <Operation name="Request" operation-activation="on" out-check-type="none" type="operation">
+
    <Operation name="RequestReply" operation-activation="on" out-check-type="sys-svc-id" type="operation">
      <Participant id-channel="TEST_CHANNEL_FILE" id-system="GVESB"/>
+
        <Participant id-channel="TEST_CHANNEL" id-system="GVESB"/>
      <Flow first-node="fillProperties" point-x="9" point-y="31">
+
        <Flow first-node="generate" point-x="20" point-y="150">
          <ChangeGVBufferNode class="it.greenvulcano.gvesb.core.flow.ChangeGVBufferNode"
+
              <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
                  id="fillProperties" input="node" next-node-id="read_validate_file"
+
                    dump-in-out="false" id="generate" id-system="GVESB" input="input"
                  op-type="change GVBuffer" output="input" point-x="-15" point-y="160" type="flow-node">
+
                    next-node-id="write" op-type="call" operation-name="TestBirt" output="report"
                <ChangeGVBuffer clear-data="false">
+
                    point-x="172" point-y="143" type="flow-node"/>
                    <OGNLScript>
+
              <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
                          property[&apos;FILE_NAME&apos;]=@it.greenvulcano.configuration.XMLConfig@get(object,&apos;@name&apos;)
+
                    dump-in-out="false" id="write" id-system="GVESB" input="report" next-node-id="end" op-type="call"
                    </OGNLScript>
+
                    operation-name="WriteReportFile" output="output" point-x="363" point-y="143" type="flow-node"/>
                </ChangeGVBuffer>
+
              <GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode" end-business-process="yes" id="end" op-type="end"
          </ChangeGVBufferNode>
+
                    output="output" point-x="563" point-y="154" type="flow-node">
                  ...
+
                  <ChangeGVBuffer clear-data="true"/>
          <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
+
            </GVEndNode>
                  id="write_file" id-system="GVESB" input="input"
+
        </Flow>
                  next-node-id="move_file" op-type="call"
 
                  operation-name="writeFile" output="input"
 
                  point-x="628" point-y="263" type="flow-node"/>
 
          <GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
 
                  end-business-process="yes" id="end" op-type="end"
 
                  output="input" point-x="747" point-y="21" type="flow-node"/>
 
      </Flow>
 
 
   </Operation>
 
   </Operation>
 
</Service>
 
</Service>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
The first operation node, ''ChangeGVBufferNode: fillProperties'' is used for setting the property ''FILE_NAME'' containing the name of the file to be written. After other elements, it is added the ''GVOperationNode: write_file'' who calls the operation ''filewriter_call: writeFile''.
+
* 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 <nowiki>${{gv.app.home}}</nowiki>/log (see [[placeholders]]).
 +
* The third node, ''GVEndNode : end'', finishes the [[flow]].

Latest revision as of 12:04, 16 November 2012

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.
append optional If true, the data are appended at the end of an existing file
appendEOL optional If true, then the attribute defines the EOL chars to append at the end of the input data. Default to nothing.

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.