Changeset 480 for tapas/service
- Timestamp:
- 04/13/12 19:46:08 (12 years ago)
- Location:
- tapas/service
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
tapas/service/implementation/com/ether/TapasServiceImpl.java
r470 r480 2 2 3 3 import com.ether.dao.ObservatoryDAO; 4 import com.ether.dao.Tapas NumRequestDAO;4 import com.ether.dao.TapasRequestDAO; 5 5 import com.ether.tapas.Observatory; 6 6 import com.ether.tapas.Request; 7 7 import com.ether.tapas.Tapas; 8 import com.ether.tapas.TapasRequest; 8 9 import com.ether.user.User; 9 10 import org.apache.commons.logging.Log; … … 27 28 import java.util.List; 28 29 import java.util.Properties; 30 import java.util.StringTokenizer; 29 31 30 32 /** … … 37 39 { 38 40 @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"; 44 51 45 52 final Element tapas = new Element( "tapas" ); … … 49 56 final Document document = new Document( tapas ); 50 57 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() ) ); 54 60 55 61 final Attribute id = new Attribute( "Id", fTapas.getId() ); … … 64 70 final Attribute idR = new Attribute( "Id", iRequest.getId().toString() ); 65 71 request.setAttribute( idR ); 66 67 72 68 73 // PREFERENCES … … 116 121 117 122 // OBSERVATORIES 118 //recuperer les coordonnees obervatoire avec requete sql : methode de tapas services -> appel methode couche persistence 119 // TapasService 120 //iRequest.getObservation().getDate() 123 121 124 final Element observation = new Element( "observation" ); 122 125 … … 131 134 observation.addContent( observatory ); 132 135 136 //recuperation des coordonnées de l'observatoire 133 137 final Observatory obs; 134 138 try … … 251 255 atmosphere.addContent( reference ); 252 256 253 final Properties prop = new Properties();254 try255 {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 = "";265 257 266 258 … … 269 261 fileECMWF = rootPath + "/" + user.getLastName() + "/" + createFileName( iRequest.getObservation().getDate(), "ecmwf" ); 270 262 271 272 263 final Element arlettyFile = new Element( "arletty_file" ); 273 264 arlettyFile.setText( fileArletty ); … … 278 269 atmosphere.addContent( ecmwfFile ); 279 270 280 281 //creer le nom des fichiers input ECMW F + ARLETTY à partir du nom court de l'observatoire282 // + calculer le bonne heure de mesure en fonction de la date demandée : 00 06 12 ou 18h283 //TapasService284 285 //créer le num de le requete en lisant dans bdd286 287 271 tapas.addContent( request ); 288 272 } 289 273 290 274 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; 291 294 } 292 295 … … 371 374 try 372 375 { 373 return _tapas NumRequestDAO.getNumRequest();376 return _tapasRequestDAO.getNumRequest()+1; 374 377 } 375 378 catch( PersistenceException e ) 376 379 { 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 ); 378 401 } 379 402 } … … 404 427 405 428 @Required 406 public void setTapas NumRequestDAO( final TapasNumRequestDAO tapasNumRequestDAO )407 { 408 _tapas NumRequestDAO = tapasNumRequestDAO;429 public void setTapasRequestDAO( final TapasRequestDAO tapasRequestDAO ) 430 { 431 _tapasRequestDAO = tapasRequestDAO; 409 432 } 410 433 … … 413 436 private ObservatoryDAO _observatoryDAO; 414 437 415 private Tapas NumRequestDAO _tapasNumRequestDAO;438 private TapasRequestDAO _tapasRequestDAO; 416 439 } -
tapas/service/implementation/service-context.xml
r466 r480 5 5 <bean id="tapasServiceTarget" class="com.ether.TapasServiceImpl" parent="backofficeServiceTarget"> 6 6 <property name="observatoryDAO" ref="refObservatoryDAO"/> 7 <property name="tapasRequestDAO" ref="refTapasRequestDAO"/> 7 8 </bean> 8 9 … … 15 16 </property> 16 17 </bean> 18 17 19 18 20 <bean id="backofficeServiceTarget" class="com.ether.BackofficeServiceImpl"> -
tapas/service/interface/com/ether/ServiceException.java
r470 r480 23 23 PERSISTENCE, 24 24 OBSERVATORY_NOT_FOUND, 25 REQUEST_NOT_FOUND, 25 26 USER_NOT_FOUND, 26 PROPERTIES_FILE_NOT_FOUND; 27 PROPERTIES_FILE_NOT_FOUND, 28 ERROR_PROCESS; 27 29 } 28 30 } -
tapas/service/interface/com/ether/TapasService.java
r470 r480 3 3 import com.ether.tapas.Observatory; 4 4 import com.ether.tapas.Tapas; 5 import com.ether.tapas.TapasRequest; 5 6 import com.ether.user.User; 6 7 import org.jdom.Document; … … 9 10 10 11 import java.util.List; 12 import java.util.Properties; 11 13 12 14 /** … … 18 20 { 19 21 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 ) 21 23 throws ServiceException; 22 24 … … 31 33 public String createFileName(String date, String type) throws ServiceException; 32 34 35 public boolean execAppelQSub( @NotNull final User user, @NotNull final Properties prop ) throws ServiceException; 36 37 Long insertTapasRequest( @NotNull User user ) throws ServiceException; 38 33 39 } -
tapas/service/test/com/ether/EtherTest.java
r402 r480 19 19 extends ServiceEtherTest 20 20 { 21 @Test21 /*@Test 22 22 public void testCreateXML() 23 23 throws Exception 24 24 { 25 25 26 getService().createXMLRequest( null);26 getService().createXMLRequest( ); 27 27 28 } 28 } */ 29 29 30 30
Note: See TracChangeset
for help on using the changeset viewer.