UMLModelElement

@constructor
@extends ExtensibleModel
@mixes UMLElementMixin
337580
function UMLModelElement() {
        type.ExtensibleModel.apply(this, arguments);

        /** @member {UMLStereotype} */
        this.stereotype = null;

        /** @member {string} */
        this.visibility = VK_PUBLIC;

        /** @member {Array.<UMLTemplateParameter>} */
        this.templateParameters = [];

        // mixin UMLElementMixin
        _.extend(UMLModelElement.prototype, UMLElementMixin);
    }
774769
function modelExport(m) {
  const result = _.mapValues(m.classes, _.head)
  result[m.__name] = m
  return result
}
610043
function UMLConnector() {
        UMLUndirectedRelationship.apply(this, arguments);

        /** @member {UMLConnectorEnd} */
        this.end1 = new UMLConnectorEnd();
        this.end1._parent = this;

        /** @member {UMLConnectorEnd} */
        this.end2 = new UMLConnectorEnd();
        this.end2._parent = this;

        /** @member {UMLAssociation} */
        this.type = null;

        /** @member {UMLConnectorKind} */
        this.kind = CK_ASSEMBLY;
    }
1069885
function UMLClassView() {
        UMLClassifierView.apply(this, arguments);
        this.fillColor  = PreferenceManager.get("uml.class.fillColor", "#ffffff") || PreferenceManager.get("view.fillColor", "#ffffff");
        this.stereotypeDisplay  = PreferenceManager.get("uml.class.stereotypeDisplay", UML.SD_LABEL);
        this.suppressAttributes = PreferenceManager.get("uml.class.suppressAttributes", false);
        this.suppressOperations = PreferenceManager.get("uml.class.suppressOperations", false);
    }
404943
function UMLObjectView() {
        UMLGeneralNodeView.apply(this, arguments);
        this.containerChangeable = true;

        /** @member {UMLSlotCompartmentView} */
        this.slotCompartment = new UMLSlotCompartmentView();
        this.slotCompartment.selectable = Core.SK_PROPAGATE;
        this.slotCompartment.parentStyle = true;
        this.addSubView(this.slotCompartment);

        this.fillColor = PreferenceManager.get("uml.object.fillColor", "#ffffff") || PreferenceManager.get("view.fillColor", "#ffffff");
    }
1064258
@Override public SVDModel createImpl() {
    SVDModel.SVDParameters parms = parameters.createImpl();
    return new SVDModel( model_id.key(), parms, null );
  }
205003
function objectExtendDeep(extended) {
  var currentObject;
  var currentType;
  var extendedType;
  var currentItem;
  var currentTypeInner;

  for (var i = 1, c = arguments.length; i < c; i++) {
    currentObject = arguments[i];
    if (!currentObject)
      continue;
    currentType = type(currentObject);
    extendedType = type(extended);
    // type mismatch
    if (currentType !== extendedType) {
      if (currentType === 'array') {
        extended = [];
      } else if (currentType === 'object' && extendedType !== 'function') {
        extended = {};
      }
      // else copy, primitive, date, regexp, function ...
    }
    // extend arrays
    if (currentType === 'array') {
      extended = extended.concat(currentObject);
    } else {
      // or objects ;)
      for (var key in currentObject) {
        if (ownProperty.call(currentObject, key)) {
          currentTypeInner = type(currentObject[key]);
          currentItem = currentObject[key];
          if (/^(object|array)$/.test(currentTypeInner)) {
            extended[key] = objectExtendDeep(extended[key], currentItem);
          } else if (currentTypeInner === 'date') {
            extended[key] = new Date(currentItem.getTime());
          } else if (currentTypeInner === 'regexp') {
            extended[key] = cloneRegExp(currentItem);
          } else {
            extended[key] = currentItem;
          }
        }
      }
    }
  }
  return extended;
}
240750
function(newModel) {
      var t = this;
      if (newModel) {
        t.model = newModel;
      }
      t.json = t.isBackbone ? t.model.toJSON() : t.model;

      // If a non-object, just print it
      if (typeof t.json !== 'object') {
        t.$el.html('');
        $(t.template.line({name:'value', value:t.json})).appendTo(t.$el);
        return;
      }

      // Re-render if the object elements differ
      var newKeys = _.keys(t.json);
      if (newKeys.length !== t.keys.length || newKeys.length !== _.intersection(t.keys, newKeys).length) {
        return t.render();
      }
      t.keys = newKeys;

      // Set each element
      for (var elemName in t.json) {
        var elem = t.elems[elemName];
        elem.value = t.getElemValue(elemName);
        t.setElemValue(elem);
      }
      return t;
    }
