Project

General

Profile

Export VOTABLE » History » Version 1

Anonymous, 05/06/2012 17:14

1 1 Anonymous
h1. Export VOTABLE
2 1 Anonymous
3 1 Anonymous
Dans contextMenu.js (client) :
4 1 Anonymous
5 1 Anonymous
<pre><code class="javascript">
6 1 Anonymous
         // ligne 864 fichier version 0.9.1
7 1 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
8 1 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){
9 1 Anonymous
                       // si oui on l'averti que ce n'est pas possible et on ne lance pas le VOTable
10 1 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 !!!");
11 1 Anonymous
12 1 Anonymous
		}else{ 
13 1 Anonymous
 // sinon on lance exportVOTable
14 1 Anonymous
15 1 Anonymous
			
16 1 Anonymous
			url += "?1=1" + request;
17 1 Anonymous
			if (!Ext.isEmpty(limit)) {
18 1 Anonymous
				url += "&limit=" + limit;
19 1 Anonymous
			}
20 1 Anonymous
			if (! Ext.isEmpty(userParameters)) {
21 1 Anonymous
				Ext.iterate(userParameters, function (key, value) {
22 1 Anonymous
					url += "&" + key + "=" + value; 
23 1 Anonymous
				});
24 1 Anonymous
			}
25 1 Anonymous
			
26 1 Anonymous
			// If Get => the Resource MUST be synchrone and then send a representation
27 1 Anonymous
			if (method == "GET") {
28 1 Anonymous
				window.open(url);
29 1 Anonymous
				Ext.getBody().unmask();
30 1 Anonymous
				return;
31 1 Anonymous
			} else {
32 1 Anonymous
				this._executeRequestForResource(url, method);
33 1 Anonymous
			}
34 1 Anonymous
		}
35 1 Anonymous
36 1 Anonymous
</code></pre>
37 1 Anonymous
38 1 Anonymous
39 1 Anonymous
Puis dans ExportVORessource.java :
40 1 Anonymous
41 1 Anonymous
<pre><code class="java">
42 1 Anonymous
     // ligne 192
43 1 Anonymous
     // Execute request to know which value are selected
44 1 Anonymous
        String primkey=""; 
45 1 Anonymous
        Integer type=0;
46 1 Anonymous
        try {
47 1 Anonymous
            primkey = databaseRequest.getRequestAsString(); //.getSelectedPrimaryKey();
48 1 Anonymous
            boolean found = primkey.contains("AN2");
49 1 Anonymous
            if(found){
50 1 Anonymous
                System.out.println("J'ai trouvé AN2 !!!\n");
51 1 Anonymous
                type=1;
52 1 Anonymous
            }else{
53 1 Anonymous
            //System.out.println("AN2 non trouvé !!!\n");
54 1 Anonymous
            if((primkey.contains("EN2_STAR_CHR") && primkey.contains("EN2_STAR_MON")) || primkey.contains("EN2_WIN") || primkey.contains("EN2_STAR_IMAG")){
55 1 Anonymous
                System.out.println("Error j'ai trouvé CHR et MON !!!\n");
56 1 Anonymous
            }else{ 
57 1 Anonymous
                if(primkey.contains("EN2_STAR_CHR")){
58 1 Anonymous
                    System.out.println("J'ai trouvé CHR !!!\n");
59 1 Anonymous
                    type = 2;
60 1 Anonymous
                } else{ 
61 1 Anonymous
                    if(primkey.contains("EN2_STAR_MON")){
62 1 Anonymous
                        System.out.println("J'ai trouvé MON !!!\n");
63 1 Anonymous
                        type = 3;   
64 1 Anonymous
                    }
65 1 Anonymous
                    }
66 1 Anonymous
                }
67 1 Anonymous
            }
68 1 Anonymous
        System.out.println("Type vaux : " + type);
69 1 Anonymous
        } catch (SitoolsException ex) {
70 1 Anonymous
            Logger.getLogger(ExportVOResource.class.getName()).log(Level.SEVERE, null, ex);
71 1 Anonymous
        }
72 1 Anonymous
       System.out.println("primkey : " + primkey); // astero et AN2_STAR dans la requete !!!
73 1 Anonymous
74 1 Anonymous
      [ ........  ]
75 1 Anonymous
76 1 Anonymous
     // ligne 246
77 1 Anonymous
    String template_name = "";
78 1 Anonymous
        if (type==1)
79 1 Anonymous
            template_name = "template_astero.ftl";
80 1 Anonymous
        else if (type==2)
81 1 Anonymous
             template_name = "template_exo_chr.ftl";
82 1 Anonymous
        else if (type==3)
