lib/services/ObjectService.js
function(objectName)
	{        
        var app = this;
        var objectName = objectName.split(".");
        var obj = {};
        try
        {
            switch(objectName.length){
                case 1:
                    for(var module in app.modules)
                    {
                        if(app.modules[module].models.hasOwnProperty(objectName[0]))
                        {
                            objectName[1]=objectName[0];
                            objectName[0]=module;
                            break;
                        }
                    }
                    break;
            }            
            if(app.modules[objectName[0]].models.hasOwnProperty(objectName[1])){
                obj = app.modules[objectName[0]].models[objectName[1]];
            }else{                
                throw "not found";
            }
        }
        catch(e)
        {                  
            switch(objectName.length){
                case 1:
                    var modulePath = path.join(app._path,"modules");                    
                    fs.readdirSync(modulePath).forEach(function(moduleName){                      
                        var objFilePath = path.join(app._path,"modules",moduleName,"models",objectName[0]);
                        if(fs.existsSync(objFilePath+".js"))
                        {                            
                            if( app.modules.hasOwnProperty(moduleName) &&
                                app.modules[moduleName].hasOwnProperty('models') && 
                                app.modules[moduleName].models.hasOwnProperty(objectName[0])){
                                var obj = app.modules[moduleName].models[objectName[0]];
                                return obj;
                            }else{
                                var obj = require(objFilePath)(app);
                                if(typeof app.modules[moduleName] != "object") app.modules[moduleName]={};
                                if(typeof app.modules[moduleName].models != "object") app.modules[moduleName].models={};     
                            }                                                
                            app.modules[moduleName].models[objectName[0]] = obj;
                        }
                    });
                    break;
                case 2:
                    var objFilePath = path.join(app._path,"modules",objectName[0],"models",objectName[1]);
                    if(fs.existsSync(objFilePath+".js"))
                    {
                        var obj = require(objFilePath)(app);
                        if(typeof app.modules[objectName[0]] != "object") app.modules[objectName[0]]={};
                        if(typeof app.modules[objectName[0]].models != "object") app.modules[objectName[0]].models={};
                        app.modules[objectName[0]].models[objectName[1]] = obj;
                    }
                    break;
            }
        }
        return obj;
	}
function(objectName)
	{        
        var app = this;
        var objectName = objectName.split(".");
        var obj = {};
        try
        {
            switch(objectName.length){
                case 1:
                    for(var module in app.modules)
                    {
                        if(app.modules[module].models.hasOwnProperty(objectName[0]))
                        {
                            objectName[1]=objectName[0];
                            objectName[0]=module;
                            break;
                        }
                    }
                    break;
            }            
            if(app.modules[objectName[0]].models.hasOwnProperty(objectName[1])){
                obj = app.modules[objectName[0]].models[objectName[1]];
            }else{                
                throw "not found";
            }
        }
        catch(e)
        {                  
            switch(objectName.length){
                case 1:
                    var modulePath = path.join(app._path,"modules");                    
                    fs.readdirSync(modulePath).forEach(function(moduleName){                      
                        var objFilePath = path.join(app._path,"modules",moduleName,"models",objectName[0]);
                        if(fs.existsSync(objFilePath+".js"))
                        {                            
                            if( app.modules.hasOwnProperty(moduleName) &&
                                app.modules[moduleName].hasOwnProperty('models') && 
                                app.modules[moduleName].models.hasOwnProperty(objectName[0])){
                                var obj = app.modules[moduleName].models[objectName[0]];
                                return obj;
                            }else{
                                var obj = require(objFilePath)(app);
                                if(typeof app.modules[moduleName] != "object") app.modules[moduleName]={};
                                if(typeof app.modules[moduleName].models != "object") app.modules[moduleName].models={};     
                            }                                                
                            app.modules[moduleName].models[objectName[0]] = obj;
                        }
                    });
                    break;
                case 2:
                    var objFilePath = path.join(app._path,"modules",objectName[0],"models",objectName[1]);
                    if(fs.existsSync(objFilePath+".js"))
                    {
                        var obj = require(objFilePath)(app);
                        if(typeof app.modules[objectName[0]] != "object") app.modules[objectName[0]]={};
                        if(typeof app.modules[objectName[0]].models != "object") app.modules[objectName[0]].models={};
                        app.modules[objectName[0]].models[objectName[1]] = obj;
                    }
                    break;
            }
        }
        return obj;
	}
function ( objectName ) { var app = this ; var objectName = objectName . split ( "." ) ; var obj = { } ; try { switch ( objectName . length ) { case 1 : for ( var module in app . modules ) { if ( app . modules [ module ] . models . hasOwnProperty ( objectName [ 0 ] ) ) { objectName [ 1 ] = objectName [ 0 ] ; objectName [ 0 ] = module ; break ; } } break ; } if ( app . modules [ objectName [ 0 ] ] . models . hasOwnProperty ( objectName [ 1 ] ) ) { obj = app . modules [ objectName [ 0 ] ] . models [ objectName [ 1 ] ] ; } else { throw "not found" ; } } catch ( e ) { switch ( objectName . length ) { case 1 : var modulePath = path . join ( app . _path , "modules" ) ; fs . readdirSync ( modulePath ) . forEach ( function ( moduleName ) { var objFilePath = path . join ( app . _path , "modules" , moduleName , "models" , objectName [ 0 ] ) ; if ( fs . existsSync ( objFilePath + ".js" ) ) { if ( app . modules . hasOwnProperty ( moduleName ) && app . modules [ moduleName ] . hasOwnProperty ( 'models' ) && app . modules [ moduleName ] . models . hasOwnProperty ( objectName [ 0 ] ) ) { var obj = app . modules [ moduleName ] . models [ objectName [ 0 ] ] ; return obj ; } else { var obj = require ( objFilePath ) ( app ) ; if ( typeof app . modules [ moduleName ] != "object" ) app . modules [ moduleName ] = { } ; if ( typeof app . modules [ moduleName ] . models != "object" ) app . modules [ moduleName ] . models = { } ; } app . modules [ moduleName ] . models [ objectName [ 0 ] ] = obj ; } } ) ; break ; case 2 : var objFilePath = path . join ( app . _path , "modules" , objectName [ 0 ] , "models" , objectName [ 1 ] ) ; if ( fs . existsSync ( objFilePath + ".js" ) ) { var obj = require ( objFilePath ) ( app ) ; if ( typeof app . modules [ objectName [ 0 ] ] != "object" ) app . modules [ objectName [ 0 ] ] = { } ; if ( typeof app . modules [ objectName [ 0 ] ] . models != "object" ) app . modules [ objectName [ 0 ] ] . models = { } ; app . modules [ objectName [ 0 ] ] . models [ objectName [ 1 ] ] = obj ; } break ; } } return obj ; }
Get specified openbiz data model class

This method it part of {@link openbiz.objects.Application},
please never call this directly by ObjectService

if need to call this method, you have to use javascript's function.apply(applicationPointer,params)
please see sample

@memberof openbiz.services.ObjectService
@param {string} objectName - The specified openbiz controller name
@returns {openbiz.objects.Controller}
@example
//below code is how to get a instance of "openbiz-cubi.user.User" class
//cubiApp is instance of openbiz.objects.Application
var myModel = cubiApp.getModel("User");
//then you can access methods of this model like 'hasPermission()'
if(myModel.hasPermission('some-permission')){
...
}
@example
//if you want to call this method directly , please try this way
require('openbiz/services/ObjectService').getController.apply(applicationPointer,objectName)
Get specified openbiz data model class