332746
function ModelUtil() {
    var self        = this;
    var cacheless   = (process.env.IS_CACHELESS == 'false') ? false : true;

    /**
     * Init
     * @contructor
     * */
    var init = function() {

        if ( !ModelUtil.instance && !getContext('modelUtil') ) {
            self.models             = self.models || {}; // used when getModel(modelName) is called
            self.entities           = {};
            self.entitiesCollection = {}; // used when getEntity(entityName) is called - handles entity relations
            self.files              = {};
            ModelUtil.instance      = self;

            setContext('modelUtil', ModelUtil.instance);

            return self
        } else {
            //if (!ModelUtil.instance) {
            //    ModelUtil.instance = getContext('modelUtil')
            //}
            //self = ModelUtil.instance;
            //ModelUtil.instance = getContext('modelUtil');
            //ModelUtil.instance = ModelUtil.instance || getContext('modelUtil');
            //self = merge(self, ModelUtil.instance, true);
            // return self
            return ModelUtil.instance || getContext('modelUtil')
        }
    }

    this.setConnection = function(bundle, name, conn) {
        if (arguments.length > 1) {
            if (!self.models) {
                self.models = {}
            }
            if (!self.entitiesCollection) {
                self.entitiesCollection = {}
            }
            if (!self.models[bundle]) {
                self.models[bundle] = {}
            }
            if (!self.entitiesCollection[bundle]) {
                self.entitiesCollection[bundle] = {}
            }
            if ( typeof(name) == 'undefined' || name == '' ) {
                throw new Error('Connection must have a name !')
            }

            if (typeof(self.models[bundle][name]) == 'undefined') {
                self.models[bundle][name] = {};
                if (!self.files[bundle]) {
                    self.files[bundle] = {}
                }
                self.files[bundle][name] = {}
            }

            if (typeof(self.entitiesCollection[bundle][name]) == 'undefined') {
                self.entitiesCollection[bundle][name] = {};
            }


            self.models[bundle][name]['_connection'] = conn;
            self.entitiesCollection[bundle][name]['_connection'] = conn;
        } else {
            self.models[bundle] = {};
            self.entitiesCollection[bundle] = {}
        }

        //setContext('modelUtil.entitiesCollection', self.entitiesCollection, true)
        ModelUtil.instance.entitiesCollection = self.entitiesCollection;
    }

    /**
    *
    * @param {string} name - Entity name
    * @param {object} module
    *
    * */
    this.setModelEntity = function(bundle, model, name, module) {
        var cacheless   = (process.env.IS_CACHELESS == 'false') ? false : true;
        
        if (arguments.length > 1) {
            if (!self.entities) {
                self.entities = {}
            }

            if (!self.entities[bundle]) {
                self.entities[bundle] = {}
            }

            if ( typeof(name) == 'undefined' || name == '' ) {
                throw new Error('`modelUtil cannot set `modelEntity whitout a name !')
            }

            if( !self.entities[bundle][model] ) {
                self.entities[bundle][model] = {}
            }

            if ( !/Entity$/.test(name) ) {
                name = name + 'Entity'
            }
            self.entities[bundle][model][name] = module

        } else {
            self.entities[bundle][model] = arguments[0]
        }

        setContext('modelUtil.entities', self.entities, true);
        ModelUtil.instance.entities = self.entities;
    }

    this.updateModel = function(bundle, model, name, entityObject) {

        if ( typeof(model) == 'undefined' || model == '' ) {
            throw new Error('`modelUtil` cannot update `entityObject` whitout a connector !')
        }

        if ( typeof(name) == 'undefined' || name == '' ) {
            throw new Error('`modelUtil` cannot set `modelEntity` whitout a name !')
        }

        if (!self.models[bundle][model][name]) {
            self.models[bundle][model][name] = {}
        }

        self.models[bundle][model][name] =  entityObject;


        ModelUtil.instance.models = self.models;
        setContext('modelUtil.models', self.models, true);

        return self.models[bundle][model][name]
    }

    this.updateEntities = function(bundle, model, name, entityObject) {

        if ( typeof(model) == 'undefined' || model == '' ) {
            throw new Error('`modelUtil` cannot update `entityObject` whitout a connector !')
        }

        if ( typeof(name) == 'undefined' || name == '' ) {
            throw new Error('`modelUtil` cannot set `modelEntity` whitout a name !')
        }

        if (!self.entitiesCollection[bundle][model][name]) {
            self.entitiesCollection[bundle][model][name] = {}
        }

        self.entitiesCollection[bundle][model][name] =  entityObject;

        return self.entitiesCollection[bundle][model][name]
    }

    this.setModel = function(bundle, name, obj) {
        if (arguments.length > 2) {
            if ( typeof(name) == 'undefined' || name == '' ) {
                var name = 'global'
            }

            if (!self.models[bundle]) {
                self.models[bundle] = {}
            }
            if (!self.entitiesCollection[bundle]) {
                self.entitiesCollection[bundle] = {}
            }
            //entitiesCollection

            if (!self.models[bundle][name]) {
                self.models[bundle][name] = {}
            }
            if (!self.entitiesCollection[bundle][name]) {
                self.entitiesCollection[bundle][name] = {}
            }

            self.models[bundle][name] = merge(self.models[bundle][name], obj);
            self.entitiesCollection[bundle][name] = merge(self.entitiesCollection[bundle][name], obj)

        } else {
            self.models[bundle][name] = {};
            self.entitiesCollection[bundle][name] = {}
        }
    }


    this.loadAllModels = function(bundles, configuration, env, cb) {

        var loadModel = function(b, bundles, configuration, env, cb) {
            var modelObject     = getContext('modelUtil').entities[bundles[b]] // to check if already laoded
                , bundle        = bundles[b]
                , len           = bundles.length
                , conf          = configuration[bundle][env]
                , connectors    = conf.content['connectors'] || undefined
                , modelConnectors  = {};


            if ( typeof(connectors) != 'undefined' && connectors != null) {
                var Model = require( _( getPath('gina').core + '/model') );
                var mObj = {};

                var models = connectors;

                var t = 0;

                var done = function(connector, modelConnectors) {
                    if ( typeof(models[connector]) != 'undefined' ) {
                        ++t
                    } else {
                        console.error('connector '+ connector +' not found in configuration')
                    }

                    if ( t == models.count() ) {
                        setContext('modelConnectors', modelConnectors);

                        var conn                = null
                            , entitiesManager   = null
                            , modelPath         = null
                            , entitiesPath      = null
                            , entitiesObject    = null
                            , foundInitError    = false;

                        // end - now, loading entities for each `loaded` model
                        for (var bundle in self.models) {

                            for (var name in self.models[bundle]) {//name as connector name
                                conn            = self.models[bundle][name]['_connection'];
                                modelPath       = _(conf.modelsPath + '/' + name);
                                entitiesPath    = _(modelPath + '/entities');
                                //Getting Entities Manager thru connector.
                                entitiesManager = new require( _(conf.modelsPath + '/index.js', true) )(conn)[name](conn, { model: name, bundle: bundle, database: conf.content['connectors'][name].database });

                                self.setConnection(bundle, name, conn);

                                // step 1: creating entities classes in the context
                                // must be done only when all models conn are alive because of `cross models/database use cases`
                                for (var nttClass in entitiesManager) {
                                    if ( !/^[A-Z]/.test( nttClass ) ) {
                                        throw new Error('Entity Class `'+ nttClass +'` should start with an uppercase !');
                                        foundInitError = true
                                    }
                                    self.setModelEntity(bundle, name, nttClass, entitiesManager[nttClass])
                                }

                                // step 2: creating entities instances
                                for (var nttClass in entitiesManager) {
                                    new entitiesManager[nttClass](conn);
                                }

                            }
                        }

                        setContext('modelUtil', ModelUtil.instance, true);
                        if (foundInitError) process.exit(1);


                        cb()
                    }
                }

                for (var c in models) {//c as connector name
                    if ( modelObject && typeof(modelObject[c]) != 'undefined' ) {
                        done(connector, modelConnectors)
                    } else {
                        //e.g. var apiModel    = new Model(config.bundle + "/api");
                        // => var apiModel = getContext('apiModel')
                        console.debug('....model ', conf.bundle + "/"+c + 'Model');
                        mObj[c+'Model'] = new Model(conf.bundle + "/" + c);
                        mObj[c+'Model']
                            .onReady(
                            function onModelReady( err, bundle, connector, conn) {
                                if (err) {
                                    console.error('found error ...');
                                    console.error(err.stack||err.message||err);
                                } else {

                                    if (!modelConnectors[bundle]) {
                                        modelConnectors[bundle] = {}
                                    }
                                    if (!modelConnectors[bundle][connector]) {
                                        modelConnectors[bundle][connector] = {
                                            conn: conn
                                        }
                                    }

                                    if ( typeof(self.models[bundle]) == 'undefined') {
                                        self.models[bundle] = {}
                                    }

                                    if ( typeof(self.models[bundle][connector]) == 'undefined') {
                                        self.models[bundle][connector] = {}
                                    }

                                    if ( typeof(self.models[bundle][connector]['_connection']) == 'undefined' ) {
                                        self.models[bundle][connector]['_connection'] = conn
                                    }

                                    if ( typeof(self.models[bundle][connector]['getConnection']) == 'undefined' ) {// only used when tryin to import multiple models into the same entity
                                        self.models[bundle][connector]['getConnection'] = function() {
                                            return self.models[bundle][connector]['_connection']
                                        }
                                    }
                                }

                                done(connector, modelConnectors)
                            })
                   }

                }


            } else {
                //throw new Error('no connector found for bundle [ '+ bundle +' ]');
                // this is normal if there is no connector.json found in the source
                if (b < bundles.length-1) {
                    loadModel(b+1, bundles, configuration, env, cb)
                } else {
                    cb()
                }

            }
        };

        loadModel(0, bundles, configuration, env, cb)
    }


    /**
     * Reload modes
     * cacheless mode only
     *
     * @param {obj} conf
     * @callback cb
     * */
    this.reloadModels = function(conf, cb) {

        if ( typeof(conf.content['connectors']) != 'undefined' && conf.content['connectors'] != null ) {

            var models              = conf.content.connectors
                , conn              = null
                , foundInitError    = false
                , entitiesManager   = null
                , modelPath         = null
                , entitiesPath      = null
                , modelConnectors   = null;


            // end - now, loading entities for each `loaded` model
            for (var bundle in self.models) {

                for (var name in self.models[bundle]) { //name as connector name
                    
                    self.models[bundle][name] = {};

                    if ( typeof(self.models[bundle][name]['_connection']) == 'undefined' ) {
                        self.models[bundle][name]['_connection'] = getContext('modelConnectors')[bundle][name].conn
                    }

                    if ( typeof(self.models[bundle][name]['getConnection']) == 'undefined' ) {// only used when tryin to import multiple models into the same entity
                        self.models[bundle][name]['getConnection'] = function() {
                            return self.models[bundle][name]['_connection']
                        }
                    }

                    conn            = getContext('modelConnectors')[bundle][name].conn;

                    modelPath       = _(conf.modelsPath + '/' + name);
                    entitiesPath    = _(modelPath + '/entities');

                    //Getting Entities Manager thru connector.
                    delete require.cache[_(conf.modelsPath + '/index.js', true)];//child
                    try {
                        entitiesManager = new require( _(conf.modelsPath + '/index.js', true) )(conn)[name](conn, { model: name, bundle: bundle, database: conf.content['connectors'][name].database });
                    } catch (err) {
                        cb(err)
                    }

                    self.setConnection(bundle, name, conn);
                    // creating entities instances
                    // must be done only when all models conn are alive because of `cross models/database use cases`
                    for (var nttClass in entitiesManager) {
                        if ( !/^[A-Z]/.test( nttClass ) ) {
                            throw new Error('Entity Class `'+ nttClass +'` should start with an uppercase ?');
                            foundInitError = true
                        }
                        self.setModelEntity(bundle, name, nttClass, entitiesManager[nttClass])
                    }

                    for (var nttClass in entitiesManager) {
                        // will force updates on self.models
                        new entitiesManager[nttClass](conn);
                    }

                    console.log('loaded model ', bundle+'/'+name);
                }
            }


            setContext('modelUtil', self, true);
            ModelUtil.instance = self;

            cb(false)

        } else {
            cb(new Error('[ '+ conf.bundle+' ] no connector found !'))
        }
    }


    /**
     * Get Model by [ bundleName ] & modelName
     *
     * @param {string} [ bundle ] - Bundle name
     * @param {string} model - Model name
     *
     * @return {object} model - Model entities
     * */
    getModel = function(bundle, model) {

        var ctx       = getContext();

        if (arguments.length == 1 || !bundle) {
            //console.debug(
            //    '\n[ 0 ] = '+ __stack[0].getFileName(),
            //    '\n[ 1 ] = '+ __stack[1].getFileName(),
            //    '\n[ 2 ] = '+ __stack[2].getFileName(),
            //    '\n[ 3 ] = '+ __stack[3].getFileName(),
            //    '\n[ 4 ] = '+ __stack[4].getFileName(),
            //    '\n[ 5 ] = '+ __stack[5].getFileName(),
            //    '\n[ 6 ] = '+ __stack[6].getFileName()
            //);


            // var model       = (arguments.length == 1) ? bundle : model
            //     , file      = ( !/node_modules/.test(__stack[1].getFileName()) ) ?  __stack[1].getFileName() : __stack[2].getFileName()
            //     , a         = file.replace('.js', '').split('/')
            //     , i         = a.length-1
            //     , bundle    = null;
            //
            // var conf        = getContext('gina').config || null;
            // if (conf) {
            //     var bundles     = conf.bundles
            //         , index     = 0;
            //
            //     for (; i >= 0; --i) {
            //         index = bundles.indexOf(a[i]);
            //         if ( index > -1 ) {
            //             bundle = bundles[index];
            //             break
            //         }
            //     }
            // } else {
            //     conf    = getContext();
            //     bundle  = conf.bundle;
            // }




            var model         = (arguments.length == 1) ? bundle : model
                , bundle    = null
                , modelPath   = null
                , file      = null
                , stackFileName = null;
            //, file      = ( !/node_modules/.test(__stack[1].getFileName()) ) ?  __stack[1].getFileName() : __stack[2].getFileName()
            for (var i = 1, len = 10; i<len; ++i) {
                stackFileName = __stack[i].getFileName();
                if ( stackFileName && !/node_modules/.test(stackFileName) ) {
                    file = stackFileName;
                    break;
                }
            }
            var a           = file.replace('.js', '').split('/')
                , i         = a.length-1;

            if (bundle == model) {
                bundle = ctx.bundle
            } else {

                if (ctx.bundles) {
                    for (; i >= 0; --i) {
                        index = ctx.bundles.indexOf(a[i]);
                        if ( index > -1 ) {
                            ctx.bundle = bundle = ctx.bundles[index];

                            break
                        }
                    }
                } else if (ctx.bundle) {
                    bundle = ctx.bundle
                }

            }
        }

        //if (!self.models) {
            self.models = ModelUtil.instance.models
        //}

        if ( typeof(model) != 'undefined' && typeof(self.models[bundle]) != 'undefined' ) {

            try {

                if ( typeof(self.models[bundle][model]['getConnection']) == 'undefined' ) {
                    self.models[bundle][model]['getConnection'] = function() {
                        return self.models[bundle][model]['_connection']
                    }
                }

                return self.models[bundle][model]
            } catch (err) {
                return undefined
            }
        }
    }

    /**
     * Get Model Entity
     *
     * @param {string} model
     * @param {string} entityName
     * @param {object} conn
     *
     * @return {object} entity
     * */
    getModelEntity = function(bundle, model, entityClassName, conn) {
        if ( typeof(entityClassName) != 'undefined' ) {
            var cacheless   = (process.env.IS_CACHELESS == 'false') ? false : true;
            try {
                var shortName = entityClassName.substr(0, 1).toLowerCase() + entityClassName.substr(1);

                if (!self.entities) {
                    if (!ModelUtil.instance) {
                        ModelUtil.instance = getContext('modelUtil')
                    }
                    self.entities           = ModelUtil.instance.entities;
                    self.entitiesCollection = ModelUtil.instance.entitiesCollection;
                    self.models             = ModelUtil.instance.models;

                    if (typeof(self.models) == 'function' ) {
                        self.models                 = {};
                        self.models[bundle]         = {};
                        self.models[bundle][model]  = {}
                    }

                }

                //console.debug(parent+'->getEntity('+shortName+')');
                if ( self.models[bundle][model][shortName] /**&& !cacheless*/) { // cacheless is filtered thanks to self.reloadModels(...)
                    //return self.models[bundle][model][shortName]
                    return self.entitiesCollection[bundle][model][shortName]
                } else {
                    var entityObject = new self.entities[bundle][model][entityClassName](conn)
                    self.entitiesCollection[bundle][model][shortName] = entityObject;

                    //setContext('modelUtil.entitiesCollection', self.entitiesCollection, true);
                    ModelUtil.instance.entitiesCollection = self.entitiesCollection;

                    return entityObject;
                }

            } catch (err) {
                throw err;
                return undefined
            }
        } else {
            return self.entities[bundle][model]
        }
    }


    return init()
}
622035
function addPropertyToModelMeta(modelName, property, meta) {
    if (!exports.propertiesByModel[modelName]) {
        exports.propertiesByModel[modelName] = {};
    }
    // TODO: investigate why we need to genericize to model (from <T>)
    exports.propertiesByModel[modelName][property] = meta;
}
1273067
function UMLSwimlaneView() {
        NodeView.apply(this, arguments);

        /** @member {Boolean} */
        this.isVertical = true;

        /** @member {LabelView} */
        this.nameLabel = new LabelView();
        this.nameLabel.horizontalAlignment = Graphics.AL_CENTER;
        this.nameLabel.verticalAlignment = Graphics.AL_TOP;
        this.nameLabel.selectable = Core.SK_NO;
        this.nameLabel.parentStyle = true;
        this.addSubView(this.nameLabel);
    }
