Changeset 480 for tapas/service


Ignore:
Timestamp:
04/13/12 19:46:08 (12 years ago)
Author:
rboipsl
Message:

insertion requete dans bdd
lancement process qsub
debut modif design

Location:
tapas/service
Files:
5 edited

Legend:

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

    r470 r480  
    22 
    33import com.ether.dao.ObservatoryDAO; 
    4 import com.ether.dao.TapasNumRequestDAO; 
     4import com.ether.dao.TapasRequestDAO; 
    55import com.ether.tapas.Observatory; 
    66import com.ether.tapas.Request; 
    77import com.ether.tapas.Tapas; 
     8import com.ether.tapas.TapasRequest; 
    89import com.ether.user.User; 
    910import org.apache.commons.logging.Log; 
     
    2728import java.util.List; 
    2829import java.util.Properties; 
     30import java.util.StringTokenizer; 
    2931 
    3032/** 
     
    3739{ 
    3840    @Transactional(readOnly = true) 
    39     public void createXMLRequest( @NotNull final Tapas fTapas, @NotNull final User user ) 
    40             throws ServiceException 
    41     { 
    42  
    43         final String fichier = "/home_local/workspace/request2.xml"; 
     41    public void createXMLRequest( @NotNull final Tapas fTapas, @NotNull final User user, @NotNull final Properties prop ) 
     42            throws ServiceException 
     43    { 
     44 
     45        final String rootPath = prop.getProperty( "root_file_path" ); 
     46        final String execPath = prop.getProperty( "exec_path" ); 
     47 
     48        final String userPath = ""; 
     49 
     50        final String fichier = rootPath+"/"+user.getLastName()+"/"+"request.xml"; 
    4451 
    4552        final Element tapas = new Element( "tapas" ); 
     
    4956        final Document document = new Document( tapas ); 
    5057 
    51         //a terme recuperer id tapas via la BDD 
    52         //Long newNum = getNumRequest(); 
    53         fTapas.setId( "1414" ); 
     58        //recuperation valeur id requete (bdd table tapas_request) 
     59        fTapas.setId( "ETHER_TAPAS_" + String.valueOf( getNumRequest() ) ); 
    5460 
    5561        final Attribute id = new Attribute( "Id", fTapas.getId() ); 
     
    6470            final Attribute idR = new Attribute( "Id", iRequest.getId().toString() ); 
    6571            request.setAttribute( idR ); 
    66  
    6772 
    6873            // PREFERENCES 
     
    116121 
    117122            // OBSERVATORIES 
    118             //recuperer les coordonnees obervatoire avec requete sql : methode de tapas services -> appel methode couche persistence 
    119             // TapasService 
    120             //iRequest.getObservation().getDate() 
     123 
    121124            final Element observation = new Element( "observation" ); 
    122125 
     
    131134            observation.addContent( observatory ); 
    132135 
     136            //recuperation des coordonnées de l'observatoire 
    133137            final Observatory obs; 
    134138            try 
     
    251255            atmosphere.addContent( reference ); 
    252256 
    253             final Properties prop = new Properties(); 
    254             try 
    255             { 
    256                 prop.load( new FileInputStream( "/home_local/workspace/tapas.properties" ) ); 
    257             } 
    258             catch( IOException e ) 
    259             { 
    260                 throw new ServiceException( ServiceException.ServiceCode.PROPERTIES_FILE_NOT_FOUND, e ); 
    261             } 
    262  
    263             final String rootPath = prop.getProperty( "root_file_path" ); 
    264             final String userPath = ""; 
    265257 
    266258 
     
    269261            fileECMWF = rootPath + "/" + user.getLastName() + "/" + createFileName( iRequest.getObservation().getDate(), "ecmwf" ); 
    270262 
    271  
    272263            final Element arlettyFile = new Element( "arletty_file" ); 
    273264            arlettyFile.setText( fileArletty ); 
     
    278269            atmosphere.addContent( ecmwfFile ); 
    279270 
    280  
    281             //creer le nom des fichiers input ECMW F + ARLETTY à partir du nom court de l'observatoire 
    282             // + calculer le bonne heure de mesure en fonction de la date demandée : 00 06 12 ou 18h 
    283             //TapasService 
    284  
    285             //créer le num de le requete en lisant dans bdd 
    286  
    287271            tapas.addContent( request ); 
    288272        } 
    289273 
    290274        createXMLFile( fichier, document ); 
     275    } 
     276 
     277 
     278    public boolean execAppelQSub( User user, Properties prop ) 
     279            throws ServiceException 
     280    { 
     281 
     282        String commande = prop.getProperty( "root_file_path" )+"/"+user.getLastName()+"/"+prop.getProperty( "process_name" )+" -f request.xml"+" -m "+user.getEmail(); 
     283 
     284        try 
     285        { 
     286            EtherHelper.execProcess(commande); 
     287        } 
     288        catch( FormattedException e ) 
     289        { 
     290            throw new ServiceException(ServiceException.ServiceCode.ERROR_PROCESS, e); 
     291        } 
     292 
     293        return true; 
    291294    } 
    292295 
     
    371374        try 
    372375        { 
    373             return _tapasNumRequestDAO.getNumRequest(); 
     376            return _tapasRequestDAO.getNumRequest()+1; 
    374377        } 
    375378        catch( PersistenceException e ) 
    376379        { 
    377             throw new ServiceException( ServiceException.ServiceCode.OBSERVATORY_NOT_FOUND, e ); 
     380            throw new ServiceException( ServiceException.ServiceCode.REQUEST_NOT_FOUND, e ); 
     381        } 
     382    } 
     383 
     384 
     385    @NotNull 
     386    @Transactional(rollbackFor = Exception.class) 
     387    public Long insertTapasRequest( @NotNull final User user ) 
     388            throws ServiceException 
     389    { 
     390 
     391        try 
     392        { 
     393            String dd="1"; 
     394 
     395            final TapasRequest ntp = new TapasRequest( user.getFirstName(),user.getLastName(),dd,_tapasRequestDAO.getNumRequest()+1); 
     396            return _tapasRequestDAO.insert( ntp ); 
     397        } 
     398        catch( PersistenceException e ) 
     399        { 
     400            throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 
    378401        } 
    379402    } 
     
    404427 
    405428    @Required 
    406     public void setTapasNumRequestDAO( final TapasNumRequestDAO tapasNumRequestDAO ) 
    407     { 
    408         _tapasNumRequestDAO = tapasNumRequestDAO; 
     429    public void setTapasRequestDAO( final TapasRequestDAO tapasRequestDAO ) 
     430    { 
     431        _tapasRequestDAO = tapasRequestDAO; 
    409432    } 
    410433 
     
    413436    private ObservatoryDAO _observatoryDAO; 
    414437 
    415     private TapasNumRequestDAO _tapasNumRequestDAO; 
     438    private TapasRequestDAO _tapasRequestDAO; 
    416439} 
  • tapas/service/implementation/service-context.xml

    r466 r480  
    55    <bean id="tapasServiceTarget" class="com.ether.TapasServiceImpl" parent="backofficeServiceTarget"> 
    66        <property name="observatoryDAO" ref="refObservatoryDAO"/> 
     7        <property name="tapasRequestDAO" ref="refTapasRequestDAO"/> 
    78    </bean> 
    89 
     
    1516        </property> 
    1617    </bean> 
     18 
    1719 
    1820    <bean id="backofficeServiceTarget" class="com.ether.BackofficeServiceImpl"> 
  • tapas/service/interface/com/ether/ServiceException.java

    r470 r480  
    2323        PERSISTENCE, 
    2424        OBSERVATORY_NOT_FOUND, 
     25        REQUEST_NOT_FOUND, 
    2526        USER_NOT_FOUND, 
    26         PROPERTIES_FILE_NOT_FOUND; 
     27        PROPERTIES_FILE_NOT_FOUND, 
     28        ERROR_PROCESS; 
    2729    } 
    2830} 
  • tapas/service/interface/com/ether/TapasService.java

    r470 r480  
    33import com.ether.tapas.Observatory; 
    44import com.ether.tapas.Tapas; 
     5import com.ether.tapas.TapasRequest; 
    56import com.ether.user.User; 
    67import org.jdom.Document; 
     
    910 
    1011import java.util.List; 
     12import java.util.Properties; 
    1113 
    1214/** 
     
    1820{ 
    1921 
    20     public void createXMLRequest( @NotNull final Tapas tapas, @NotNull final User user ) 
     22    public void createXMLRequest( @NotNull final Tapas tapas, @NotNull final User user, @NotNull final Properties prop ) 
    2123            throws ServiceException; 
    2224 
     
    3133    public String createFileName(String date, String type) throws ServiceException; 
    3234 
     35    public boolean execAppelQSub( @NotNull final User user, @NotNull final Properties prop ) throws ServiceException; 
     36 
     37    Long insertTapasRequest( @NotNull User user ) throws ServiceException; 
     38 
    3339} 
  • tapas/service/test/com/ether/EtherTest.java

    r402 r480  
    1919        extends ServiceEtherTest 
    2020{ 
    21     @Test 
     21    /*@Test 
    2222    public void testCreateXML() 
    2323            throws Exception 
    2424    { 
    2525 
    26         getService().createXMLRequest( null ); 
     26        getService().createXMLRequest( ); 
    2727 
    28     } 
     28    } */ 
    2929 
    3030 
Note: See TracChangeset for help on using the changeset viewer.