variables.componentName = "catalogSyncController";
variables.syncTaskPrefix = getExternalSyncScheduledTaskPrefix(); // "Course-Catalog-";
// ADF Scheduler Job Names
variables.jobMonitorSync = variables.syncTaskPrefix & "Sync-Monitor"; // "Course-Catalog-Sync-Monitor";
variables.jobDeptSync = variables.syncTaskPrefix & "Department-Sync"; // "Course-Catalog-Department-Sync";
variables.jobProgramSync = variables.syncTaskPrefix & "Program-Sync"; // "Course-Catalog-Program-Sync";
variables.jobCourseSync = variables.syncTaskPrefix & "Course-Sync"; // "Course-Catalog-Course-Sync";
variables.jobProgReqSync = variables.syncTaskPrefix & "Program-Requirements-Sync"; // "Course-Catalog-Program-Requirements-Sync";
variables.jobCoursePrereqSync = variables.syncTaskPrefix & "Course-Prerequisites-Sync"; // "Course-Catalog-Course-Prerequisites-Sync";
// Default params for batch schedule processing
variables.ScheduleDelay = 2; // Minutes till next schedule item
variables.TasksPerBatch = 20; // How many tasks to do per iteration
var dateTimeStamp = Now();
// 1) Reset the ptCourseCatalogImport application Struct
application.ptCourseCatalogImport = StructNew();
// 2 ) Reset the JOB ADFScheduler application Structs
application.ADFScheduler[variables.jobDeptSync] = StructNew();
application.ADFScheduler[variables.jobProgramSync] = StructNew();
application.ADFScheduler[variables.jobCourseSync] = StructNew();
application.ADFScheduler[variables.jobProgReqSync] = StructNew();
application.ADFScheduler[variables.jobCoursePrereqSync] = StructNew();
// 3) Initialize the Sync Monitor
initSyncMonitor();
return true;
// Reset the monitor variable space
application.ptCourseCatalogSyncMonitor = StructNew();
// Update the Course Catalog Import Job date/time stamp
application.ptCourseCatalogSyncMonitor.startDateTime = now();
// Start with the first stage
application.ptCourseCatalogSyncMonitor.stage = 0;
// Set the status
application.ptCourseCatalogSyncMonitor.status = "start";
// Build the scheduled task to monitor the import process
updateMonitorSchedule();
return true;
var schedStatus = "";
// Determine the stage for the sync process
// 0 = Start
// 1 = Departments
// 2 = Programs
// 3 = Courses & Schedules
// 4 = Program Course Requirements
// 5 = Course Prerequisites
// 6 = Complete
switch (application.ptCourseCatalogSyncMonitor.stage) {
case "0":
// Start the sync process with the Departments
buildDepartmentSyncJob();
application.ptCourseCatalogSyncMonitor.status = "active";
application.ptCourseCatalogSyncMonitor.stage = 1; // Update the stage
updateMonitorSchedule();
break;
case "1":
// Check the status of the Department sync
schedStatus = application.ptCourseCatalog.scheduler.getScheduleStatus(scheduleName=variables.jobDeptSync);
// If the Department are complete, then start the Program sync
if ( schedStatus.status EQ "complete" ) {
buildProgramSyncJob();
application.ptCourseCatalogSyncMonitor.stage = 2; // Update the stage
}
updateMonitorSchedule();
break;
case "2":
// Check the status of the Program sync
schedStatus = application.ptCourseCatalog.scheduler.getScheduleStatus(scheduleName=variables.jobProgramSync);
// If the Department are complete, then start the Program sync
if ( schedStatus.status EQ "complete" ) {
buildCourseSyncJob();
application.ptCourseCatalogSyncMonitor.stage = 3; // Update the stage
}
updateMonitorSchedule();
break;
case "3":
// Check the status of the Course sync
schedStatus = application.ptCourseCatalog.scheduler.getScheduleStatus(scheduleName=variables.jobCourseSync);
// If the Department are complete, then start the Program sync
if ( schedStatus.status EQ "complete" ) {
buildProgramReqsSyncJob();
application.ptCourseCatalogSyncMonitor.stage = 4; // Update the stage
}
updateMonitorSchedule();
break;
case "4":
// Check the status of the Course sync
schedStatus = application.ptCourseCatalog.scheduler.getScheduleStatus(scheduleName=variables.jobProgReqSync);
// If the Department are complete, then start the Program sync
if ( schedStatus.status EQ "complete" ) {
buildCoursePreReqsSyncJob();
application.ptCourseCatalogSyncMonitor.stage = 5; // Update the stage
}
updateMonitorSchedule();
break;
case "5":
// Check the status of the Course sync
schedStatus = application.ptCourseCatalog.scheduler.getScheduleStatus(scheduleName=variables.jobCoursePrereqSync);
// If the Department are complete, then start the Program sync
if ( schedStatus.status EQ "complete" ) {
application.ptCourseCatalogSyncMonitor.stage = 6; // Update the stage
}
updateMonitorSchedule();
break;
case "6":
// Monitor is completed
application.ptCourseCatalogSyncMonitor.status = "complete";
// Delete the scheduled task
application.ptCourseCatalog.utils.deleteScheduledTask(taskName=variables.jobMonitorSync);
break;
default:
// Monitor has failed, the stage is not defined
application.ptCourseCatalogSyncMonitor.status = "fail";
// Delete the scheduled task
application.ptCourseCatalog.utils.deleteScheduledTask(taskName=variables.jobMonitorSync);
break;
}
return true;
var scheduleURL = "http://#cgi.server_name#:#cgi.server_port##application.ADF.ajaxProxy#?bean=catalogSyncController&method=runSyncMonitor";
var logFilePrefix = dateFormat(now(), "yyyymmdd") & "." & request.site.name & ".";
var schedLogFileName = logFilePrefix & "scheduledStatus-" & variables.jobMonitorSync & ".html";
// Build the scheduled task to monitor the import process
// - check job Monitor every 1 minute
application.ptCourseCatalog.utils.setScheduledTask(url=scheduleURL,
taskName=variables.jobMonitorSync,
schedLogFileName=schedLogFileName,
minuteDelay=1);
return true;
// Get the external Department data
var extDeptDataQry = application.ptCourseCatalog.catalogSyncDAO.getDepartmentCodes();
var i = 1;
// Build the command array
var cmdArray = ArrayNew(1);
var tempCmd = StructNew();
var scheduleParams = StructNew();
var rowCount = 0;
var startRow = 1;
// Set the schedule params
scheduleParams.delay = variables.ScheduleDelay; // Minutes till next schedule item
scheduleParams.tasksPerBatch = variables.TasksPerBatch; // How many tasks to do per iteration
// set the rowCount to the number of items returned by the query
rowCount = extDeptDataQry.recordCount;
if ( IsNumeric(arguments.syncRowCount) AND arguments.syncRowCount LT rowCount)
rowCount = arguments.syncRowCount;
// the startRow to the first row unless a syncStartRow is passed in
if ( IsNumeric(arguments.syncStartRow) AND arguments.syncStartRow GT 1 ) {
startRow = arguments.syncStartRow;
rowCount = startRow + rowCount - 1; // the New Row count is the startRow plus rowCount minus 1 (startRow=2,rowCount=5: 2,3,4,5,6)
// Check to of rowCount is not less than the startRow or greater than the total query recordCount
if ( rowCount LT startRow )
rowCount = startRow;
else if ( rowCount GT extDeptDataQry.recordCount )
rowCount = extDeptDataQry.recordCount;
}
// Loop over the external data
for ( i=startRow; i LTE rowCount; i++ ) {
// Build the temp command to keep calling
tempCmd = StructNew();
tempCmd.bean = "catalogSyncController";
tempCmd.method = "syncDepartment";
tempCmd.args = StructNew();
tempCmd.args.deptCode = extDeptDataQry.deptCode[i];
tempCmd.args.returnFormat = "JSON";
// Add the temp call to the command
ArrayAppend(cmdArray, tempCmd);
}
if ( ArrayLen(cmdArray) ) {
// Load into the Scheduler
application.ADF.scheduler.scheduleProcess(scheduleName=variables.jobDeptSync,
commands=cmdArray,
scheduleParams=scheduleParams,
startProcessNow=false);
return true;
}
else
return false;
// Get the external Department data
var extProgramDataQry = application.ptCourseCatalog.catalogSyncDAO.getProgramID();
var i = 1;
// Build the command array
var cmdArray = ArrayNew(1);
var tempCmd = StructNew();
var scheduleParams = StructNew();
var rowCount = 0;
var startRow = 1;
// Set the schedule params
scheduleParams.delay = variables.ScheduleDelay; // Minutes till next schedule item
scheduleParams.tasksPerBatch = variables.TasksPerBatch; // How many tasks to do per iteration
// set the rowCount to the number of items returned by the query
rowCount = extProgramDataQry.recordCount;
if ( IsNumeric(arguments.syncRowCount) AND arguments.syncRowCount LT rowCount)
rowCount = arguments.syncRowCount;
// the startRow to the first row unless a syncStartRow is passed in
if ( IsNumeric(arguments.syncStartRow) AND arguments.syncStartRow GT 1 ) {
startRow = arguments.syncStartRow;
rowCount = startRow + rowCount - 1; // the New Row count is the startRow plus rowCount minus 1 (startRow=2,rowCount=5: 2,3,4,5,6)
// Check to of rowCount is not less than the startRow or greater than the total query recordCount
if ( rowCount LT startRow )
rowCount = startRow;
else if ( rowCount GT extProgramDataQry.recordCount )
rowCount = extProgramDataQry.recordCount;
}
// Loop over the external data
for ( i=startRow; i LTE rowCount; i++ ) {
// Build the temp command to keep calling
tempCmd = StructNew();
tempCmd.bean = "catalogSyncController";
tempCmd.method = "syncProgram";
tempCmd.args = StructNew();
tempCmd.args.extProgramID = extProgramDataQry.dbProgramID[i];
tempCmd.args.returnFormat = "JSON";
// Add the temp call to the command
ArrayAppend(cmdArray, tempCmd);
}
if ( ArrayLen(cmdArray) ) {
// Load into the Scheduler
application.ADF.scheduler.scheduleProcess(scheduleName=variables.jobProgramSync,
commands=cmdArray,
scheduleParams=scheduleParams,
startProcessNow=false);
return true;
}
else
return false;
// Get the external Department data
var extCourseDataQry = application.ptCourseCatalog.catalogSyncDAO.getCourseID();
var i = 1;
// Build the command array
var cmdArray = ArrayNew(1);
var tempCmd = StructNew();
var scheduleParams = StructNew();
var rowCount = 0;
var startRow = 1;
// Set the schedule params
scheduleParams.delay = variables.ScheduleDelay; // Minutes till next schedule item
scheduleParams.tasksPerBatch = variables.TasksPerBatch; // How many tasks to do per iteration
// set the rowCount to the number of items returned by the query
rowCount = extCourseDataQry.recordCount;
if ( IsNumeric(arguments.syncRowCount) AND arguments.syncRowCount LT rowCount)
rowCount = arguments.syncRowCount;
// the startRow to the first row unless a syncStartRow is passed in
if ( IsNumeric(arguments.syncStartRow) AND arguments.syncStartRow GT 1 ) {
startRow = arguments.syncStartRow;
rowCount = startRow + rowCount - 1; // the New Row count is the startRow plus rowCount minus 1 (startRow=2,rowCount=5: 2,3,4,5,6)
// Check to of rowCount is not less than the startRow or greater than the total query recordCount
if ( rowCount LT startRow )
rowCount = startRow;
else if ( rowCount GT extCourseDataQry.recordCount )
rowCount = extCourseDataQry.recordCount;
}
// Loop over the external data
for ( i=startRow; i LTE rowCount; i++ ) {
// Build the temp command to keep calling
tempCmd = StructNew();
tempCmd.bean = "catalogSyncController";
tempCmd.method = "syncCourse";
tempCmd.args = StructNew();
tempCmd.args.extCourseID = extCourseDataQry.dbCourseID[i];
tempCmd.args.returnFormat = "JSON";
// Add the temp call to the command
ArrayAppend(cmdArray, tempCmd);
}
if ( ArrayLen(cmdArray) ) {
// Load into the Scheduler
application.ADF.scheduler.scheduleProcess(scheduleName=variables.jobCourseSync,
commands=cmdArray,
scheduleParams=scheduleParams,
startProcessNow=false);
return true;
}
else
return false;
// Get the external Department data
var extProgramDataQry = application.ptCourseCatalog.catalogSyncDAO.getProgramID();
var i = 1;
// Build the command array
var cmdArray = ArrayNew(1);
var tempCmd = StructNew();
var scheduleParams = StructNew();
var rowCount = 0;
var startRow = 1;
// Set the schedule params
scheduleParams.delay = variables.ScheduleDelay; // Minutes till next schedule item
scheduleParams.tasksPerBatch = variables.TasksPerBatch; // How many tasks to do per iteration
// set the rowCount to the number of items returned by the query
rowCount = extProgramDataQry.recordCount;
if ( IsNumeric(arguments.syncRowCount) AND arguments.syncRowCount LT rowCount)
rowCount = arguments.syncRowCount;
// the startRow to the first row unless a syncStartRow is passed in
if ( IsNumeric(arguments.syncStartRow) AND arguments.syncStartRow GT 1 ) {
startRow = arguments.syncStartRow;
rowCount = startRow + rowCount - 1; // the New Row count is the startRow plus rowCount minus 1 (startRow=2,rowCount=5: 2,3,4,5,6)
// Check to of rowCount is not less than the startRow or greater than the total query recordCount
if ( rowCount LT startRow )
rowCount = startRow;
else if ( rowCount GT extProgramDataQry.recordCount )
rowCount = extProgramDataQry.recordCount;
}
// Loop over the external data
for ( i=startRow; i LTE rowCount; i++ ) {
// Build the temp command to keep calling
tempCmd = StructNew();
tempCmd.bean = "catalogSyncController";
tempCmd.method = "syncProgramReqs";
tempCmd.args = StructNew();
tempCmd.args.extProgramID = extProgramDataQry.dbProgramID[i];
tempCmd.args.returnFormat = "JSON";
// Add the temp call to the command
ArrayAppend(cmdArray, tempCmd);
}
if ( ArrayLen(cmdArray) ) {
// Load into the Scheduler
application.ADF.scheduler.scheduleProcess(scheduleName=variables.jobProgReqSync,
commands=cmdArray,
scheduleParams=scheduleParams,
startProcessNow=false);
return true;
}
else
return false;
var extCourseDataQry = application.ptCourseCatalog.catalogSyncDAO.getCourseID();
var i = 1;
// Build the command array
var cmdArray = ArrayNew(1);
var tempCmd = StructNew();
var scheduleParams = StructNew();
var rowCount = 0;
var startRow = 1;
// Set the schedule params
scheduleParams.delay = variables.ScheduleDelay; // Minutes till next schedule item
scheduleParams.tasksPerBatch = variables.TasksPerBatch; // How many tasks to do per iteration
// set the rowCount to the number of items returned by the query
rowCount = extCourseDataQry.recordCount;
if ( IsNumeric(arguments.syncRowCount) AND arguments.syncRowCount LT rowCount)
rowCount = arguments.syncRowCount;
// the startRow to the first row unless a syncStartRow is passed in
if ( IsNumeric(arguments.syncStartRow) AND arguments.syncStartRow GT 1 ) {
startRow = arguments.syncStartRow;
rowCount = startRow + rowCount - 1; // the New Row count is the startRow plus rowCount minus 1 (startRow=2,rowCount=5: 2,3,4,5,6)
// Check to of rowCount is not less than the startRow or greater than the total query recordCount
if ( rowCount LT startRow )
rowCount = startRow;
else if ( rowCount GT extCourseDataQry.recordCount )
rowCount = extCourseDataQry.recordCount;
}
// Loop over the external data
for ( i=startRow; i LTE rowCount; i++ ) {
// Build the temp command to keep calling
tempCmd = StructNew();
tempCmd.bean = "catalogSyncController";
tempCmd.method = "syncCoursePreReqs";
tempCmd.args = StructNew();
tempCmd.args.extCourseID = extCourseDataQry.dbCourseID[i];
tempCmd.args.returnFormat = "JSON";
// Add the temp call to the command
ArrayAppend(cmdArray, tempCmd);
}
if ( ArrayLen(cmdArray) ) {
// Load into the Scheduler
application.ADF.scheduler.scheduleProcess(scheduleName=variables.jobCoursePrereqSync,
commands=cmdArray,
scheduleParams=scheduleParams,
startProcessNow=false);
return true;
}
else
return false;
var syncStatus = StructNew();
var extDepartmentDataQry = QueryNew("null");
var deptCCAPIData = StructNew();
var ceDeptDataArray = ArrayNew(1);
var runCCAPI = false; // Flag to determine if we need to run the ccapi command
var runPageAPI = false; // Flag to determine if we need to run page processing
var runSyncProcess = true; // Flag to determine if we need to run the main sync processing...final say (Default: true)
var departmentID = "";
var newColData = ArrayNew(1);
var csPageURL = "";
var csSubsitePath = "";
var apiUserID = getAPIUserID();
// Init the sync return status variables.
syncStatus.syncComplete = false; // Flag for if the sync process was completed
syncStatus.ccapiComplete = false; // Flag for if the CCAPI command was called
syncStatus.msg = "";
syncStatus.data = StructNew();
// Add the needed GCE field as a column in the External Query
QueryAddColumn(extDepartmentDataQry,"schoolID","VarChar",newColData);
// Set the default value of the SchoolID
extDepartmentDataQry["schoolID"][1] = "";
// Get and set the School UniqueID based on the School Code
if ( StructKeyExists(extDepartmentDataQry,"schoolCode") AND LEN(TRIM(extDepartmentDataQry["schoolCode"][1])) )
extDepartmentDataQry["schoolID"][1] = application.ptCourseCatalog.schoolService.getSchoolIDBySchoolCode(SchoolCode=extDepartmentDataQry["schoolCode"][1]);
// IMPORTANT!!! - DO NOT IMPORT if there is NOT a valid schoolID
if ( LEN(TRIM(extDepartmentDataQry["schoolID"][1])) EQ 0 ) {
runSyncProcess = false;
syncStatus.msg = "No valid schoolID was found for Dept Code: #arguments.deptCode#";
}
if ( runSyncProcess ) {
// Get the Department CE record if it exists
ceDeptDataArray = application.ptCourseCatalog.departmentDAO.getDepartments(idFieldName="deptCode",
uniqueID=arguments.deptCode);
// Check if running an add or edit
if ( ArrayLen(ceDeptDataArray) ){ // Edit
// Build the CCAPI data based on the external data and CE record
deptCCAPIData = buildCCAPIParams(extDataQry=extDepartmentDataQry,
ceDataArray=ceDeptDataArray);
departmentID = deptCCAPIData.uniqueID;
// Check if the external data fields have updated from the element data record fields
if ( StructKeyExists(deptCCAPIData,"tempUpdateReq") AND deptCCAPIData.tempUpdateReq )
runCCAPI = true;
// Check to see if a valid cspage exists... if not set the runCCAPI flag to true to re-create the record and the page
if ( runCCAPI EQ false AND StructKeyExists(deptCCAPIData,"catalogPageID") AND IsNumeric(deptCCAPIData.catalogPageID) AND deptCCAPIData.catalogPageID GT 0 ) {
csPageURL = application.ptCourseCatalog.csData.getCSPageURL(pageID=deptCCAPIData.catalogPageID);
if ( LEN(TRIM(csPageURL)) EQ 0 ) {
// Since the page is gone...
// 1) run the CCAPI to create the page
runCCAPI = true;
// 2) Check to make sure we have a valid subsite to create a page in
if ( StructKeyExists(deptCCAPIData,"deptSubsiteID") AND IsNumeric(deptCCAPIData.deptSubsiteID) AND deptCCAPIData.deptSubsiteID GT 0 ) {
csSubsitePath = application.ptCourseCatalog.csData.getSubsiteURLbySubsiteID(subsiteID=deptCCAPIData.deptSubsiteID);
}
// 3) If there is not a valid subsite create it
if ( LEN(TRIM(csSubsitePath)) EQ 0 AND StructKeyExists(deptCCAPIData,"schoolID") AND LEN(TRIM(deptCCAPIData.schoolID)) ) {
deptCCAPIData.deptSubsiteID = buildDeptSubsiteDefaultPath(deptData=deptCCAPIData);
}
}
}
}
else { // Add
// Convert the query to an structure
deptCCAPIData = application.ptCourseCatalog.data.queryRowToStruct(extDepartmentDataQry);
departmentID = createUUID();
deptCCAPIData.uniqueID = departmentID;
runCCAPI = true;
// Set the default for template
if ( StructKeyExists(application.ptCourseCatalog.appConfig, "defaultDeptTemplate")
AND isNumeric(application.ptCourseCatalog.appConfig.defaultDeptTemplate)
AND (application.ptCourseCatalog.appConfig.defaultDeptTemplate > 0) ) {
deptCCAPIData.deptTemplateID = application.ptCourseCatalog.appConfig.defaultDeptTemplate;
}
// Set the defaults for subsites
if ( StructKeyExists(deptCCAPIData,"schoolID") AND LEN(TRIM(deptCCAPIData.schoolID)) ) {
deptCCAPIData.deptSubsiteID = buildDeptSubsiteDefaultPath(deptData=deptCCAPIData);
}
else {
// if no parent School ID... do NOT add the records to the element
runCCAPI = false;
}
}
if ( runCCAPI ) {
//application.ptCourseCatalog.utils.doDump(deptCCAPIData, "deptCCAPIData", false);
// Run the element CCAPI to add/edit
syncStatus.data = application.ptCourseCatalog.departmentDAO.departmentCCAPI(dataValues=deptCCAPIData);
// Update the flag for if the element record was add/edit
if ( StructKeyExists(syncStatus.data, "CONTENTUPDATED") ) {
syncStatus.ccapiComplete = syncStatus.data.CONTENTUPDATED;
// Update the flag for page processing API call
if ( syncStatus.ccapiComplete
AND (IsNumeric(deptCCAPIData.deptSubsiteID) AND deptCCAPIData.deptSubsiteID GT 0)
AND (IsNumeric(deptCCAPIData.deptTemplateID) AND deptCCAPIData.deptTemplateID GT 0) )
runPageAPI = true;
}
}
} // runSyncProcess
// Run the page processing
pageProcess = application.ptCourseCatalog.catalogPageController.handleProcessCatalogPage(contentType="department",contentID=departmentID);
// Add the page processing results to the syncStatus
syncStatus.pageData = pageProcess;
//application.ptCourseCatalog.utils.doDump(pageProcess, "pageProcess", false);
// Flag to mark the sync was completed for the record
syncStatus.syncComplete = true;
var syncStatus = StructNew();
var extProgramDataQry = QueryNew("null");
var programCCAPIData = StructNew();
var ceProgramDataArray = ArrayNew(1);
var runCCAPI = false; // Flag to determine if we need to run the ccapi command
var runPageAPI = false; // Flag to determine if we need to run page processing
var runSyncProcess = true; // Flag to determine if we need to run the main sync processing...final say (Default: true)
var programUUID = "";
var newColData = ArrayNew(1);
var csPageURL = "";
var apiUserID = getAPIUserID();
// Init the sync return status variables.
syncStatus.syncComplete = false; // Flag for if the sync process was completed
syncStatus.ccapiComplete = false; // Flag for if the CCAPI command was called
syncStatus.msg = "";
syncStatus.data = StructNew();
// Add the needed GCE fields as Columns to the External Query
QueryAddColumn(extProgramDataQry,"deptID","VarChar",newColData);
QueryAddColumn(extProgramDataQry,"degreeID","VarChar",newColData);
QueryAddColumn(extProgramDataQry,"termID","VarChar",newColData);
// Go get and set the Department ID in the External Query from the provided Department Code
if ( StructKeyExists(extProgramDataQry,"DeptCode") )
extProgramDataQry["deptID"][1] = application.ptCourseCatalog.departmentService.getDepartmentIDByDeptCode(deptCode=extProgramDataQry["DeptCode"][1]);
// Go get and set the Degree ID in the External Query from the provided Degree Name
if ( StructKeyExists(extProgramDataQry,"DegreeName") )
extProgramDataQry["degreeID"][1] = application.ptCourseCatalog.degreeService.getDegreeIDByDegreeName(degreeName=extProgramDataQry["DegreeName"][1]);
// Go get and set the Term ID in the External Query from the provided Term Code
if ( StructKeyExists(extProgramDataQry,"TermCode") )
extProgramDataQry["termID"][1] = application.ptCourseCatalog.termService.getTermIDByTermCode(termCode=extProgramDataQry["TermCode"][1]);
// IMPORTANT!!! - DO NOT IMPORT if there is NOT a valid deptID, termID and degreeID
if ( LEN(TRIM(extProgramDataQry["deptID"][1])) EQ 0 ) {
runSyncProcess = false;
syncStatus.msg = syncStatus.msg & "No valid deptID was found for External Program ID: #arguments.extProgramID#. ";
}
if ( LEN(TRIM(extProgramDataQry["termID"][1])) EQ 0 ) {
runSyncProcess = false;
syncStatus.msg = syncStatus.msg & "No valid termID was found for External Program ID: #arguments.extProgramID#. ";
}
if ( LEN(TRIM(extProgramDataQry["degreeID"][1])) EQ 0 ) {
runSyncProcess = false;
syncStatus.msg = "No valid degreeID was found for External Program ID: #arguments.extProgramID#. ";
}
if ( runSyncProcess ) {
// Get the Program CE record if it exists
ceProgramDataArray = application.ptCourseCatalog.programDAO.getProgramByExternalProgramID(extProgramID=arguments.extProgramID);
// Check if running an add or edit
if ( ArrayLen(ceProgramDataArray) ){ // Edit
// Build the CCAPI data based on the external data and CE record
programCCAPIData = buildCCAPIParams(extDataQry=extProgramDataQry,
ceDataArray=ceProgramDataArray);
programUUID = programCCAPIData.uniqueID;
// Check if the external data fields have updated from the element data record fields
if ( StructKeyExists(programCCAPIData,"tempUpdateReq") AND programCCAPIData.tempUpdateReq )
runCCAPI = true;
// Check to see if a valid cspage exists... if not set the runCCAPI flag to re-create the record and the page
if ( runCCAPI EQ false AND StructKeyExists(programCCAPIData,"catalogPageID") AND IsNumeric(programCCAPIData.catalogPageID) AND programCCAPIData.catalogPageID GT 0 ) {
csPageURL = application.ptCourseCatalog.csData.getCSPageURL(pageID=programCCAPIData.catalogPageID);
if ( LEN(TRIM(csPageURL)) EQ 0 )
runCCAPI = true;
}
}
else { // Add
// Convert the query to an array
programCCAPIData = application.ptCourseCatalog.data.queryRowToStruct(extProgramDataQry);
programUUID = createUUID();
programCCAPIData.uniqueID = programUUID;
// Set the default for template
if ( StructKeyExists(application.ptCourseCatalog.appConfig, "defaultProgramTemplate")
AND isNumeric(application.ptCourseCatalog.appConfig.defaultProgramTemplate)
AND (application.ptCourseCatalog.appConfig.defaultProgramTemplate > 0) ){
programCCAPIData.progTemplateID = application.ptCourseCatalog.appConfig.defaultProgramTemplate;
}
runCCAPI = true;
}
if ( runCCAPI ) {
//application.ptCourseCatalog.utils.doDump(programCCAPIData, "programCCAPIData", false);
// Run the element CCAPI to add/edit
syncStatus.data = application.ptCourseCatalog.programDAO.programCCAPI(dataValues=programCCAPIData);
// Update the flag for if the element record was add/edit
if ( StructKeyExists(syncStatus.data, "CONTENTUPDATED") ) {
syncStatus.ccapiComplete = syncStatus.data.CONTENTUPDATED;
// Update the flag for page processing API call
if ( syncStatus.ccapiComplete
AND (IsNumeric(programCCAPIData.progTemplateID) AND programCCAPIData.progTemplateID GT 0) )
runPageAPI = true;
/*AND (IsNumeric(programCCAPIData.deptSubsiteID) AND programCCAPIData.deptSubsiteID GT 0) */
}
}
} // runSyncProcess
// Run the page processing
pageProcess = application.ptCourseCatalog.catalogPageController.handleProcessCatalogPage(contentType="program",
contentID=programUUID);
// Add the page processing results to the syncStatus
syncStatus.pageData = pageProcess;
//application.ptCourseCatalog.utils.doDump(pageProcess, "pageProcess", false);
// Flag to mark the sync was completed for the record
syncStatus.syncComplete = true;
var syncStatus = StructNew();
var extCourseDataQry = QueryNew("null");
var courseCCAPIData = StructNew();
var ceCourseDataArray = ArrayNew(1);
var runCCAPI = false; // Flag to determine if we need to run the ccapi command
var runPageAPI = false; // Flag to determine if we need to run page processing
var runSyncProcess = true; // Flag to determine if we need to run the main sync processing...final say (Default: true)
var courseUUID = "";
var courseScheduleData = "";
var newColData = ArrayNew(1);
var csPageURL = "";
var apiUserID = getAPIUserID();
// Init the sync return status variables.
syncStatus.syncComplete = false; // Flag for if the sync process was completed
syncStatus.ccapiComplete = false; // Flag for if the CCAPI command was called
syncStatus.msg = "";
syncStatus.data = StructNew();
syncStatus.subdata = StructNew();
// Add the needed GCE fields as Columns to the External Query
QueryAddColumn(extCourseDataQry,"deptID","VarChar",newColData);
QueryAddColumn(extCourseDataQry,"termID","VarChar",newColData);
// Go get and set the Department ID in the External Query from the provided Department Code
if ( StructKeyExists(extCourseDataQry,"DeptCode") )
extCourseDataQry["deptID"][1] = application.ptCourseCatalog.departmentService.getDepartmentIDByDeptCode(deptCode=extCourseDataQry["DeptCode"][1]);
// Go get and set the Term ID in the External Query from the provided Term Code
if ( StructKeyExists(extCourseDataQry,"TermCode") )
extCourseDataQry["termID"][1] = application.ptCourseCatalog.termService.getTermIDByTermCode(termCode=extCourseDataQry["TermCode"][1]);
// IMPORTANT!!! - DO NOT IMPORT if there is not a valid deptID and termID
if ( LEN(TRIM(extCourseDataQry["deptID"][1])) EQ 0 ) {
runSyncProcess = false;
syncStatus.msg = syncStatus.msg & "No valid deptID was found for External Course ID: #arguments.extCourseID#. ";
}
if ( LEN(TRIM(extCourseDataQry["termID"][1])) EQ 0 ) {
runSyncProcess = false;
syncStatus.msg = syncStatus.msg & "No valid termID was found for External Course ID: #arguments.extCourseID#. ";
}
if ( runSyncProcess ) {
// Get the Course CE record if it exists
ceCourseDataArray = application.ptCourseCatalog.courseDAO.getCourseByExternalCourseID(extCourseID=arguments.extCourseID);
// Check if running an add or edit
if ( ArrayLen(ceCourseDataArray) ){ // Edit
// Build the CCAPI data based on the external data and CE record
courseCCAPIData = buildCCAPIParams(extDataQry=extCourseDataQry,
ceDataArray=ceCourseDataArray);
courseUUID = courseCCAPIData.uniqueID;
// Check if the external data fields have updated from the element data record fields
if ( StructKeyExists(courseCCAPIData,"tempUpdateReq") AND courseCCAPIData.tempUpdateReq )
runCCAPI = true;
// Check to see if a valid cspage exists... if not set the runCCAPI flag to re-create the record and the page
if ( runCCAPI EQ false AND StructKeyExists(courseCCAPIData,"catalogPageID") AND IsNumeric(courseCCAPIData.catalogPageID) AND courseCCAPIData.catalogPageID GT 0 ) {
csPageURL = application.ptCourseCatalog.csData.getCSPageURL(pageID=courseCCAPIData.catalogPageID);
if ( LEN(TRIM(csPageURL)) EQ 0 )
runCCAPI = true;
}
}
else { // Add
// Convert the query to an array
courseCCAPIData = application.ptCourseCatalog.data.queryRowToStruct(extCourseDataQry);
courseUUID = createUUID();
courseCCAPIData.uniqueID = courseUUID;
// Set the default for template
if ( StructKeyExists(application.ptCourseCatalog.appConfig, "defaultCourseTemplate")
AND isNumeric(application.ptCourseCatalog.appConfig.defaultCourseTemplate)
AND (application.ptCourseCatalog.appConfig.defaultCourseTemplate > 0) ){
courseCCAPIData.courseTemplateID = application.ptCourseCatalog.appConfig.defaultCourseTemplate;
}
runCCAPI = true;
}
// Sync the Schedule external data for the Course Element
courseScheduleData = syncCourseToSchedules(extCourseID=arguments.extCourseID,ceCourseID=courseUUID);
// Add the schedule sync process data to the result struct
syncStatus.subdata = courseScheduleData;
// Set the list of Schedule element UUIDs into the Course "schedIDList" field
if ( isStruct(courseScheduleData)
AND StructKeyExists(courseScheduleData, "syncComplete")
AND courseScheduleData.syncComplete )
courseCCAPIData.schedIDList = courseScheduleData.data;
if ( runCCAPI ) {
//application.ptCourseCatalog.utils.doDump(courseCCAPIData, "courseCCAPIData", false);
// Run the element CCAPI to add/edit
syncStatus.data = application.ptCourseCatalog.courseDAO.courseCCAPI(dataValues=courseCCAPIData);
// Update the flag for if the element record was add/edit
if ( StructKeyExists(syncStatus.data, "CONTENTUPDATED") ) {
syncStatus.ccapiComplete = syncStatus.data.CONTENTUPDATED;
// Update the flag for page processing API call
if ( syncStatus.ccapiComplete
AND (IsNumeric(courseCCAPIData.courseTemplateID) AND courseCCAPIData.courseTemplateID GT 0) )
runPageAPI = true;
/*AND (IsNumeric(courseCCAPIData.deptSubsiteID) AND courseCCAPIData.deptSubsiteID GT 0) */
}
}
} // runSyncProcess
// Run the page processing
pageProcess = application.ptCourseCatalog.catalogPageController.handleProcessCatalogPage(contentType="course",
contentID=courseUUID);
// Add the page processing results to the syncStatus
syncStatus.pageData = pageProcess;
//application.ptCourseCatalog.utils.doDump(pageProcess, "pageProcess", false);
// Flag to mark the sync was completed for the record
syncStatus.syncComplete = true;
var syncStatus = StructNew();
var extScheduleDataQry = QueryNew("null");
var scheduleCCAPIData = StructNew();
var ceScheduleDataArray = ArrayNew(1);
var runCCAPI = false; // Flag to determine if we need to run the ccapi command
var scheduleUUID = "";
var newColData = ArrayNew(1);
// Init the sync return status variables.
syncStatus.syncComplete = false; // Flag for if the sync process was completed
syncStatus.ccapiComplete = false; // Flag for if the CCAPI command was called
syncStatus.msg = "";
syncStatus.data = StructNew();
if ( LEN(arguments.extScheduleID) ) {
// Get the external database record for the External Schedule ID
extScheduleDataQry = application.ptCourseCatalog.catalogSyncDAO.getScheduleByID(extScheduleID=arguments.extScheduleID);
// Set the data struct for the Schedule data
if ( isQuery(extScheduleDataQry)
AND extScheduleDataQry.recordCount ) {
// Parse the 'schedDays' from the query to match the APP schedule weekday list format
extWeekdayList = extScheduleDataQry["SchedDays"][1];
// Rewrite the Query value for "SchedDays" to the App Full Day Name comma-delimited style
extScheduleDataQry["SchedDays"][1] = application.ptCourseCatalog.scheduleDaysService.weekdayListSerializer(weekdayList=extWeekdayList,convertFrom="initial",convertTo="name",delimiterOut=",");
// Add the needed GCE field as a Column to the External Query
QueryAddColumn(extScheduleDataQry,"buildingID","VarChar",newColData);
// Go get and set the Building ID in the External Query from the provided Building Code
if ( StructKeyExists(extScheduleDataQry,"BuildingCode") )
extScheduleDataQry["buildingID"][1] = application.ptCourseCatalog.buildingService.getBuildingIDByBuildingCode(buildingCode=extScheduleDataQry["BuildingCode"][1]);
// Get the Schedule CE record if it exists
ceScheduleDataArray = application.ptCourseCatalog.scheduleDAO.getScheduleByExternalScheduleID(extScheduleID=arguments.extScheduleID);
// Check if running an add or edit
if ( ArrayLen(ceScheduleDataArray) ){ // Edit
// Build the CCAPI data based on the external data and CE record
scheduleCCAPIData = buildCCAPIParams(extDataQry=extScheduleDataQry,
ceDataArray=ceScheduleDataArray);
scheduleUUID = scheduleCCAPIData.uniqueID;
// Check if the external data fields have updated from the element data record fields
if ( StructKeyExists(scheduleCCAPIData,"tempUpdateReq")
AND scheduleCCAPIData.tempUpdateReq )
runCCAPI = true;
}
else { // Add
// Convert the query to an array
scheduleCCAPIData = application.ptCourseCatalog.data.queryRowToStruct(extScheduleDataQry);
scheduleUUID = createUUID();
scheduleCCAPIData.uniqueID = scheduleUUID;
scheduleCCAPIData.parentID = arguments.ceCourseID;
runCCAPI = true;
}
if ( runCCAPI ) {
//application.ptCourseCatalog.utils.doDump(scheduleCCAPIData, "scheduleCCAPIData", false);
// Run the element CCAPI to add/edit
syncStatus.data = application.ptCourseCatalog.scheduleDAO.scheduleCCAPI(dataValues=scheduleCCAPIData);
// Update the flag for if the element record was add/edit
if ( StructKeyExists(syncStatus.data, "CONTENTUPDATED") )
syncStatus.ccapiComplete = syncStatus.data.CONTENTUPDATED;
}
// Store the Schedule UUID into the "data" for the return
syncStatus.data = scheduleUUID;
// Flag to mark the sync was completed for the record
syncStatus.syncComplete = true;
}
else
syncStatus.msg = "No external schedule matching the external schedule ID [External Schedule ID = #arguments.extScheduleID#]";
}
else
syncStatus.msg = "No external schedule ID argument defined.";
return syncStatus;
var syncStatus = StructNew();
var scheduleSyncStatus = "";
var extScheduleDataQry = QueryNew("null");
var sItm = 1;
var extSchedID = "";
// Init the sync return status variables.
syncStatus.syncComplete = false; // Flag for if the sync process was completed
syncStatus.msg = "";
syncStatus.data = ""; // List for the Schedule Element UUIDs - To be stored in the Course element.
syncStatus.subdata = ArrayNew(1);
if ( LEN(arguments.extCourseID) ) {
// Get the External Schedule records for the External Course ID
extScheduleDataQry = application.ptCourseCatalog.catalogSyncDAO.getSchedulesByCourseID(extCourseID=arguments.extCourseID);
// Loop over the External Schedule data records
if ( isQuery(extScheduleDataQry)
AND extScheduleDataQry.recordCount ) {
// Loop over the records in the recurrence properties query
for ( sItm=1; sItm LTE extScheduleDataQry.RecordCount; sItm=sItm+1 ) {
// set the extSchedID from the external schedule data
extSchedID = extScheduleDataQry["dbScheduleID"][sItm];
// Sync the Schedule records
scheduleSyncStatus = syncSchedule(extScheduleID=extSchedID,ceCourseID=arguments.ceCourseID);
// Set the Schedule UUID into the list
if ( isStruct(scheduleSyncStatus)
AND StructKeyExists(scheduleSyncStatus,"syncComplete")
AND scheduleSyncStatus.syncComplete
AND isSimpleValue(scheduleSyncStatus.data) ) {
// Build an array of the results from each of the sync'd schedule items to this methods syncStatus return value
ArrayAppend(syncStatus.subdata,scheduleSyncStatus);
syncStatus.data = application.ptCourseCatalog.data.listAppendNoDuplicates(list=syncStatus.data,
value=scheduleSyncStatus.data);
}
syncStatus.syncComplete = true;
}
}
else
syncStatus.msg = "No external schedules matching the external course ID [External Course ID = #arguments.extCourseID#]";
}
else
syncStatus.msg = "No external course ID argument defined.";
return syncStatus;
var syncStatus = StructNew();
var courseArray = ArrayNew(1);
var ceProgramDataArray = ArrayNew(1);
var programCCAPIData = StructNew();
var i = 1;
var childCourseUUID = "";
var newChildCourseUUIDlist = "";
var oldChildCourseUUIDList = "";
var runCCAPI = false;
// Init the sync return status variables.
syncStatus.syncComplete = false; // Flag for if the sync process was completed
syncStatus.ccapiComplete = false; // Flag for if the CCAPI command was called
syncStatus.msg = "";
syncStatus.data = StructNew();
if ( LEN(TRIM(arguments.extProgramID)) ) {
// Based on the external program id, get the required courses
// Returns an Array containing the Course CE "uniqueID" field value.
courseArray = getProgramReqs(extProgramID=arguments.extProgramID);
// Build the array into a list of the Course UUID's
for ( i=1; i LTE ArrayLen(courseArray); i++) {
if ( ArrayLen(courseArray) AND StructKeyExists(courseArray[1],"values") AND StructKeyExists(courseArray[1].values,"uniqueID") AND LEN(TRIM(courseArray[1].values.uniqueID)) ) {
childCourseUUID = courseArray[i].values.uniqueID;
// Add the Child Course UUID to the Course UUID list
newChildCourseUUIDlist = application.ptCourseCatalog.data.listAppendNoDuplicates(list=newChildCourseUUIDlist,value=childCourseUUID);
}
}
// Get the Program CE record based on the "dbProgramID"
ceProgramDataArray = application.ptCourseCatalog.programDAO.getProgramByExternalProgramID(extProgramID=arguments.extProgramID);
// Check if a program record exists
if ( ArrayLen(ceProgramDataArray) ) { // if so, Update
// Set the 'old' Child Course ID list from the CE Course Record
if ( ArrayLen(ceProgramDataArray) AND StructKeyExists(ceProgramDataArray[1],"values") AND StructKeyExists(ceProgramDataArray[1].values,"reqCourseIDList") )
oldChildCourseUUIDList = ceProgramDataArray[1].values.reqCourseIDList;
// Check if the new Course UUID list and the old UUID list are different or have the same UUIDs, if different set the runCCAPI to update the course
if ( application.ptCourseCatalog.data.IsListDifferent(oldChildCourseUUIDList,newChildCourseUUIDlist) ) {
// Build the CCAPI data based on the external data and CE record
programCCAPIData = ceProgramDataArray[1].values;
programCCAPIData['datapageid'] = ceProgramDataArray[1].pageid;
programCCAPIData['reqCourseIDList'] = newChildCourseUUIDlist;
runCCAPI = true;
}
// Update the Course Prerequisite field with the list of Course UUID's
// Call the CCAPI to update the element record
if ( runCCAPI ) {
//application.ptCourseCatalog.utils.doDump(programCCAPIData, "programCCAPIData", false);
// Run the element CCAPI to add/edit
syncStatus.data = application.ptCourseCatalog.programDAO.programCCAPI(dataValues=programCCAPIData);
// Update the flag for if the element record was add/edit
if ( StructKeyExists(syncStatus.data, "CONTENTUPDATED") )
syncStatus.ccapiComplete = syncStatus.data.CONTENTUPDATED;
}
// Flag to mark the sync was completed for the record
syncStatus.syncComplete = true;
}
else {
syncStatus.msg = "No program element record matching the external program ID [External Program ID = #arguments.extProgramID#]";
syncStatus.syncComplete = true;
}
}
else {
syncStatus.msg = "No external program ID argument defined.";
}
return syncStatus;
var syncStatus = StructNew();
var courseArray = ArrayNew(1);
var ceCourseDataArray = ArrayNew(1);
var courseCCAPIData = StructNew();
var i = 1;
var childCourseUUID = "";
var newChildCourseUUIDlist = "";
var oldChildCourseUUIDList = "";
var runCCAPI = false;
// Init the sync return status variables.
syncStatus.syncComplete = false; // Flag for if the sync process was completed
syncStatus.ccapiComplete = false; // Flag for if the CCAPI command was called
syncStatus.msg = "";
syncStatus.data = StructNew();
if ( LEN(TRIM(arguments.extCourseID)) ) {
// Based on the external course id, get the prerequisite courses
// Returns an Array containing the Course CE "uniqueID" field value.
courseArray = getCoursePreReqs(extCourseID=arguments.extCourseID);
// Build the array into a list of the Course UUID's
for ( i=1; i LTE ArrayLen(courseArray); i++) {
if ( ArrayLen(courseArray) AND StructKeyExists(courseArray[1],"values") AND StructKeyExists(courseArray[1].values,"uniqueID") AND LEN(TRIM(courseArray[1].values.uniqueID)) ) {
childCourseUUID = courseArray[i].values.uniqueID;
// Add the Child Course UUID to the Course UUID list
newChildCourseUUIDlist = application.ptCourseCatalog.data.listAppendNoDuplicates(list=newChildCourseUUIDlist,value=childCourseUUID);
}
}
// Get the Course CE record based on the "dbCourseID"
ceCourseDataArray = application.ptCourseCatalog.courseDAO.getCourseByExternalCourseID(extCourseID=arguments.extCourseID);
// Check if a course record exists
if ( ArrayLen(ceCourseDataArray) ) { // if so, Update
// Set the 'old' Child Course ID list from the CE Course Record
if ( ArrayLen(ceCourseDataArray) AND StructKeyExists(ceCourseDataArray[1],"values") AND StructKeyExists(ceCourseDataArray[1].values,"prereqCourseIDList") )
oldChildCourseUUIDList = ceCourseDataArray[1].values.prereqCourseIDList;
// Check if the new Course UUID list and the old UUID list are different or have the same UUIDs, if different set the runCCAPI to update the course
if ( application.ptCourseCatalog.data.IsListDifferent(oldChildCourseUUIDList,newChildCourseUUIDlist) ) {
// Build the CCAPI data based on the external data and CE record
courseCCAPIData = ceCourseDataArray[1].values;
courseCCAPIData['datapageid'] = ceCourseDataArray[1].pageid;
courseCCAPIData['prereqCourseIDList'] = newChildCourseUUIDlist;
runCCAPI = true;
}
// Update the Course Prerequisite field with the list of Course UUID's
// Call the CCAPI to update the element record
if ( runCCAPI ) {
//application.ptCourseCatalog.utils.doDump(courseCCAPIData, "courseCCAPIData", false);
// Run the element CCAPI to add/edit
syncStatus.data = application.ptCourseCatalog.courseDAO.courseCCAPI(dataValues=courseCCAPIData);
// Update the flag for if the element record was add/edit
if ( StructKeyExists(syncStatus.data, "CONTENTUPDATED") )
syncStatus.ccapiComplete = syncStatus.data.CONTENTUPDATED;
}
// Flag to mark the sync was completed for the record
syncStatus.syncComplete = true;
}
else {
syncStatus.msg = "No course element record matching the external course ID [External Course ID = #arguments.extCourseID#]";
syncStatus.syncComplete = true;
}
}
else {
syncStatus.msg = "No external course ID argument defined.";
}
return syncStatus;
var courseUUIDArray = ArrayNew(1);
var extCourseReqQry = QueryNew("null");
var extBindID = "";
var extParentCourseID = "";
var extChildCourseID = "";
var extChildCourseIDlist = "";
var ceChildArray = ArrayNew(1);
var cItm = 1;
// Query the "courseprereqs" external table
extCourseReqQry = application.ptCourseCatalog.catalogSyncDAO.getProgramReqs(extProgramID=arguments.extProgramID);
// Loop over the External Course data records
if ( isQuery(extCourseReqQry) AND extCourseReqQry.recordCount ) {
// Loop over the records in the recurrence properties query
for ( cItm=1; cItm LTE extCourseReqQry.RecordCount; cItm=cItm+1 ) {
// set the extBindID from the external schedule data
extBindID = extCourseReqQry["ID"][cItm]; // The Binding Table's unique ID
// Set the external ParentCourseID
extParentCourseID = arguments.extProgramID; // The value of the Parent Program ID (that was passed in)
// Set the external ChildCourseID
extChildCourseID = extCourseReqQry["ChildCourseID"][cItm]; // The value of the Child Course ID
if ( ListFindNoCase(extChildCourseIDlist,extChildCourseID) EQ 0 ) {
// Get the Child Course Record from the Course Element by the external Course ID
ceChildArray = application.ptCourseCatalog.courseDAO.getCourseByExternalCourseID(extCourseID=extChildCourseID);
// Add the Course CE "uniqueID" field into the array
if ( ArrayLen(ceChildArray) ) {
ArrayAppend(courseUUIDArray,ceChildArray[1]);
// Add the external Child Course ID to a temp list to help prevent dups from being added to the return Array
extChildCourseIDlist = application.ptCourseCatalog.data.listAppendNoDuplicates(list=extChildCourseIDlist,value=extChildCourseID);
}
}
}
}
return courseUUIDArray;
var courseUUIDArray = ArrayNew(1);
var extCoursePreReqQry = QueryNew("null");
var extBindID = "";
var extParentCourseID = "";
var extChildCourseID = "";
var extChildCourseIDlist = "";
var ceChildArray = ArrayNew(1);
var cItm = 1;
// Query the "courseprereqs" external table
extCoursePreReqQry = application.ptCourseCatalog.catalogSyncDAO.getCoursePreReqs(extCourseID=arguments.extCourseID);
// Loop over the External Course data records
if ( isQuery(extCoursePreReqQry) AND extCoursePreReqQry.recordCount ) {
// Loop over the records in the recurrence properties query
for ( cItm=1; cItm LTE extCoursePreReqQry.RecordCount; cItm=cItm+1 ) {
// set the extBindID from the external schedule data
extBindID = extCoursePreReqQry["ID"][cItm]; // The Binding Table's unique ID
// Set the external ParentCourseID
extParentCourseID = arguments.extCourseID; // The value of the Parent Course ID (that was passed in)
// Set the external ChildCourseID
extChildCourseID = extCoursePreReqQry["ChildCourseID"][cItm]; // The value of the Child Course ID
if ( ListFindNoCase(extChildCourseIDlist,extChildCourseID) EQ 0 ) {
// Get the Child Course Record from the Course Element by the external Course ID
ceChildArray = application.ptCourseCatalog.courseDAO.getCourseByExternalCourseID(extCourseID=extChildCourseID);
// Add the Course CE "uniqueID" field into the array
if ( ArrayLen(ceChildArray) ) {
ArrayAppend(courseUUIDArray,ceChildArray[1]);
// Add the external Child Course ID to a temp list to help prevent dups from being added to the return Array
extChildCourseIDlist = application.ptCourseCatalog.data.listAppendNoDuplicates(list=extChildCourseIDlist,value=extChildCourseID);
}
}
}
}
return courseUUIDArray;
var ccapiData = StructNew();
var extElementFields = "";
var i = 1;
var currKey = "";
var updateReq = false;
// Load the current CE data into the ccapiData struct
if ( ArrayLen(arguments.ceDataArray) ) {
ccapiData = arguments.ceDataArray[1].values;
ccapiData['datapageid'] = arguments.ceDataArray[1].pageid;
}
// Get the fields from the external data query
if ( isQuery(arguments.extDataQry) ){
extElementFields = arrayToList(arguments.extDataQry.GetColumnNames());
}
// Loop over the external data and load into ccapiData
for (i=1; i LTE ListLen(extElementFields); i=i+1) {
currKey = ListGetAt(extElementFields,i);
if ( StructKeyExists(ccapiData, "#currKey#") ) {
// Check if any difference in the fields
if ( TRIM(arguments.extDataQry[currKey][1]) NEQ TRIM(ccapiData[currKey]) ){
updateReq = true;
//application.ptCourseCatalog.utils.doDump(currKey, "currKey", false);
}
// Set the field into the main data struct
ccapiData[currKey] = TRIM(arguments.extDataQry[currKey][1]);
}
}
// Set the update required into the element data as a temp variable
ccapiData['tempUpdateReq'] = updateReq;
// Check that the ID field exists and contains a UUID
if ( (NOT StructKeyExists(ccapiData, "uniqueID")) OR (LEN(ccapiData["uniqueID"]) LTE 0) )
ccapiData["uniqueID"] = createUUID();
return ccapiData;
var newSubsiteID = 0;
var subsiteMask = getDefaultDeptSubsiteMask();
var maskValue = "";
var lowerCaseStatus = getForceSubsiteNameLowerCaseStatus();
var buildSchoolSubsites = getEnableBuildSchoolSubsitesStatus();
var deptSubsiteName = "";
var deptSubsitePath = "";
var contentNameFieldA = "deptName";
var contentMaskA = "{department name}";
var contentNameFieldB = "deptCode";
var contentMaskB = "{department code}";
var schoolData = StructNew();
var schoolSubsitePath = "";
var newSchoolSubsiteID = 0;
if ( StructKeyExists(arguments.deptData,"schoolID") AND LEN(TRIM(arguments.deptData.schoolID)) ) {
// Get the school record based on the school id
schoolData = application.ptCourseCatalog.schoolDAO.getSchoolBySchoolID(schoolID=arguments.deptData.schoolID);
}
if ( StructCount(schoolData) GT 0 ) {
if ( StructKeyExists(schoolData,"values") ) {
// If the school element record has an assigned school Subsite get the School Subsite Path
if ( StructKeyExists(schoolData.values,"schoolSubsiteID") AND IsNumeric(schoolData.values.schoolSubsiteID) AND schoolData.values.schoolSubsiteID GT 0 ) {
// Get the subsite path for the School subsite
schoolSubsitePath = application.ptCourseCatalog.csData.getSubsiteURLbySubsiteID(subsiteID=schoolData.values.schoolSubsiteID);
}
// If the School Subsite Path does not exist the SchoolSubsiteID must not be valid
if ( buildSchoolSubsites AND LEN(TRIM(schoolSubsitePath)) EQ 0 ) {
newSchoolSubsiteID = buildSchoolSubsiteDefaultPath(schoolData=schoolData.values,csPageID=schoolData.pageid);
schoolSubsitePath = application.ptCourseCatalog.csData.getSubsiteURLbySubsiteID(subsiteID=newSchoolSubsiteID);
}
}
if ( LEN(TRIM(schoolSubsitePath)) ) {
// Check the mask and set the subsite name
maskValue = ListLast(subsiteMask,"/");
if ( maskValue EQ contentMaskA AND StructKeyExists(arguments.deptData,contentNameFieldA) )
deptSubsiteName = arguments.deptData[contentNameFieldA];
else if ( maskValue EQ contentMaskB AND StructKeyExists(arguments.deptData,contentNameFieldB) )
deptSubsiteName = arguments.deptData[contentNameFieldB];
if ( LEN(TRIM(deptSubsiteName)) ) {
// Make the department subsite name safe for CS
// and possibly force lower-case
deptSubsiteName = application.ptCourseCatalog.csData.makeCSSafe(stringToFix=deptSubsiteName,makeLowerCase=lowerCaseStatus);
// Build the subsite path and create the subsite
deptSubsitePath = schoolSubsitePath & deptSubsiteName;
// Get the new subsite ID when building the subsites from the provided path
newSubsiteID = application.ptCourseCatalog.csSubsite.buildSubsitesFromPath(subsitePath=deptSubsitePath);
return newSubsiteID;
}
}
}
return 0;
var newSubsiteID = 0;
var subsiteMask = getDefaultSchoolSubsiteMask();
var maskValue = "";
var lowerCaseStatus = getForceSubsiteNameLowerCaseStatus();
var baseSubsiteID = getDefaultBaseCatalogSubsiteID();
var baseSubsitePath = "";
var schoolSubsiteName = "";
var schoolSubsitePath = "";
var contentNameFieldA = "schoolName";
var contentMaskA = "{school name}";
var contentNameFieldB = "schoolCode";
var contentMaskB = "{school code}";
var validSubsitePath = "";
var newSchoolData = StructNew();
var schoolUpdateComplete = false;
// Does the school record already have a school subsite ID assigned
if ( StructKeyExists(arguments.schoolData,"schoolSubsiteID") AND IsNumeric(arguments.schoolData.schoolSubsiteID) AND arguments.schoolData.schoolSubsiteID GT 0 ) {
// Check if this Subsite ID is still valid
validSubsitePath = application.ptCourseCatalog.csData.getSubsiteURLbySubsiteID(arguments.schoolData.schoolSubsiteID);
if ( LEN(TRIM(validSubsitePath)) ) {
return arguments.schoolData.schoolSubsiteID;
}
}
// Do we have a catalog BaseSubsiteID in the config to build a school subsite under
if ( IsNumeric(baseSubsiteID) AND baseSubsiteID GT 0 ) {
baseSubsitePath = application.ptCourseCatalog.csData.getSubsiteURLbySubsiteID(subsiteID=baseSubsiteID);
// Check the mask and set the subsite name
maskValue = ListLast(subsiteMask,"/");
if ( maskValue EQ contentMaskA AND StructKeyExists(arguments.schoolData,contentNameFieldA) )
schoolSubsiteName = arguments.schoolData[contentNameFieldA];
else if ( maskValue EQ contentMaskB AND StructKeyExists(arguments.schoolData,contentNameFieldB) )
schoolSubsiteName = arguments.schoolData[contentNameFieldB];
if ( LEN(TRIM(schoolSubsiteName)) ) {
// Make the school subsite name safe for CS
// and possibly force lower-case
schoolSubsiteName = application.ptCourseCatalog.csData.makeCSSafe(stringToFix=schoolSubsiteName,makeLowerCase=lowerCaseStatus);
// Build the subsite path and create the subsite
schoolSubsitePath = baseSubsitePath & schoolSubsiteName;
// Get the school Subsite ID (and create the path if needed)
newSubsiteID = application.ptCourseCatalog.csSubsite.buildSubsitesFromPath(subsitePath=schoolSubsitePath);
// Update the School Record via the CCAPI
if ( newSubsiteID GT 0 AND arguments.csPageID GT 0 ) {
newSchoolData = arguments.schoolData;
newSchoolData.datapageid = arguments.csPageID;
newSchoolData.schoolSubsiteID = newSubsiteID;
// Run the element CCAPI to add/edit
schoolUpdateStatus = application.ptCourseCatalog.schoolDAO.schoolCCAPI(dataValues=newSchoolData);
// Update the flag for if the element record was add/edit
if ( StructKeyExists(schoolUpdateStatus,"CONTENTUPDATED") ) {
schoolUpdateComplete = schoolUpdateStatus.CONTENTUPDATED;
}
else {
doErrorLogging(variables.componentName,"buildSchoolSubsiteDefaultPath",schoolUpdateStatus,"School SubsiteID Update Failed!");
}
}
return newSubsiteID;
}
}
return 0;