dustin@745: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz dustin@745: * Software engineering by Intevation GmbH dustin@745: * dustin@745: * This file is Free Software under the GNU GPL (v>=3) dustin@745: * and comes with ABSOLUTELY NO WARRANTY! Check out dustin@745: * the documentation coming with IMIS-Labordaten-Application for details. dustin@745: */ dustin@745: dustin@745: /** dustin@745: * A Messprogramm. dustin@745: * This class represents and defines the model of a 'Messprogramm' dustin@745: **/ dustin@745: Ext.define('Lada.model.Messprogramm', { dustin@745: extend: 'Ext.data.Model', dustin@745: dustin@745: fields: [{ dustin@745: name: 'id' dustin@745: }, { dustin@754: name: 'test', dustin@745: type: 'boolean' dustin@745: }, { dustin@745: name: 'netzbetreiberId', dustin@745: serialize: function(value) { dustin@745: if (value === '') { dustin@745: return null; dustin@745: } dustin@745: return value; dustin@745: } dustin@745: }, { dustin@745: name: 'mstId' dustin@745: }, { dustin@754: name: 'name' dustin@754: }, { dustin@745: name: 'datenbasisId' dustin@745: }, { dustin@745: name: 'baId' dustin@745: }, { dustin@745: name: 'gemId' dustin@745: }, { dustin@745: name: 'ortId' dustin@745: }, { dustin@745: name: 'mediaDesk' dustin@745: }, { dustin@745: name: 'umwId', dustin@745: serialize: function(value) { dustin@745: if (value === '') { dustin@745: return null; dustin@745: } dustin@745: return value; dustin@745: } dustin@745: }, { dustin@745: name: 'probenartId' dustin@745: }, { dustin@745: name: 'probenintervall' dustin@745: }, { dustin@745: name: 'teilintervallVon' dustin@745: }, { dustin@745: name: 'teilintervallBis' dustin@745: }, { dustin@745: name: 'intervallOffset' dustin@745: }, { dustin@774: name: 'gueltigVon', dustin@774: type: 'date', dustin@774: convert: function(v) { dustin@793: var firstofyeartimestamp = new Date( dustin@793: Date.UTC( dustin@793: new Date().getFullYear(),0,1)) dustin@793: .valueOf(); dustin@793: var dayToMilli = 86400000; dustin@793: dustin@774: if (!v) { dustin@774: return v; dustin@774: } dustin@793: //check if v might be a date dustin@793: // unless we go back in time this will work dustin@793: if (v < 1000) { dustin@793: v = v * dayToMilli; dustin@793: v = v + firstofyeartimestamp; dustin@793: v = new Date(v); dustin@793: } dustin@793: return v; dustin@774: }, dustin@781: serialize: function(value) { dustin@781: if (value instanceof Date && !isNaN(value.valueOf())) { dustin@793: return Ext.Date.getDayOfYear(value); dustin@781: } dustin@781: } dustin@745: }, { dustin@774: name: 'gueltigBis', dustin@774: type: 'date', dustin@774: convert: function(v) { dustin@793: var firstofyeartimestamp = new Date( dustin@793: Date.UTC( dustin@793: new Date().getFullYear(),0,1)) dustin@793: .valueOf(); dustin@793: var dayToMilli = 86400000; dustin@793: dustin@774: if (!v) { dustin@774: return v; dustin@774: } dustin@793: dustin@793: //check if v might be a date dustin@793: // unless we go back in time this will work dustin@793: if (v < 1000) { dustin@793: v = v * dayToMilli; dustin@793: v = v + firstofyeartimestamp; dustin@793: v = new Date(v); dustin@793: } dustin@793: return v; dustin@774: }, dustin@781: serialize: function(value) { dustin@781: if (value instanceof Date && !isNaN(value.valueOf())) { dustin@793: return Ext.Date.getDayOfYear(value); dustin@781: } dustin@781: } dustin@745: }, { dustin@745: name: 'probeNehmerId' dustin@745: }, { dustin@745: name: 'probeKommentar' dustin@745: }, { dustin@745: name: 'letzteAenderung', dustin@745: type: 'date', dustin@745: convert: function(v) { dustin@745: if (!v) { dustin@745: return v; dustin@745: } dustin@745: return new Date(v); dustin@970: } dustin@745: }], dustin@745: dustin@745: idProperty: 'id', dustin@745: dustin@745: proxy: { dustin@745: type: 'rest', dustin@999: url: 'lada-server/rest/messprogramm', dustin@745: reader: { dustin@745: type: 'json', dustin@745: root: 'data' dustin@745: } dustin@745: } dustin@754: });