Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "SMILA/Documentation/HowTo/How to filter and access record data in BPEL"

(Writing an attribute)
(Using records in BPEL)
Line 50: Line 50:
 
* a attribute value: <tt>$<variable>.records/rec:Record[<index>]/rec:A[@n="<Attribute-Name>"]/rec:L/rec:V</tt>
 
* a attribute value: <tt>$<variable>.records/rec:Record[<index>]/rec:A[@n="<Attribute-Name>"]/rec:L/rec:V</tt>
 
* a attribute annotation: <tt>$<variable>.records/rec:Record[<index>]/rec:A[@n="<Attribute-Name>"]/rec:AN[@n="<Annotation-Name>"]/rec:V</tt>
 
* a attribute annotation: <tt>$<variable>.records/rec:Record[<index>]/rec:A[@n="<Attribute-Name>"]/rec:AN[@n="<Annotation-Name>"]/rec:V</tt>
* a record annotation: <tt>$<variable>.records/rec:Record[<index>]/rec:AN[@n="<Annotation-Name>"]/rec:V</tt>
+
* a record annotation: <tt>$<variable>.records/rec:Record[<index>]/rec:An[@n="<Annotation-Name>"]/rec:V</tt>
  
 
For more details on the XML schemas and the WSDL see the files <tt>id.xsd</tt>, <tt>record.xsd</tt> and <tt>processor.wsdl</tt> in folder <tt>configuration/org.eclipse.eilf.processing.bpel/pipelines</tt>.
 
For more details on the XML schemas and the WSDL see the files <tt>id.xsd</tt>, <tt>record.xsd</tt> and <tt>processor.wsdl</tt> in folder <tt>configuration/org.eclipse.eilf.processing.bpel/pipelines</tt>.

Revision as of 05:48, 30 September 2008

This tutorial shows how to add Record Attributes and Annotations to a BPEL workflow object and read or write them. This is only necessary if you want to make record data available for use in BPEL (e.g. to pass parameters to a webservice). It is not required for the usage of Pipelets or ProcessingServices.

Adding record data to the BPEL workflow object

By default the workflow object contains only the Record IDs. To add additional Record Attributes and Annotations (Attachments are not supported!) you can configure the BlackboardService accordingly, by providing the file org.eclipse.eilf.blackboard/RecordFilters.xml in the global configuration folder. Therin you can define a filter named workflow-object (the name of ths filter is defined in the processing service config file org.eclipse.eilf.processing.bpel/processor.properties) that lists all Attributes and Annotations you want to have access to in BPEL. Note that you also have to include Attributes/Annotations you want to write data to. You can also define wether the Annotations of an Attribute should be copied too, by setting the xml attribute keepAnnotations="true".

Example

Here is an example RecordFilters.xml:

<RecordFilters>
  <Filter name="workflow-object">
    <Attribute name="Filename" keepAnnotations="true"/>
    <Attribute name="Path" keepAnnotations="true"/>
    <Attribute name="LastModifiedDate" keepAnnotations="false"/>
    <Attribute name="Url" keepAnnotations="true"/>
    <Attribute name="Title" keepAnnotations="true"/>
    <Attribute name="Extension" keepAnnotations="true"/>
    <Attribute name="Size" keepAnnotations="false"/>
    <Attribute name="MimeType" keepAnnotations="true"/>
 
    <Annotation name="some-workflow-annotation" />
    <Annotation name="some-other-workflow-annotation" />
  </Filter>
</RecordFilters>

Using records in BPEL

In order to work with records in BPEL some requirements must be met:

  • XML namespaces for processor and record must be defined
  • the processor.wsdl must be imported
  • a variable (e.g. request) must be defined that contains the ProcessorMessage

Here are the corresponding XML snipptes:

<process ... xmlns:proc="http://www.eclipse.org/eilf/processor" xmlns:rec="http://www.eclipse.org/eilf/record" ... >
    ...
	<import location="processor.wsdl" namespace="http://www.eclipse.org/eilf/processor" importType="http://schemas.xmlsoap.org/wsdl/" />
    ...
	<variables>
		<variable name="request" messageType="proc:ProcessorMessage" />
	</variables>
    ...
</process>

Now it is possible to access records and their contents via the variable request. Variable request contains an array of records. Each record can be accessed via it's index (starting at 1). So to be able to process all records you have to wrap record access and execution of any business logic in a loop.

Here are some templates to access (read or write)

  • a attribute value: $<variable>.records/rec:Record[<index>]/rec:A[@n="<Attribute-Name>"]/rec:L/rec:V
  • a attribute annotation: $<variable>.records/rec:Record[<index>]/rec:A[@n="<Attribute-Name>"]/rec:AN[@n="<Annotation-Name>"]/rec:V
  • a record annotation: $<variable>.records/rec:Record[<index>]/rec:An[@n="<Annotation-Name>"]/rec:V

For more details on the XML schemas and the WSDL see the files id.xsd, record.xsd and processor.wsdl in folder configuration/org.eclipse.eilf.processing.bpel/pipelines.

Examples

Reading an attribute

The value of attribute Title is read from the first record and stored in the variable input.param.

...
<assign name="copy-attribute-to-variable">			
    <copy>
        <from>$request.records/rec:Record[1]/rec:A[@n="Title"]/rec:L/rec:V</from>
        <to>$input.param</to>
    </copy>
</assign>
...


Writing an attribute

The value of variable respponse.param is stored in attribute Title of the second record.

...
<assign name="copy-variable-to-attribute">
    <copy>
        <from>$response.param</from>
        <to>$request.records/rec:Record[2]/rec:A[@n="Title"]/rec:L/rec:V</to>
    </copy>
</assign>
...

Note that in standard BPEL the target element that you want to copy data to, must exist already before text can be stored in it, it is not possible to add new attributes, literal and values to the workflow object this simply.

Back to the top