Appboard/2.4/builder/data processing scripts

Revision as of 04:09, 3 September 2013 by imported>Mike.berman (create page for AppBoard 2.4)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Data Processing Script is a tool for customizing Data Sources in AppBoard to meet specific needs of a customer solution. By inserting Groovy script into the data processing, AppBoard can process the data according to a set of coded instructions. This allows data to be manipulated or pre-processed while passing between the raw back-end data source and AppBoard.


Applying a Data Processing Script

  1. Open the AppBoard Builder and click on "Data Sources"
  2. Select the data source to be affected and click the "Edit" button
  3. Advance through the data source wizard to the "explore" stage
  4. Select the table you want to transform and then click the "Advanced" button
  5. Configure the Data Processing Script
    1. Input the path name of the script
      1. typically Data Processing Script are kept in the following directory: ${appboard_server}/webapps/enportal/WEB-INF/groovy-script
    2. Set the priority (default 10)
      1. priority is only important if you have multiple scripts active
    3. Set script to run on "Response" or "Refresh"
      1. Response (called every time the client requests)
        1. Example when to use: performing a join or status determination by requesting data from another dataset
      2. Refresh (called only when data is fetched from source)
        1. Example when to use: substringing a value
  6. Click through the wizard to finish
  7. View the appropriate data collection (re-query if necessary) to see if data is being updated


Data Processing Script Example

TrimSiteCode.groovy

import com.edgetech.services.ServiceRequestFacade
import com.edgetech.services.ServiceResponseFacade
import com.edgetech.services.GenericRecord
import com.edgetech.services.Association
import com.edgetech.services.impl.ServiceRequestHelper
 
import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
 
// trim extra whitespace and concatenate two fields into a new one
 
ServiceResponseFacade serviceResponse = responseFacade;
ServiceRequestFacade serviceRequest = requestFacade;
 
                Collection recordsToClean = serviceResponse.getOrderedGenericRecords();
                if ( ( recordsToClean != null ) && !recordsToClean.isEmpty() ) {
                  for ( GenericRecord recordToClean:recordsToClean ) {
                                String siteCode = recordToClean.getAttributeValueAsString("SITE_CODE");
                                if ( siteCode != null ) {
                                                recordToClean.setAttributeValue("SITE_CODE", siteCode.trim());
                                                String stateCode = recordToClean.getAttributeValueAsString("STATE");
                                                if ( stateCode != null ) {
                                                                recordToClean.setAttributeValue("SITE_CODE2", siteCode.trim() + stateCode.trim());
                                                }
                                }
                                String region = recordToClean.getAttributeValueAsString("REGION");
                                if ( region != null ) {
                                                recordToClean.setAttributeValue("REGION", region.trim());
                                }
                  }
                }