Project

General

Profile

Corot » History » Version 9

Anonymous, 05/06/2012 15:57

1 1 Anonymous
h1. Corot
2 1 Anonymous
3 1 Anonymous
4 8 Anonymous
h2. Scripts de création des imagettes 
5 8 Anonymous
6 8 Anonymous
Premièrement, récupérer la liste des corotid à traiter. On peut séparer par run_code pour faire tourner le script moins longtemps et faire moins chauffer le corot-lightcurve et son repertoire 'temp'.
7 8 Anonymous
8 8 Anonymous
On récupère donc les corotid depuis pgadmin3 (exemple pour SRa05 et EN2_STAR_CHR : select distinct corotid from exo_n2_view where run_code like 'SRa05%' and en2_star_mon; )
9 8 Anonymous
10 8 Anonymous
Puis avec emacs on rajoute le début de l'url : http://idoc-corot-lightcurve.ias.u-psud.fr/rest/tempo/basic/N2/SRa05/ (dans un fichier, par exemple "links.txt")
11 8 Anonymous
12 8 Anonymous
On utilise tempo qui pointe vers les data privés mais sans authentification (ligne à décommenter dans spring-config.xml sur idc-appli2 : /usr/local/tomcat_corot/webapps/corot-lightcurve/WEB-INF/conf)
13 8 Anonymous
14 8 Anonymous
Puis on exécute le script perl qui va générer les *.png dans  /usr/local/tomcat_corot/webapps/corot-lightcurve/temp/ : 
15 8 Anonymous
16 8 Anonymous
<pre><code class="java">
17 8 Anonymous
18 8 Anonymous
#!/usr/bin/perl
19 8 Anonymous
open READ, "< links.txt";
20 8 Anonymous
while (<READ>)
21 8 Anonymous
{
22 8 Anonymous
  chomp;
23 8 Anonymous
  system("curl $_ | grep \"alt=\\\"Light curve for corot id\" >> adr_img.txt");
24 8 Anonymous
}
25 8 Anonymous
26 8 Anonymous
</code></pre>
27 8 Anonymous
28 8 Anonymous
29 8 Anonymous
On obtient une ligne par imagette générée.
30 8 Anonymous
31 8 Anonymous
<img src="http://idoc-corot-lightcurve.ias.u-psud.fr/temp/lightcurve_8653845841090318133.png" alt="Light curve for corot id : 223925326 (run SRa05)" />
32 8 Anonymous
33 8 Anonymous
Il faut ensuite copier les imagettes en local et les renommer : D'abord éditer avec Emacs (avec des replace string) pour obtenir :
34 8 Anonymous
35 8 Anonymous
http://idoc-corot-lightcurve.ias.u-psud.fr/temp/lightcurve_8653845841090318133.png > img_exo_223925326_SRa05.png
36 8 Anonymous
37 8 Anonymous
Puis lancer le 2eme script perl :
38 8 Anonymous
39 8 Anonymous
<pre><code class="java">
40 8 Anonymous
41 8 Anonymous
#!/usr/bin/perl
42 8 Anonymous
open READ, "< adr_img.txt";
43 8 Anonymous
while (<READ>)
44 8 Anonymous
{
45 8 Anonymous
  chomp;
46 8 Anonymous
  system("curl $_");
47 8 Anonymous
}
48 8 Anonymous
49 8 Anonymous
</code></pre>
50 8 Anonymous
51 8 Anonymous
52 1 Anonymous
h2. Gestion des imagettes dans le Detail
53 1 Anonymous
54 1 Anonymous
Dans le fichier : /usr/local/Sitools2_Corot/workspace/client-user/js/components/viewDataDetail/viewDataDetail.js
55 1 Anonymous
Ligne 102 : collapsed : false
56 2 Anonymous
57 2 Anonymous
58 2 Anonymous
h2. Export VOTABLE
59 3 Anonymous
60 3 Anonymous
Dans contextMenu.js (client) :
61 3 Anonymous
62 3 Anonymous
<pre><code class="javascript">
63 4 Anonymous
         // ligne 864 fichier version 0.9.1
64 3 Anonymous
        // on test que l'utilisateur ne selectionne pas CHR et MON en meme temps + qu'il n'a pas pris de WINDESC et d'IMAG
