lib/impl/dataSources/index.js
function list(connections, params, callback) {

  logger.debug("Listing Data Sources", params);

  var currentTime = new Date(params.currentTime);
  //If listing data sources needing a cache update, need to supply a valid date.
  if (params.listDataSourcesNeedingUpdate && !params.currentTime && currentTime.toString() !== "Invalid Date") {
    return callback(buildErrorResponse({error: new Error("An currentTime Date Object Is Required To List Data Sources Requiring Update"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
  }

  async.waterfall([
    function findDataSources(cb) {
      var query = {};

      lookUpDataSources(connections, {
        query: query,
        lean: true
      }, function(err, dataSources) {
        if (err) {
          return cb(buildErrorResponse({
            error: err,
            userDetail: "Unexpected Error When Searching For A Data Source",
            code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
          }));
        }

        logger.debug("Listing Data Sources", {dataSources: dataSources});

        //Only return Data Sources with a valid data source update time
        if (params.listDataSourcesNeedingUpdate) {
          dataSources = checkUpdateInterval(dataSources, currentTime);
        }

        logger.debug("Listing Data Sources", {dataSourceAfterFilter: dataSources});

        dataSources = _.map(dataSources, processDataSourceResponse);

        return cb(undefined, dataSources);
      });
    },
    function getFormsUsingDataSources(dataSources, cb) {
      async.map(dataSources, function(dataSource, cb) {
        checkFormsUsingDataSource(connections, dataSource, cb);
      }, cb);
    }
  ], callback);
}
function list(connections, params, callback) {

  logger.debug("Listing Data Sources", params);

  var currentTime = new Date(params.currentTime);
  //If listing data sources needing a cache update, need to supply a valid date.
  if (params.listDataSourcesNeedingUpdate && !params.currentTime && currentTime.toString() !== "Invalid Date") {
    return callback(buildErrorResponse({error: new Error("An currentTime Date Object Is Required To List Data Sources Requiring Update"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
  }

  async.waterfall([
    function findDataSources(cb) {
      var query = {};

      lookUpDataSources(connections, {
        query: query,
        lean: true
      }, function(err, dataSources) {
        if (err) {
          return cb(buildErrorResponse({
            error: err,
            userDetail: "Unexpected Error When Searching For A Data Source",
            code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
          }));
        }

        logger.debug("Listing Data Sources", {dataSources: dataSources});

        //Only return Data Sources with a valid data source update time
        if (params.listDataSourcesNeedingUpdate) {
          dataSources = checkUpdateInterval(dataSources, currentTime);
        }

        logger.debug("Listing Data Sources", {dataSourceAfterFilter: dataSources});

        dataSources = _.map(dataSources, processDataSourceResponse);

        return cb(undefined, dataSources);
      });
    },
    function getFormsUsingDataSources(dataSources, cb) {
      async.map(dataSources, function(dataSource, cb) {
        checkFormsUsingDataSource(connections, dataSource, cb);
      }, cb);
    }
  ], callback);
}
function list ( connections , params , callback ) { logger . debug ( "Listing Data Sources" , params ) ; var currentTime = new Date ( params . currentTime ) ; //If listing data sources needing a cache update, need to supply a valid date. if ( params . listDataSourcesNeedingUpdate && ! params . currentTime && currentTime . toString ( ) !== "Invalid Date" ) { return callback ( buildErrorResponse ( { error : new Error ( "An currentTime Date Object Is Required To List Data Sources Requiring Update" ) , code : ERROR_CODES . FH_FORMS_INVALID_PARAMETERS } ) ) ; } async . waterfall ( [ function findDataSources ( cb ) { var query = { } ; lookUpDataSources ( connections , { query : query , lean : true } , function ( err , dataSources ) { if ( err ) { return cb ( buildErrorResponse ( { error : err , userDetail : "Unexpected Error When Searching For A Data Source" , code : ERROR_CODES . FH_FORMS_UNEXPECTED_ERROR } ) ) ; } logger . debug ( "Listing Data Sources" , { dataSources : dataSources } ) ; //Only return Data Sources with a valid data source update time if ( params . listDataSourcesNeedingUpdate ) { dataSources = checkUpdateInterval ( dataSources , currentTime ) ; } logger . debug ( "Listing Data Sources" , { dataSourceAfterFilter : dataSources } ) ; dataSources = _ . map ( dataSources , processDataSourceResponse ) ; return cb ( undefined , dataSources ) ; } ) ; } , function getFormsUsingDataSources ( dataSources , cb ) { async . map ( dataSources , function ( dataSource , cb ) { checkFormsUsingDataSource ( connections , dataSource , cb ) ; } , cb ) ; } ] , callback ) ; }
Listing All Data Sources. In The Environment, this will include the current cache data.
@param connections
@param params
- listDataSourcesNeedingUpdate: Flag For Only Returning Data Sources That Require An Update
- currentTime: Time Stamp To Compare Data Source Last Updated Timestamps To
@param callback
Listing All Data Sources . In The Environment this will include the current cache data .