/*
Helper to return a valid id from app data
490351
function(c) {
    return c.cid || c.id || c.containerName || c.containerID || c.name;
  }
712102
function getFormIds(req, res, next) {
  var params = {
    appId: req.params.projectid || req.params.id
  };

  forms.getAppFormsForApp(_.extend(req.connectionOptions, params), function(err, appFormResult) {
    if (err) {
      return next(err);
    }

    //Only Want The Form Ids
    req.appformsResultPayload = {
      data: _.map(_.compact(appFormResult.forms), function(form) {
        return form._id.toString();
      }),
      type: constants.resultTypes.formProjects
    };

    next();
  });
}
1060202
function Id (_id) {
  var dec
  var hex

  if (typeof _id === 'number') {
    dec = _id
    var tmp = ('00000000000000' + _id.toString(16))
    hex = tmp.substring(tmp.length - 12, tmp.length)
  }
  if (typeof _id === 'string') {
    dec = parseInt(_id, 16)
    hex = _id
  }
  if (typeof _id === 'undefined') {
    hex = sha1((~~(Math.random() * 1e9)).toString(36) + Date.now())
      .substring(0, 12)
    dec = parseInt(hex, 16)
  }

  this.toHex = function () {
    return hex
  }

  this.toDec = function () {
    return dec
  }

  this.next = function () {
    if (hex === maxHex) {
      return '000000000000'
    } else {
      var a = ('000000000000' + ((dec + 1).toString(16)))
      return a.substring(a.length - 12, a.length)
    }
  }

  return this
}
29396
function rndid(len) {
  len = len || 8;
  const id = rndm(len);

  if (document.getElementById(id)) {
    return rndid(len);
  }

  return id;
}
1322785
function getFingerData( id ) {
			for(var i=0; i<fingerData.length; i++) {
				if(fingerData[i].identifier == id) {
					return fingerData[i];	
				}
			}
		}
238598
def verify_id(ctx, param, app):
    """"""
    if app is None:
        raise TypeError("Select an experiment using the --app parameter.")
    elif app[0:5] == "dlgr-":
        raise ValueError(
            "The --app parameter requires the full "
            "UUID beginning with {}-...".format(app[5:13])
        )
    return app
1236948
@Override
	public String isValidID(String id) {
		Data data;
		try {
			data = identities.find(id, identities.reuse());
		} catch (IOException e) {
			return getName() + " could not lookup " + id + ": " + e.getLocalizedMessage();
		}
		return data==null?id + "is not an Identity in " + getName():null;
	}
708883
function getSourceId(callback) {
    if (!callback)
        throw '"callback" parameter is mandatory.';
    if (sourceId)
        return callback(sourceId);
    screenCallback = callback;
    window.postMessage('get-sourceId', '*');
}
428912
function(req) {

    var pk = module.exports.parsePk(req);

    // Validate the required `id` parameter
    if (!pk) {

      var err = new Error(
        'No `id` parameter provided.' +
        '(Note: even if the model\'s primary key is not named `id`- ' +
        '`id` should be used as the name of the parameter- it will be ' +
        'mapped to the proper primary key name)'
      );
      err.status = 400;
      throw err;
    }

    return pk;
  }
313800
function getRequestId(req) {
  const id = uuid.v1();
  req.id = id;
  return {
    req_id: id,
  };
}
1243592
function getMaxOperationId() {
        var query = new Query(operationTableName);
        return store.read(query.orderByDescending('id').take(1)).then(function(result) {
            Validate.isArray(result);
            
            if (result.length === 0) {
                return 0;
            } else if (result.length === 1) {
                return result[0].id;
            } else {
                throw new Error('something is wrong!');
            }
        });
    }
678715
function isId(property) {
    Validate.isString(property);
    Validate.notNullOrEmpty(property);

    return property.toLowerCase() === idPropertyName.toLowerCase();
}
1175710
function getUserData(data, checks) {
  if (Array.isArray(data) ? data.length === 0 : data.total === 0) {
    throw new errors.BadRequest('User not found.', { errors: { $className: 'badParams' } });
  }
  
  const users = Array.isArray(data) ? data : data.data;
  const user = users[0];
  
  if (users.length !== 1) {
    throw new errors.BadRequest('More than 1 user selected.',
      { errors: { $className: 'badParams' } });
  }

  if (checks.indexOf('isNotVerified') !== -1 && user.isVerified) {
    throw new errors.BadRequest('User is already verified.',
      { errors: { $className: 'isNotVerified' } });
  }

  if (checks.indexOf('isVerified') !== -1 && !user.isVerified) {
    throw new errors.BadRequest('User is not verified.',
      { errors: { $className: 'isVerified' } });
  }
  
  if (checks.indexOf('verifyNotExpired') !== -1 && user.verifyExpires < Date.now()) {
    throw new errors.BadRequest('Verification token has expired.',
      { errors: { $className: 'verifyExpired' } });
  }

  if (checks.indexOf('resetNotExpired') !== -1 && user.resetExpires < Date.now()) {
    throw new errors.BadRequest('Password reset token has expired.',
      { errors: { $className: 'resetExpired' } });
  }

  return user;
}
765330
function checkPath(id)
{
  var i;

  for (i = 0; i < this.pathsKeys.length; i++)
  {
    if (id.indexOf(this.pathsKeys[i]) == 0)
    {
      if (this.paths[this.pathsKeys[i]] == 'empty:')
      {
        id = 'empty:';
      }
      else
      {
        id = id.replace(this.pathsKeys[i], this.paths[this.pathsKeys[i]]);
      }
      break;
    }
  }

  return id;
}
1239133
function getElementById(v, id) {
    if (!v) {
        return undefined;
    }
    if (v.id === id) {
        return view;
    }
    var retVal=undefined;
    var viewCallBack = function (child) {
        if (child.id === id) {
            retVal = child;
            return false;
        }

        // Android patch for ListView
        if (child._realizedItems && child._realizedItems.size !== child._childrenCount) {
            for (var key in child._realizedItems) {
                if (child._realizedItems.hasOwnProperty(key)) {
                    // We return false, when we have a hit; so if we have a hit we can stop searching
                    if (!viewCallBack(child._realizedItems[key])) {
                        return false;
                    }
                }
            }
        }

        return true;
    };

    viewBase.eachDescendant(v, viewCallBack);

    if (typeof retVal === "undefined") {
        // Android patch for ListView
        if (v._realizedItems && v._realizedItems.size !== v._childrenCount) {
            for (var key in v._realizedItems) {
                if (v._realizedItems.hasOwnProperty(key)) {
                    // viewCallback will return false, if we found a match
                    if (!viewCallBack(v._realizedItems[key])) {
                        return retVal;
                    }
                }
            }
        }
    }

    return retVal;
}
688343
function extractRunId(app_id, mqtt_channel) {
    var pc = '/nutella/apps/' + app_id + '/runs/';
    var sp =  mqtt_channel.replace(pc, '').split('/');
    return sp[0];
}
62331
function getNextId() {
    var dataIds = Object.keys(idIndexData)

    dataIds.sort(function (a, b) {
      return b - a
    })

    if (dataIds && dataIds[0]) {
      var id = _.parseInt(dataIds[0]) + 1
      return id
    } else {
      return 1
    }
  }