Blame view

js/app/models/AmdaTimeObject.js 3.85 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
/**
 * Project      : AMDA-NG
 * Name         : AmdaTimeObject.js
 * Description  : Base Amda Business Object Definition
 * @class amdaModel.AmdaTimeObject
 * @extends amdaModel.AmdaObject
 * 
 * @author elena
 * @version $Id: AmdaTimeObject.js 1534 2013-05-24 13:30:26Z myriam $ 
15171cfc   Elena.Budnik   rm 6751
10
 * @todo Validations
16035364   Benjamin Renard   First commit
11
12
13
14
 */


Ext.define('amdaModel.TTobject', {
aa23703f   Benjamin Renard   Fix TT operation ...
15
16
17
18
19
     extend: 'amdaModel.AmdaObject',

     fields : [
         {name: 'nodeType', type: 'string'}
     ],
16035364   Benjamin Renard   First commit
20
21
22
23
24
     
     getJsonValues : function () {
         var values  = new Object();
         values.timeTableName = this.get('name');
         values.id = this.get('id');
aa23703f   Benjamin Renard   Fix TT operation ...
25
         values.nodeType = this.get('nodeType');
16035364   Benjamin Renard   First commit
26
27
28
29
         return values;
     }
}); 

16035364   Benjamin Renard   First commit
30
31
32
Ext.define('amdaModel.AmdaTimeObject', {	
    extend: 'amdaModel.AmdaObject',    
    statics:{
437c4dbc   Benjamin Renard   First implementat...
33
        inputTimeSrc: ['TimeTable','Interval','Catalog']
15171cfc   Elena.Budnik   rm 6751
34
    },
16035364   Benjamin Renard   First commit
35
    fields : [
15171cfc   Elena.Budnik   rm 6751
36
37
38
39
        { name: 'resultId', type: 'string'}, 
        { name: 'folderId', type: 'string'}, 
        { name: 'processId', type: 'string'},
        { name: 'timesrc', type: 'string'/*, defaultValue: amdaModel.AmdaTimeObject.inputTimeSrc[1] /*'Interval'*/ },
9193d9a6   Hacene SI HADJ MOHAND   request ok
40
41
42
43
        { 
            name: 'startDate', 
            type: 'date', 
            defaultValue:Ext.Date.add(Ext.Date.clearTime(new Date()),Ext.Date.DAY,-1),
15171cfc   Elena.Budnik   rm 6751
44
45
            convert: function(value,rec) {
                if (!Ext.isDate(value)) {
e5ea39d5   Hacene SI HADJ MOHAND   ms ok
46
47
48
                    var valueString = new String(value).replaceAll('\/','\-');
                    var date = new Date(valueString);
                        return date;
15171cfc   Elena.Budnik   rm 6751
49
50
51
52
53
                }
                return value;
            }
        },
        { 
9193d9a6   Hacene SI HADJ MOHAND   request ok
54
55
56
            name: 'stopDate', 
            type: 'date', 
            defaultValue: Ext.Date.clearTime (new Date()), persist: false, 
e5ea39d5   Hacene SI HADJ MOHAND   ms ok
57
58
59
60
61
           convert: function(value,rec) {
                if (!Ext.isDate(value)) {
                    var valueString = new String(value).replaceAll('\/','\-');
                    var date = new Date(valueString);
                        return date;
15171cfc   Elena.Budnik   rm 6751
62
63
                }
                return value;
e5ea39d5   Hacene SI HADJ MOHAND   ms ok
64
            }
15171cfc   Elena.Budnik   rm 6751
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
        }, 
        { 
            name: 'durationDay', type: 'int',  
            convert: function(value, rec) {
                var zoneOffset = rec.get('stopDate').getTimezoneOffset() - rec.get('startDate').getTimezoneOffset();
                
                return Ext.String.leftPad(Math.floor((rec.get('stopDate') - rec.get('startDate') - zoneOffset*60000)/86400000),4,'0');      
            }
        }, 
        { 
            name: 'durationHour', type: 'int',  
            convert: function(value, rec) {
                var zoneOffset = rec.get('stopDate').getTimezoneOffset() - rec.get('startDate').getTimezoneOffset(); 
                var diffH = (rec.get('stopDate') - rec.get('startDate') - zoneOffset*60000)/3600000 % 24;
                
                return Ext.String.leftPad(Math.floor(diffH), 2, '0');      
            }
        }, 
        { 
            name: 'durationMin', type: 'int',  
            convert: function(value, rec) {
                var diffM = (rec.get('stopDate') - rec.get('startDate'))/60000 % 60;
                
                return Ext.String.leftPad(Math.floor(diffM), 2, '0');      
            }
        },
        { 
            name: 'durationSec', type: 'int',  
            convert: function(value, rec) {
                var diffS = (rec.get('stopDate') - rec.get('startDate'))/1000 % 60;
                
                return Ext.String.leftPad(Math.floor(diffS), 2, '0');      
            }
b852834a   Hacene SI HADJ MOHAND   progress
98
99
100
101
102
103
104
105
106
        },
          { 
            name: 'durationMs', type: 'int',  
            convert: function(value, rec) {
                var diffS = (rec.get('stopDate') - rec.get('startDate'))%1000;
                
                return Ext.String.leftPad(Math.floor(diffS), 3, '0');      
            }
        },
15171cfc   Elena.Budnik   rm 6751
107
108
        { name: 'timeTables', defaultValue: null }    // array of TTobject
    ]
16035364   Benjamin Renard   First commit
109
});