variables.shim_dataSource = "commonspot-external"; //request.site.datasource
variables.shim_db_type = "mysql"; // mssql, mysql
variables.shim_tableName = 'profiles_sync';
// Added as the prProfile.xml config option
// Drops Profile Page that are no longer in the External database
//variables.enableDropProfiles = true;
//variables.dropProfilesType = "delete"; // Set delete or deactivate
variables.shim_idFieldName = "External_ID";
variables.shim_idFieldSqlType = "INT"; //CF_SQL_#variables.shim_idFieldCfType#
variables.shim_idFieldCfType = "INTEGER"; //CF_SQL_#variables.shim_idFieldCfType#
var retQry = QueryNew('tmp');
SELECT *
FROM #variables.shim_tableName#
var retQry = QueryNew('tmp');
SELECT *
FROM #variables.shim_tableName#
WHERE EXTERNAL_ID =
AND pageID =
var retQry = QueryNew('tmp');
SELECT *
FROM #variables.shim_tableName#
WHERE userid =
var retQry = QueryNew('tmp');
SELECT *
FROM #variables.shim_tableName#
WHERE external_id =
var retQry = QueryNew('tmp');
SELECT *
FROM #variables.shim_tableName#
WHERE id =
var retData = StructNew();
var syncQry = getSyncRecord(externalID=arguments.externalID,pageid=arguments.pageid);
retData.pageID = arguments.pageid;
retData.EXTERNAL_ID = arguments.externalID;
retData.userID = arguments.userID;
if ( syncQry.RecordCount )
retData = updateSyncRecord(id=syncQry.id,externalID=arguments.externalID,pageid=arguments.pageid,datapageid=arguments.datapageid,userID=arguments.userID,profileData=arguments.profileData,pageData=arguments.pageData);
else
retData = createSyncRecord(externalID=arguments.externalID,pageid=arguments.pageid,datapageid=arguments.datapageid,userID=arguments.userID,profileData=arguments.profileData,pageData=arguments.pageData);
return retData;
var retData = StructNew();
var insQry = '';
var syncData = StructNew();
var key = '';
retData.syncType = 'new';
retData.EXTERNAL_ID = arguments.externalID;
retData.pageID = arguments.pageid;
retData.userID = arguments.userID;
// Build the Sync Data for the insert
syncData.FileName = arguments.pageData.FileName;
syncData.Name = arguments.pageData.Name;
syncData.Title = arguments.pageData.Title;
syncData.Description = arguments.pageData.Description;
syncData.Caption = arguments.pageData.Caption;
INSERT INTO #variables.shim_tableName#
(
EXTERNAL_ID,
pageID,
DataPageID,
UserID,
#key#,
lastUpdate,
saveType
)
VALUES
(
,
,
,
,
dValue = syncData[key];
,
,
)
return retData;
var retData = StructNew();
var updateQry = '';
var syncData = StructNew();
var key = '';
retData.syncType = 'update';
retData.EXTERNAL_ID = arguments.externalID;
retData.pageID = arguments.pageid;
retData.userID = arguments.userID;
// Build the Sync Data for the update
syncData.FileName = arguments.pageData.FileName;
syncData.Name = arguments.pageData.Name;
syncData.Title = arguments.pageData.Title;
syncData.Description = arguments.pageData.Description;
syncData.Caption = arguments.pageData.Caption;
UPDATE #variables.shim_tableName#
SET
EXTERNAL_ID = ,
pageID = ,
DataPageID = ,
UserID = ,
dValue = syncData[key];
#key# = ,
lastUpdate = ,
saveType =
WHERE ID =
return retData;
var retData = StructNew();
var deleteQry = '';
var syncRecordsQry = getSyncRecordByUserID(userid=Arguments.userid);
var logMsg = '';
var logData = StructNew();
retData.userid = arguments.userid;
retData.status = false;
retData.pageids = ArrayNew(1);
if ( syncRecordsQry.recordcount )
retData.pageids = ListToArray(ValueList(syncRecordsQry.PageID));
DELETE FROM #variables.shim_tableName#
WHERE userid =
retData.status = true;
retData.status = false;
logMsg = 'Error: Failed to Delete Profile Sync Record!';
logData = cfcatch;
application.ptprofile.log.doTextLogging('profileSync','deleteSyncRecordByUserID','ptProfile',logMsg,logData);
logMsg = 'Skip: No Profile Sync Record to delete!';
application.ptprofile.log.doTextLogging('profileSync','deleteSyncRecordByUserID','ptProfile',logMsg,logData);
return retData;
var retData = StructNew();
var deleteQry = '';
var logMsg = '';
var logData = StructNew();
retData.status = false;
DELETE FROM #variables.shim_tableName#
WHERE external_id =
retData.status = true;
retData.status = false;
logMsg = 'Error: Failed to Delete Profile Sync Record by External ID!';
logData = cfcatch;
application.ptprofile.log.doTextLogging('profileSync','deleteSyncRecordByExternalID','ptProfile',logMsg,logData);
return retData;
var retData = StructNew();
var deleteQry = '';
var logMsg = '';
var logData = StructNew();
retData.pageID = arguments.pageid;
retData.status = false;
DELETE FROM #variables.shim_tableName#
WHERE pageID =
retData.status = true;
retData.status = false;
logMsg = 'Error: Failed to Delete Profile Sync Record!';
logData = cfcatch;
application.ptprofile.log.doTextLogging('profileSync','deleteSyncRecordByPageID','ptProfile',logMsg,logData);
return retData;
var retQry = QueryNew('userid,datapageid,external_id');
var syncProfileQry = getAllSyncRecords();
var i = 1;
var extProfileQry = application.ptProfile.profileService.getExternalProfileData(); // Get all external data then use QofQ for lookups
var extRecordQry = QueryNew('temp');
var userid = '';
var externalid = '';
var profileDataPageID = 0;
var row = 1;
var QofQ = QueryNew('temp');
var profileIDfield = getProfileIdField();
for ( i=1; i LTE syncProfileQry.recordCount; i++ ) {
userid = syncProfileQry.userid[i];
externalid = syncProfileQry.external_id[i];
//dataPageID = syncProfileQry.dataPageID[i]; // not in sync table
// LOOK for sync record in External Datasource using a Query of Queries
QofQ = new Query();
QofQ.setDBType('query');
QofQ.setAttributes(rs=extProfileQry); // needed for QoQ of ALL external records QUERY
QofQ.addParam(name='extid', value='#lcase(externalid)#', cfsqltype='cf_sql_varchar');
QofQ.setSQL('SELECT #profileIDfield# FROM rs where lower(#profileIDfield#) = :extid');
//QofQ.addParam(name='userid', value='#lcase(userid)#', cfsqltype='cf_sql_varchar');
//QofQ.setSQL('SELECT userid FROM rs where lower(userid) = :userid');
QofQ.setMaxRows(1); // limit max rows, if desired
extRecordQry = QofQ.execute().getResult();
//WriteDump(var=extRecordQry,label='extQry');
// DO NOT USE!! - DO NOT LOOKUP EVERY INDIVIDUAL USERID ONE AT A TIME!!!
//extRecordQry = application.ptProfile.profileService.getExternalProfileData(userid=userid);
// If External Data has NO records for the this UserID, add to the drop query
if ( extRecordQry.RecordCount EQ 0 )
{
// Use the datapageid stored in the sync table ... not the profile object (too expensive)!!
profileDataPageID = syncProfileQry.DataPageID[i];
// DO NOT USE!!
//profileObj = server.ADF.objectFactory.getBean("profile").initProfile(userid);
//profileDataPageID = profileObj.GetProfileCEDataPageID();
// Build Return qry
QueryAddRow(retQry, 1);
QuerySetCell( retQry, 'userid', userid, row );
QuerySetCell( retQry, 'datapageid', profileDataPageID, row );
QuerySetCell( retQry, 'external_id', externalid, row );
row++;
}
}
return retQry;
/*
* CUSTOMIZE AT THE SITE LEVEL
*/