Creates a model type
@class
@param {string} name - name of the model
@param {string} prefix - file name prefix associated with the model
5056
function ModelType(name, prefix, endp) {
  this.name = name;
  this.prefix = prefix;
  this.endp = endp;
}
587254
function Model(namespace) {
    var self = this;
    this.i = 0;
    var local = {
        modelPath: null,
        entitiesPath: null,
        connection: null,
        files: {},
        toReload: [],
        trying: 0
    };

    var _configuration = null;
    var _connector = null;

    var cacheless = (process.env.IS_CACHELESS == 'false') ? false : true;
    var standalone = config.Host.isStandalone();


    var setup = function(namespace) {
        if ( typeof(namespace) == 'undefined' || namespace == '') {
            console.error('gina', 'MODEL:ERR:1', 'EEMPTY: Model namespace', __stack);
        }

        var model, namespace = namespace.split(/\//g);
        _connector = namespace[1];//Has to be writtien the same for the connetors.json decalration or for the model folder
        var bundle = namespace[0];
        namespace.shift();
        //Capitalize - Normalize
        if (namespace.length > 1) {
            //            for (var i; i<namespace.length; ++i) {
            //                namespace[i] = namespace[i].substring(0, 1).toUpperCase() + namespace[i].substring(1);
            //            }

            model = namespace.join(".");
        } else {
            //Dir name.
            model = namespace[0];
        }


        console.debug("\nBundle: ", bundle);
        console.debug("Model: ", model);
        self.name       = _connector;
        self.bundle     = bundle;
        self.model      = model;
        self.modelDirName = model;
        var modelConnectors = getContext('modelConnectors');
        if (modelConnectors) {
            self.connectors = getContext('modelConnectors')[self.name];
            self.database = self.connectors.database;
        } else {
            self.connectors = {};
        }

    }

    /**
     * Init
     *
     * @param {string} namesapce
     *
     * @private
     * */
    var init = function(reload) {

        var bundle          = self.bundle;
        var model           = self.model;
        var modelDirName    = self.modelDirName;

        // this is supposed to happen on load or for dev env; on reload, with a checksum
        var conf        = getConfigSync(bundle);
        local.locals    = conf.locals;

        if (conf) {
            _configuration = conf.connectors;

            console.debug("CONF READY ", model, conf.path);
            //TODO - More controls...

            //For now, I just need the F..ing entity name.
            var modelPath       = local.modelPath = _(conf.path + '/' + modelDirName);
            var entitiesPath    = local.entitiesPath = _(modelPath + '/entities');
            console.debug('models scaning... ', entitiesPath, fs.existsSync(entitiesPath));
            if (!fs.existsSync(entitiesPath)) {
                fs.mkdirSync(entitiesPath) // creating empty path
            }

            var connectorPath   = _(modelPath + '/lib/connector.js');
            //Getting Entities Manager.
            var exists = fs.existsSync(connectorPath);
            if (exists) {
                if (cacheless)
                    delete require.cache[_(connectorPath, true)];

                var Connector = require(_(connectorPath, true));

                self.connect(
                    Connector,
                    function onConnect(err, conn) {
                        if (err) {
                            console.error(err.stack);
                            self.emit('model#ready', err, self.bundle, self.name, null)

                        } else {
                            local.connection = conn;
                            self.emit('model#ready', false, self.bundle, self.name, conn)
                        }
                    }
                )
            } else {//Means that no connector was found in models.

                //finished.
                self.emit('model#ready', new Error('[ '+self.name+' ] No connector found'), self.bundle, self.name, conn)
            }

        } else {
            console.debug("no configuration found...");
            self.emit('model#ready', new Error('no configuration found for your model: ' + model), self.bundle, self.name, null)
        }

        return self
    }


    this.connect = function(Connector, callback) {
        if ( typeof(self.connectors[_connector]) == 'undefined' ) {
            self.connectors[_connector] = {};
            var connector = new Connector( self.getConfig(_connector) );

            connector.onReady( function(err, conn){
                self.connectors[_connector].err = err;
                self.connectors[_connector].conn = conn;

                callback(err, conn);
            });

        } else {
            callback(self.connectors[_connector].err, self.connectors[_connector].conn);
        }
    }

    this.reload = function(conf, cb) {
        setup(namespace);
        init(cb)
    }

    /**
     * Get Model configuration
     *
     * @param {string} bundle
     *
     * @callback callback
     * @param {boolean|string} err - Error Status response
     * @param {object} conf - Configuration response
     *
     * @private
     * */
    var getConfigSync = function(bundle, i) {
        var i = i || 0;
        var configuration = config.getInstance(bundle);

        try {

            var locals = _locals = utilsConfig.getSync('gina', 'locals.json')
        } catch (err) {
            console.emerg('Error while calling `Model::getConfigSync()` '+ err.stack||err.message);
            if ( i < 10) {
                console.debug('about to retry to load locals.json');
                setTimeout(function(){

                    i = i+1;
                    console.debug('retry ('+i+') ...');
                    return getConfigSync(bundle, i)
                }, 300)

            } else {
                throw new Error('Config could not be loaded');
                process.exit(1)
            }
            return false
        }

        if ( typeof(configuration) != 'undefined' && locals) {

            var env = configuration.Env.current;
            var conf = configuration.Env.getConf(bundle, env);

            // configuration object.
            var confObj = {
                connectors  : conf.content.connectors,
                path        : conf.modelsPath,
                locals      : locals
            };

            return confObj
        } else {
            throw new Error('Config not instantiated');
            return undefined
        }
    }

    /**
     * Get Model Configuration
     *
     * @return {object|undefined} configuration
     * */
    this.getConfig = function(connector){
        var connector = ( typeof(connector) == 'undefined' ) ?  _connector : connector;

        if (_configuration) {
            return ( typeof(connector) != 'undefined' ) ? _configuration[connector] : undefined
        } else {
            return undefined
        }
    }


    this.onReady = function(callback) {
        self.once('model#ready', function(err, bundle, model, conn) {
            // entities == null when the database server has not started.
            if ( err ) {
                console.error(err.stack||err.message)
                //console.log('No entities found for [ '+ self.name +':'+ entityName +'].\n 1) Check if the database is started.\n2) Check if exists: /models/entities/'+ entityName);
            }
            callback(err, bundle, model, conn)
        });
        setup(namespace);
        return init()
    };

    return this
}
536125
function Model(attributes, options) {
  var _attributes = attributes || {};
  options = options || {};
  this.attributes = Object.create(null);
  this.set(_attributes, options);
  this.initialize.apply(this, arguments);
}
178587
function create (name, level) {
  name = name || 'karma'
  let logger
  if (loggerCache.hasOwnProperty(name)) {
    logger = loggerCache[name]
  } else {
    logger = log4js.getLogger(name)
    loggerCache[name] = logger
  }
  if (helper.isDefined(level)) {
    logger.setLevel(level)
  }
  return logger
}
40089
function(name, graphType){
    Flotr.graphTypes[name] = graphType;
    Flotr.defaultOptions[name] = graphType.options || {};
    Flotr.defaultOptions.defaultType = Flotr.defaultOptions.defaultType || name;
  }
1311200
function ModelClassFactory(name, options) {
        if (!isUndef(options)) {
          return config(name, options);
        }
        return registry[name] || undefined;
      }
17654
def created_model(name)
      factory, name_or_index = *parse_model(name)

      if name_or_index.blank?
        models_by_index(factory).last
      elsif name_or_index.is_a?(Integer)
        models_by_index(factory)[name_or_index]
      else
        models_by_name(factory)[name_or_index] or raise ModelNotKnownError, name
      end
    end
324048
public function AddAttribute( $prefix, $name, $parentType = "xs:anySimpleType" )
	{
		$attribute = array();

		$parts = explode( ":", $parentType );
		$parentLocalName = count( $parts ) == 1 ? $parts[0] : $parts[1];
		// BMS 2018-04-09 Fixing the kluge
		$parentPrefix = count( $parts ) == 1 ? SCHEMA_PREFIX : $parts[0];

		$type = $this->getType( $parentLocalName, $parentPrefix );
		if ( ! $type )
		{
			return false;
		}

		$attribute['types'][] = $type;

		$attribute += array(
			'name' => $name,
			'prefix' => $prefix,
			'use' => "optional",
			'class' => 'attribute',
		);

		$this->attributes[ "$prefix:$name"] = $attribute;

		return $this->attributes[ "$prefix:$name"];
	}
1065480
function createElasticsearch (args, model) {
    // get client - throw error if not set
    var elasticsearchClient = model.elasticsearch()
    // document to store in elastic search
    var body
    // use raw data to build body
    if (args.raw) {
        body = elasticSearchBodyFromRaw(model, args.raw)
    }
    // use record to build body
    else if (args.record) {
        body = elasticSearchBodyFromRecord(model, args.record)
    }
    else {
        // ignore errors
        return
    }
    // get id from originalId or id
    var id = body.originalId || body.id
    // if instance does not have id cannot store
    if (!id) {
        // ignore errors
        return
    }
    // get record type
    var type = model.esType
        ? _.get(body.data, model.esType) || model.name
        : model.name
    // if record is deleted then delete from elasticsearch
    if (body.isDeleted) {
        return elasticsearchClient.delete({
            id: id,
            index: model.esIndex,
            type: type,
        })
        // ignore error
        .catch(console.error)
    }
    // otherwise create/update record with elasticsearch
    else {
        return elasticsearchClient.index({
            body: body,
            id: id,
            index: model.esIndex,
            type: type,
        })
        // ignore error
        .catch(console.error)
    }
}
47699
function(name, config) {
            config = config || {};
            config = _.defaults(config, {
                loader: configs.resources.loader
            });
            config = _.extend(config, {
                namespace: name
            });
            Resources.namespaces[name] = config;
        }
469381
function SchemaTypeWrapper(type) {
  var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];


  return new SchemaType(type, options);
}
635526
function SuiteModel (name) {
  this.className = 'js.' + name
  this.scenarios = []
  this.tagMap = {}
  this.tagMap.JS = new TagModel('JS')

  log('Creating new model ' + this.className)
}
970016
function initModels(seqObj, modelFiles, models, tablePrefix) {
    modelFiles.forEach((item) => {
      var modelFn;
      try {
        modelFn = require(item.fullPath);
      } catch (e) {
        console.error('Thorin.sql: could not require model: ' + item.fullPath + '\n', e.stack);
        return;
      }
      if (modelFn == null) return;  // we skip it
      if (typeof modelFn !== 'function') {
        console.error(thorin.error('SQL.INVALID_MODEL', 'SQL Model: ' + item.fullPath + ' must export a function(modelObj){}'));
        return;
      }
      if (modelFn.name === 'extend') {
        if (typeof extendModels[item.code] === 'undefined') extendModels[item.code] = [];
        extendModels[item.code].push(modelFn);
        return;
      }
      let modelObj = loader.buildModel(seqObj, modelFn, item, tablePrefix);
      if (modelObj) {
        if (typeof models[modelObj.code] !== 'undefined') {
          console.error(thorin.error('SQL.ADD_MODEL', 'SQL Store: model ' + modelObj.code + ' was already declared.'));
          return;
        }
        models[modelObj.code] = modelObj;
      }
    });
  }
