I'm looking for some nice worked examples/documetnation of using the Dynamic Java Component to generate/insert new data records in the data stream. Or any advice on the best way to append new records into a preexisting record stream
eg
I have 100 records and I want to insert a new record in at postion 51 ,so I would end up with 101 records.
Many Thanks,
Paul.

Hi Paul,
Are you using the Dynamic Java component to do a larger task, and also require it to add the empty data record? If not, it would be easier to add new records using a combination of the Generate Empty Data component along with some of our other native components.
I've attached a protocol with a component that generates an empty data record at the index ("row number") specified. You just have to specify the index on the Empty Data Record Index parameter on the component.
Hope that helps. Let me know if you have a specific need to do this within Java, and I can take a look at doing it that way.
Cheers,
Craig
Paul,
In order to perform this sort of task you need to set the return state of the component appropriately and probably also check for when you are processing new data records with the isNewData() method.
There is quite a good description of this in the Protocol Development Quick Start Guide which you can find in the Help Center or at http://doc.accelrys.com/library/PipelinePilot/doc/prot_dev_quickstart.pdf
I'm no programmer, and particularly not a Java programmer, but the attached protocol shows a very simple Dynamic VB.Net component that adds a record after every 10th record processed. The principle is the save in the dynamiuc Java
Please let me know if this helps.
Malcolm
Hi Paul,
Here is a simple example that lets you create N data records with the Dynamic Java component. As Malcolm pointed out, the key is the return value. If set to "ReadyForNewData" a new data record will be produced and onProcess() will be called again on that new data record. To prevent creating an endless number of data records, you will want to have some logic built in to eventually return "DoneProcessingData" which will then cause onFinalize() to be called without a new data record. Also note that the "ReadyForNewData" return state in onInitialize() creates the first data record, which onProcess() is then called on. So the flow can be thought of like this:
onIntialize()
ReadyForNewData -> Create Data Record 1
onProcess()
Process Data Record 1
ReadyForNewData -> Create Data Record 2
onProcess()
Process Data Record 2
ReadyForNewData -> Create Data Record 3
onProcess()
Process Data Record 3
DoneProcessingData
onFinalize()
Ian Kerman
Pipeline Pilot Support
Part of a larger task and I would really like to know how to do this but I can't seem to find any simple examples of how to add records with any of the dynamic components (.net, java, etc.), this seems to be the one limitation of out of the box PP is that adding new records to the stream is a little difficult compared with the range of excellent operations you can do to existing records.
But your example is very good, but I would like to add more than one record and do some customisations.. etc...
Hi Paul,
I borrowed from what Ian and Malcolm posted to come up with a Java solution to the problem you describe in your last post (adding 1 or more records at a certain location in the set of data records).
Please see the attached protocol, which uses the Dynamic Java component to generate a specified number of empty data records at a specific data record index ("row number").
Hope that helps. Let me know if you have any questions.
Cheers,
Craig