/** * Project  : AMDA-NG * Name : Search.js * Description : Condition Business Object Definition * @class amdaModel.Search * @extends amdaModel.AmdaObject * * @author myriam * @version $Id: Search.js 2068 2014-02-06 11:27:38Z elena $ ****************************************************************************** * FT Id : Date : Name - Description ****************************************************************************** * : :23/06/2011: myriam – creation * : :04/07/2011: elena – event Execute * : :06/07/2011: elena – date fields */ Ext.define('amdaModel.Search', { extend: 'amdaModel.AmdaTimeObject', fields : [ // {name: 'name', type: 'string', defaultValue: 'Search'}, {name: 'sampling', type: 'float', defaultValue: '600'}, {name: 'gap', type: 'int', defaultValue: '5'}, {name: 'description', type: 'string'}, {name: 'expression', type: 'string'}, {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' ], propertiesToCopy : 'id,name,sampling,gap,description,expression,last_update,sampling_mode,reference_param', getJsonValues : function(hasId){ var myValues = new Object(); if (hasId) { myValues.id = this.get('id'); } myValues.name = this.get('name'); myValues.sampling = this.get('sampling'); myValues.gap = this.get('gap'); myValues.sampling_mode = this.get('sampling_mode'); myValues.reference_param = this.get('reference_param'); myValues.description = this.get('description'); myValues.expression = this.get('expression').replace(/\n/g," ");; myValues.timesrc = this.get('timesrc'); // if there's at least one timeTable name into 'timeTables' collection if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){ // myValues.timeTables = this.get('timeTables').items; // get complete timeTables collection var timeTables = this.get('timeTables'); // init an empty array for timeTables myValues.timeTables=[]; // for each interval record Ext.Array.each(timeTables, function(item, index, all){ // get Json simplified value if (!item.$className) { myValues.timeTables[index] = {timeTableName : item.timeTableName, id : item.id}; } // get Json simplified value else { myValues.timeTables[index] = item.getJsonValues(); } }); } else { myValues.startDate = this.get('startDate'); myValues.stopDate = this.get('stopDate'); myValues.durationDay = this.get('durationDay'); myValues.durationHour = this.get('durationHour'); myValues.durationMin = this.get('durationMin'); myValues.durationSec = this.get('durationSec'); } myValues.leaf = true; myValues.nodeType = amdaModel.SearchNode.nodeType; return myValues; } });