Changeset 389 for tapas/service
- Timestamp:
- 03/02/12 18:07:28 (12 years ago)
- Location:
- tapas/service
- Files:
-
- 7 edited
- 1 copied
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 } -
tapas/service/implementation/service-context.xml
r384 r389 4 4 <beans> 5 5 <bean id="tapasServiceTarget" class="com.ether.TapasServiceImpl"> 6 < property name="plateformDAO" ref="refPlateformDAO" />7 <property name="parameterDAO" ref="refParameterDAO" /> 6 <!--<property name="plateformDAO" ref="refPlateformDAO" /> 7 <property name="parameterDAO" ref="refParameterDAO" />--> 8 8 </bean> 9 9 -
tapas/service/implementation/service-context_test.xml
r388 r389 3 3 4 4 <beans> 5 <bean id="tapasService Target" class="com.ether.TapasServiceImpl">6 < property name="plateformDAO" ref="refPlateformDAO" />7 <property name="parameterDAO" ref="refParameterDAO" /> 5 <bean id="tapasService" class="com.ether.TapasServiceImpl"> 6 <!--<property name="plateformDAO" ref="refPlateformDAO" /> 7 <property name="parameterDAO" ref="refParameterDAO" />--> 8 8 </bean> 9 9 10 <bean id="tapasService" parent="transactionProxy">11 <property name="target">12 <ref bean="tapasServiceTarget" />13 </property>14 <property name="transactionAttributeSource">15 <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />16 </property>17 </bean>18 10 19 11 </beans> -
tapas/service/interface/com/ether/TapasService.java
r384 r389 1 1 package com.ether; 2 2 3 import org.jdom.Document; 3 4 import org.jetbrains.annotations.NotNull; 4 5 import org.jetbrains.annotations.Nullable; … … 13 14 extends Service 14 15 { 16 17 public void createXMLRequest(); 18 19 public void createXMLFile( final String fichier, final Document document ); 20 15 21 @Nullable 16 22 List<Plateform> getAllPlateforms() throws ServiceException; -
tapas/service/test/com/ether/EtherTest.java
r376 r389 2 2 3 3 import org.jetbrains.annotations.NotNull; 4 import org.junit.Assert; 5 import org.junit.Test; 4 6 5 7 import javax.imageio.ImageIO; … … 9 11 import java.io.File; 10 12 import java.io.Serializable; 13 import java.text.DateFormat; 11 14 import java.text.ParseException; 15 import java.text.SimpleDateFormat; 16 import java.util.Calendar; 17 import java.util.Date; 12 18 13 19 /** … … 16 22 */ 17 23 public class EtherTest 24 extends ServiceEtherTest 18 25 { 26 @Test 27 public void testCreateXML() 28 throws Exception 29 { 30 31 getService().createXMLRequest(); 32 33 } 34 35 19 36 @NotNull 20 37 protected double[] createDataArray( @NotNull final Integer size, @NotNull final Integer begin ) -
tapas/service/test/com/ether/OtherTest.java
r376 r389 20 20 { 21 21 @Test 22 public void test DatesMoisPlusUn()22 public void testCreateXML() 23 23 throws Exception 24 24 { 25 25 26 final DateFormat shortDateFormat = new SimpleDateFormat( "MMyyyy" ); 26 27 final DateFormat completDateFormat = new SimpleDateFormat( "dd-MM-yyyy" ); … … 37 38 } 38 39 39 @Test40 public void testDates()41 throws Exception42 {43 List<Date> dates = new ArrayList<Date>();44 final DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );45 40 46 dates.add( dateFormat.parse( "2007-01-01" ) );47 dates.add( dateFormat.parse( "2007-01-02" ) );48 41 49 final DateFormat shortFormat = new SimpleDateFormat( "yyyy" );50 Set<String> shortDates = new HashSet<String>();51 for ( final Date aDate : dates )52 {53 shortDates.add( shortFormat.format( aDate ) );54 }55 }56 42 } -
tapas/service/test/com/ether/ServiceEtherTest.java
r384 r389 10 10 public ServiceEtherTest() 11 11 { 12 super( " etherService" );12 super( "tapasService" ); 13 13 } 14 14 -
tapas/service/test/com/ether/ServiceTestHelper.java
r376 r389 19 19 { 20 20 return new String[] { 21 "classpath:dao-context.xml", 22 "classpath:service-context.xml", 23 "classpath:hibernate_test.cfg.xml", }; 21 // "classpath:dao-context.xml", 22 "classpath:service-context_test.xml", 23 // "classpath:hibernate_test.cfg.xml", 24 }; 24 25 } 25 26
Note: See TracChangeset
for help on using the changeset viewer.