Changeset 466 for tapas/service


Ignore:
Timestamp:
04/04/12 17:17:40 (12 years ago)
Author:
rboipsl
Message:

creation form xml

Location:
tapas/service
Files:
3 edited

Legend:

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

    r451 r466  
    3939        final Element request = new Element( "request" ); 
    4040 
    41  
    4241        //On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer 
    4342        final Document document = new Document( tapas ); 
    4443 
    4544        //a terme recuperer id tapas via la BDD 
    46         Long newNum = getNumRequest(); 
     45        //Long newNum = getNumRequest(); 
     46        fTapas.setId( "1414" ); 
    4747 
    4848        final Attribute id = new Attribute( "Id", fTapas.getId() ); 
     
    5858            request.setAttribute( idR ); 
    5959 
    60             //final Observatory obs = getObservatoryByName( iRequest.getObservation().getObservatory().getName() ); 
    6160 
    6261            // PREFERENCES 
    6362            final Element preferences = new Element( "preferences" ); 
    6463 
    65             // Element format 
     64            //format 
    6665            final Element format = new Element( "format" ); 
    6766            //final Attribute validF = new Attribute( "valid", iRequest.getPreference().getFormat().getFirstValue() ); 
    6867            final Attribute validF = new Attribute( "valid", "ACII,FITS,NETCDF" ); 
    6968            format.setAttribute( validF ); 
    70             format.setText( iRequest.getPreference().getFormat().getSecondValue() ); 
    71  
     69            format.setText( iRequest.getPreference().getFormat().getSecondValue()); 
    7270            preferences.addContent( format ); 
    7371 
    74             // Element rayleighExtinction 
    75             /* final Element rayleighExtinction = new Element( "rayleigh_extinction" ); 
    76           final Attribute validR = new Attribute( "valid", iRequest.getPreference().getRayleighExtinction().getFirstValue() ); 
    77           rayleighExtinction.setAttribute( validR ); 
    78           rayleighExtinction.setText( iRequest.getPreference().getRayleighExtinction().getSecondValue() ); 
    79           preferences.addContent( rayleighExtinction );*/ 
    80  
     72            //rayleighExtinction 
     73            final Element rayleighExtinction = new Element( "rayleigh_extinction" ); 
     74            //final Attribute validR = new Attribute( "valid", iRequest.getPreference().getRayleighExtinction().getFirstValue() ); 
     75            Attribute validR = new Attribute( "valid", "YES,NO" ); 
     76            rayleighExtinction.setAttribute( validR ); 
     77            rayleighExtinction.setText( iRequest.getPreference().getRayleighExtinction().getSecondValue()); 
     78            preferences.addContent( rayleighExtinction ); 
     79 
     80            //h2o 
     81            final Element h2oe = new Element( "h2o_extinction" ); 
     82            validR = new Attribute( "valid", "YES,NO"); 
     83            h2oe.setAttribute( validR ); 
     84            h2oe.setText( iRequest.getPreference().getH2oExtinction().getSecondValue() ); 
     85            preferences.addContent( h2oe ); 
     86 
     87            //o2 
     88            final Element o2e = new Element( "o2_extinction" ); 
     89            validR = new Attribute( "valid", "YES,NO"); 
     90            o2e.setAttribute( validR ); 
     91            o2e.setText( iRequest.getPreference().getO2Extinction().getSecondValue() ); 
     92            preferences.addContent( o2e ); 
     93 
     94            //o3 
     95            final Element o3e = new Element( "o3_extinction" ); 
     96            validR = new Attribute( "valid", "YES,NO"); 
     97            o3e.setAttribute( validR ); 
     98            o3e.setText( iRequest.getPreference().getO3Extinction().getSecondValue()); 
     99            preferences.addContent( o3e ); 
     100 
     101            //co2 
     102            final Element co2e = new Element( "co2_extinction" ); 
     103            validR = new Attribute( "valid", "YES,NO"); 
     104            co2e.setAttribute( validR ); 
     105            co2e.setText( iRequest.getPreference().getCo2Extinction().getSecondValue() ); 
     106            preferences.addContent( co2e ); 
    81107 
    82108            request.addContent( preferences ); 
     
    85111            //recuperer les coordonnees obervatoire avec requete sql : methode de tapas services -> appel methode couche persistence 
    86112            // TapasService 
    87  
    88  
    89             //creer le nome des fichiers input ECMW F + ARLETTY à partir du nom court de l'observatoire 
     113            //iRequest.getObservation().getDate() 
     114            final Element observation = new Element( "observation" ); 
     115 
     116            // date mesure 
     117            final Element mdate = new Element( "date" ); 
     118            mdate.setText( iRequest.getObservation().getDate()); 
     119 
     120            observation.addContent( mdate ); 
     121 
     122            //observatoire 
     123            final Element observatory = new Element( "observatory" ); 
     124            observation.addContent( observatory ); 
     125 
     126            final Observatory obs; 
     127            try 
     128            { 
     129                obs = _observatoryDAO.selectByPrimaryKey( iRequest.getObservation().getObservatory().getId() ); 
     130            } 
     131            catch( PersistenceException e ) 
     132            { 
     133                throw new ServiceException(ServiceException.ServiceCode.OBSERVATORY_NOT_FOUND,e); 
     134            } 
     135 
     136 
     137            final Element name = new Element( "name" ); 
     138            name.setText(obs.getName()); 
     139            observatory.addContent( name ); 
     140 
     141            final Element longitude = new Element( "longitude" ); 
     142            longitude.setText( obs.getLongitude().toString() ); 
     143            observatory.addContent( longitude ); 
     144 
     145            final Element latitude = new Element( "latitude" ); 
     146            latitude.setText( obs.getLatitude().toString() ); 
     147            observatory.addContent( latitude ); 
     148 
     149            final Element altitude = new Element( "altitude" ); 
     150            altitude.setText( obs.getAltitude().toString()); 
     151            observatory.addContent( altitude ); 
     152 
     153 
     154 
     155            //los 
     156            final Element los = new Element( "los" ); 
     157            observation.addContent( los ); 
     158 
     159            final Element ra_j2000 = new Element( "ra_j2000" ); 
     160            ra_j2000.setText( iRequest.getObservation().getLos().getRaJ2000() ); 
     161            los.addContent( ra_j2000 ); 
     162 
     163            final Element dec_j2000  = new Element( "dec_j2000" ); 
     164            dec_j2000.setText( iRequest.getObservation().getLos().getDecJ2000() ); 
     165            los.addContent( dec_j2000 ); 
     166 
     167            final Element zenith_angle = new Element( "zenith_angle" ); 
     168 
     169            Attribute a1 = new Attribute( "min", "0" ); 
     170            Attribute a2 = new Attribute( "max", "90" ); 
     171 
     172            zenith_angle.setAttribute( a1 ); 
     173            zenith_angle.setAttribute( a2 ); 
     174 
     175            zenith_angle.setText( iRequest.getObservation().getLos().getZenithAngle()); 
     176 
     177            los.addContent( zenith_angle ); 
     178 
     179 
     180            //instrument 
     181            final Element instrument = new Element( "instrument" ); 
     182            observation.addContent( instrument ); 
     183 
     184            final Element spectral_choice = new Element( "spectral_choice" ); 
     185            Attribute a3 = new Attribute( "valid", iRequest.getObservation().getInstrument().getSpectralChoice().getFirstValue()); 
     186            spectral_choice.setAttribute( a3 ); 
     187            spectral_choice.setText( iRequest.getObservation().getInstrument().getSpectralChoice().getSecondValue()); 
     188            instrument.addContent( spectral_choice ); 
     189 
     190 
     191 
     192            request.addContent( observation ); 
     193 
     194            //creer le nom des fichiers input ECMW F + ARLETTY à partir du nom court de l'observatoire 
    90195            // + calculer le bonne heure de mesure en fonction de la date demandée : 00 06 12 ou 18h 
    91196            //TapasService 
    92197 
    93  
    94198            //créer le num de le requete en lisant dans bdd 
    95  
    96199 
    97200            tapas.addContent( request ); 
     
    152255    @Nullable 
    153256    @Transactional(readOnly = true) 
    154     public Observatory getObservatoryByName( @NotNull final String name ) 
    155             throws ServiceException 
    156     { 
    157         try 
    158         { 
    159             return _observatoryDAO.getObservatoryByName( name ); 
     257    public Observatory getObservatoryById( @NotNull final long id ) 
     258            throws ServiceException 
     259    { 
     260        try 
     261        { 
     262            return _observatoryDAO.getObservatoryById( id ); 
    160263        } 
    161264        catch( PersistenceException e ) 
  • tapas/service/implementation/service-context.xml

    r447 r466  
    55    <bean id="tapasServiceTarget" class="com.ether.TapasServiceImpl" parent="backofficeServiceTarget"> 
    66        <property name="observatoryDAO" ref="refObservatoryDAO"/> 
    7         <property name="tapasNumRequestDAO" ref="refTapasNumRequestDAO"/> 
    87    </bean> 
    98 
  • tapas/service/interface/com/ether/TapasService.java

    r447 r466  
    2424    public List<Observatory> getAllObservatories() throws ServiceException; 
    2525 
    26     public Observatory getObservatoryByName(@NotNull final String name) throws ServiceException; 
     26    public Observatory getObservatoryById(@NotNull final long id) throws ServiceException; 
    2727 
    2828    public Long getNumRequest() throws ServiceException; 
Note: See TracChangeset for help on using the changeset viewer.