Kettle OpenVPMS Loader - how to specify 'next index number' for a collection?

I am trying to load customer phone, mobile and email data from an RxWorks database. In the transform I have no problems switching the rows to the appropriate OpenVPMS Loader step depending on whether these are phone numbers, mobile numbers or email addresses.

In the 'Map To' slot, if you want to load the first phone number, the entry is like: $CLIENTID<party.customerperson>contacts[0]<contact.phoneNumber>telephoneNumber

This works happily if you have one contact per customer, but if you have multiple contacts, then you really need a syntax that says 'give me the next available contact index' - something like: $CLIENTID<party.customerperson>contacts[+]<contact.phoneNumber>telephoneNumber

I have had a look at the source, and as far as I can see, you have to have a number between the square brackets, and there is no special number (like -1 or 9999999) that instructs the Loader to give you the next available index.

Am I missing something in the syntax, or is there no way to say 'load this contact into the next available slot'?

Regards, Tim G

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Kettle OpenVPMS Loader - how to specify 'next index ...

You can specify another index value e.g:

   $CLIENTID<party.customerperson>contacts[1]<contact.phoneNumber>telephoneNumber

but in general this won't work as clients may have different numbers of contacts.

What you can do is create a unique id for each contact to differentiate contacts. So your steps are:

1. input contacts from database, sorted

2. use the 'Add Sequence' step to add a sequence, 'CONTACT_ID'

3. use 'CONTACT_ID' as the value for the 'Id Field Name' in the OpenVPMS Loader step

The CONTACT_ID is solely used to uniquely identify the input row. You don't need it for any other purpose. You can then use:

 $CLIENTID<party.customerperson>contacts[0]<contact.phoneNumber>telephoneNumber

to load multiple rows for a client, assuming that CLIENTID is a value from the input rows that identifies the client.

-Tim

Re: Kettle OpenVPMS Loader - how to specify 'next index ...

Tim A - again, thanks for this, it enabled me to get things working, and I will add to my 'OpenVPMS Loader plugin for Pentaho Kettle' article in the near future.

Regards, Tim

Syndicate content