Helper methods --------------
181466
function callnTimes (object, methodName, count) {
    let returnValue
    while (count--) returnValue = object[methodName]()
    return returnValue
  }
126459
void initInputsByIdMap() {
    inputsById.clear();
    for (CompilerInput input : externs) {
      InputId id = input.getInputId();
      CompilerInput previous = putCompilerInput(id, input);
      if (previous != null) {
        report(JSError.make(DUPLICATE_EXTERN_INPUT, input.getName()));
      }
    }
    for (CompilerInput input : moduleGraph.getAllInputs()) {
      InputId id = input.getInputId();
      CompilerInput previous = putCompilerInput(id, input);
      if (previous != null) {
        report(JSError.make(DUPLICATE_INPUT, input.getName()));
      }
    }
  }
688975
function(view, config) {
  var formInputs = getForm(view);

  formInputs = _.reject(formInputs, function(el) {
    var reject;
    var myType = getElementType(el);
    var extractor = config.keyExtractors.get(myType);
    var identifier = extractor($(el));

    var foundInIgnored = _.find(config.ignoredTypes, function(ignoredTypeOrSelector) {
      return (ignoredTypeOrSelector === myType) || $(el).is(ignoredTypeOrSelector);
    });

    var foundInInclude = _.includes(config.include, identifier);
    var foundInExclude = _.includes(config.exclude, identifier);

    if (foundInInclude) {
      reject = false;
    } else {
      if (config.include) {
        reject = true;
      } else {
        reject = (foundInExclude || foundInIgnored);
      }
    }

    return reject;
  });

  return formInputs;
}
323534
function (model, data, action, options) {
                var schema = model.schema,
                    schemaDefinition,
                    schemaType,
                    value,
                    factory,
                    newData = {};

                // convert top level properties to Models respective to there schema
                for (var key in schema) {
                    if (schema.hasOwnProperty(key)) {

                        schemaDefinition = schema[key];
                        schemaType = schemaDefinition.type;
                        value = this._getValueForKey(data, key, schemaType, schemaDefinition);

                        factory = null;
                        var typeResolver,
                            entity,
                            i,
                            list;
                        if (schemaType instanceof Array) {
                            if (schemaType.length === 1) {
                                typeResolver = schemaType[0];
                            } else if (schemaType.length === 0) {
                                this.log('ModelFactory for ListItem for "' + key + '" not defined', 'warn');
                                factory = Entity;
                            } else {
                                throw "Cannot determinate ModelFactory. Multiple factories defined for '" + key + "'.";
                            }

                            if (typeResolver instanceof Function) {
                                factory = typeResolver;
                                typeResolver = null;
                            }

                            if (value && value instanceof Array) {
                                // only create the list if items are there
                                list = newData[key] = new List();

                                for (i = 0; i < value.length; i++) {

                                    if (typeResolver) {
                                        factory = typeResolver.resolve(value[i], key);
                                    }

                                    if ((factory && factory.classof(Entity))) {
                                        entity = this.$dataSource._getContext(factory, model, value[i]).createEntity(factory, this._getIdForValue(value[i], factory));
                                        if (entity instanceof Entity && !(entity instanceof Model)) {
                                            entity.$parent = model;
                                            entity.$parentEntity = model;
                                        }
                                        entity.set(this._parseModel(entity, value[i], action, options));

                                        list.add(entity);
                                    } else {
                                        list.add(value[i]);
                                    }

                                }
                            }


                        } else if (Collection && schemaType.classof(Collection)) {
                            var contextForChildren = this.$dataSource._getContext(schemaType, model, value);
                            if (contextForChildren) {
                                if (model.$[key] instanceof Collection) {
                                    newData[key] = model.$[key];
                                    list = model.$[key];
                                } else {
                                    list = newData[key] = contextForChildren.createCollection(schemaType, (value instanceof Object) && !(value instanceof Array) ? value : null);
                                    list.$parent = contextForChildren.$contextModel;
                                }
                                if (value && value instanceof Array) {
                                    list.reset(this.parseCollection(list, value, action, options));
                                }

                            }
                        } else if (schemaType === Date && value && !(value instanceof Date)) {
                            newData[key] = moment(value, this.$dataSource.$.dateFormat).toDate();
                        } else if (schemaType.classof(Entity)) {
                            var id;
                            if (value && schemaType instanceof TypeResolver) {
                                factory = schemaType.resolve(value, key);
                            } else {
                                factory = schemaType || Entity;
                            }

                            if (!(factory && factory.classof(Entity))) {
                                throw "Factory for type '" + key + "' isn't an instance of Entity";
                            }

                            if (factory.classof(Model) && factory.prototype.$isDependentObject) {
                                id = key;
                                value = value || {};
                            } else if (value) {
                                id = this._getIdForValue(value, factory);
                            }
                            if (value) {
                                newData[key] = entity = this.$dataSource._getContext(factory, model, value).createEntity(factory, id);
                                if (entity instanceof Entity && !(entity instanceof Model)) {
                                    entity.$parent = model;
                                    entity.$parentEntity = model;
                                }
                                entity.set(this._parseModel(entity, value, action, options));
                            }

                        }
                    }
                }

                // add all values that are not defined in schema ...
                _.defaults(newData, data);

                return model.parse(newData);
            }
