Let’s back up a little and make sure we understand what we’re trying to do.
The primary goal is to use Vector instead of a document list (IData array) for creating and building a collection of documents. This is to avoid the performance issues associated with appending a document one at a time to an IData array.
The desired functions for this are:
- Create a new Vector
- Add a document to a Vector
- Add multiple documents (an IData array) to a Vector
- Add one Vector to another Vector
- Transform the Vector a document list (an IData array)
Code for 1, 2 and 5 is in this post.
For 3 and 4, slight tweaks to the code for 2 would do the trick.
[highlight=java]
// Code for adding a document list to the Vector
IDataCursor pipelineCursor = pipeline.getCursor();
// get Vector and docList from pipeline
IData docList = IDataUtil.getIDataArray( pipelineCursor, “docList” );
Vector vector = (Vector)IDataUtil.get( pipelineCursor, “vector” );
pipelineCursor.destroy();
//append all documents in docList to Vector
if ( docList != null) {
for(int i=0; i<docList.length; i++)
vector.add(document);
}
// Don’t need to do the following–vector is already in the pipeline
//IDataCursor pipelineCursor1 = pipeline.getCursor();
//IDataUtil.put( pipelineCursor1, “vector”, vector );
//pipelineCursor1.destroy();
///////////////////////////////////
// Code for adding the contents of a Vector to another Vector
IDataCursor pipelineCursor = pipeline.getCursor();
// get the vectors from pipeline
Vector v1 = (Vector)IDataUtil.get( pipelineCursor, “vector1” );
Vector v2 = (Vector)IDataUtil.get( pipelineCursor, “vector2” );
pipelineCursor.destroy();
//append contents of first vector to second vector
if (v1 != null && v2 != null) {
v2.addAll(v1);
}[/highlight]
Hope this clarifies things.
#Flow-and-Java-services#webMethods#Integration-Server-and-ESB