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"

m (Writing an attribute)
(General review on content and style)
Line 1: Line 1:
This tutorial shows how to add [[SMILA/Glossary#R|Record]] [[SMILA/Glossary#A|Attributes]] and [[SMILA/Glossary#A|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 [[SMILA/Glossary#P|Pipelets]] or [[SMILA/Glossary#P|ProcessingServices]].
+
This tutorial shows how to add [[SMILA/Glossary#R|record]] [[SMILA/Glossary#A|attributes]] and [[SMILA/Glossary#A|annotations]] to a BPEL workflow object and read or write them. Note that this procedure is only necessary if you want to make record data available for being used in BPEL (e.g. to pass parameters to a web service). It is not required for the usage of [[SMILA/Glossary#P|pipelets]] or [[SMILA/Glossary#P|processing services]].  
  
 
== Adding record data to the BPEL workflow object==
 
== 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 <tt>org.eclipse.eilf.blackboard/RecordFilters.xml</tt> 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 <tt>org.eclipse.eilf.processing.bpel/processor.properties</tt>) 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 <tt>keepAnnotations="true"</tt>.  
+
Because the workflow object contains the record IDs only, it is not possible by default to access the data contained in a record. However, you can configure the [[SMILA/Glossary#B|blackboard service]] to add particular attributes and annotations to the workflow object to make theme available for being used in BPEL. This is achieved by providing the file <tt>org.eclipse.eilf.blackboard/RecordFilters.xml</tt> in the global configuration folder and defining a filter named ''workflow-object'' that lists all attributes and annotations that you want to have access to in BPEL. The name of this filter is defined by the ''record.filter'' parameter set in the configuration file of the processing service found at <tt>org.eclipse.eilf.processing.bpel/processor.properties</tt>. If you wish to write data to attributes and annotations you will have to add them to the filter likewise. Set the XML attribute ''keepAnnotations'' to ''"true"'' if you want to define that the annotations of an attribute should be copied to the workflow object too.  
  
 
=== Example ===
 
=== Example ===
Here is an example <tt>RecordFilters.xml</tt>:
+
 
 +
The following listing shows an exemplary configuration of the file <tt>RecordFilters.xml</tt>. It adds a couple of attributes (e.g. ''Filename'', ''Path'', ''LastModifiedData'', ...) to the workflow object. For some of the attributes the ''keepAnnotations'' parameter is set to ''"true"'' to define that the object should include the annotations of the corresponding attribute too.
 
<source lang="xml">
 
<source lang="xml">
 
<RecordFilters>
 
<RecordFilters>
Line 26: Line 27:
  
 
== Using records in BPEL ==
 
== Using records in BPEL ==
 +
Next to the configuration of the attribute/annotation filter mentioned above, you will have to make sure that the following requirements are met if you wish to access records in BPEL:
 +
* The XML namespaces for <tt>processor</tt> and <tt>record</tt> must be defined.
 +
* The processor ''processor.wsdl'' must be imported.
 +
* A variable (e.g. ''request'') must be defined that contains the ''ProcessorMessage''.
  
In order to work with records in BPEL some requirements must be met:
+
Here are the corresponding XML snippets:
* 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:
+
 
<source lang="xml">
 
<source lang="xml">
 
<process ... xmlns:proc="http://www.eclipse.org/eilf/processor" xmlns:rec="http://www.eclipse.org/eilf/record" ... >
 
<process ... xmlns:proc="http://www.eclipse.org/eilf/processor" xmlns:rec="http://www.eclipse.org/eilf/record" ... >
Line 45: Line 45:
 
</source>
 
</source>
  
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.
+
Provided that you added the filter configuration and ensured the requirements above it is possible to access records and their contents via the variable ''request''. This variable contains an array of records. Each record can be accessed via its index number (starting at 1). So to be able to process all records, you will have to wrap the record access and execution of any business logic in a loop.
  
Here are some templates to access (read or write)
+
Here are some templates to access (read or write):
* a attribute value: <tt>$<variable>.records/rec:Record[<index>]/rec:A[@n="<Attribute-Name>"]/rec:L/rec:V</tt>
+
* an 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>
+
* an 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 the folder <tt>configuration/org.eclipse.eilf.processing.bpel/pipelines</tt>.
  
 
=== Examples ===
 
=== Examples ===
  
 
==== Reading an attribute ====
 
==== Reading an attribute ====
The value of attribute '''Title''' is read from the first record and stored in the variable '''input.param'''.
+
The value of the attribute ''Title'' is read from the first record and stored in the variable ''input.param''.
 
<source lang="xml">
 
<source lang="xml">
 
...
 
...
Line 68: Line 68:
 
...
 
...
 
</source>
 
</source>
 
  
 
==== Writing an attribute ====
 
==== Writing an attribute ====
The value of variable '''respponse.param''' is stored in attribute '''Title''' of the second record.  
+
The value of the variable ''response.param'' is stored in the attribute ''Title'' of the second record.  
  
 
<source lang="xml">
 
<source lang="xml">
Line 84: Line 83:
 
</source>
 
</source>
  
Note that in standard BPEL <assign> the target element that you want to write 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.
+
Note that in standard BPEL the target element that you want to write data to, must already exist before text can be stored in it, thus it is not possible to add new attributes, literal, and values to the workflow object this simply.

Revision as of 07:07, 6 October 2008

This tutorial shows how to add record attributes and annotations to a BPEL workflow object and read or write them. Note that this procedure is only necessary if you want to make record data available for being used in BPEL (e.g. to pass parameters to a web service). It is not required for the usage of pipelets or processing services.

Adding record data to the BPEL workflow object

Because the workflow object contains the record IDs only, it is not possible by default to access the data contained in a record. However, you can configure the blackboard service to add particular attributes and annotations to the workflow object to make theme available for being used in BPEL. This is achieved by providing the file org.eclipse.eilf.blackboard/RecordFilters.xml in the global configuration folder and defining a filter named workflow-object that lists all attributes and annotations that you want to have access to in BPEL. The name of this filter is defined by the record.filter parameter set in the configuration file of the processing service found at org.eclipse.eilf.processing.bpel/processor.properties. If you wish to write data to attributes and annotations you will have to add them to the filter likewise. Set the XML attribute keepAnnotations to "true" if you want to define that the annotations of an attribute should be copied to the workflow object too.

Example

The following listing shows an exemplary configuration of the file RecordFilters.xml. It adds a couple of attributes (e.g. Filename, Path, LastModifiedData, ...) to the workflow object. For some of the attributes the keepAnnotations parameter is set to "true" to define that the object should include the annotations of the corresponding attribute too.

<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

Next to the configuration of the attribute/annotation filter mentioned above, you will have to make sure that the following requirements are met if you wish to access records in BPEL:

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

Here are the corresponding XML snippets:

<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>

Provided that you added the filter configuration and ensured the requirements above it is possible to access records and their contents via the variable request. This variable contains an array of records. Each record can be accessed via its index number (starting at 1). So to be able to process all records, you will have to wrap the record access and execution of any business logic in a loop.

Here are some templates to access (read or write):

  • an attribute value: $<variable>.records/rec:Record[<index>]/rec:A[@n="<Attribute-Name>"]/rec:L/rec:V
  • an 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 the folder configuration/org.eclipse.eilf.processing.bpel/pipelines.

Examples

Reading an attribute

The value of the 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 the variable response.param is stored in the 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 write data to, must already exist before text can be stored in it, thus it is not possible to add new attributes, literal, and values to the workflow object this simply.

Back to the top