582367
function create({values, name, root} = {}) {
  const envName = _getFileName(name);
  const envPath = path.resolve(
    root || config.get('env.rootDirectory'),
    envName,
  );
  const envContents = _getFileContents(values);

  fs.writeFileSync(envPath, envContents);
}
851831
function typeCreateHandler(docObject, newScope) {
		
		docObject && addDocObjectToDocMap(docObject, docMap, filename, comment && comment.line);
		if (newScope) {
			scope = newScope;
		}
	}
256912
function createModel (namespace) {
  const model = (namespace) ? { namespace: namespace } : {}
  model.models = {}
  model.reducers = {}
  model.effects = {}
  model.subscriptions = {}
  model.state = {}

  return {
    start: function () {
      return model
    },
    state: function (value) {
      mutate(model.state, value)
    },
    reducer: function (key, value) {
      model.reducers[key] = value
    },
    subscription: function (key, value) {
      model.subscriptions[key] = value
    },
    effect: function (key, value) {
      model.effects[key] = value
    }
  }
}
583138
function generateNames(model, prefix, name) {
    if (name === void 0) { name = ""; }
    model.fullPackageName = prefix + (name != "." ? name : "");
    // Copies the settings (I'm lazy)
    model.properties = argv.properties;
    model.explicitRequired = argv.explicitRequired;
    model.camelCaseProperties = argv.camelCaseProperties;
    model.camelCaseGetSet = argv.camelCaseGetSet;
    model.underscoreGetSet = argv.underscoreGetSet;
    model.generateBuilders = argv.generateBuilders;
    var newDefinitions = {};
    // Generate names for messages
    // Recursive call for all messages
    var key;
    for (key in model.messages) {
        var message = model.messages[key];
        newDefinitions[message.name] = "Builder";
        generateNames(message, model.fullPackageName, "." + (model.name ? model.name : ""));
    }
    // Generate names for enums
    for (key in model.enums) {
        var currentEnum = model.enums[key];
        newDefinitions[currentEnum.name] = "";
        currentEnum.fullPackageName = model.fullPackageName + (model.name ? "." + model.name : "");
    }
    // For fields of types which are defined in the same message,
    // update the field type in consequence
    for (key in model.fields) {
        var field = model.fields[key];
        if (typeof newDefinitions[field.type] !== "undefined") {
            field.type = model.name + "." + field.type;
        }
    }
    model.oneofsArray = [];
    for (key in model.oneofs) {
        var oneof = model.oneofs[key];
        model.oneofsArray.push({ name: key, value: oneof });
    }
    // Add the new definitions in the model for generate builders
    var definitions = [];
    for (key in newDefinitions) {
        definitions.push({ name: key, type: ((model.name ? (model.name + ".") : "") + key) + newDefinitions[key] });
    }
    model.definitions = definitions;
}