1313459
void init() throws MpJwtProcessingException {
        String methodName = "init";
        if (tc.isDebugEnabled()) {
            Tr.entry(tc, methodName);
        }
        setUpJsseHelper();
        if (this.jsseHelper == null) {
            if (tc.isDebugEnabled()) {
                Tr.exit(tc, methodName);
            }
            return;
        }
        Properties sslProps = null;
        try {
            sslProps = getSslPropertiesFromJsseHelper();
        } catch (Exception e) {
            String msg = Tr.formatMessage(tc, "ERROR_LOADING_SSL_PROPS", new Object[] { e.getLocalizedMessage() });
            Tr.error(tc, msg);
            throw new MpJwtProcessingException(msg, e);
        }
        setKeystoreAndTruststoreNames(sslProps);
        if (tc.isDebugEnabled()) {
            Tr.exit(tc, methodName);
        }
    }
1074849
public function run() : void
    {
        $request = Request::getCurrent();
        $response = $this->handle($request);
        $response->send();
    }
603920
protected function initData()
    {
        if ($this->data !== null) {
            return;
        }

        if ($this->value !== null) {
            $this->data = $this->value;
            return;
        }

        if ($this->model instanceof Model) {
            $data = ($this->model->hasProperty($this->attribute) || isset($this->model->{$this->attribute}))
                ? ArrayHelper::getValue($this->model, $this->attribute, [])
                : [];

            if (!is_array($data) && empty($data)) {
                return;
            }

            if (!($data instanceof \Traversable)) {
                $data = (array) $data;
            }

            foreach ($data as $index => $value) {
                $this->data[$index] = $value;
            }
        }
    }
797224
function(api, modelDefinition) {
		this.parentAPI = api;
		this.childModels = [];

		this.initialized = false;

		this.model = modelDefinition.model;
		this.path = this.model.tableName.toLowerCase();
		this.modelRouter = Express.Router();
		this.primaryKey = Helpers.getPrimaryKey(this.model);

		/**
		 * Array of valid columns in the class minus the primary key
		 * However the primary key is only 'not valid' to be set if it is
		 * marked as auto-generated.
		 */
		this.validColumns = _.keys(this.model.rawAttributes);

		if(this.model.rawAttributes[this.primaryKey]._autoGenerated)
			this.validColumns.splice(this.validColumns.indexOf(this.primaryKey), 1);

		this._initializeOptions(modelDefinition);
		this._initializeAssociationOptions(modelDefinition);
		this._initializeRoutes(modelDefinition);

		this.filter = Helpers.mergeTriplicate({
			// If this is filled out, don't allow these parameters to be used.
			blacklist: [],

			// If this is filled out, ONLY allow these parameters to be used.
			whitelist: [],

			// Include these fields in output
			include: [],

			// Exclude these fields from output
			exclude: []
		}, this.model.filter || {}, modelDefinition.filter || {});
	}
1081592
def method_missing(sym, *args, &block)
      if (data && data[sym])
        data[sym]
      else
        super(sym, *args, &block)
      end
    end
