Contents Hide
importClass (Packages.au.com.brightsoft.integrator.bi.Job) ;
importClass (Packages.au.com.brightsoft.integrator.bi.Task) ;
importClass (Packages.au.com.brightsoft.integrator.bi.FilePoint) ;
importClass (Packages.au.com.brightsoft.integrator.bi.FileSet) ;
importClass (Packages.au.com.brightsoft.integrator.bi.DatabasePoint) ;
importClass (Packages.au.com.brightsoft.integrator.bi.DatabaseSet) ;
function run()
{
try
{
ScriptSession.logInfo("Creating job...") ;
// Create the job manager instance
var jobManager = ScriptSession.createJobManagerObject() ;
// Create the job definition
var job = new Job("Import contacts job") ;
// Task definition
var task = new Task("Task for importing contacts") ;
// Create source (CSV file)
var contactsFile = new FilePoint("fileCONTACTS") ;
var setFileContacts = new FileSet("CONTACTS", "c:/temp/contacts_sample.csv", "MappingContactsFile") ;
contactsFile.addSet(setFileContacts) ;
// Create destination (database table)
var contactsTable = new DatabasePoint("jdbcCONTACTS") ;
contactsTable.setURL("jdbc:sqlserver://localhost:1433;DatabaseName=test") ;
contactsTable.setUserName("testuser") ;
contactsTable.setPassword("testpwd") ;
contactsTable.setDriverName("com.microsoft.sqlserver.jdbc.SQLServerDriver") ;
contactsTable.setQueryName("QueryContacts") ;
var setTableContacts = new DatabaseSet("CONTACTS", "CONTACTS", "MappingContactsTable") ;
contactsTable.addSet(setTableContacts) ;
// Add source and destination definitons to task definition
task.setSource(contactsFile) ;
task.setOldSource(contactsTable) ;
task.setDestination(contactsTable) ;
// Add the task to the job
job.addTask(task) ;
// Run the job
ScriptSession.logInfo("Running job...") ;
jobManager.run(job) ;
ScriptSession.logInfo("Job has completed successfully") ;
}
catch (error)
{
ScriptSession.logError("Failed to run job " + error.toString()) ;
}
}
Note:
The layout of the CSV file and CONTACTS tables are not given in the example and can be defined as required in the BEP project.
Assumes the CONTACTS table definition exists in the BEP project.
Assumes the mappings MappingContactsFile and MappingContactsTable defined in the BEP project.
Assumes the query QueryContacts is defined in the project.
The database details are arbitrary and should be set-up as needed.