727486
function _validateIsModel(model) {
  let parentClass = Object.getPrototypeOf(model);
  while (parentClass.name !== 'Model' && parentClass.name !== '') {
    parentClass = Object.getPrototypeOf(parentClass);
  }
  validationUtils.booleanTrue(
    parentClass.name === 'Model',
    'Parameter is not an Objection.js model'
  );
}
39309
function UMLCollaborationView() {
        UMLGeneralNodeView.apply(this, arguments);

        /** @member {UMLTemplateParameterCompartmentView} */
        this.templateParameterCompartment = new UMLTemplateParameterCompartmentView();
        this.templateParameterCompartment.selectable = Core.SK_PROPAGATE;
        this.templateParameterCompartment.parentStyle = true;
        this.addSubView(this.templateParameterCompartment);

        this.fillColor = PreferenceManager.get("uml.collaboration.fillColor", "#ffffff") || PreferenceManager.get("view.fillColor", "#ffffff");
    }
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);
            }
877355
function componentMixin(tag$$1) {
      var mixins = [], len = arguments.length - 1;
      while ( len-- > 0 ) mixins[ len ] = arguments[ len + 1 ];

      each(mixins, function (mix) {
        var instance;
        var obj;
        var props = [];

        // properties blacklisted and will not be bound to the tag instance
        var propsBlacklist = ['init', '__proto__'];

        mix = isString(mix) ? mixin(mix) : mix;

        // check if the mixin is a function
        if (isFunction$1(mix)) {
          // create the new mixin instance
          instance = new mix();
        } else { instance = mix; }

        var proto = Object.getPrototypeOf(instance);

        // build multilevel prototype inheritance chain property list
        do { props = props.concat(Object.getOwnPropertyNames(obj || instance)); }
        while (obj = Object.getPrototypeOf(obj || instance))

        // loop the keys in the function prototype or the all object keys
        each(props, function (key) {
          // bind methods to tag
          // allow mixins to override other properties/parent mixins
          if (!contains(propsBlacklist, key)) {
            // check for getters/setters
            var descriptor = getPropDescriptor(instance, key) || getPropDescriptor(proto, key);
            var hasGetterSetter = descriptor && (descriptor.get || descriptor.set);

            // apply method only if it does not already exist on the instance
            if (!tag$$1.hasOwnProperty(key) && hasGetterSetter) {
              Object.defineProperty(tag$$1, key, descriptor);
            } else {
              tag$$1[key] = isFunction$1(instance[key]) ?
                instance[key].bind(tag$$1) :
                instance[key];
            }
          }
        });

        // init method will be called automatically
        if (instance.init)
          { instance.init.bind(tag$$1)(tag$$1.opts); }
      });

      return tag$$1
    }
85608
@Override
    public T createMixin(final Elements elems) {
        AbstractMixinInitializer initializer = new AbstractMixinInitializer() {
            @Override
            protected void initialize() {
                implement(Object.class).with(elems);
                implement(InternalWebElements.class).with(elems);
                implement(FreezableElements.class).with(elems);
                implement(ExpressionWebElements.class).with(elems);
                // this way, we can use an optimized implementation for frozen
                // and native WebElements
                if (elems instanceof BasicElements) {
                    implement(BasicElements.class).with(elems);
                }
            }
        };
        return rootClass.newInstance(MixinInitializers.combine(initializer, baseInitializer));
    }
564224
function () {

        Meta.globalTag ('dummy')

        $assertEveryCalled (function (mkay1, mkay2) { var this_ = undefined

            var Trait = $trait ({
                somethingHappened: $trigger () })

            var Other = $trait ({
                somethingHappened: $dummy (function (_42) { $assert (this, this_); $assert (_42, 42); mkay1 () }) })

            var Compo = $component ({
                $traits: [Trait, Other],
                somethingHappened: function (_42) { $assert (this, this_); $assert (_42, 42); mkay2 () } })

            this_ = new Compo ()
            this_.somethingHappened (42) }) }