Changeset 524 for tapas


Ignore:
Timestamp:
06/04/12 16:17:51 (12 years ago)
Author:
vmipsl
Message:

réparation décalage horaire

Location:
tapas
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tapas/common/implementation/com/ether/DateHelper.java

    r469 r524  
    163163    public static final String ENGLISH_DATE_PATTERN_SHORT = "yyyy-MM-dd"; 
    164164    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"; 
    165166 
    166167    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  
    4949        final String dataPath = prop.getProperty( "data_path" ); 
    5050 
    51         final String fichier = servicePath+"/"+"request.xml"; 
     51        final String fichier = servicePath + "/" + "request.xml"; 
    5252        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() ); 
    5454 
    5555        //On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer 
     
    109109            preferences.addContent( o3e ); 
    110110 
    111            //o2 
     111            //o2 
    112112            final Element o2e = new Element( "o2_extinction" ); 
    113113            validR = new Attribute( "valid", "YES,NO" ); 
     
    132132            // date mesure 
    133133            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() ); 
    135138 
    136139            observation.addContent( mdate ); 
     
    273276 
    274277 
    275             String fileArletty = "", fileECMWF = "", shortName=""; 
     278            String fileArletty = "", fileECMWF = "", shortName = ""; 
    276279            //rajouter annee/mois 
    277280 
    278281            shortName = obs.getShortName(); 
    279282 
    280             fileArletty = dataPath + "/" + createFileName( iRequest.getObservation().getDate(), "arletty",shortName ); 
     283            fileArletty = dataPath + "/" + createFileName( iRequest.getObservation().getDate(), "arletty", shortName ); 
    281284            fileECMWF = dataPath + "/" + createFileName( iRequest.getObservation().getDate(), "ecmwf", shortName ); 
    282285 
     
    294297        tapas.addContent( listRequest ); 
    295298 
    296         String commandePath = servicePath+"/"+fTapas.getId(); 
    297         createXMLFile( document, commandePath,prop ); 
     299        String commandePath = servicePath + "/" + fTapas.getId(); 
     300        createXMLFile( document, commandePath, prop ); 
    298301 
    299302 
     
    307310 
    308311        final String usersPath = prop.getProperty( "users_path" ); 
    309         String commande = "mkdir -p "+usersPath+"/"+user.getEmail(); 
     312        String commande = "mkdir -p " + usersPath + "/" + user.getEmail(); 
    310313 
    311314        try 
     
    318321        } 
    319322 
    320         EtherHelper.pause(4000); 
     323        EtherHelper.pause( 4000 ); 
    321324 
    322325        //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(); 
    324327 
    325328        try 
     
    332335        } 
    333336 
    334         EtherHelper.pause(4000); 
     337        EtherHelper.pause( 4000 ); 
    335338 
    336339    } 
     
    340343            throws ServiceException 
    341344    { 
    342         String commande=""; 
    343         String commandePath=prop.getProperty( "service_path" )+"/"+repCommande+"/"; 
     345        String commande = ""; 
     346        String commandePath = prop.getProperty( "service_path" ) + "/" + repCommande + "/"; 
    344347 
    345348        //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; 
    347350 
    348351        try 
     
    355358        } 
    356359 
    357         EtherHelper.pause(7000); 
     360        EtherHelper.pause( 7000 ); 
    358361 
    359362        //final String fichier = commandePath+"commande.txt"; 
     
    370373        }*/ 
    371374 
    372         EtherHelper.pause(7000); 
    373  
    374         commande="chmod 777 -R "+commandePath; 
     375        EtherHelper.pause( 7000 ); 
     376 
     377        commande = "chmod 777 -R " + commandePath; 
    375378 
    376379        try 
     
    383386        } 
    384387 
    385         EtherHelper.pause(7000); 
     388        EtherHelper.pause( 7000 ); 
    386389 
    387390        //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(); 
    389392 
    390393        /*PrintWriter out  = null; 
     
    406409        try 
    407410        { 
    408             EtherHelper.execProcess(commande); 
     411            EtherHelper.execProcess( commande ); 
    409412        } 
    410413        catch( FormattedException e ) 
    411414        { 
    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         String heure; 
    424         int val; 
    425  
    426  
    427         val = Math.abs( Integer.parseInt( heure ) ); 
    428  
    429         return heure; 
    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{ 
     426String heure; 
     427int val; 
     428 
     429 
     430val = Math.abs( Integer.parseInt( heure ) ); 
     431 
     432return heure; 
     433}                    */ 
    431434 
    432435    public String createFileName( String date, String type, String nomCourt ) 
     
    436439        String annee = date.substring( 0, 4 ); 
    437440        //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 = ""; 
    442445 
    443446        Calendar cal = Calendar.getInstance(); 
    444447 
    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        { 
    457463            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"; 
    463469 
    464470        //+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"; 
    477483 
    478484        return fileName; 
     
    487493            try 
    488494            { 
    489                 EtherHelper.execProcess( "mkdir -p "+commandePath); 
     495                EtherHelper.execProcess( "mkdir -p " + commandePath ); 
    490496            } 
    491497            catch( FormattedException e ) 
     
    494500            } 
    495501 
    496             EtherHelper.pause(5000); 
     502            EtherHelper.pause( 5000 ); 
    497503 
    498504 
     
    506512            } */ 
    507513 
    508             final String fichier = commandePath+"/"+"request.xml"; 
     514            final String fichier = commandePath + "/" + "request.xml"; 
    509515 
    510516            //On utilise ici un affichage classique avec getPrettyFormat() 
     
    556562        try 
    557563        { 
    558             return _tapasRequestDAO.getNumRequest()+1; 
     564            return _tapasRequestDAO.getNumRequest() + 1; 
    559565        } 
    560566        catch( PersistenceException e ) 
     
    573579        try 
    574580        { 
    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 ); 
    578584            return _tapasRequestDAO.insert( ntp ); 
    579585        } 
  • tapas/web/project/formTapas_script.jsp

    r515 r524  
    637637 
    638638            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(); 
    640640            observation.observatory = observatory; 
    641641 
Note: See TracChangeset for help on using the changeset viewer.