1192085
function () {
            /*  determine parameters  */
            var params = $cs.params("value", arguments, {
                name:        { pos: 0, req: true,      valid: "string"   },
                value:       { pos: 1, def: undefined, valid: "any"      },
                force:       { pos: 2, def: false,     valid: "boolean"  },
                injected:    {         def: false,     valid: "boolean"  },
                op:          {         def: [],        valid: "(string|[string?]|[string,number,number])" },
                returnowner: {         def: false,     valid: "boolean"  }
            });

            /*  determine operation  */
            if (typeof params.op === "string")
                params.op = [ params.op ];
            if (params.op.length === 0)
                params.op = (_cs.isdefined(params.value) ? [ "set" ] : [ "get" ]);
            else if (!params.op[0].match(/^(?:get|set|splice|delete|push|pop|shift|unshift)$/))
                throw _cs.exception("value", "invalid operation \"" + params.op[0] + "\"");
            if (   params.op[0] === "splice"
                && (   params.op.length !== 3
                    || typeof params.op[1] !== "number"
                    || typeof params.op[2] !== "number"))
                throw _cs.exception("value", "invalid arguments for operation \"splice\"");

            /*  parse the value name into selection path segments  */
            var path = _cs.select_parse(params.name);

            /*  create new canonical name out of the parsed path segments  */
            var pathName = path.join(".");

            /*  determine component owning model with requested value  */
            var owner = null;
            var model = null;
            var comp  = this;
            while (comp !== null) {
                owner = comp.property({ name: "ComponentJS:model", returnowner: true });
                if (!_cs.isdefined(owner))
                    throw _cs.exception("value", "no model found containing value \"" + path[0] + "\"");
                model = owner.property("ComponentJS:model");
                if (_cs.isdefined(model.spec[path[0]]))
                    break;
                comp = owner.parent();
            }
            if (comp === null)
                throw _cs.exception("value", "no model found containing value \"" + path[0] + "\"");

            /*  get new model value  */
            var value_new = params.value;

            /*  translate special-case array operations to splice operation  */
            var obj;
            switch (params.op[0]) {
                case "unshift":
                    params.op = [ "splice", 0, 0 ];
                    break;
                case "shift":
                    params.op = [ "splice", 0, 1 ];
                    value_new = undefined;
                    break;
                case "push":
                    obj = $cs.select(model.data, path);
                    params.op = [ "splice", obj.length, 0 ];
                    break;
                case "pop":
                    obj = $cs.select(model.data, path);
                    params.op = [ "splice", obj.length - 1, 1 ];
                    value_new = undefined;
                    break;
            }

            /*  get old model value  */
            var ev;
            var result;
            var value_old = $cs.select(model.data, path);
            if (params.op[0] === "splice") {
                /*  splice operation is on collection itself,
                    so pick the target collection element!  */
                if (params.op[2] > 0)
                    value_old = $cs.select(value_old, "" + params.op[1]);
                else
                    value_old = undefined;
            }
            else if (params.op[0] === "get") {
                if (owner.property({ name: "ComponentJS:model:subscribers:get", def: 0, bubbling: false }) > 0) {
                    /*  send event to observers for value get and allow observers
                        to reject value get operation and/or change old value to get  */
                    ev = owner.publish({
                        name:      "ComponentJS:model:" + pathName + ":" + params.op[0],
                        args:      [ value_old, value_old, params.op, pathName ],
                        capturing: false,
                        spreading: false,
                        bubbling:  false,
                        async:     false
                    });
                    if (ev.processing()) {
                        /*  allow value to be overridden by event result  */
                        result = ev.result();
                        if (typeof result !== "undefined")
                            value_old = result;
                    }
                }
            }

            /*  optionally set/delete/splice new model value  */
            if (   (   params.op[0] === "set"
                    && (params.force || value_old !== value_new))
                || params.op[0] === "delete"
                || params.op[0] === "splice"                     ) {

                /*  check validity of new value  */
                if (   params.op[0] === "set"
                    || (   params.op[0] === "splice"
                        && value_new !== undefined  )) {
                    var subPath = (
                          params.op[0] === "splice"
                        ? path.slice(1).concat([ "0" ])
                        : path.slice(1)
                    );
                    if (!_cs.validate_at(value_new, model.spec[path[0]].valid, subPath))
                        throw _cs.exception("value", "model field \"" + params.name + "\" receives " +
                            "new value " + _cs.json(value_new) + ", which does not validate " +
                            "against \"" + model.spec[path[0]].valid + "\"" +
                            (subPath.length > 0 ? " at sub-path \"" + subPath.join(".") + "\"" : ""));
                }

                /*  send event to observers for value set/delete/splice operation
                    and allow observers to reject operation and/or change new value to set  */
                var cont = true;
                if (owner.property({ name: "ComponentJS:model:subscribers:" + params.op[0], def: 0, bubbling: false }) > 0) {
                    ev = owner.publish({
                        name:      "ComponentJS:model:" + pathName + ":" + params.op[0],
                        args:      [ value_new, value_old, params.op, pathName ],
                        capturing: false,
                        spreading: false,
                        bubbling:  false,
                        async:     false
                    });
                    if (!ev.processing()) {
                        if (params.injected)
                            throw _cs.exception("value", "model field \"" + params.name + "\" receives (again) " +
                                "value " + _cs.json(value_new) + ", which is rejected by observers, " +
                                "but the value was indicated to be already injected by third-parties " +
                                "(so it technically no longer can be rejected)");
                        cont = false;
                    }
                    else {
                        /*  allow value to be overridden  */
                        result = ev.result();
                        if (typeof result !== "undefined")
                            value_new = result;
                    }
                }
                if (cont && !model.spec[path[0]].autoreset) {
                    /*  perform destructive operation on model  */
                    if (params.op[0] === "set") {
                        /*  set value in model  */
                        $cs.select(model.data, path, value_new);
                    }
                    else if (params.op[0] === "splice") {
                        /*  splice value into model  */
                        obj = $cs.select(model.data, path);
                        if (!(obj instanceof Array))
                            throw new _cs.exception("value", "cannot splice: target object is not of Array type");
                        if (typeof value_new !== "undefined")
                            obj.splice(params.op[1], params.op[2], value_new);
                        else
                            obj.splice(params.op[1], params.op[2]);
                    }
                    else if (params.op[0] === "delete") {
                        /*  delete value from model  */
                        if (path.length < 2)
                            throw new _cs.exception("value", "cannot delete model root or top-level model entry");
                        obj = $cs.select(model.data, path.slice(0, path.length - 1));
                        var pathSegment = path[path.length - 1];
                        if (obj instanceof Array)
                            obj.splice(parseInt(pathSegment, 10), 1);
                        else if (typeof obj === "object")
                            delete obj[pathSegment];
                        else
                            throw new _cs.exception("value", "cannot delete: target object is neither Array nor Object type");
                    }

                    /*  synchronize model with underlying store  */
                    if (model.spec[path[0]].store) {
                        var store = owner.store("model");
                        store[path[0]] = model.data[path[0]];
                        owner.store("model", store);
                    }

                    /*  send event to observers after value finally changed  */
                    if (owner.property({ name: "ComponentJS:model:subscribers:changed", def: 0, bubbling: false }) > 0) {
                        owner.publish({
                            name:      "ComponentJS:model:" + pathName + ":changed",
                            args:      [ value_new, value_old, params.op, pathName ],
                            noresult:  true,
                            capturing: false,
                            spreading: false,
                            bubbling:  false,
                            async:     true
                        });
                    }
                }
            }

            /*  return old model value  */
            return (params.returnowner ? owner : value_old);
        }
