Categorized Grouping Agent Example(3.0)

In a workflow the Cat Group agent is usually connected with one Analysis agent before and after the agent.


Typical workflow containing a Categorized Grouping agent

Analysis_1

In the first Analysis agent a UDR of the type CGAgentInUDR is created and populated.

The example below shows a possible Analysis_1 agent configuration:

Example - Analysis_1 agent configuration

consume{
                
//Create CGAgentInUDR.

CatGroup.CGAgentInUDR udr = udrCreate(CatGroup.CGAgentInUDR); 
            
//Set categoryId, data and filename UDR values.

debug(input.categoryID);
    udr.categoryID = (string)input.categoryID;
    udr.data = input.OriginalData;
    udr.fileName= "IncomingFile"; //When "Activate use of  
                        //grouping" is enabled in the Cat_Group 
                        //profile this file name will be used for
                        //the grouped data in the tar-file.
            
//When closeGroup is set to "true" the category can be closed 
//from APL, else settings in the Cat_Group profile will be used.

udr.closeGroup = false;
            
//Route UDR

udrRoute(udr);

}



When the  CGAgentInUDR  is created, the field structure can be viewed from the  UDR Internal Format Browser . For further information, see Categorized Grouping Related UDR Types in Categorized Grouping(3.0).

Cat_Group_1

The Cat Group agent is configured via the GUI. For configuration instructions see Categorized Grouping Profile(3.0).

When configured correctly incoming UDRs with different categoryIDs are collected and handled by the agent to return UDRs consisting of identical categoryID types.

The outgoing data is collected in a CGAgentOutUDR with the following structure.

Example - Outgoing data collected in a CGAgentOutUDR

internal CGAgentOutUDR {
    string categoryID;
    int closingCondition;  //Indicates closing condition 
                             that emits the file.
    bytearray data;
    boolean isLastPartial; //True if last UDR of the input file.
    int partialNumber;     //Sequence number of the UDR in the 
                           //file. 1 for the first, 2 for the
                           //second so on.
};

Analysis_2

In the Analysis_2 agent the CGAgentOutUDR will be processed in the way the agent is configured. In this example one directory, one directory delimiter and one file name are created. The CGAgentOutUDR information is thereafter put in amultiForwardingUDR and last routed to the Disk_2 agent.


Example - Analysis agent processing the CGAgentOutUDR

persistent int counter = 1;
                
consume {
//Create a fntUDR

FNT.FNTUDR fntudr = udrCreate(FNT.FNTUDR);
                
//Create a directory name

fntAddString(fntudr, "CG_Directory");

//Add a directory delimiter.

fntAddDirDelimiter(fntudr);

//Create a filename.

fntAddString(fntudr, "File_" + (string)counter);

//Create a multiForwardingUDR.

FNT.MultiForwardingUDR multiUDR = udrCreate(FNT.MultiForwardingUDR);

//Add the fntUDR created above containing the directory, 
//directory delimiter and the file name.

multiUDR.fntSpecification = fntudr;

//Add the data from the CGAgentOutUDR to the multiForwardingUDR.

multiUDR.content = input.data;

// print closingCondition, 
//  0 = timeout, 
//  1 = close on deactivation, 
//  2 = APL requested closure, 
//  3 = input file count limit is reached, 
//  4 = the input file size limit is reached

debug("Closing condition= " + input.closingCondition);
                
udrRoute(multiUDR);
counter = counter + 1;
}