Parameter.js 2.59 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'}, // only used if 'sampling_mode' is 'timestep'
	    {name: 'units', type: 'string'},
	    {name: 'buildchain', type: 'string'},
	    {name: 'description', type: 'string'},
	    {name: 'ytitle', type: 'string'},
        { name: 'fill_value', type: 'string' },
            {name: 'dim_1', type: 'number'},
            {name: 'dim_2', type: 'number'},
	    {name: 'last_update', type: 'int', defaultValue: 0},
	    {name: 'sampling_mode', type: 'string', defaultValue: 'timestep'}, // 'timestep' or 'refparam'
	    {name: 'reference_param', type: 'string'} // only used if 'sampling_mode' is 'refparam'
	],
    
    /**
     * 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('fill_value').match(/[0-9]/gi) != null) {
            myValues.fill_value = this.get('fill_value');
        }
        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;
	myValues.sampling_mode = this.get('sampling_mode');
	myValues.reference_param = this.get('reference_param');
        return myValues;
    }
  
});