lib/impl/dataTargets.js
function get(connections, params, cb) {
  var failed = validate(params).has(CONSTANTS.DATA_TARGET_ID);

  if (failed) {
    return cb(buildErrorResponse({error: new Error("An ID Parameter Is Required To Get A Data Target"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
  }

  if (!misc.checkId(params._id)) {
    return cb(buildErrorResponse({error: new Error("Invalid ID Paramter"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
  }

  async.waterfall([
    function findDataTargets(cb) {
      var query = {

      };

      //Searching By ID.
      query[CONSTANTS.DATA_TARGET_ID] = params._id;

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

        //Checking if the Data Target exists. Should be only one
        if (dataTargets.length !== 1) {
          return cb(buildErrorResponse({
            error: new Error("Data Target Not Found"),
            systemDetail: "Requested ID: "  + params[CONSTANTS.DATA_TARGET_ID],
            code: ERROR_CODES.FH_FORMS_NOT_FOUND
          }));
        }

        return cb(undefined, dataTargets[0]);
      });
    },
    function checkForms(dataTargetJSON, cb) {
      //Checking For Any Forms Associated With The Data Target
      checkFormsUsingDataTarget(connections, dataTargetJSON, cb);
    }
  ], cb);
}
function get(connections, params, cb) {
  var failed = validate(params).has(CONSTANTS.DATA_TARGET_ID);

  if (failed) {
    return cb(buildErrorResponse({error: new Error("An ID Parameter Is Required To Get A Data Target"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
  }

  if (!misc.checkId(params._id)) {
    return cb(buildErrorResponse({error: new Error("Invalid ID Paramter"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
  }

  async.waterfall([
    function findDataTargets(cb) {
      var query = {

      };

      //Searching By ID.
      query[CONSTANTS.DATA_TARGET_ID] = params._id;

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

        //Checking if the Data Target exists. Should be only one
        if (dataTargets.length !== 1) {
          return cb(buildErrorResponse({
            error: new Error("Data Target Not Found"),
            systemDetail: "Requested ID: "  + params[CONSTANTS.DATA_TARGET_ID],
            code: ERROR_CODES.FH_FORMS_NOT_FOUND
          }));
        }

        return cb(undefined, dataTargets[0]);
      });
    },
    function checkForms(dataTargetJSON, cb) {
      //Checking For Any Forms Associated With The Data Target
      checkFormsUsingDataTarget(connections, dataTargetJSON, cb);
    }
  ], cb);
}
function get ( connections , params , cb ) { var failed = validate ( params ) . has ( CONSTANTS . DATA_TARGET_ID ) ; if ( failed ) { return cb ( buildErrorResponse ( { error : new Error ( "An ID Parameter Is Required To Get A Data Target" ) , code : ERROR_CODES . FH_FORMS_INVALID_PARAMETERS } ) ) ; } if ( ! misc . checkId ( params . _id ) ) { return cb ( buildErrorResponse ( { error : new Error ( "Invalid ID Paramter" ) , code : ERROR_CODES . FH_FORMS_INVALID_PARAMETERS } ) ) ; } async . waterfall ( [ function findDataTargets ( cb ) { var query = { } ; //Searching By ID. query [ CONSTANTS . DATA_TARGET_ID ] = params . _id ; lookUpDataTargets ( connections , { query : query , lean : true } , function ( err , dataTargets ) { if ( err ) { return cb ( buildErrorResponse ( { error : err , userDetail : "Unexpected Error When Searching For A Data Target" , code : ERROR_CODES . FH_FORMS_UNEXPECTED_ERROR } ) ) ; } //Checking if the Data Target exists. Should be only one if ( dataTargets . length !== 1 ) { return cb ( buildErrorResponse ( { error : new Error ( "Data Target Not Found" ) , systemDetail : "Requested ID: " + params [ CONSTANTS . DATA_TARGET_ID ] , code : ERROR_CODES . FH_FORMS_NOT_FOUND } ) ) ; } return cb ( undefined , dataTargets [ 0 ] ) ; } ) ; } , function checkForms ( dataTargetJSON , cb ) { //Checking For Any Forms Associated With The Data Target checkFormsUsingDataTarget ( connections , dataTargetJSON , cb ) ; } ] , cb ) ; }
Get A Specific Data Target Definition
@param connections
@param params
@param cb
Get A Specific Data Target Definition