83 1 Anonymous
             template_name = "template_exo_mon.ftl";
84 1 Anonymous
        
85 1 Anonymous
        
86 1 Anonymous
        System.out.println("j'envoie le template : " + template_name);
87 1 Anonymous
        
88 1 Anonymous
        //Return the response
89 1 Anonymous
        if (type!=0)
90 1 Anonymous
           return new VOTableRepresentation(dataModel, template_name);
91 1 Anonymous
        else
92 1 Anonymous
           return null;
93 1 Anonymous
</code></pre>
94 1 Anonymous
95 1 Anonymous
96 1 Anonymous
97 1 Anonymous
Les templates.ftl doivent être dans le folder de VOTableRepresentation.java et doivent être bien définis.
98 1 Anonymous
99 1 Anonymous
Exemple :  Pour EN2_STAR_MON, template_exo_mon.ftl
100 1 Anonymous
101 1 Anonymous
<pre><code class="XML">
102 1 Anonymous
103 1 Anonymous
<?xml version="1.0" encoding="UTF-8"?>
104 1 Anonymous
<VOTABLE version="1.2" 
105 1 Anonymous
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
106 1 Anonymous
xsi:schemaLocation="http://www.ivoa.net/xml/VOTable/v1.2" 
107 1 Anonymous
xmlns="http://www.ivoa.net/xml/VOTable/v1.2">
108 1 Anonymous
<!--
109 1 Anonymous
 !  VOTable written by MHUSSON@IAS version 0.1 (mhusson@ias.u-psud.fr)
110 1 Anonymous
 !  at 2012-03-30
111 1 Anonymous
 !  Best use with TOPCAT 3.9 or higher version
112 1 Anonymous
 !-->
113 1 Anonymous
    <RESOURCE name="COROT N2 EN2MON">        
114 1 Anonymous
        <DESCRIPTION>COROT N2 PUBLIC DATA VOTABLE STREAM FORMAT</DESCRIPTION>          
115 1 Anonymous
	<PARAM name="COROT VERSION" datatype="char" arraysize="*" value="N2">
116 1 Anonymous
		<DESCRIPTION>COROT N2 FITS STREAM</DESCRIPTION>
117 1 Anonymous
	</PARAM>
118 1 Anonymous
	<INFO name="SITOOLS2 COROT PROJECT" value="http://idoc-corotn2-public-v2.ias.u-psud.fr">
119 1 Anonymous
		VOTABLE generated with SItools2 COROT and exportVO Ressource (J-C.Malapert@CNES, M.Husson@IAS)
120 1 Anonymous
	</INFO>
121 1 Anonymous
 	<TABLE ID="reference">
122 1 Anonymous
	<FIELD ID="date" arraysize="23" datatype="char" name="DATE" unit="yyyy-mm-jjThh:mi:ss"/>
123 1 Anonymous
	<FIELD ID="datejd" datatype="double" name="DATEJD" unit="COROT JULIAN DAY"/>
124 1 Anonymous
	<FIELD ID="datehel" datatype="double" name="DATEHEL" unit="COROT JULIAN DAY"/>
125 1 Anonymous
	<FIELD ID="status" datatype="int" name="STATUS"/>
126 1 Anonymous
	<FIELD ID="whiteflux" datatype="float" name="WHITEFLUX" unit="ELECTRONS"/>
127 1 Anonymous
	<FIELD ID="whitefluxdev" datatype="float" name="WHITEFLUXDEV" unit="ELECTRONS"/>
128 1 Anonymous
	<FIELD ID="bg" datatype="float" name="BG" unit="ELECTRONS PER PIXEL"/>
129 1 Anonymous
	<FIELD ID="correc" datatype="float" name="CORREC" unit="ELECTRONS"/>
130 1 Anonymous
	</TABLE>
131 1 Anonymous
	<#list rows as row>
132 1 Anonymous
	<TABLE ref="reference" name="${row["file"]}">
133 1 Anonymous
	<PARAM name="COROT ID" value="${row["corotid"]}"/>
134 1 Anonymous
	<PARAM name="COROT RUN" value="${row["run_code"]}"/>
135 1 Anonymous
        	<DATA>
136 1 Anonymous
			<FITS extnum="1">
137 1 Anonymous
				<STREAM actuate="onRequest" href="${row["download"]}"/>
138 1 Anonymous
			</FITS>
139 1 Anonymous
        	   </DATA>
140 1 Anonymous
        </TABLE>
141 1 Anonymous
    	</#list>
142 1 Anonymous
    </RESOURCE>
143 1 Anonymous
</VOTABLE>
144 1 Anonymous
145 1 Anonymous
</code></pre>