Parameter.js 1.84 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'}
	],
    
    /**
     * 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.nodeType = amdaModel.DerivedParamNode.nodeType;
        return myValues;
    }
  
});