65 3 Anonymous
	if((request.search("EN2_STAR_CHR")!=-1 && request.search("EN2_STAR_MON")!=-1) || request.search("EN2_WIN")!=-1 || request.search("EN2_STAR_IMAG")!=-1){
66 3 Anonymous
                       // si oui on l'averti que ce n'est pas possible et on ne lance pas le VOTable
67 3 Anonymous
			Ext.Msg.alert("WARNING !", "DONT SELECT WINDESCRIPTOR OR IMAG" +  "<br/>"  + " ALSO DONT PICK EN2_STAR_MON AND EN2_STAR_CHR AT THE SAME TIME PLEASE !!!");
68 3 Anonymous
69 3 Anonymous
		}else{ 
70 3 Anonymous
 // sinon on lance exportVOTable
71 3 Anonymous
72 3 Anonymous
			
73 3 Anonymous
			url += "?1=1" + request;
74 3 Anonymous
			if (!Ext.isEmpty(limit)) {
75 3 Anonymous
				url += "&limit=" + limit;
76 3 Anonymous
			}
77 3 Anonymous
			if (! Ext.isEmpty(userParameters)) {
78 3 Anonymous
				Ext.iterate(userParameters, function (key, value) {
79 3 Anonymous
					url += "&" + key + "=" + value; 
80 3 Anonymous
				});
81 3 Anonymous
			}
82 3 Anonymous
			
83 3 Anonymous
			// If Get => the Resource MUST be synchrone and then send a representation
84 3 Anonymous
			if (method == "GET") {
85 3 Anonymous
				window.open(url);
86 3 Anonymous
				Ext.getBody().unmask();
87 3 Anonymous
				return;
88 3 Anonymous
			} else {
89 3 Anonymous
				this._executeRequestForResource(url, method);
90 3 Anonymous
			}
91 3 Anonymous
		}
92 3 Anonymous
93 6 Anonymous
</code></pre>
94 5 Anonymous
95 5 Anonymous
96 5 Anonymous
Puis dans ExportVORessource.java :
97 5 Anonymous
98 5 Anonymous
<pre><code class="java">
99 5 Anonymous
     // ligne 192
100 5 Anonymous
     // Execute request to know which value are selected
101 5 Anonymous
        String primkey=""; 
102 5 Anonymous
        Integer type=0;
103 5 Anonymous
        try {
104 5 Anonymous
            primkey = databaseRequest.getRequestAsString(); //.getSelectedPrimaryKey();
105 5 Anonymous
            boolean found = primkey.contains("AN2");
106 5 Anonymous
            if(found){
107 5 Anonymous
                System.out.println("J'ai trouvé AN2 !!!\n");
108 5 Anonymous
                type=1;
109 5 Anonymous
            }else{
110 5 Anonymous
            //System.out.println("AN2 non trouvé !!!\n");
111 5 Anonymous
            if((primkey.contains("EN2_STAR_CHR") && primkey.contains("EN2_STAR_MON")) || primkey.contains("EN2_WIN") || primkey.contains("EN2_STAR_IMAG")){
112 5 Anonymous
                System.out.println("Error j'ai trouvé CHR et MON !!!\n");
113 5 Anonymous
            }else{ 
114 5 Anonymous
                if(primkey.contains("EN2_STAR_CHR")){
115 5 Anonymous
                    System.out.println("J'ai trouvé CHR !!!\n");
116 5 Anonymous
                    type = 2;
117 5 Anonymous
                } else{ 
118 5 Anonymous
                    if(primkey.contains("EN2_STAR_MON")){
119 5 Anonymous
                        System.out.println("J'ai trouvé MON !!!\n");
120 5 Anonymous
                        type = 3;   
121 5 Anonymous
                    }
122 5 Anonymous
                    }
123 5 Anonymous
                }
124 5 Anonymous
            }
125 5 Anonymous
        System.out.println("Type vaux : " + type);
126 5 Anonymous
        } catch (SitoolsException ex) {
127 5 Anonymous
            Logger.getLogger(ExportVOResource.class.getName()).log(Level.SEVERE, null, ex);
128 5 Anonymous
        }
129 5 Anonymous
       System.out.println("primkey : " + primkey); // astero et AN2_STAR dans la requete !!!
130 5 Anonymous
131 5 Anonymous
      [ ........  ]
132 5 Anonymous
133 5 Anonymous
     // ligne 246
134 5 Anonymous
    String template_name = "";
135 5 Anonymous
        if (type==1)
