5 Creating Import Processor Scripts

This chapter describes creating Import Processor scripts.

You can develop scripts for the Import Processor to perform a wide variety of functions. Some common tasks include:

  • Skipping the importing of certain image files

  • Changing Capture batch properties

  • Skipping the importing of a batch

  • Adding page level metadata values during importing

  • After importing, moving images to a different folder

If an Import Job specifies a script to use during processing, the Import Processor Bean will create an instance of the JDK's ScriptRuntime class and initialize it with the script specified in the job. The Import Processor Bean, Import Manager Bean, and import sources all share this scripting runtime.

Capture enables you to create Import Processor scripts to customize the importing process. For more information, see Oracle Fusion Middleware Managing Oracle WebCenter Enterprise Capture.

This chapter contains the following sections:

5.1 Import Processor Events

Import Processor scripts are JavaScript modules that enable you to customize the behavior of certain Import Processor events.

This section describes the following Import Processor events:

5.1.1 preProcess

The preProcess event occurs prior to the pre-processing of the import source. Initialization code can be performed here.

Syntax Parameter
public void preProcess(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.2 process

The process event signals the start of the import process.

Syntax Parameter
public process(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.3 postProcess

The postProcess event occurs after the import source has been processed.

Syntax Parameter
public void postProcess(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.4 preCreateBatch

The preCreateBatch event occurs immediately after a new batch is started.

Syntax Parameter
public void preCreateBatch(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.5 postCreateBatch

The postCreateBatch event occurs immediately after a batch is created, but before any documents have been created.

Syntax Parameter
public void postCreateBatch(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.6 preCreateDocument

The preCreateDocument event occurs prior to a new document being created.

Syntax Parameter
public void preCreateDocument(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.7 postCreateDocument

The preCreateDocument event occurs after a new document has been created.

Syntax Parameter
public void postCreateDocument(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.8 preImportFile

The preImportFile event occurs prior to a file being imported.

Syntax Parameter
public void preImportFile(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.9 postImportFile

The postImportFile event occurs after a file is imported.

Syntax Parameter
public void postImportFile(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.10 preRelease

The preRelease event occurs prior to a batch being released.

Syntax Parameter
public void preRelease(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.11 postRelease

The postRelease event occurs after a batch has been released.

Syntax Parameter
public void postRelease(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.12 preDatabaseSearch

The preDatabaseSearch event occurs prior to a database lookup.

Syntax Parameter
public void preDatabaseSearch(ImportProcessorContext ctx); ImportProcessorContext ctx

5.1.13 processDatabaseSearchResults

The processDatabaseSearchResults event occurs after the database lookup has returned the search results.

Syntax Parameter
public void processDatabaseSearchResults(ImportProcessorContext ctx); ImportProcessorContext ctx

5.2 Email Source Events

This section describes the following email source events:

5.2.1 deleteMessage

The deleteMessage event occurs in the email message post-processing step when an email message is about to be deleted.

Syntax Parameter
public void deleteMessage(ImportProcessorContext ctx, EmailSourceContext emailCtx); ImportProcessorContext ctx

EmailSourceContext emailCtx


5.2.2 moveMessage

The moveMessage event occurs in the email message post-processing step when an email message is about to be moved to an email folder.

Syntax Parameter
public void moveMessage(ImportProcessorContext ctx, EmailSourceContext emailCtx); ImportProcessorContext ctx

EmailSourceContext emailCtx


5.2.3 newAttachment

The newAttachment event occurs when a new email attachment is about to be processed.

Syntax Parameter
public void newAttachment(ImportProcessorContext ctx, EmailSourceContext emailCtx); ImportProcessorContext ctx

EmailSourceContext emailCtx


5.2.4 newMessage

The newMessage event occurs when a new email message is about to be processed.

Syntax Parameter
public void newMessage(ImportProcessorContext ctx, EmailSourceContext emailCtx); ImportProcessorContext ctx

EmailSourceContext emailCtx


5.3 Folder Source Events

This section describes the following folder source events:

5.3.1 deleteDocumentFile

The deleteDocumentFile event occurs in the folder post-processing step when a file from the folder is about to be deleted.

Syntax Parameter
public void deleteDocumentFile(ImportProcessorContext ctx, FolderSourceContext folderCtx); ImportProcessorContext ctx

FolderSourceContext folderCtx


5.3.2 newFolder

The newFolder event occurs when a new folder is about to be processed.

Syntax Parameter
public void newFolder(ImportProcessorContext ctx, FolderSourceContext folderCtx); ImportProcessorContext ctx

FolderSourceContext folderCtx


5.3.3 renameDocumentFile

The renameDocumentFile event occurs in the folder post-processing step when a file from the folder is about to be renamed.

Syntax Parameter
public void renameDocumentFile(ImportProcessorContext ctx, FolderSourceContext folderCtx); ImportProcessorContext ctx

FolderSourceContext folderCtx


5.4 List File Source Events

This section describes the following list file source events:

5.4.1 deleteListFile

The deleteListFile event occurs in the list file post-processing step when a list file is about to be deleted.

Syntax Parameter
public void deleteListFile(ImportProcessorContext ctx, ListFileSourceContext listFileCtx); ImportProcessorContext ctx

ListFileSourceContext listFileCtx


5.4.2 newFolder

The newFolder event occurs when a new folder containing list files is about to be processed.

Syntax Parameter
public void newFolder(ImportProcessorContext ctx, ListFileSourceContext listFileCtx); ImportProcessorContext ctx

ListFileSourceContext listFileCtx


5.4.3 newListFile

The newListFile event occurs when a new list file is about to be processed.

Syntax Parameter
public void newListFile(ImportProcessorContext ctx, ListFileSourceContext listFileCtx); ImportProcessorContext ctx

ListFileSourceContext listFileCtx


5.4.4 newListFileLine

The newListFileLine event occurs when a new line in the list file is about to be processed.

Syntax Parameter
public void newListFileLine(ImportProcessorContext ctx, ListFileSourceContext listFileCtx); ImportProcessorContext ctx

ListFileSourceContext listFileCtx


5.4.5 renameListFile

The renameListFile event occurs in the list file post-processing step when a list file is about to be renamed.

Syntax Parameter
public void renameListFile(ImportProcessorContext ctx, ListFileSourceContext listFileCtx); ImportProcessorContext ctx

ListFileSourceContext listFileCtx


5.5 Import Processor Classes

In Capture, you can describes an Import Processor event class for every type of event you maintain in the database.

This section describes the following Import Processor classes:

In addition to the following event classes that can be used to design Import Processor scripts, there are some common classes that pertain to the Recognition Processor and the Import Processor. For more information on the common classes, see Section 6.1.

5.5.1 EmailSourceContext

The EmailSourceContext class contains all classes used in the processing of an email source.

Property Type Description
account String Name of the email account currently being processed.
folder Folder Email folder currently being processed.
message Message Email message currently being processed.
attachmentFilename String File name of the email message attachment currently being processed.

For more information on the Folder and Message class definitions, see the Javamail API documentation.

5.5.2 FolderSourceContext

The FolderSourceContext class contains all classes used in the processing of a folder source.

Property Type Description
folderName String Name of the directory currently being processed.
documentFilename String Name of the file currently being processed.
renamedDocumentFilename String If the post-processing step indicates the file should have a prefix added to it or the extension changed, this property indicates the changed file name.

5.5.3 ImportJob

Import jobs are configured within a Capture Workspace to import batches from import sources such as a file system folder, a delimited list file, or an inbox/folder of an email server.

Property Type Description
jobID String A value that uniquely identifies the job in the system.
workspaceID String Identifier of the workspace to which the job belongs.
jobName String A human-readable name for the job.
dbSearchID String Identifier of the database search to use when processing the job.
dbSearchFieldID String Identifier of the database search field to use when processing the job.
imageDownsample Integer Determines how to sample an image:
  • 0 – None (retain image format).

  • 1 – Down-sample color to 8 bit grayscale.

  • 2 – Down-sample color or grayscale to black and white.

jpegQuality Integer The JPEG quality ratio 0 to 99.
batchPrefix String Batch prefix to use when creating batch names.
defaultBatchStatusID String Identifier of the batch status to associate with batches created by this job.
defaultPriority Integer Default priority assigned to batches ranging from 0 to 10.
defaultDocumentTypeID String Default document profile for documents created by this job.
searchResultOption Integer Determines how to handle database lookups that return more than one result.
  • 0 – Use the first record.

  • 1 – Ignore results (do not populate fields).

scriptID String Unique identifier of a script to use for this job.
importFrequency Integer A value, specified in seconds, that determines how often a job should be polled for work to process. The following values are possible:
  • 0 – Inactive

  • 30 – Every 30 seconds

  • 60 – Every 1 minute

  • 300 – Every 5 minutes

  • 900 – Every 15 minutes

  • 1800 – Every 30 minutes

  • 3600 – Every 1 hour

  • -1 – Daily (Specify Time)

hour Integer If the importFrequency is set to Daily, this specifies the hour of the day.
minute Integer If the importFrequency is set to Daily, this specifies the minute of the day.
lastCheck Date Date or time the job was last checked for processing. This will be updated by the Import Job Scheduler after a job is polled for work to process.
fieldMappings Map<String, FieldMappingInfo> A set of values that map Capture fields to import source metadata fields.
importSourceClassName String Name of the Java class that provides the implementation of the import source for this job.
batchProcessorClassName String Name of the class that will be used to process the batch when it is released. If this value is null, the batch lock will be discarded and the batch will be put in a READY state.
batchProcessorJobID String A unique identifier for a batch processor job. If this value is null, either the processor does not support jobs or the batch is going to be put in a READY state.
imageFailureAction Integer Specifies the action to be taken if an invalid image is encountered:
  • 0 – Abort the batch

  • 1 – Skip the item

locale Locale Specifies the locale of the list file source.
defaultDateFormat String Specifies the default date format of dates in the list file source.
description String Description of this job.
encoding String Specifies the file encoding of the list file source.
isJobOnline Boolean Indicates whether this job should be processed.

5.5.4 ImportProcessorContext

The ImportProcessorContext class contains properties relevant to the job being processed. An instance of this class is created before processing is started and is passed to an import source at various stages throughout processing.

Property Type Description
cancel Boolean When this boolean value is set to True, it will cancel the operation being performed.
cancelDBSearch Boolean When this boolean value is set to True, it will cancel the database lookup.
dBSearchResults DBSearchResults Contains the results from a database lookup.
sourceName String Name of the import source that the current Import Job is configured to use.
logger Logger An instance of java.util.logging.Logger that can be used to log additional entries.
importJob ImportJob Current Import Job being processed.
batchLock BatchLockEntity Contains the batch lock entity for the batch, after a new batch has been created.
importSourceFile String Name of the file currently being processed.
documentEntity DocumentEntity Document entity associated with the file currently being processed.
documentPageEntity DocumentPageEntity Document page entity associated with the file currently being processed.
lastMultiPageTiffNumber Integer Contains the current page number of a multi-page TIFF file being processed.
workspaceEntity CaptureWorkspaceEntity Workspace entity associated with the current batch.

5.5.5 ListFileSourceContext

The ListFileSourceContext class contains all classes used in the processing of a list file source.

Property Type Description
folderName String Name of the folder currently being processed.
listFilename String Name of the list file currently being processed.
listFileLine String Contents of the line currently being processed in the list file.
documentFilename String Name of the file currently being processed from the current line in the list file.
renamedListFilename String If the post-processing step indicates the list file should have a prefix added to it or the extension changed, this property indicates the changed list file name.

5.6 Sample Import Processor Script

The following sample script sets each document's title to the name of the file being imported. When the documents are later committed, their document title can be mapped to an output field.

importClass(java.io.File);
 
function preCreateDocument(event) { // ImportProcessorContext
    var document;   // DocumentEntity
    var sourceFile; // File
 
    sourceFile = new File(event.getImportSourceFile());
    document = event.getDocumentEntity();
 
    // Set the document title to be the name of the source file
    document.setDocumentTitle(sourceFile.getName());    
}