- Timestamp:
- 03/02/12 18:07:28 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tapas/service/implementation/com/ether/TapasServiceImpl.java
r384 r389 5 5 import org.apache.commons.logging.Log; 6 6 import org.apache.commons.logging.LogFactory; 7 import org.jdom.*; 8 import org.jdom.output.Format; 9 import org.jdom.output.XMLOutputter; 7 10 import org.jetbrains.annotations.NotNull; 8 11 import org.jetbrains.annotations.Nullable; … … 10 13 import org.springframework.transaction.annotation.Transactional; 11 14 15 import java.io.FileOutputStream; 12 16 import java.util.List; 17 import java.util.prefs.Preferences; 13 18 14 19 /** 15 * @author vmipsl16 * @date 07 mar 201120 * @author rboipsl 21 * @date 2 mars 2012 17 22 */ 18 23 public class TapasServiceImpl 19 24 implements TapasService 20 25 { 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 21 85 @Nullable 22 86 @Transactional(readOnly = true) … … 83 147 private PlateformDAO _plateformDAO; 84 148 private ParameterDAO _parameterDAO; 149 85 150 }
Note: See TracChangeset
for help on using the changeset viewer.