Ignore:
Timestamp:
03/02/12 18:07:28 (12 years ago)
Author:
rboipsl
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tapas/service/implementation/com/ether/TapasServiceImpl.java

    r384 r389  
    55import org.apache.commons.logging.Log; 
    66import org.apache.commons.logging.LogFactory; 
     7import org.jdom.*; 
     8import org.jdom.output.Format; 
     9import org.jdom.output.XMLOutputter; 
    710import org.jetbrains.annotations.NotNull; 
    811import org.jetbrains.annotations.Nullable; 
     
    1013import org.springframework.transaction.annotation.Transactional; 
    1114 
     15import java.io.FileOutputStream; 
    1216import java.util.List; 
     17import java.util.prefs.Preferences; 
    1318 
    1419/** 
    15  * @author vmipsl 
    16  * @date 07 mar 2011 
     20 * @author rboipsl 
     21 * @date 2 mars 2012 
    1722 */ 
    1823public class TapasServiceImpl 
    1924        implements TapasService 
    2025{ 
     26 
     27    public void createXMLRequest() 
     28 
     29    { 
     30        String idF = "Ether_TAPAS_0000001"; 
     31        String idRF = "1"; 
     32        String validFF = "ASCII"; 
     33        String validRF = "YES"; 
     34 
     35        String xvalidFF = "ASCII,FITS,NETCDF"; 
     36        String xvalidRF = "YES,NO"; 
     37        String fichier = "request1.xml"; 
     38 
     39        final Element racine = new Element( "tapas" ); 
     40        final Element request = new Element( "request" ); 
     41        final Element preferences = new Element( "preferences" ); 
     42        final Element format = new Element( "format" ); 
     43        final Element rayleighExtinction = new Element( "rayleigh_extinction" ); 
     44 
     45        //On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer 
     46        final Document document = new Document( racine ); 
     47 
     48        final Attribute id = new Attribute( "Id", idF ); 
     49        racine.setAttribute( id ); 
     50 
     51        final Attribute idR = new Attribute( "Id", idRF ); 
     52        request.setAttribute( idR ); 
     53 
     54        racine.addContent( request ); 
     55        request.addContent( preferences ); 
     56 
     57        final Attribute validF = new Attribute( "valid", xvalidFF ); 
     58        format.setAttribute( validF ); 
     59        format.setText( validFF ); 
     60 
     61        final Attribute validR = new Attribute( "valid", xvalidRF ); 
     62        rayleighExtinction.setAttribute( validR ); 
     63        rayleighExtinction.setText( validRF ); 
     64 
     65        createXMLFile( fichier, document ); 
     66    } 
     67 
     68 
     69    public void createXMLFile( final String fichier, final Document document ) 
     70    { 
     71        try 
     72        { 
     73            //On utilise ici un affichage classique avec getPrettyFormat() 
     74            final XMLOutputter sortie = new XMLOutputter( Format.getPrettyFormat() ); 
     75            //Remarquez qu'il suffit simplement de créer une instance de FileOutputStream 
     76            //avec en argument le nom du fichier pour effectuer la sérialisation. 
     77            sortie.output( document, new FileOutputStream( fichier ) ); 
     78        } 
     79        catch( java.io.IOException ignored ) 
     80        { 
     81        } 
     82    } 
     83 
     84 
    2185    @Nullable 
    2286    @Transactional(readOnly = true) 
     
    83147    private PlateformDAO _plateformDAO; 
    84148    private ParameterDAO _parameterDAO; 
     149 
    85150} 
Note: See TracChangeset for help on using the changeset viewer.