Parameter.js 2.04 KB
/**
 * Project      : AMDA-NG
 * Name         : parameter.js
 * Description  : Parameter Business Object Definition
 * @class amdaModel.Parameter
 * @extends amdaModel.AmdaObject 
 * 
 * @author cdarmon
 * @version $Id: Parameter.js 1435 2013-04-04 14:24:04Z elena $
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :15/12/2010: CDA – creation
 *      :           :22/06/2011: elena - extends generic class AmdaObject
 */
 
Ext.define('amdaModel.Parameter', {
	
	extend: 'amdaModel.AmdaObject',
	
    fields : [
	    {name: 'timestep', type: 'string'},
	    {name: 'units', type: 'string'},
	    {name: 'buildchain', type: 'string'},
	    {name: 'description', type: 'string'},
	    {name: 'ytitle', type: 'string'},
                        {name: 'dim_1', type: 'number'},
                        {name: 'dim_2', type: 'number'}
	],
    
    /**
     * get parameter values into  object to be sent to Server
     * @return object
     */
//TODO utf8_encode() and Ext.urlEncode() ???
    getJsonValues : function (hasId) {
        var myValues  = new Object();       
        if (hasId) {
            myValues.id = this.get('id');
        }
        myValues.name = this.get('name');
        myValues.buildchain = this.get('buildchain').replace(/\n/g," ");
        myValues.timestep = this.get('timestep');
        myValues.leaf = true;
        if (this.get('ytitle').match(/[a-z,0-9]/gi) != null) {
            myValues.ytitle = this.get('ytitle');
        }
        if (this.get('description').match(/[a-z,0-9]/gi) != null) {
            myValues.description = this.get('description');
        }
        if (this.get('units').match(/[a-z,0-9]/gi) != null) {
            myValues.units = this.get('units');
        }
        myValues.dim_1 = this.get('dim_1');
        myValues.dim_2 = this.get('dim_2');
        myValues.nodeType = amdaModel.DerivedParamNode.nodeType;
        return myValues;
    }
  
});