1092438
function() {
      var self = this;
      // Start by removing all old bindings and falling back to the initialized binding contents
      this.bindings = _.extend({}, this._bindings);

      // Stickit model two-way bindings
      _.each(this.$('[data-model]'), function(element) {
        var attr = $(element).data('model'),
            options = self.__getFieldOptions(attr),
            fieldBinding = self.__generateModelFieldBinding(attr, options);

        //add select options
        if ($(element).is('select')) {
          fieldBinding.selectOptions = self.__generateSelectOptions(element, options);
        }

        self.bindings['[data-model="' + attr + '"]'] = fieldBinding;
      });
    }
1051012
function(view, model, options) {
      if (model.associatedViews) {
        model.associatedViews.push(view);
      } else {
        model.associatedViews = [view];
      }
      _.extend(model, mixin(view, options));
    }
714163
public function initialize()
    {
        $userMethods = $this->getCustomMethods();

        // Parse EntityMap for method based relationship
        if (count($userMethods) > 0) {
            $this->relationships = $this->parseMethodsForRelationship($userMethods);
        }

        // Parse EntityMap for dynamic relationships
        if (count($this->dynamicRelationships) > 0) {
            $this->relationships = $this->relationships + $this->getDynamicRelationships();
        }
    }
1178768
function View(primaryModel, relatedModels, attributes) {
  if (false === (this instanceof View)) throw new Error('new operator required');
  if (!(primaryModel instanceof Model)) throw new Error('argument must be a Model');
  if (typeof relatedModels != 'object') throw new Error('object expected');
  if (!(attributes instanceof Array)) throw new Error('array of attributes expected');
  this.primaryModel = primaryModel;
  this.relatedModels = relatedModels;
  this.attributes = attributes;
  var id = new Attribute('id', 'ID');
  id.model = primaryModel;
  this.attributes.unshift(id);

  /**
   * Make sure relatedModels valid
   */
  for (var relatedModel in relatedModels) {
    if (relatedModels.hasOwnProperty(relatedModel)) {
      var obj = relatedModels[relatedModel];
      //console.log('relatedModel ' + relatedModel);
      //console.log('obj ' + JSON.stringify(obj));
      if (typeof obj != 'object') throw new Error('relatedModel key values expect object');
      if (obj.id === undefined) throw new Error('relatedModel key values expect object with id key');
      if (obj.model === undefined) throw new Error('relatedModel key values expect object with model key');
      if (!(obj.id instanceof Attribute)) throw new Error('relatedModel id must be a Attribute');
      if (!(obj.model instanceof Model)) throw new Error('relatedModel model must be a Model');
    }
  }
  /**
   * Check attributes
   */
  for (var i = 0; i < attributes.length; i++) {
    var attribute = attributes[i];
    if (!(attribute instanceof Attribute)) throw new Error('attribute array must contain Attributes');
    if (!(attribute.model instanceof Model)) {
      throw new Error('attribute array must contain Attributes with model references');
    }

  }
}
508232
public function validate() {

		if ($this->getFieldName() === null) {
			throw new ValidationException("'fieldName' can't be null", 'fieldName', $this);
		}
		if ($this->getSorting() === null) {
			throw new ValidationException("'sorting' can't be null", 'sorting', $this);
		}
	}
