More documentation can be found here: https://docs.oracle.com/cd/E29542_01/doc.1111/e28275/c01_intro.htm
Script to generate the logs:
----------------------------------------------------------------------------------------------load("nashorn:mozilla_compat.js");
function logRPCEvent (rpc, funcName) {
var logger = rpc.getLogger();
logger.info("PrintRecogProcEvents.js entered function: " + funcName);
}
function initialize(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "initialize");
}
function processBatch(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "processBatch");
}
function restoreCaptureBatch(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "restoreCaptureBatch");
}
function beginPhase(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "beginPhase");
}
function endPhase(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "endPhase");
}
function extractBatchItem(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "extractBatchItem");
}
function barcodesFoundOnItem(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "barcodesFoundOnItem");
}
function batchItemAllValidBarcodes(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "batchItemAllValidBarcodes");
}
function determineSeparatorPage(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "determineSeparatorPage");
}
function batchItemValidBarcode(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "batchItemValidBarcode");
}
function determineDocType(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "determineDocType");
}
function beginDatabaseLookup(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "beginDatabaseLookup");
}
function determineIndexValues(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "determineIndexValues");
}
function renameOrigCaptureDocTitle(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "renameOrigCaptureDocTitle");
}
function createCaptureDoc(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "createCaptureDoc");
}
function postProcess(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "postProcess");
}
function endBatchProcess(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "endBatchProcess");
}
----------------------------------------------------------------------------------------------
Script to Update the Date format
----------------------------------------------------------------------------------------------load("nashorn:mozilla_compat.js");
importClass(java.text.SimpleDateFormat);
importClass(java.util.Date);
function logRPCEvent(rpc, logText) {
var logger = rpc.getLogger();
logger.info("[WWW] - " + logText);
}
function determineIndexValues(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "determineIndexValues");
convertDateFormat(rpc);
}
function convertDateFormat(rpc) {
logRPCEvent(rpc, "convertDateFormat");
var DOCUMENT_DATE_FIELD = "Document Date";
var documentDate = getIndexID(rpc, DOCUMENT_DATE_FIELD);
logRPCEvent(rpc, "Get Index Field Id: " + documentDate);
var capturedDocument = rpc.getBle().getBatch().getDocuments().get(0);
logRPCEvent(rpc, "Captured Document : " + capturedDocument);
var indexValues = rpc.getDocument().getIndexValues();
for (var i = 0; i < indexValues.size(); i++) {
var iv = indexValues.get(i);
if (iv.getFieldID().equals(documentDate)) {
logRPCEvent(rpc, "FieldID: [" + iv.getFieldID() + "] FieldValue: [" + iv.getFieldValue() + "]");
var documentDateCapturedValue = iv.getFieldValue();
iv.setFieldValue(formatRequiredDate(documentDateCapturedValue));
}
}
}
// @Format the date to yyyy-MM-dd'T'HH:mm:ss'Z'
function formatRequiredDate(currentDate) {
var REQUIRED_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
var LOOKUP_DATE_PATTERN = "MM-dd-yyyy";
var currentDateFormat = new SimpleDateFormat(LOOKUP_DATE_PATTERN);
var inputDate = currentDateFormat.parse(currentDate);
currentDateFormat.applyPattern(REQUIRED_PATTERN);
return currentDateFormat.format(inputDate);
}
// @Return the field object from document
function getFieldDefination(document, field) {
return document.getParentBatch().getWorkspace().getFieldDefinitions().findByName(field);
}
// @Get the index Id
function getIndexID(rpc, indexName) {
var workspace = rpc.getWorkspaceEntity();
var indexDef = findIndexDefinitionByName(workspace, indexName, rpc);
if (indexDef != null) {
var indexID = indexDef.getIndexFieldID();
}
logRPCEvent(rpc, " In getIndexID : indexID [" + indexID + "]");
return indexID;
}
// @Get the index definition by name
function findIndexDefinitionByName(workspace, indexName, rpc) {
logRPCEvent(rpc, " In findIndexDefinitionByName : Workspace [" + workspace + "], Index Name: [" + indexName + "]");
var indexDefs = workspace.getIndexDefinitions();
var size = indexDefs.size();
var foundIndexDef = null;
for (var i = 0; i < size; i++) {
var indexDef = indexDefs.get(i);
if (indexName.equals(indexDef.getFieldName())) {
foundIndexDef = indexDef;
break;
}
}
logRPCEvent(rpc, " In findIndexDefinitionByName : foundIndexDef [" + foundIndexDef + "]");
return foundIndexDef;
}
----------------------------------------------------------------------------------------------
Steps to configure in Capture:
- Copy the following code to a text file.
- Open the WebCenter Workspace Console.
- Select the desired Workspace.
- Select the "Advanced" train stop / tab.
- Click the "Add New Script" button.
- Select type "Recognition Processor" and name the script appropriately. For example, LogsRecProcEvents.
- Select the file created above and click submit.
- Select the "Processing" tab.
- Select the desired Recognition Processor job and click the Edit (pencil) icon.
- Go to the "Extensions" train stop / tab.
- Click the "Script" pulldown menu.
- Select the script created in the Advanced Tab, (e.g. LogsRecProcEvents).
- Click "Submit" to apply the script.
No comments:
Post a Comment