/*!
Sets up hooks for the new Model
@param InstanceModel
481341
function setupHooks (InstanceModel, config) {
  const ourHookedFnNames = ['save', 'remove', 'index']
  const schema = InstanceModel.schema
  const hooks = _.values(schema.hooks)

  _.forEach(hooks, ho => {
    let addHookFn = 'addDynamicHooks'
    if (!config.promisify) {
      addHookFn = 'addFlexibleHooks'
    }
    InstanceModel.prototype[addHookFn](ho.name)
    const mwopts = { passParams: true }
    _.forEach(ho.fns, (fn, index) => {
      if (ourHookedFnNames.indexOf(ho.name) >= 0) {
        const mwFn = fn
        if (ho.hook === 'post') {
          ho.fns[index] = function (next) {
            mwFn.apply(this)
            next()
          }
        }

        mwopts.passParams = false
      }
    })
    InstanceModel.prototype[ho.hook](ho.name, ho.fns, mwopts)
  })
}
256392
protected void init() {
        FormModel model = createFormModel();
        if(getId() == null)
            formId = model.getId();
        if (model instanceof ValidatingFormModel) {
            ValidatingFormModel validatingFormModel = (ValidatingFormModel) model;
            setFormModel(validatingFormModel);
        } else {
            throw new IllegalArgumentException("Unsupported form model implementation " + formModel);
        }
        getApplicationConfig().applicationObjectConfigurer().configure(this, getId());
	}
551143
def SetModel( self, model, adapter=None ):
        """"""
        self.model = model
        if adapter is not None:
            self.adapter = adapter
        self.UpdateDrawing()
776334
public void registerType(ModelElementType modelElementType, Class<? extends ModelElementInstance> instanceType) {
    QName qName = ModelUtil.getQName(modelElementType.getTypeNamespace(), modelElementType.getTypeName());
    typesByName.put(qName, modelElementType);
    typesByClass.put(instanceType, modelElementType);
  }
441942
public void setModel(Database databaseModel, DescriptorRepository objModel)
    {
        _dbModel       = databaseModel;
        _preparedModel = new PreparedModel(objModel, databaseModel);
    }
339101
function setModel(Model, modelName) {
    let authConfigs;
    if (!internals.acl) {
        throw new Error('Attempt to shield model before setting acl');
    }

    if (!internals.authConfig.length) {
        throw new Error('Attempt to shield model before seting configs');
    }

    // raise shield around Model
    new Shield(Model, internals.acl);
    authConfigs = getAuthConfigs(modelName);
    _.each(authConfigs, _.bind(Model.shield.addRules, Model.shield));
    internals.models[modelName] = Model;
}
84888
function initModel (args) {
    // if model is not passed then do nothing
    if (!args.model) {
        return
    }
    // if paths is false then do not create any default paths
    if (args.paths === false) {
        return
    }
    // require object to have ImmutableCoreObject class property
    assert.ok(args.model.ImmutableCoreModel, 'invalid model')
    // save model
    this.model = args.model
    // register controller with model
    this.model.controller = this
    // if model has data then create form for it
    if (this.model.schemaData && _.keys(this.model.schemaData.properties).length) {
        // build args for new form
        var formArgs = {
            action: './',
            method: 'POST',
            model: this.model,
            submit: {
                title: 'Create '+changeCase.titleCase(this.model.name),
            },
            title: 'New '+changeCase.titleCase(this.model.name),
        }
        // merge any args for form
        _.merge(formArgs, args.form)
        // create new form instance from model
        this.form = new ImmutableCoreModelForm(formArgs)
    }
    // create path entry if it does not exist
    if (!this.paths) {
        this.paths = {}
    }
    // create actions object
    this.actions = {}
    // merge actions from controller spec
    if (defined(args.actions)) {
        // do not allow array
        if (Array.isArray(args.actions)) {
            throw new Error(`actions array deprecated for controller ${this.model.name}`)
        }
        // get actions from controller spec
        _.merge(this.actions, args.actions)
    }
    // create list view controller
    this.initModelList(args)
    // new instance controller
    this.initModelNew(args)
    // create instance controller
    this.initModelCreate(args)
    // get instance controller
    this.initModelRead(args)
    // update instance controller
    this.initModelUpdate(args)
    // link model to relations controller
    this.initModelLink(args)
    // unlink model from relation controller
    this.initModelUnlink(args)
    // delete instance controller
    this.initModelDelete(args)
    // model schema controller
    this.initModelSchema(args)
    // validate data controller
    this.initModelValidate(args)
}
397649
protected function setup_instance() {
		switch ( $this->wp_type ) {
			case 'post':
				$wp_post = get_post( $this->get_id() );
				if ( ! is_null( $wp_post ) && get_post_type( $wp_post->ID ) === $this->object_type ) {
					$this->set_instance( $wp_post );
				}
				break;

			case 'term':
				$wp_term = get_term( $this->get_id(), $this->object_type );
				if ( ! is_null( $wp_term ) && ! is_wp_error( $wp_term ) ) {
					$this->set_instance( $wp_term );
				}
				break;
		}
	}
716772
public function add_model($class, $instance = null, $method = 'set_form_fields')
	{
		$this->fieldset->add_model($class, $instance, $method);

		return $this;
	}
762070
protected function initViewModel() {
        if($this->viewModel == null) {
            $this->viewModel = new ViewModel();
            $this->viewModel->setTerminal(true);
        }
    }
246460
public void register(T instance) {
		if(!isContained(instance)) {
			registry.add(instance);
			if(current == null) {
				current = instance;
			}
		}
	}
248408
public void setModel(TableModel model)
    {
// Column 3 and 4: (Scroll Pane Headings)
        if (m_model != null)
            m_model.removeTableModelListener(this);
        m_model = model;
        if (model != null)
            model.addTableModelListener(this);
        this.setupPanel();      // setup a new panel
    }
19203
@Override
    public void initializeInstance(PopulationModel populationModel) {
        super.initializeInstance(populationModel);
        parentSelection.initializeInstance(populationModel.getPopulation());
    }
1054219
@Override
    public boolean add(ClientPresentationModel model) {
        boolean success = super.add(model);
        if (success) {
            List<ClientAttribute> attributes = model.getAttributes();
            for (ClientAttribute attribute : attributes) {
                attribute.addPropertyChangeListener(attributeChangeListener);
            }
            if (!model.isClientSideOnly()) {
                getClientConnector().send(CreatePresentationModelCommand.makeFrom(model));
            }
        }
        return success;
    }
66477
function bindModel(proc, model) {
  const actualModel = model || {};
  proc.model = actualModel;
  proc.logic.model = actualModel;

  if (!actualModel.__proc) {
    Object.defineProperty(actualModel, '__proc', {
      value: proc,
      enumerable: false,
      configurable: true
    });
  }
}
866671
void updateInstance(T instance) {
        T oldInstance = this.instance.getAndSet(Preconditions.checkNotNull(instance, "instance"));
        if (oldInstance != null && oldInstance != instance) {
            oldInstance.close();
        }
    }
951071
function(model, options) {
    options = options ? _.clone(options) : {};
    if (!(model = this._prepareModel(model, options))) return false;
    if (!options.wait) this.add(model, options);
    return this._callAdapter('addToIndex', options, model);
  }