228407
function initArgs () {
    // set default for where if not set
    this.args.where = requireValidOptionalObject(this.args.where)
    // do not allow arguments that should only be used internally
    this.assert(!defined(this.args.accessId), 'accessId not allowed')
    this.assert(!defined(this.args.accessIdName), 'accessIdName not allowed')
    // custom select columns are deprecated
    this.assert(!defined(this.args.select), 'select is deprecated')
    // if view is array with false value set to false
    if (Array.isArray(this.args.view) && this.args.view.length === 1 && this.args.view[0] === false) {
        this.args.view = false
    }
    // one is an alias for limit:1
    if (this.args.one) {
        // one cannot be set with limit
        this.assert(!defined(this.args.limit), 'one cannot be used with limit')
        // set limit:1
        this.args.limit = 1
        // delete one
        delete this.args.one
    }
    // normalize where args
    _.each(this.args.where, (options, property) => {
        // if there is only one operator then see if query can be simplified
        if (typeof options === 'object' && options && _.keys(options).length === 1) {
            // if operator is eq then replace object with direct query
            if (defined(options.eq)) {
                this.args.where[property] = options.eq
            }
            // if operator is in then replace object with direct query
            if (defined(options.in)) {
                this.args.where[property] = options.in
            }            
        }
    })
    // if model has d(eleted) column then default to isDeleted:false
    if (defined(this.model.columns.d) && !defined(this.args.where.isDeleted)) {
        this.args.where.isDeleted = false
    }
}
1156979
function (source) {
  if (false === (this instanceof List)) throw new Error('new operator required');
  if (source instanceof Model) {
    this.model = source;
  } else if (source instanceof View) {
    this.view = source;
    this.model = this.view.primaryModel;
  } else {
    throw new Error('argument required: model');
  }
  this.attributes = source.attributes;
  this._items = [];
  this._itemIndex = -1;
}