Project

General

Profile

Export VOTABLE

Dans contextMenu.js (client) :

         // ligne 864 fichier version 0.9.1
        // 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
    if((request.search("EN2_STAR_CHR")!=-1 && request.search("EN2_STAR_MON")!=-1) || request.search("EN2_WIN")!=-1 || request.search("EN2_STAR_IMAG")!=-1){
                       // si oui on l'averti que ce n'est pas possible et on ne lance pas le VOTable
            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 !!!");

        }else{ 
 // sinon on lance exportVOTable

            url += "?1=1" + request;
            if (!Ext.isEmpty(limit)) {
                url += "&limit=" + limit;
            }
            if (! Ext.isEmpty(userParameters)) {
                Ext.iterate(userParameters, function (key, value) {
                    url += "&" + key + "=" + value; 
                });
            }

            // If Get => the Resource MUST be synchrone and then send a representation
            if (method == "GET") {
                window.open(url);
                Ext.getBody().unmask();
                return;
            } else {
                this._executeRequestForResource(url, method);
            }
        }

Puis dans ExportVORessource.java :

     // ligne 192
     // Execute request to know which value are selected
        String primkey=""; 
        Integer type=0;
        try {
            primkey = databaseRequest.getRequestAsString(); //.getSelectedPrimaryKey();
            boolean found = primkey.contains("AN2");
            if(found){
                System.out.println("J'ai trouvé AN2 !!!\n");
                type=1;
            }else{
            //System.out.println("AN2 non trouvé !!!\n");
            if((primkey.contains("EN2_STAR_CHR") && primkey.contains("EN2_STAR_MON")) || primkey.contains("EN2_WIN") || primkey.contains("EN2_STAR_IMAG")){
                System.out.println("Error j'ai trouvé CHR et MON !!!\n");
            }else{ 
                if(primkey.contains("EN2_STAR_CHR")){
                    System.out.println("J'ai trouvé CHR !!!\n");
                    type = 2;
                } else{ 
                    if(primkey.contains("EN2_STAR_MON")){
                        System.out.println("J'ai trouvé MON !!!\n");
                        type = 3;   
                    }
                    }
                }
            }
        System.out.println("Type vaux : " + type);
        } catch (SitoolsException ex) {
            Logger.getLogger(ExportVOResource.class.getName()).log(Level.SEVERE, null, ex);
        }
       System.out.println("primkey : " + primkey); // astero et AN2_STAR dans la requete !!!

      [ ........  ]

     // ligne 246
    String template_name = "";
        if (type==1)
            template_name = "template_astero.ftl";
        else if (type==2)
             template_name = "template_exo_chr.ftl";
        else if (type==3)
             template_name = "template_exo_mon.ftl";

        System.out.println("j'envoie le template : " + template_name);

        //Return the response
        if (type!=0)
           return new VOTableRepresentation(dataModel, template_name);
        else
           return null;

Les templates.ftl doivent être dans le folder de VOTableRepresentation.java et doivent être bien définis.

Exemple : Pour EN2_STAR_MON, template_exo_mon.ftl


<?xml version="1.0" encoding="UTF-8"?>
<VOTABLE version="1.2" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.ivoa.net/xml/VOTable/v1.2" 
xmlns="http://www.ivoa.net/xml/VOTable/v1.2">
<!--
 !  VOTable written by MHUSSON@IAS version 0.1 (mhusson@ias.u-psud.fr)
 !  at 2012-03-30
 !  Best use with TOPCAT 3.9 or higher version
 !-->
    <RESOURCE name="COROT N2 EN2MON">        
        <DESCRIPTION>COROT N2 PUBLIC DATA VOTABLE STREAM FORMAT</DESCRIPTION>          
    <PARAM name="COROT VERSION" datatype="char" arraysize="*" value="N2">
        <DESCRIPTION>COROT N2 FITS STREAM</DESCRIPTION>
    </PARAM>
    <INFO name="SITOOLS2 COROT PROJECT" value="http://idoc-corotn2-public-v2.ias.u-psud.fr">
        VOTABLE generated with SItools2 COROT and exportVO Ressource (J-C.Malapert@CNES, M.Husson@IAS)
    </INFO>
     <TABLE ID="reference">
    <FIELD ID="date" arraysize="23" datatype="char" name="DATE" unit="yyyy-mm-jjThh:mi:ss"/>
    <FIELD ID="datejd" datatype="double" name="DATEJD" unit="COROT JULIAN DAY"/>
    <FIELD ID="datehel" datatype="double" name="DATEHEL" unit="COROT JULIAN DAY"/>
    <FIELD ID="status" datatype="int" name="STATUS"/>
    <FIELD ID="whiteflux" datatype="float" name="WHITEFLUX" unit="ELECTRONS"/>
    <FIELD ID="whitefluxdev" datatype="float" name="WHITEFLUXDEV" unit="ELECTRONS"/>
    <FIELD ID="bg" datatype="float" name="BG" unit="ELECTRONS PER PIXEL"/>
    <FIELD ID="correc" datatype="float" name="CORREC" unit="ELECTRONS"/>
    </TABLE>
    <#list rows as row>
    <TABLE ref="reference" name="${row["file"]}">
    <PARAM name="COROT ID" value="${row["corotid"]}"/>
    <PARAM name="COROT RUN" value="${row["run_code"]}"/>
            <DATA>
            <FITS extnum="1">
                <STREAM actuate="onRequest" href="${row["download"]}"/>
            </FITS>
               </DATA>
        </TABLE>
        </#list>
    </RESOURCE>
</VOTABLE>