- Timestamp:
- 06/04/12 16:17:51 (12 years ago)
- Location:
- tapas
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tapas/common/implementation/com/ether/DateHelper.java
r469 r524 163 163 public static final String ENGLISH_DATE_PATTERN_SHORT = "yyyy-MM-dd"; 164 164 public static final String ENGLISH_DATE_PATTERN = "yyyy-MM-dd HH:mm"; 165 public static final String ENGLISH_DATE_LONG_PATTERN = "yyyy-MM-dd HH:mm:ss"; 165 166 166 167 public static final String ORDERED_FORMAT_PLUS_GMT = "yyyy-MM-dd HH:mm:ss.SSSS Z"; -
tapas/service/implementation/com/ether/TapasServiceImpl.java
r515 r524 49 49 final String dataPath = prop.getProperty( "data_path" ); 50 50 51 final String fichier = servicePath +"/"+"request.xml";51 final String fichier = servicePath + "/" + "request.xml"; 52 52 final Element tapas = new Element( "tapas" ); 53 final List<Element> listRequest = new ArrayList<Element>( fTapas.getRequests().size());53 final List<Element> listRequest = new ArrayList<Element>( fTapas.getRequests().size() ); 54 54 55 55 //On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer … … 109 109 preferences.addContent( o3e ); 110 110 111 //o2111 //o2 112 112 final Element o2e = new Element( "o2_extinction" ); 113 113 validR = new Attribute( "valid", "YES,NO" ); … … 132 132 // date mesure 133 133 final Element mdate = new Element( "date" ); 134 mdate.setText( iRequest.getObservation().getDate() ); 134 final Calendar calendar = Calendar.getInstance(); 135 calendar.setTimeInMillis( Long.valueOf( iRequest.getObservation().getDate() ) ); 136 mdate.setText( DateHelper.formatDate( calendar.getTime(), DateHelper.ENGLISH_DATE_LONG_PATTERN ) ); 137 // mdate.setText( iRequest.getObservation().getDate() ); 135 138 136 139 observation.addContent( mdate ); … … 273 276 274 277 275 String fileArletty = "", fileECMWF = "", shortName ="";278 String fileArletty = "", fileECMWF = "", shortName = ""; 276 279 //rajouter annee/mois 277 280 278 281 shortName = obs.getShortName(); 279 282 280 fileArletty = dataPath + "/" + createFileName( iRequest.getObservation().getDate(), "arletty", shortName );283 fileArletty = dataPath + "/" + createFileName( iRequest.getObservation().getDate(), "arletty", shortName ); 281 284 fileECMWF = dataPath + "/" + createFileName( iRequest.getObservation().getDate(), "ecmwf", shortName ); 282 285 … … 294 297 tapas.addContent( listRequest ); 295 298 296 String commandePath = servicePath +"/"+fTapas.getId();297 createXMLFile( document, commandePath, prop );299 String commandePath = servicePath + "/" + fTapas.getId(); 300 createXMLFile( document, commandePath, prop ); 298 301 299 302 … … 307 310 308 311 final String usersPath = prop.getProperty( "users_path" ); 309 String commande = "mkdir -p " +usersPath+"/"+user.getEmail();312 String commande = "mkdir -p " + usersPath + "/" + user.getEmail(); 310 313 311 314 try … … 318 321 } 319 322 320 EtherHelper.pause( 4000);323 EtherHelper.pause( 4000 ); 321 324 322 325 //commande = "chown -R "+prop.getProperty( "chown_user" )+" "+usersPath+"/"+user.getEmail(); 323 commande = "chmod 777 -R " +usersPath+"/"+user.getEmail();326 commande = "chmod 777 -R " + usersPath + "/" + user.getEmail(); 324 327 325 328 try … … 332 335 } 333 336 334 EtherHelper.pause( 4000);337 EtherHelper.pause( 4000 ); 335 338 336 339 } … … 340 343 throws ServiceException 341 344 { 342 String commande ="";343 String commandePath =prop.getProperty( "service_path" )+"/"+repCommande+"/";345 String commande = ""; 346 String commandePath = prop.getProperty( "service_path" ) + "/" + repCommande + "/"; 344 347 345 348 //copie run qsub dans repertoire commande 346 commande = "cp " +prop.getProperty( "src_path" )+"/"+prop.getProperty( "process_name" )+" "+commandePath;349 commande = "cp " + prop.getProperty( "src_path" ) + "/" + prop.getProperty( "process_name" ) + " " + commandePath; 347 350 348 351 try … … 355 358 } 356 359 357 EtherHelper.pause( 7000);360 EtherHelper.pause( 7000 ); 358 361 359 362 //final String fichier = commandePath+"commande.txt"; … … 370 373 }*/ 371 374 372 EtherHelper.pause( 7000);373 374 commande ="chmod 777 -R "+commandePath;375 EtherHelper.pause( 7000 ); 376 377 commande = "chmod 777 -R " + commandePath; 375 378 376 379 try … … 383 386 } 384 387 385 EtherHelper.pause( 7000);388 EtherHelper.pause( 7000 ); 386 389 387 390 //execution qsub pour la commande en cours 388 commande = commandePath +"/"+prop.getProperty( "process_name" )+" -f request.xml"+" -m "+user.getEmail();391 commande = commandePath + "/" + prop.getProperty( "process_name" ) + " -f request.xml" + " -m " + user.getEmail(); 389 392 390 393 /*PrintWriter out = null; … … 406 409 try 407 410 { 408 EtherHelper.execProcess( commande);411 EtherHelper.execProcess( commande ); 409 412 } 410 413 catch( FormattedException e ) 411 414 { 412 throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS, e);413 } 414 415 EtherHelper.pause(7000);416 417 return true;418 } 419 420 421 /* public String findMeasureHour( String date )422 423 424 425 426 427 428 429 430 415 throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS, e ); 416 } 417 418 EtherHelper.pause( 7000 ); 419 420 return true; 421 } 422 423 424 /* public String findMeasureHour( String date ) 425 { 426 String heure; 427 int val; 428 429 430 val = Math.abs( Integer.parseInt( heure ) ); 431 432 return heure; 433 } */ 431 434 432 435 public String createFileName( String date, String type, String nomCourt ) … … 436 439 String annee = date.substring( 0, 4 ); 437 440 //String mois = String.valueOf( Integer.parseInt(date.substring(5,7))-1); 438 String mois = date.substring( 5,7);439 String heure = date.substring( 11,13);440 String jour = date.substring( 8,10);441 String ind ="";441 String mois = date.substring( 5, 7 ); 442 String heure = date.substring( 11, 13 ); 443 String jour = date.substring( 8, 10 ); 444 String ind = ""; 442 445 443 446 Calendar cal = Calendar.getInstance(); 444 447 445 try { 446 Date dd = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(jour+"/"+mois+"/"+annee+" "+heure+":00:00"); 447 cal.setTime(dd); 448 } 449 catch( ParseException e ) { 450 451 } 452 453 int iheure = cal.get(Calendar.HOUR_OF_DAY)+2; 454 455 if( iheure < 3) ind = "00"; 456 else if ( iheure >= 21) { 448 try 449 { 450 Date dd = new SimpleDateFormat( "dd/MM/yyyy HH:mm:ss" ).parse( jour + "/" + mois + "/" + annee + " " + heure + ":00:00" ); 451 cal.setTime( dd ); 452 } 453 catch( ParseException e ) 454 { 455 456 } 457 458 int iheure = cal.get( Calendar.HOUR_OF_DAY ) + 2; 459 460 if( iheure < 3 ) ind = "00"; 461 else if( iheure >= 21 ) 462 { 457 463 ind = "00"; 458 cal.add( Calendar.DAY_OF_MONTH, +1);459 } 460 else if( Math.abs( 6-iheure) < 3 || iheure == 3 ) ind = "06";461 else if( Math.abs( 12 - iheure) < 3 || iheure == 9 ) ind = "12";462 else if( Math.abs( 18 - iheure) < 3 || iheure == 15 ) ind = "18";464 cal.add( Calendar.DAY_OF_MONTH, +1 ); 465 } 466 else if( Math.abs( 6 - iheure ) < 3 || iheure == 3 ) ind = "06"; 467 else if( Math.abs( 12 - iheure ) < 3 || iheure == 9 ) ind = "12"; 468 else if( Math.abs( 18 - iheure ) < 3 || iheure == 15 ) ind = "18"; 463 469 464 470 //+1 sur le mois pour recuperer le numero correct du mois considere 465 if (cal.get(Calendar.MONTH)+1 <10) mois="0"+String.valueOf(cal.get(Calendar.MONTH)+1);466 else mois =""+String.valueOf(cal.get(Calendar.MONTH)+1);467 468 if (cal.get(Calendar.DAY_OF_MONTH) <10) jour="0"+ cal.get(Calendar.DAY_OF_MONTH);469 else jour =""+cal.get(Calendar.DAY_OF_MONTH);470 471 annee =""+cal.get(Calendar.YEAR);472 473 fileName = "/" +annee+"/"+mois+"/"+jour+"/"+nomCourt+"_"+annee+mois+jour+ind;474 475 if( type == "arletty" ) fileName = fileName +".arl";476 else if ( type == "ecmwf" ) fileName = fileName+"_qo3.txt";471 if( cal.get( Calendar.MONTH ) + 1 < 10 ) mois = "0" + String.valueOf( cal.get( Calendar.MONTH ) + 1 ); 472 else mois = "" + String.valueOf( cal.get( Calendar.MONTH ) + 1 ); 473 474 if( cal.get( Calendar.DAY_OF_MONTH ) < 10 ) jour = "0" + cal.get( Calendar.DAY_OF_MONTH ); 475 else jour = "" + cal.get( Calendar.DAY_OF_MONTH ); 476 477 annee = "" + cal.get( Calendar.YEAR ); 478 479 fileName = "/" + annee + "/" + mois + "/" + jour + "/" + nomCourt + "_" + annee + mois + jour + ind; 480 481 if( type == "arletty" ) fileName = fileName + ".arl"; 482 else if( type == "ecmwf" ) fileName = fileName + "_qo3.txt"; 477 483 478 484 return fileName; … … 487 493 try 488 494 { 489 EtherHelper.execProcess( "mkdir -p " +commandePath);495 EtherHelper.execProcess( "mkdir -p " + commandePath ); 490 496 } 491 497 catch( FormattedException e ) … … 494 500 } 495 501 496 EtherHelper.pause( 5000);502 EtherHelper.pause( 5000 ); 497 503 498 504 … … 506 512 } */ 507 513 508 final String fichier = commandePath +"/"+"request.xml";514 final String fichier = commandePath + "/" + "request.xml"; 509 515 510 516 //On utilise ici un affichage classique avec getPrettyFormat() … … 556 562 try 557 563 { 558 return _tapasRequestDAO.getNumRequest() +1;564 return _tapasRequestDAO.getNumRequest() + 1; 559 565 } 560 566 catch( PersistenceException e ) … … 573 579 try 574 580 { 575 String dd ="1";576 577 final TapasRequest ntp = new TapasRequest( user.getFirstName(), user.getLastName(),dd,_tapasRequestDAO.getNumRequest()+1);581 String dd = "1"; 582 583 final TapasRequest ntp = new TapasRequest( user.getFirstName(), user.getLastName(), dd, _tapasRequestDAO.getNumRequest() + 1 ); 578 584 return _tapasRequestDAO.insert( ntp ); 579 585 } -
tapas/web/project/formTapas_script.jsp
r515 r524 637 637 638 638 var observation = new Object(); 639 observation.date = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() ) ;639 observation.date = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() ).getTime(); 640 640 observation.observatory = observatory; 641 641
Note: See TracChangeset
for help on using the changeset viewer.