136 5 Anonymous
            template_name = "template_astero.ftl";
137 5 Anonymous
        else if (type==2)
138 5 Anonymous
             template_name = "template_exo_chr.ftl";
139 5 Anonymous
        else if (type==3)
140 5 Anonymous
             template_name = "template_exo_mon.ftl";
141 5 Anonymous
        
142 5 Anonymous
        
143 5 Anonymous
        System.out.println("j'envoie le template : " + template_name);
144 5 Anonymous
        
145 5 Anonymous
        //Return the response
146 7 Anonymous
        if (type!=0)
147 7 Anonymous
           return new VOTableRepresentation(dataModel, template_name);
148 7 Anonymous
        else
149 7 Anonymous
           return null;
150 6 Anonymous
</code></pre>
151 6 Anonymous
152 6 Anonymous
153 6 Anonymous
154 6 Anonymous
Les templates.ftl doivent être dans le folder de VOTableRepresentation.java et doivent être bien définis.
155 6 Anonymous
156 6 Anonymous
Exemple :  Pour EN2_STAR_MON, template_exo_mon.ftl
157 6 Anonymous
158 6 Anonymous
<pre><code class="XML">
159 6 Anonymous
160 6 Anonymous
<?xml version="1.0" encoding="UTF-8"?>
161 6 Anonymous
<VOTABLE version="1.2" 
162 6 Anonymous
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
163 6 Anonymous
xsi:schemaLocation="http://www.ivoa.net/xml/VOTable/v1.2" 
164 6 Anonymous
xmlns="http://www.ivoa.net/xml/VOTable/v1.2">
165 6 Anonymous
<!--
166 6 Anonymous
 !  VOTable written by MHUSSON@IAS version 0.1 (mhusson@ias.u-psud.fr)
167 6 Anonymous
 !  at 2012-03-30
168 6 Anonymous
 !  Best use with TOPCAT 3.9 or higher version
169 6 Anonymous
 !-->
170 6 Anonymous
    <RESOURCE name="COROT N2 EN2MON">        
171 6 Anonymous
        <DESCRIPTION>COROT N2 PUBLIC DATA VOTABLE STREAM FORMAT</DESCRIPTION>          
172 6 Anonymous
	<PARAM name="COROT VERSION" datatype="char" arraysize="*" value="N2">
173 6 Anonymous
		<DESCRIPTION>COROT N2 FITS STREAM</DESCRIPTION>
174 6 Anonymous
	</PARAM>
175 6 Anonymous
	<INFO name="SITOOLS2 COROT PROJECT" value="http://idoc-corotn2-public-v2.ias.u-psud.fr">
176 6 Anonymous
		VOTABLE generated with SItools2 COROT and exportVO Ressource (J-C.Malapert@CNES, M.Husson@IAS)
177 6 Anonymous
	</INFO>
178 6 Anonymous
 	<TABLE ID="reference">
179 6 Anonymous
	<FIELD ID="date" arraysize="23" datatype="char" name="DATE" unit="yyyy-mm-jjThh:mi:ss"/>
180 6 Anonymous
	<FIELD ID="datejd" datatype="double" name="DATEJD" unit="COROT JULIAN DAY"/>
181 6 Anonymous
	<FIELD ID="datehel" datatype="double" name="DATEHEL" unit="COROT JULIAN DAY"/>
182 6 Anonymous
	<FIELD ID="status" datatype="int" name="STATUS"/>
183 6 Anonymous
	<FIELD ID="whiteflux" datatype="float" name="WHITEFLUX" unit="ELECTRONS"/>
184 6 Anonymous
	<FIELD ID="whitefluxdev" datatype="float" name="WHITEFLUXDEV" unit="ELECTRONS"/>
185 6 Anonymous
	<FIELD ID="bg" datatype="float" name="BG" unit="ELECTRONS PER PIXEL"/>
186 6 Anonymous
	<FIELD ID="correc" datatype="float" name="CORREC" unit="ELECTRONS"/>
187 6 Anonymous
	</TABLE>
188 6 Anonymous
	<#list rows as row>
189 6 Anonymous
	<TABLE ref="reference" name="${row["file"]}">
190 6 Anonymous
	<PARAM name="COROT ID" value="${row["corotid"]}"/>
191 6 Anonymous
	<PARAM name="COROT RUN" value="${row["run_code"]}"/>
192 6 Anonymous
        	<DATA>
