var jobDataValues = StructNew();
// Get the job type
var jobTypeData = application.ptImport.JobDAO.getJobType(typeName=arguments.jobType);
var delayedStartMinSpan = 0;
if (NOT len(arguments.jobStartDate))
arguments.jobStartDate = request.formattedtimestamp;
//application.adf.utils.logappend(msg=jobTypeData, logfile='importContentDebug.html', label='jobTypeData');
//application.adf.utils.logappend(msg=arguments, logfile='importContentDebug.html', label='arguments for createJob');
jobDataValues.ID = createUUID();
jobDataValues.name = arguments.jobName;
jobDataValues.typeID = jobTypeData.ID;
jobDataValues.recordsToRun = arguments.jobRecordCount;
jobDataValues.currentRecord = 0;
jobDataValues.status = "Scheduled";
// Set the start date time
if ( NOT LEN(arguments.jobStartDate) ){
jobDataValues.startDateTime = request.formattedtimestamp;
delayedStartMinSpan = 0;
}
else {
jobDataValues.startDateTime = arguments.jobStartDate;
// TODO - GET THE time span in minutes from the date entered
delayedStartMinSpan = 2;
}
// Set the scheduled task name to be unique
jobDataValues.scheduledTaskName = arguments.jobName & "-" & dateFormat(jobDataValues.startDateTime,'yymmdd') & "-" & timeFormat(jobDataValues.startDateTime,'hhmm');
// Set the job items into the CE
application.ptImport.JobService.createJobItem(jobID=jobDataValues.ID, dataID=arguments.jobItemIDs);
// Set the Job
application.ptImport.JobDAO.setJob(jobData=jobDataValues);
//application.adf.utils.logappend(msg=jobDataValues, logfile='importContentDebug.html', label='jobDataValues for createJob');
if ( delayedStartMinSpan GT 0 ) {
application.ptImport.utils.setScheduledTask(
url="#request.site.url#_cs_apps/ajaxProxy.cfm?bean=JobController&method=runJob&jobID=#jobDataValues.ID#",
taskName=jobDataValues.scheduledTaskName,
schedLogFileName="#arguments.jobName#_scheduled_task.log",
minuteDelay=delayedStartMinSpan);
//application.adf.utils.logappend(logfile='importContentDebug.html', msg='Scheduling task for later: url="#request.site.url#_cs_apps/ajaxProxy.cfm?bean=JobController&method=runJob&jobID=#jobDataValues.ID#", taskName=#jobDataValues.scheduledTaskName#, schedLogFileName="#arguments.jobName#_scheduled_task.log", minuteDelay=#delayedStartMinSpan#',label='Scheduling Task for later');
}
else {
// Start the job right now
//runJob(jobID=jobDataValues.ID);
//application.adf.utils.logappend(msg='Not scheduling the task', logfile='importContentDebug.html', label='Not scheduling');
}
//return application.ptImport.JobDAO.setJob(jobData=jobDataValues);
return jobDataValues.ID;
// Get the job data
var jobData = application.ptImport.JobDAO.getJob(jobID=arguments.jobID);
var jobParams = StructNew();
var appConfig = application.ptImport.getAppConfig();
var jobTypeQry = QueryNew("null");
var jobUpdateStatus = false;
if ( jobData.RecordCount ){
// Set the current status for the
jobParams.jobID = arguments.jobID;
jobParams.currentRecord = jobData.currentRecord + 1;
jobParams.stopRecord = jobData.currentRecord + appConfig.run_per_pass;
// Check that the stop doesn't exceed the total records
if ( jobParams.stopRecord GT jobData.recordsToRun )
jobParams.stopRecord = jobData.recordsToRun;
// Get the job type data
jobTypeQry = application.ptImport.JobDAO.getJobType(typeID=jobData.typeID);
jobParams.type = jobTypeQry.name;
// Update the Import Job Status
jobUpdateStatus = application.ptImport.JobService.setJobStatus(
jobID=arguments.jobID,
status="Processing");
// Call the functions to process jobs
/* if ( jobTypeQry.name EQ "subsites-mapping" ){
// Run the subsite controller to build mappings
application.ptImport.SubsiteController.buildMappingRecords(jobData=jobParams);
} */
/* else if ( jobTypeQry.name EQ "pages-mapping" ){
// Run the page controller to build mappings
application.ptImport.PageController.buildMappingRecords(jobData=jobParams);
} */
if ( ( jobTypeQry.name EQ "subsites-mapping" )
OR ( jobTypeQry.name EQ "subsites-build" )
OR ( jobTypeQry.name EQ "pages-mapping" )
OR ( jobTypeQry.name EQ "pages-build" )
OR ( jobTypeQry.name EQ "documents-mapping" )
OR ( jobTypeQry.name EQ "documents-build" )
OR ( jobTypeQry.name EQ "images-mapping" )
OR ( jobTypeQry.name EQ "images-build" )
OR ( jobTypeQry.name EQ "links-build" ))
{
// Process the job items
processJobItems(jobData=jobParams);
}
else{
// TODO - Catch error of no job type
return false;
}
// Check if we are complete or need to reschedule
if ( jobParams.stopRecord GTE jobData.recordsToRun ){
// delete
deleteScheduledJob(jobID=arguments.jobID);
jobNewStatus = "Complete";
}
else {
// reschedule
rescheduleJob(jobID=arguments.jobID);
jobNewStatus = "Scheduled";
}
// Update the Import Job Status
jobUpdateStatus = application.ptImport.JobService.setJobStatus(
jobID=arguments.jobID,
status=jobNewStatus);
return true;
}
else
return false;
// Get the job item data
var jobItemQry = application.ptImport.jobDAO.getJobItem(jobID=arguments.jobData.jobID);
var i = 1;
var jobItemStatus = "complete";
var itemDataID = "";
//application.ADF.utils.dodump(jobItemQry, "jobItemQry", false);
//application.ADF.utils.abort();
// Loop over the map data and create the subsites
for ( i = #arguments.jobData.currentRecord#; i LTE #arguments.jobData.stopRecord#; i=i+1 )
{
// Set the current item data ID
itemDataID = jobItemQry.dataID[i];
//application.ADF.utils.dodump(i, "i", false);
//application.ADF.utils.dodump(itemDataID, "itemDataID", false);
//application.ADF.utils.abort();
// Build the page
if ( arguments.jobData.type EQ "subsites-mapping" )
jobItemStatus = application.ptImport.SubsiteController.buildMapping(jobItemDataID=itemDataID);
else if ( arguments.jobData.type EQ "subsites-build" )
jobItemStatus = application.ptImport.SubsiteController.buildSubsite(jobItemDataID=itemDataID);
else if ( arguments.jobData.type EQ "pages-mapping" )
jobItemStatus = application.ptImport.PageController.buildMapping(jobItemDataID=itemDataID);
else if ( arguments.jobData.type EQ "pages-build" )
jobItemStatus = application.ptImport.PageController.buildPage(jobItemDataID=itemDataID);
else if ( arguments.jobData.type EQ "documents-mapping" )
jobItemStatus = application.ptImport.DocumentController.buildMapping(jobItemDataID=itemDataID);
else if ( arguments.jobData.type EQ "documents-build" )
jobItemStatus = application.ptImport.DocumentController.buildDocument(jobItemDataID=itemDataID);
else if ( arguments.jobData.type EQ "images-mapping" )
jobItemStatus = application.ptImport.ImageController.buildMapping(jobItemDataID=itemDataID);
else if ( arguments.jobData.type EQ "images-build" )
jobItemStatus = application.ptImport.ImageController.buildImage(jobItemDataID=itemDataID);
else if ( arguments.jobData.type EQ "links-build" )
jobItemStatus = application.ptImport.PageController.fixLinks(jobItemDataID=itemDataID);
// Update the job data and job item data with the status
jobProcessingStatus = application.ptImport.JobController.updateJobProcessing(
jobid=arguments.jobData.jobID,
currentRecord=i,
itemDataID=itemDataID,
itemStatus=jobItemStatus);
}
// Update the Job Item record
var jobItemStatus = application.ptImport.JobService.updateJobItem(
jobID=arguments.jobID,
dataID=arguments.itemDataID,
status=arguments.itemStatus);
// Update the Job record
var jobStatus = application.ptImport.JobService.setJobStatus(
jobID=arguments.jobID,
status="Processing",
currentRecord=arguments.currentRecord);
return true;
// Get the job data
var jobData = application.ptImport.JobDAO.getJob(jobID=arguments.jobID);
var appConfig = application.ptImport.getAppConfig();
application.ptImport.utils.setScheduledTask(
url="#request.site.url#_cs_apps/ajaxProxy.cfm?bean=JobController&method=runJob&jobID=#jobData.ID#",
taskName=jobData.scheduledTaskName,
schedLogFileName="#jobData.name#_scheduled_task.log",
minuteDelay=appConfig.run_pause_mins);
return true;
// Get the job data
var jobData = application.ptImport.JobDAO.getJob(jobID=arguments.jobID);
application.ptImport.utils.deleteScheduledTask(taskName=jobData.scheduledTaskName);
return true;