Routes and mapping

1. Define a route to the data resource

You checked that the data exists in the deployment and copied the path to the resource to your clipboard. Now, you will create a route that connects to your data.

Did you know: Camel routes

Routes describe the path to the data, and then manage the data you find at the end of the path. 

Routes are a technical concept. Depending on your role when working with Axway Decision Insight, you may or may not need to understand all the technical details. However, it is useful  to understand some basic aspects of Camel and Camel routes.

In this tutorial, you will learn the basics of building a simple route. The tutorial skips some of the complex technical explanations, but may go a little deeper into technology than you might need. To learn more about Camel, for example, the different options for the csv command, you can always Google camel csv. The search results will almost always list a useful resource in the top two or three links.

Note: Camel can be used in Java or XML. Almost all the examples given are for Java coders. XML examples are available on the Internet. Learning Camel with XML should be easy once you are familiar with Camel in Java.

Concept: Marshalling

Camel borrows a concept from the railroad industry called marshalling. Railroads maintain marshalling yards at various junctions along their track network. A marshalling yard is a set of branches and parallel tracks used to stage cars in sequence as they link together the pieces of a train.

Column-oriented data is a bit like a marshalling yard: columns represent the sequences of cars on a staging track. In your case, you want to read each track siding in sequence. Camel calls this action an unmarshal.

 

The following procedure describes how to create a route.

Step

Action

1

From the Application Data Integration screen, on the main menu, click Routes.

2

Click New Routing Context. The Details pane is displayed.

3

In the Name field, enter the name of your route. For example, RouOrder.

4

At the start, the text box in the Details pane should look like this:

The first line defines the characteristics of what follows. Lines 2 and 3 are an XML pair that mark the start and end of the route definition. Everything you add will fall between these two lines.

5

Put your cursor at the end of line 2 and press the Enter key to insert a blank line before the </routes> tag.

Type <route>.

Notice that when you type the closing >, Decision Insight automatically adds the closing </route> statement to the right of your tag.

6 Press the Enter key to create a new line between the closing and opening route tags. That blank line is where you will define the path to your data.
7

On the blank line after <route>, paste the path you copied from the Resources page. If you didn’t copy it, you can manually type the path:

<from uri="tnd-resource:resOrder" />

8

Put the mouse cursor at the end of the line you pasted or added in the previous step and press the Enter key to create a new blank line.

Enter <unmarshal>. Decision Insight automatically adds the </unmarshal> tag to close the pair.

Press the Enter key to create a new line between the closing and opening unmarshal tags.

9

Camel includes a connector for comma-separated value data.
On the blank line between the unmarshal pair, invoke this connector with:

<csv 

Complete the statement with two modifiers about the header record and the delimiter that match what we used in our resource:

skipHeaderRecord ="true" delimiter="|"/ 

Notice that when you enter the / character, Decision Insight automatically adds the closing > bracket.

10 Now, you are ready to have Camel pull the data apart for you. Just after the </unmarshal> tag, press the Enter key to create a new line.
In the blank line, enter <split>. Decision Insight automatically adds the closing tag for you.
11 Press the Enter key to create a new line between the closing and opening split tags.
12 Now, you need to tell Camel how to handle your data. One way is to use the Simple Expression language: in the blank line between the <split> tags, type <simple>. Decision Insight automatically adds the closing tag.
13

Between the two simple tags, type ${body}.

Note: ${body} is a placeholder for expressions you will use in a minute.

14

Your route should look like the image below. If it does, then that is as far as you need to go toward defining the route for now. Your route is not complete yet. However, there is a best practice that will make completing the route less complex for beginners.

Click Save.

 

2. Map the parameters for the file entity

The next important concept to understand is mapping. The purpose of a Camel route is to bring data from the source —here, the Order data file— into the model, entities, and attributes you defined in the deployment.

The data file you created provides the information needed to instantiate Order entities, but the data still needs is a map to connect the data file to the elements in deployment. In Decision Insight terminology, that is the mapping.

Did you know: Connecting resources, routes, mappings, and entities

A thread connects all the parts of your data. Information coming from a route (or a resource) uses the mapping to place the data into the entity attributes. The following diagram shows how to link everything together:

The following procedure explains how to map the data fields from the data file to your File entity fields of the same name.

Step

Action

1

From the Application Data Integration screen, on the main menu, click Mappings.

2

Click New Mapping. The Details pane is displayed.

3

In the Name field, give the mapping a name. For example, mapOrder.

Note: Mappings can have the same name as routes.

4

Click Add parameter. The Add Parameter dialog box is displayed.

5

Add the following parameters:

  • CustomerName, CustomerReference, CycleNumber (as Strings)

  • Timestamp (as an Instant).

The Details pane updates each time you update the parameter list.

Caution: Don’t click Save yet – you have only just begun to define the mapping.

 

Note: The Mappings pane is read horizontally, left to right. The white space between sections may occasionally look as if the information lines up vertically. Make sure to read the display as it was intended - across.

For more information about mappings see the Mapping page in the Glossary.

Related Links