193 6 Anonymous
			<FITS extnum="1">
194 6 Anonymous
				<STREAM actuate="onRequest" href="${row["download"]}"/>
195 6 Anonymous
			</FITS>
196 6 Anonymous
        	   </DATA>
197 6 Anonymous
        </TABLE>
198 6 Anonymous
    	</#list>
199 6 Anonymous
    </RESOURCE>
200 6 Anonymous
</VOTABLE>
201 6 Anonymous
202 6 Anonymous
</code></pre> 
203 9 Anonymous
204 9 Anonymous
205 9 Anonymous
h2. Les composants de formulaire : 
206 9 Anonymous
207 9 Anonymous
Le Date Begin-end : qui permet de faire une requête sur deux colonnes différentes, "date de début" et "date de fin". On récupère ainsi les observations dont la date de début est intervenu après "date de début" et dont la fin est intervenu avant la "date de fin".
208 9 Anonymous
209 9 Anonymous
Le code javascript correspondant : 
210 9 Anonymous
211 9 Anonymous
Partie ADMIN : 
212 9 Anonymous
213 9 Anonymous
<pre><code class="javascript">
214 9 Anonymous
215 9 Anonymous
/*global Ext, sitools, ID, i18n, document, showResponse, alertFailure, LOCALE, ImageChooser, 
216 9 Anonymous
 showHelp*/
