// Get the data from the spreadsheet
subsiteMapQry = application.ptImport.ImportService.readExcelToQuery(excelFileExpandedPath=ExpandPath(appConfig.subsite_mapping_source));
// Loop over the query
for ( i=1; i LTE subsiteMapQry.RecordCount; i++ ){
// Set the current record into a struct
currData = structNew();
currData.Path_in_File_Structure = TRIM(subsiteMapQry.Path_in_File_Structure[i]);
// TODO - Fix to work for both CS and Non-CS imports
//currData.ID = TRIM(application.ptImport.SubsiteDAO.getExternalSubsiteID(currData.Path_in_File_Structure));
currData.ID = subsiteMapQry.ID[i];
currData.Desired_Path = TRIM(subsiteMapQry.Desired_Path[i]);
currData.Name = TRIM(subsiteMapQry.Name[i]);
currData.Display = TRIM(subsiteMapQry.Display[i]);
currData.Description = TRIM(subsiteMapQry.Description[i]);
currData.TemplateName = TRIM(subsiteMapQry.Template_Name[i]);
// Get the current record data
currRecQry = application.ptImport.SubsiteDAO.getSourceData(oldSubsiteURL=currData.Path_in_File_Structure);
// Check if a data records exists
if ( currRecQry.recordCount ){
// Update the record
application.ptImport.SubsiteDAO.updateSourceData(currData);
}
else {
// Create a new record
application.ptImport.SubsiteDAO.createSourceData(currData);
}
}
return application.ptImport.SubsiteDAO.getSourceData();
// Get the mapping data
var sourceQry = application.ptImport.SubsiteDAO.getSourceData(oldSubsiteID=arguments.jobItemDataID);
var setStatus = false;
var subsiteData = StructNew();
var i = 1;
var jobProcessingStatus = false;
var jobItemStatus = "complete";
// Get the map record data
mapQuery = application.ptImport.SubsiteDAO.getMappingData(sourceID=arguments.jobItemDataID);
//application.ADF.utils.dodump(mapQuery,"mapQuery", false);
// Check if the record exists
if ( mapQuery.RecordCount ){
// Update for the record data page id
mapDataArray = application.ptImport.cedata.buildCEDataArrayFromQuery(ceDataQuery=mapQuery);
//application.ADF.utils.dodump(mapDataArray,"mapDataArray", false);
// Set the Values data into the subsitedata
subsiteData = mapDataArray[1].Values;
subsiteData.dataPageID = mapDataArray[1].pageID;
}
else {
// Create the record
subsiteData.sourceID = sourceQry.ID[i];
subsiteData.oldSubsiteID = sourceQry.oldSubsiteID[i];
subsiteData.oldSubsiteURL = application.ptImport.csData.formatSubsiteURL(sourceQry.OldSubsiteURL[i]);
subsiteData.newSubsiteURL = application.ptImport.csData.formatSubsiteURL(sourceQry.NewSubsiteURL[i]);
subsiteData.name = sourceQry.NewSubsiteName[i];
subsiteData.displayName = sourceQry.NewSubsiteDisplayName[i];
subsiteData.description = sourceQry.NewSubsiteDescription[i];
}
//application.ADF.utils.dodump(subsiteData,"subsiteData", false);
// Set the record data
setStatus = application.ptImport.SubsiteDAO.setMappingData(data=subsiteData);
//application.ADF.utils.dodump(setStatus,"setStatus", false);
// TODO - Update the status for the job item
if ( NOT setStatus.contentUpdated ){
jobItemStatus = "error";
}
return jobItemStatus;
// Get the job item data
var jobItemStatus = "complete";
var subsiteData = StructNew();
var needsUpdate = 0;
// Get the subsite map record data
var subsiteDataQuery = application.ptImport.SubsiteDAO.getMappingData(pageID=arguments.jobItemDataID);
// Set the query to an array
var subsiteDataArray = application.ptImport.cedata.buildCEDataArrayFromQuery(ceDataQuery=subsiteDataQuery);
var createResult = "";
var updateMapResult = "";
//application.ADF.utils.dodump(subsiteDataQuery,"subsiteDataQuery", false);
//application.ADF.utils.dodump(subsiteDataArray,"subsiteDataArray", false);
try {
// Check that we have a record
if ( ArrayLen(subsiteDataArray) )
{
// Check if the new subsite name matches the new subsite path subsite name
if ( ListLast(subsiteDataArray[1].values.newSubsiteURL, "/") EQ subsiteDataArray[1].values.name )
{
// check to see if this subsite exists already
if ( not application.ptImport.csData.getSubsiteID(subsiteDataArray[1].values.newSubsiteURL) )
{
// create the subsite
createResult = application.ptImport.SubsiteDAO.createSubsite(subsiteDataArray[1].values);
//application.ADF.utils.dodump(createResult,"createResult", false);
if( createResult.subsiteCreated )
{
needsUpdate = 1;
}
else
{
needsUpdate = 0;
// Error - Subsite was not created
jobItemStatus = createResult.Response;
}
}
else if( not len(subsiteDataQuery.newSubsiteURL) )
{
needsUpdate = 1;
jobItemStatus = "Error: No value for the New Subsite URL Path.";
}
else // The subsite exists already
{
needsUpdate = 1;
jobItemStatus = "Subsite already exists.";
}
// update the element record
if( needsUpdate )
{
// update the subsite creation date to now
subsiteDataArray[1].values.dateCreated = application.ptImport.date.csDateFormat(now());
// add in the flag that the subsite has been created
subsiteDataArray[1].values.newSubsiteID = application.ptImport.CSData.getSubsiteID(subsiteDataArray[1].values.newSubsiteURL);
// Set the data to update the Subsite Map Data
subsiteData = subsiteDataArray[1].values;
subsiteData["dataPageID"] = subsiteDataArray[1].pageid;
//application.ADF.utils.dodump(subsiteData,"subsiteData", false);
updateMapResult = application.ptImport.SubsiteDAO.setMappingData(subsiteData);
//application.ADF.utils.dodump(updateMapResult,"updateMapResult", false);
if ( NOT updateMapResult.CONTENTUPDATED ){
// TODO - Error updating the subsite mapping data
jobItemStatus = "Error: Error updating the subsite mapping data";
}
}
}
else
{
// Not a match with the newSubsiteURL and the Subsite name
jobItemStatus = "Error: New Subsite URL path value does not match the New Subsite Name defined.";
}
}
else
{
// TODO - Error no data for the query
jobItemStatus = "Error: No data for the job item ID - #arguments.jobItemDataID#.";
}
}
catch(Any e) {
// TODO - Error no data for the query
//application.ADF.utils.dodump(e, "cfcatch", false);
jobItemStatus = "Error: Error building subsite.";
}