Contents Hide
// Creating a Base64 Object
blob = new Blob(record.get(i));
str = util.encodeBase64(blob);
// Accessing the object
bytes = util.decodeBase64(str);
Note:
blob is a binary object, initialised by the new Blob() method.
str = string value of converted binary data.
record.get(i) is binary record data.
bytes = array of binary data.
The sample code below has a similar effect to having a mapping with 'Need to Decompress Data' set to true.

byteValue = record.get(5);
if (byteValue != null)
{
blobValue = new Blob(byteValue);
blobValue.decompress();
psInsertRecord.setBytes(6, blobValue.getBytes());
}
else
{
psInsertRecord.setNull(6, java.sql.Types.BLOB);
}
Note:
byteValue = Field from BrightForms in base64binary format; processed by script as byte[].
blobValue = Blob created from byte array 'byteValue'. Used to decompress the data, using the Blob.decompress() method.
psInsertRecord = Java prepared statement
Similar to a join statement in SQL.
vectData = new Vector() ;
vectData.add(parentResultSet);
vectData.add(childResultSet1);
vectData.add(childResultSet2);
vectRelationships = getRelationships() ;
result = Util.groupData(vectData, vectRelationships);
Note:
vectData = vector of ResultSets to which the grouping (join) occurs over.
parentResultSet = parent table (result set). The size of this vector will be the size of the resulting vector of the groupData function 'result'.
childResultSet1, childReportSet2 = child tables. Their field(s) will be grouped based on the parent table and the join. As there are two child tables; three tables in total, the size of the returned vectors' vectors will be 3.
vectRelationships = vector of relationships for the grouping (join) to occur over.
getRelationships(); = subfunction which returns a vector of vectors (length 4; 4-tuples) with defined relationships between parent and child tables. Further explained in Example 5.
result = A vector of vectors (length n; n-tuples of ResultSets where n is the size of vectData) containing the grouped results.
The following will read the result given in Example 3 and will return the sizes of each subset to BrightServer's info log via the ScriptSession object.
for (i = 0; i < result.size(); i++)
{
tuple = result.get(i);
orderedParent = tuple.get(0);
ScriptSession.logInfo(orderedParent.size());
orderedChild1 = tuple.get(1);
ScriptSession.logInfo(orderedChild.size());
orderedChild2 = tuple.get(2);
SriptSession.logInfo(orderedChild.size());
}
Note:
orderedParent - a subset of parent Records. As it's the parent table, only one table exists in this recorrd set.
orderedChild1, orderedChild2 - a subset of child records from tables defined in childResultSet1 and childResultSet2 respectively.
the output to the system's output log will be 1, n and m, where n and m are variable values, which vary given the number of matches found after making the grouping.
The following creates a relationship with the relationship similar to the following SQL statement:
SELECT * FROM ORDER, ORDER_ITEM
WHERE ID = ORDER_ID
A similar relationship may be used in conjunction with the example shown in Example 3.
function getRelationships()
{
vectRelationship = new Vector();
vectRelationship.add("ORDER");
vectRelationship.add("ORDER_ITEM");
srcKeys = new Vector();
srcKeys.add("ID");
vectRelationship.add(srcKeys);
dstKeys = new Vector();
dstKeys.add("ORDER_ID");
vectRelationship.add(dstKeys);
vect = new Vector();
vect.add(vectRelationship);
return vect;
}
Note:
vectRelationship = a relationship for the tables defined in section 3, this example will be specifying that the join is over "ORDER", "ORDER_ITEM" and that the relationship is ID = ORDER_ID. It is a vector of length 4; a 4-tuple.
"ORDER", "ORDER_ITEM" = names of the tables which the relationship occurs over. Represented by strings.
srcKeys, dstKeys = variables where the join occurs. As ID = ORDER_ID, srcKeys.get(0) == destKeys.get(0) and so forth,
vect = resulting vector of relationships. vectRelationship is added to this, as it is the only relationship. Other relationships similar to this one may additionally be defined within this vector before it returns and is used when creating a grouping.