217 9 Anonymous
Ext.namespace('sitools.component.forms.multiParam');
218 9 Anonymous
219 9 Anonymous
sitools.component.forms.multiParam.DateBeginEnd = Ext.extend(sitools.component.forms.multiParam.abstractForm, {
220 9 Anonymous
    height : 250,
221 9 Anonymous
    id : 'sitools.component.forms.definitionId',
222 9 Anonymous
    initComponent : function () {
223 9 Anonymous
        this.winPropComponent.specificHeight = 350;
224 9 Anonymous
        this.winPropComponent.specificWidth = 400;
225 9 Anonymous
        sitools.component.forms.multiParam.DateBeginEnd.superclass.initComponent.call(this);
226 9 Anonymous
     
227 9 Anonymous
228 9 Anonymous
        
229 9 Anonymous
    /*
230 9 Anonymous
     * Build all the Columns mapping for the configuration, 
231 9 Anonymous
     * this object needs three columns
232 9 Anonymous
     */
233 9 Anonymous
    var labels = ['DATE FROM', 'DATE TO'];
234 9 Anonymous
    for (var i = 1; i <= 2; i++) {
235 9 Anonymous
		this['mapParam' + i] = new Ext.form.ComboBox({
236 9 Anonymous
		    fieldLabel : labels[i - 1],
237 9 Anonymous
		    triggerAction : 'all',
238 9 Anonymous
		    name : "PARAM" + i,
239 9 Anonymous
		    specificType : "mapParam", 
240 9 Anonymous
		    columnIndex : i, 
241 9 Anonymous
		    lazyRender : true,
242 9 Anonymous
		    mode : 'local',
243 9 Anonymous
		    store : this.storeColumn,
244 9 Anonymous
		    valueField : 'columnAlias',
245 9 Anonymous
		    displayField : 'header',
246 9 Anonymous
		    anchor : '100%', 
247 9 Anonymous
		    allowBlank : false 
248 9 Anonymous
		    
249 9 Anonymous
		}); 
250 9 Anonymous
		
251 9 Anonymous
		if (this.action == "modify") {
252 9 Anonymous
			Ext.apply(this['mapParam' + i], {
253 9 Anonymous
				value : this.selectedRecord.data.code[i - 1]
254 9 Anonymous
			});
255 9 Anonymous
		}
256 9 Anonymous
       
257 9 Anonymous
		this.insert(i, this['mapParam' + i]);
258 9 Anonymous
    }
259 9 Anonymous
260 9 Anonymous
    this.componentDefaultValue1 = new Ext.form.DateField({
261 9 Anonymous
        fieldLabel : i18n.get('label.defaultValue') + ' (DATE FROM)',
262 9 Anonymous
        name : 'componentDefaultValue1',
263 9 Anonymous
        anchor : '100%',
264 9 Anonymous
        format : DEFAULT_DATE_FORMAT
265 9 Anonymous
    });
266 9 Anonymous
    this.componentDefaultValue2 = new Ext.form.DateField({
267 9 Anonymous
        fieldLabel : i18n.get('label.defaultValue') + ' (DATE TO)',
268 9 Anonymous
        name : 'componentDefaultValue2',
269 9 Anonymous
        anchor : '100%',
270 9 Anonymous
        format : DEFAULT_DATE_FORMAT
271 9 Anonymous
    });
272 9 Anonymous
273 9 Anonymous
    this.add(this.componentDefaultValue1);
274 9 Anonymous
    this.add(this.componentDefaultValue2);
275 9 Anonymous
276 9 Anonymous
    
277 9 Anonymous
},
278 9 Anonymous
onRender : function () {
279 9 Anonymous
    sitools.component.forms.multiParam.DateBeginEnd.superclass.onRender.apply(this, arguments);
280 9 Anonymous
    if (this.action == 'modify') {
281 9 Anonymous
        if (!Ext.isEmpty(this.selectedRecord.data.defaultValues)) {
282 9 Anonymous
            if (Ext.isString(this.selectedRecord.data.defaultValues[0])) {
283 9 Anonymous
                this.componentDefaultValue1.setValue(this.selectedRecord.data.defaultValues[0].split('T')[0]);
284 9 Anonymous
            }
285 9 Anonymous
            else {
286 9 Anonymous
                this.componentDefaultValue1.setValue(this.selectedRecord.data.defaultValues[0].split('T')[0]);
287 9 Anonymous
            }
288 9 Anonymous
            if (Ext.isString(this.selectedRecord.data.defaultValues[1])) {
289 9 Anonymous
                this.componentDefaultValue2.setValue(this.selectedRecord.data.defaultValues[1].split('T')[0]);
290 9 Anonymous
            }
291 9 Anonymous
            else {
292 9 Anonymous
                this.componentDefaultValue2.setValue(this.selectedRecord.data.defaultValues[1].split('T')[0]);
293 9 Anonymous
            }
294 9 Anonymous
        }
295 9 Anonymous
    }
296 9 Anonymous
},
297 9 Anonymous
afterRender : function () {
298 9 Anonymous
    sitools.component.forms.multiParam.DateBeginEnd.superclass.afterRender.apply(this, arguments);
299 9 Anonymous
    if (this.action == 'modify') {
300 9 Anonymous
		if (!Ext.isEmpty(this.selectedRecord.data.defaultValues)) {
301 9 Anonymous
            this.componentDefaultValue1.setValue(this.selectedRecord.data.defaultValues[0]);
302 9 Anonymous
            this.componentDefaultValue2.setValue(this.selectedRecord.data.defaultValues[1]);
303 9 Anonymous
            
304 9 Anonymous
        }
305 9 Anonymous
    }
306 9 Anonymous
   
307 9 Anonymous
},
308 9 Anonymous
309 9 Anonymous
_onValidate : function (action, gridFormComponents) {
310 9 Anonymous
    var f = this.getForm();
311 9 Anonymous
    if (!f.isValid()) {
312 9 Anonymous
    	Ext.Msg.alert(i18n.get('label.error'), i18n.get('warning.invalidForm'));
313 9 Anonymous
        return false;
314 9 Anonymous
    }
315 9 Anonymous
    var defaultValue1 = Ext.isEmpty(f.findField('componentDefaultValue1')) ? "" : f.findField('componentDefaultValue1').getValue();
316 9 Anonymous
    var defaultValue2 = Ext.isEmpty(f.findField('componentDefaultValue2')) ? "" : f.findField('componentDefaultValue2').getValue();
317 9 Anonymous
318 9 Anonymous
	var columnObjects = this.find('specificType', 'mapParam');
319 9 Anonymous
	var code = [];
320 9 Anonymous
	Ext.each(columnObjects, function (columnObject) {
321 9 Anonymous
		code.push(columnObject.getValue());
322 9 Anonymous
	});
323 9 Anonymous
  
324 9 Anonymous
    if (action == 'modify') {
325 9 Anonymous
        var rec = gridFormComponents.getSelectionModel().getSelected();
326 9 Anonymous
        
327 9 Anonymous
        var labelParam1 = Ext.isEmpty(f.findField('LABEL_PARAM1')) ? "" : f.findField('LABEL_PARAM1').getValue();
328 9 Anonymous
        var css = Ext.isEmpty(f.findField('CSS')) ? "" : f.findField('CSS').getValue();
329 9 Anonymous
        
330 9 Anonymous
        rec.set('label', labelParam1);
331 9 Anonymous
        rec.set('code', code);
332 9 Anonymous
        rec.set('css', css);
333 9 Anonymous
        rec.set('componentDefaultHeight', f.findField('componentDefaultHeight').getValue());
334 9 Anonymous
        rec.set('componentDefaultWidth', f.findField('componentDefaultWidth').getValue());
335 9 Anonymous
336 9 Anonymous
        rec.set('defaultValues', [ defaultValue1, defaultValue2]);
337 9 Anonymous
    } else {
338 9 Anonymous
        var formComponentsStore = gridFormComponents.getStore();
339 9 Anonymous
        
340 9 Anonymous
        // Génération de l'id
341 9 Anonymous
        var lastId = 0;
342 9 Anonymous
        var greatY = 0;
343 9 Anonymous
        formComponentsStore.each(function (component) {
344 9 Anonymous
            if (component.data.id > lastId) {
345 9 Anonymous
                lastId = parseInt(component.data.id, 10);
346 9 Anonymous
            }
347 9 Anonymous
            if (component.data.ypos > greatY) {
348 9 Anonymous
                greatY = parseInt(component.data.ypos, 10)  + parseInt(component.data.height, 10);
349 9 Anonymous
            }
350 9 Anonymous
351 9 Anonymous
        });
352 9 Anonymous
        var componentId = lastId + 1;
353 9 Anonymous
        componentId = componentId.toString();
354 9 Anonymous
        var componentYpos = greatY + 10;
355 9 Anonymous
        
356 9 Anonymous
        formComponentsStore.add(new Ext.data.Record({
357 9 Anonymous
            label : f.findField('LABEL_PARAM1').getValue(),
358 9 Anonymous
            type : this.ctype,
359 9 Anonymous
            code : code,
360 9 Anonymous
            width : f.findField('componentDefaultWidth').getValue(),
361 9 Anonymous
            height : f.findField('componentDefaultHeight').getValue(),
362 9 Anonymous
            id : componentId,
363 9 Anonymous
            ypos : componentYpos,
364 9 Anonymous
            css : f.findField('CSS').getValue(),
365 9 Anonymous
            jsAdminObject : this.jsAdminObject,
366 9 Anonymous
            jsUserObject : this.jsUserObject,
367 9 Anonymous
            defaultValues : [ defaultValue1, defaultValue2 ]
368 9 Anonymous
        }));
369 9 Anonymous
    }
370 9 Anonymous
    return true;
371 9 Anonymous
}
372 9 Anonymous
373 9 Anonymous
});
374 9 Anonymous
375 9 Anonymous
</code></pre>
376 9 Anonymous
377 9 Anonymous
378 9 Anonymous
partie CLIENT : 
379 9 Anonymous
380 9 Anonymous
<pre><code class="javascript">
381 9 Anonymous
/***************************************
382 9 Anonymous
* Copyright 2011 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
383 9 Anonymous
* 
384 9 Anonymous
* This file is part of SITools2.
385 9 Anonymous
* 
386 9 Anonymous
* SITools2 is free software: you can redistribute it and/or modify
387 9 Anonymous
* it under the terms of the GNU General Public License as published by
388 9 Anonymous
* the Free Software Foundation, either version 3 of the License, or
389 9 Anonymous
* (at your option) any later version.
390 9 Anonymous
* 
391 9 Anonymous
* SITools2 is distributed in the hope that it will be useful,
392 9 Anonymous
* but WITHOUT ANY WARRANTY; without even the implied warranty of
393 9 Anonymous
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
394 9 Anonymous
* GNU General Public License for more details.
395 9 Anonymous
* 
396 9 Anonymous
* You should have received a copy of the GNU General Public License
397 9 Anonymous
* along with SITools2.  If not, see <http://www.gnu.org/licenses/>.
398 9 Anonymous
***************************************/
399 9 Anonymous
/*global Ext, sitools*/
400 9 Anonymous
Ext.ns('sitools.component.users.SubSelectionParameters.SingleSelection');
401 9 Anonymous
402 9 Anonymous
sitools.component.users.SubSelectionParameters.SingleSelection.DateBeginEnd = Ext.extend(Ext.Container, {
403 9 Anonymous
404 9 Anonymous
    initComponent : function () {
405 9 Anonymous
        this.fieldFrom = new Ext.form.DateField({
406 9 Anonymous
            allowBlank : true,
407 9 Anonymous
            format : DEFAULT_DATE_FORMAT, 
408 9 Anonymous
            width : 165,
409 9 Anonymous
            height : this.height,
410 9 Anonymous
            value : new Date(this.defaultValues[0]).format(DEFAULT_DATE_FORMAT)
411 9 Anonymous
        });
412 9 Anonymous
        this.fieldTo = new Ext.form.DateField({
413 9 Anonymous
            allowBlank : true,
414 9 Anonymous
            format : DEFAULT_DATE_FORMAT, 
415 9 Anonymous
            width : 165,
416 9 Anonymous
            height : this.height,
417 9 Anonymous
            value : new Date(this.defaultValues[1]).format(DEFAULT_DATE_FORMAT)
418 9 Anonymous
        });
419 9 Anonymous
        Ext.apply(this, {
420 9 Anonymous
            layout : 'table',
421 9 Anonymous
            columns : 2,     /* 3*/
422 9 Anonymous
            fieldLabel : this.label,
423 9 Anonymous
            stype : "sitoolsFormContainer",
424 9 Anonymous
425 9 Anonymous
            items : [ new Ext.Container({
426 9 Anonymous
            	border : false,
427 9 Anonymous
            	html : this.label + " : ", 
428 9 Anonymous
            	width : "150"
429 9 Anonymous
            }), this.fieldFrom, new Ext.Container({
430 9 Anonymous
                border : false,
431 9 Anonymous
                html : '&nbsp;'
432 9 Anonymous
            }), this.fieldTo ]
433 9 Anonymous
        });
434 9 Anonymous
        sitools.component.users.SubSelectionParameters.SingleSelection.DateBeginEnd.superclass.initComponent.apply(
435 9 Anonymous
                this, arguments);
436 9 Anonymous
    },
437 9 Anonymous
438 9 Anonymous
    /**
439 9 Anonymous
     * The code of the parameter to notify changed event.
440 9 Anonymous
     */
441 9 Anonymous
    code : null,
442 9 Anonymous
443 9 Anonymous
    /**
444 9 Anonymous
     * The left bound of the period.
445 9 Anonymous
     */
446 9 Anonymous
    fieldFrom : null,
447 9 Anonymous
448 9 Anonymous
    /**
449 9 Anonymous
     * The right bound of the period.
450 9 Anonymous
     */
451 9 Anonymous
    fieldTo : null,
452 9 Anonymous
453 9 Anonymous
    notifyValueSelected : function () {
454 9 Anonymous
        this.parent.notifyValueChanged(this.code);
455 9 Anonymous
    },
456 9 Anonymous
457 9 Anonymous
    isValueDefined : function () {
458 9 Anonymous
        if (this.fieldFrom.getValue() && this.fieldTo.getValue()) {
459 9 Anonymous
            return true;
460 9 Anonymous
        } else {
461 9 Anonymous
            return false;
462 9 Anonymous
        }
463 9 Anonymous
    },
464 9 Anonymous
465 9 Anonymous
    getSelectedValue : function () {
466 9 Anonymous
        return {
467 9 Anonymous
            from : this.fieldFrom.getValue(),
468 9 Anonymous
            to : this.fieldTo.getValue()
469 9 Anonymous
        };
470 9 Anonymous
    },
471 9 Anonymous
    
472 9 Anonymous
    getParameterValue : function () {
473 9 Anonymous
        var value = this.getSelectedValue();
474 9 Anonymous
        if (Ext.isEmpty(value) || Ext.isEmpty(value.from) || Ext.isEmpty(value.to)) {
475 9 Anonymous
            return null;
476 9 Anonymous
        }
477 9 Anonymous
        return this.type + "|" + this.code + "|" + value.from.format('Y-m-d') + "|" + value.to.format('Y-m-d') ;
478 9 Anonymous
    }
479 9 Anonymous
});
480 9 Anonymous
</code></pre>
481 9 Anonymous
482 9 Anonymous
483 9 Anonymous
Code JAVA à inclure dans *workspace/fr.cnes.sitools.extensions/src/fr/cnes/sitools/filter* et référencer la classe dans le fichier *fr.cnes.sitools.filter.FilterHelper*
484 9 Anonymous
485 9 Anonymous
<pre><code class="java">
486 9 Anonymous
487 9 Anonymous
</code></pre>