Changeset 440


Ignore:
Timestamp:
03/26/12 17:00:15 (12 years ago)
Author:
rboipsl
Message:

ajout anotations
usermandatory

Location:
tapas
Files:
9 edited
2 copied

Legend:

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

    r416 r440  
    1919        _isLoginMandatory = annotation.loginMandatory(); 
    2020        _isRequestMandatory = annotation.requestMandatory(); 
     21        _isUserMandatory = annotation.userMandatory(); 
    2122        _isBackofficeMethod = annotation.backofficeMethod(); 
    2223        _params = new ArrayList<ParamDescription>(); 
     
    99100    } 
    100101 
     102 
    101103    public void setRequestMandatory( final Boolean requestMandatory ) 
    102104    { 
    103105        _isRequestMandatory = requestMandatory; 
     106    } 
     107 
     108    public Boolean isUserMandatory() 
     109    { 
     110        return _isUserMandatory; 
     111    } 
     112 
     113    public void setUserMandatory( final Boolean userMandatory ) 
     114    { 
     115        _isUserMandatory = userMandatory; 
    104116    } 
    105117 
     
    136148    private Boolean _isLoginMandatory; 
    137149    private Boolean _isRequestMandatory; 
     150    private Boolean _isUserMandatory; 
    138151    private Boolean _isBackofficeMethod; 
    139152    @Nullable 
  • tapas/common/implementation/com/ether/annotation/ControllerMethod.java

    r416 r440  
    2121    boolean requestMandatory() default false; 
    2222 
     23    boolean userMandatory() default false; 
     24 
    2325    boolean backofficeMethod() default false; 
    2426 
  • tapas/common/implementation/com/ether/annotation/UserMandatory.java

    r434 r440  
    88@Retention(RetentionPolicy.RUNTIME) 
    99@Target(ElementType.PARAMETER) 
    10 public @interface RequestMandatory 
     10public @interface UserMandatory 
    1111{ 
    1212} 
  • tapas/domain/interface/com/ether/SpectralUnit.java

    r434 r440  
    11package com.ether; 
     2 
     3import java.lang.reflect.Field; 
    24 
    35/** 
     
    57 * Date: 19 march 2012 
    68 */ 
    7 public enum YesNo 
     9public enum SpectralUnit 
    810{ 
    9     YES, 
    10     NO 
     11    NM, 
     12    CM 
     13 
     14    /*"Vacuum Wavelength (nm)", 
     15    'Standard Wavelength (nm)', 
     16    'Wavenumber (cm-1)'*/ 
     17 
    1118} 
  • tapas/service/implementation/com/ether/TapasServiceImpl.java

    r420 r440  
    3636        final Element tapas = new Element( "tapas" ); 
    3737        final Element request = new Element( "request" ); 
    38         final Element preferences = new Element( "preferences" ); 
    39         final Element format = new Element( "format" ); 
    40         final Element rayleighExtinction = new Element( "rayleigh_extinction" ); 
     38 
    4139 
    4240        //On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer 
     
    5149        for( final Request iRequest : requests ) 
    5250        { 
     51            // Id de la request 
    5352            final Attribute idR = new Attribute( "Id", iRequest.getId().toString() ); 
    5453            request.setAttribute( idR ); 
    5554 
    56             tapas.addContent( request ); 
    57             request.addContent( preferences ); 
     55            // PREFERENCES 
     56            final Element preferences = new Element( "preferences" ); 
    5857 
     58            // Element format 
     59            final Element format = new Element( "format" ); 
    5960            final Attribute validF = new Attribute( "valid", iRequest.getPreference().getFormat().getFirstValue() ); 
    6061            format.setAttribute( validF ); 
    6162            format.setText( iRequest.getPreference().getFormat().getSecondValue() ); 
     63            preferences.addContent( format ); 
    6264 
     65            // Element rayleighExtinction 
     66            final Element rayleighExtinction = new Element( "rayleigh_extinction" ); 
    6367            final Attribute validR = new Attribute( "valid", iRequest.getPreference().getRayleighExtinction().getFirstValue() ); 
    6468            rayleighExtinction.setAttribute( validR ); 
    6569            rayleighExtinction.setText( iRequest.getPreference().getRayleighExtinction().getSecondValue() ); 
     70            preferences.addContent( rayleighExtinction ); 
    6671 
     72            // 
     73 
     74            request.addContent( preferences ); 
     75 
     76            // OBSERVATORIES 
     77 
     78 
     79 
     80 
     81            tapas.addContent( request ); 
    6782        } 
    6883 
  • tapas/web/WEB-INF/servlet-context.xml

    r414 r440  
    55       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
    66       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> 
     7 
    78 
    89    <!-- i18n --> 
  • tapas/web/project/formTapas.jsp

    r439 r440  
    2929    <tiles:put name="body" type="string"> 
    3030 
    31         <div id="formulaire"></div> 
     31        <div id="formulaire"> 
     32 
     33        </div> 
    3234 
    3335        <div id="errors"></div> 
     
    3840            tapasTexts["<%=WebException.WebCode.ERROR_JSON_TAPAS_IS_NULL%>"] = "<spring:message code="error.ERROR_JSON_TAPAS_IS_NULL"/>"; 
    3941 
    40             var interfaceTapas = new InterfaceTapas( ${jSonFileFormats}, ${jSonYesNos} ); 
     42            //var interfaceTapas = new InterfaceTapas(${jSonFileFormats},${jSonYesNos},${jSonObservatories},${jSonSelectUnits}); 
     43            var interfaceTapas = new InterfaceTapas(${jSonFileFormats},${jSonYesNos},${jSonObservatories}); 
    4144        </script> 
    4245 
  • tapas/web/project/formTapas_script.jsp

    r439 r440  
    22var InterfaceTapas = Class.create( { 
    33 
    4     initialize: function( jsonFileFormats, jsonYesNos ) 
     4    initialize: function( jsonFileFormats, jsonYesNos, jsonObservatories ) 
    55    { 
    66        /** *********** CONTAINERS *********** **/ 
     
    1010        this.jsonFileFormats = jsonFileFormats || null; 
    1111        this.jsonYesNos = jsonYesNos || null; 
     12        this.jSonObservatories = jsonObservatories || null; 
     13        //this.jSonSelectUnits = jsonSelectUnits || null; 
    1214 
    1315        this.containerErrors.hide(); 
    1416 
    1517        this.createForm(); 
    16         this.createCalendar( this.containerForm ); 
     18 
    1719    }, 
    1820 
     
    2325    { 
    2426        // Create input for date text 
    25         var inputDateId = "observationDate"; 
     27        var inputDateId = "iobservation_date"; 
    2628        var inputDate = $( document.createElement( "input" ) ); 
    2729        inputDate.attr( {id:inputDateId, size:"17"} ); 
     
    6567        var input = $( document.createElement( "input" ) ); 
    6668 
    67  
    6869        input.attr( {id: inputId} ); 
    6970        td1.html( texte ); 
    7071        tr.append( td1 ); 
    7172        if( type == 'format' ) this.displayFileFormats( td2 ); 
    72         else if( type == 'yesno' ) this.displayYesNo( td2 ); 
     73        else if( type == 'yesno' ) this.displayYesNo( td2, inputId ); 
     74        else if( type == 'observatories' ) this.displayObservatories( td2 ); 
     75        else if( type == 'spectralUnit' ) this.displaySpectralUnits( td2 ); 
    7376 
    7477        tr.append( td2 ); 
     
    8083    { 
    8184 
    82         //Creation div 
     85        //Creation div / tab 
    8386        var divPreference = $( document.createElement( "div" ) ); 
    8487        var tabPreference = $( document.createElement( "table" ) ); 
    8588 
    86         this.createTrList( "File format", "p1", tabPreference, 'format' ); 
    87         this.createTr( "Rayleigh extinction", "p2", tabPreference ); 
    88         this.createTrList( "H20 extinction", "p3", tabPreference, 'yesno' ); 
    89         this.createTrList( "O3 extinction", "p4", tabPreference, 'yesno' ); 
    90         this.createTrList( "O2 extinction", "p5", tabPreference, 'yesno' ); 
    91         this.createTrList( "CO2 extinction", "p6", tabPreference, 'yesno' ); 
     89        var divObservation = $( document.createElement( "div" ) ); 
     90        var tabObservation = $( document.createElement( "table" ) ); 
     91 
     92        this.createTrList( "File format", "iformat", tabPreference, 'format' ); 
     93        this.createTr( "Rayleigh extinction", "irextinction", tabPreference ); 
     94        this.createTrList( "H20 extinction", "ih2oe", tabPreference, 'yesno' ); 
     95        this.createTrList( "O3 extinction", "io3e", tabPreference, 'yesno' ); 
     96        this.createTrList( "O2 extinction", "io2e", tabPreference, 'yesno' ); 
     97        this.createTrList( "CO2 extinction", "ico2e", tabPreference, 'yesno' ); 
     98 
     99        this.createTrList( "Observatory", "iobservatory", tabObservation, 'observatories' ); 
     100 
     101 
     102 
     103        this.createCalendar( tabObservation ); 
     104 
     105 
     106 
     107        this.createTr( "Right LOS ascension", "ira", tabObservation ); 
     108        this.createTr( "LOS declension", "ide", tabObservation ); 
     109        this.createTr( "Zenith angle", "iza", tabObservation ); 
     110        // this.createTrList("Spectral unit", "ispectral_choice", tabObservation, 'spectralUnit'); 
     111        this.createTr( "Spectral range", "ispectral_ranger", tabObservation ); 
     112 
    92113 
    93114        divPreference.append( tabPreference ); 
    94115        this.containerForm.append( divPreference ); 
    95116 
     117        divObservation.append( tabObservation ); 
     118        this.containerForm.append( divObservation ); 
     119 
    96120        //jQuery.proxy permet d'envoyer le contexte this courant 
    97121        var submitButton = new Button( {value:tapasTexts["label.submitButton"], parent:this.containerForm, id:"button_submit", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickSubmit, this )} ); 
     
    104128    requestCreateXML: function() 
    105129    { 
    106         var tapasForm = this.createTapasForm(); 
     130        var tapasForm = this.createTapasObject(); 
    107131        //passage de javascript a json grace au jquery 
    108132        var jsonTapasForm = $.toJSON( tapasForm ); 
     
    130154        this.requestCreateXML(); 
    131155    }, 
     156 
    132157 
    133158    // OTHERS ******************************************************** 
     
    160185 
    161186 
     187    displayObservatories: function( container ) 
     188    { 
     189        var paramSelect = new Object(); 
     190        paramSelect.id = "select_observatory"; 
     191        paramSelect.parent = container; 
     192        this.selectObservatories = new Select( paramSelect ); 
     193        //ajouter select vide avec add 
     194        this.selectObservatories.add( "-1", "-- Select an observatory --" ); 
     195        jQuery.each( this.jSonObservatories, jQuery.proxy( function ( i, jsonObservatory ) 
     196        { 
     197            this.selectObservatories.add( jsonObservatory.id, jsonObservatory.name ); 
     198        }, this ) ); 
     199        this.selectObservatories.selectFirst( true ); 
     200    }, 
     201 
     202 
     203    displaySpectralUnits: function( container ) 
     204    { 
     205        var paramSelect = new Object(); 
     206        paramSelect.id = "select_spectral_unit"; 
     207        paramSelect.parent = container; 
     208        this.selectSpectralUnits = new Select( paramSelect ); 
     209        //ajouter select vide avec add 
     210        this.selectSpectralUnits.add( "-1", "-- Select unit --" ); 
     211        jQuery.each( this.jSonSpectralUnit, jQuery.proxy( function ( i, jsonSpectralUnit ) 
     212        { 
     213            this.selectSpectralUnits.add( jsonSpectralUnit.id, jsonSpectralUnit.name ); 
     214        }, this ) ); 
     215        this.selectSpectralUnits.selectFirst( true ); 
     216    }, 
     217 
    162218    showErrors: function( result ) 
    163219    { 
     
    166222    }, 
    167223 
    168     createTapasForm: function() 
     224    createTapasObject: function() 
    169225    { 
    170226        // PREFERENCE 
     
    172228 
    173229        preference.format = new Object(); 
    174         preference.format.firstValue = $( "#1" ).val(); 
    175         preference.format.secondValue = $( "#2" ).val(); 
     230        //toutes les valeurs possibles 
     231        //preference.format.firstValue = $( "#select_formats" ).val(); 
     232        preference.format.firstValue = this.selectFormats.getValues(); 
     233        //la valeur selectionnee 
     234        preference.format.secondValue = this.selectFormats.getValue(); 
     235 
    176236 
    177237        var pair = new Object(); 
    178238        pair.firstValue = "YES,NO"; 
    179         pair.secondValue = "YES"; 
    180  
    181         preference.rayleighExtinction = pair; 
     239        pair.secondValue = this.selectFormats.getValue(); 
     240 
     241        preference.rayleighExtinction = new Object(); 
     242        ; 
    182243        preference.h2oExtinction = pair; 
    183244        preference.o3Extinction = pair; 
     
    188249        // Observatory 
    189250        var observatory = new Object(); 
    190         observatory.name = "SanFernandoObs.RSanFernando"; 
    191  
    192         observatory.longitude = new Object(); 
    193         observatory.longitude.min = "-180"; 
    194         observatory.longitude.max = "180"; 
    195         observatory.longitude.value = -118.491666666667; 
    196  
    197         observatory.latitude = new Object(); 
    198         observatory.latitude.min = "-90"; 
    199         observatory.latitude.max = "90"; 
    200         observatory.latitude.value = 34.3083333333333; 
    201  
    202         observatory.altitude = new Object(); 
    203         observatory.altitude.min = "0"; 
    204         observatory.altitude.max = "10000"; 
    205         observatory.altitude.value = 371; 
     251        //observatory.name = this.selectFormats.name; 
     252 
     253        observatory.longitude = this.longitude.value; 
     254        observatory.latitude = this.latitude.value; 
     255        observatory.altitude = this.altitude.value; 
     256 
    206257 
    207258        // Los 
     
    234285 
    235286        var observation = new Object(); 
    236         observation.date = this.calendarConverter.parse( $( "#observationDate" ).val() ).getTime(); 
     287        observation.date = this.calendarConverter.parse( $( "#iobservation_date" ).val() ).getTime(); 
    237288        observation.observatory = observatory; 
    238289        observation.los = los; 
     
    251302        atmosphere.ecmwfFile = new Array(); 
    252303        atmosphere.ecmwfFile[0] = "/home/ferron/tmp/tapas/ecmwf12.txt"; 
     304 
    253305 
    254306        // REQUEST 
  • tapas/web/resources/css/tapas.css

    r439 r440  
    137137    -moz-border-radius-topright: 0; 
    138138    -webkit-border-radius: 0; /*#E8EFF3*//* #618EAC*/ 
    139     background: -moz-linear-gradient(white, #F6DC12); 
     139    background: -moz-linear-gradient(white, #52251C); 
    140140    background: -webkit-linear-gradient(white, #F6DC12); 
    141     background: -ms-linear-gradient(white, #F6DC12) repeat scroll 0 0 transparent; /*For IE10*/ 
     141    background: -ms-linear-gradient(white,#C03000 ) repeat scroll 0 0 transparent; /*For IE10*/ 
    142142    filter: progid:DXImageTransform.Microsoft.gradient(GradientType = 0, startColorstr = 'white', endColorstr = '#F6DC12'); /*For IE7-8-9*/ 
    143143    min-height: 400px; 
  • tapas/web/src/com/ether/Controller.java

    r420 r440  
    77import com.ether.tapas.Observatory; 
    88import com.ether.tapas.Tapas; 
     9import com.ether.user.User; 
    910import com.ether.user.UserRole; 
    1011import net.sf.json.JSONObject; 
    1112import org.apache.commons.logging.Log; 
    1213import org.apache.commons.logging.LogFactory; 
     14import org.jetbrains.annotations.NotNull; 
    1315 
    1416import java.util.ArrayList; 
     
    3335            throws WebException 
    3436    { 
    35  
    3637        try 
    3738        { 
     
    5859    /** *********************** CALLS ***************************** **/ 
    5960    /** *********************************************************** **/ 
    60     @ControllerMethod(jsonResult = true) 
    61     public JSONObject createUserRequest( @ParamName("jsonTapas") @Mandatory @UseJSON final Tapas javaTapas ) 
     61    @ControllerMethod(jsonResult = true, userMandatory = true) 
     62    public JSONObject createUserRequest( @ParamName("jsonTapas") @Mandatory @UseJSON final Tapas javaTapas, @NotNull final User user ) // TODO rajouter parametre USER 
    6263            throws WebException 
    6364    { 
     
    6566            throw new WebException( WebException.WebCode.ERROR_JSON_TAPAS_IS_NULL, "Serialization error : jsonTapas is null", WebException.getExceptionThrowable() ); 
    6667 
     68        //TODO recuperer le USER via ControllerEther 
     69 
    6770        //appel a createxml 
    68         getTapasService().createXMLRequest( javaTapas ); 
     71        getTapasService().createXMLRequest( javaTapas ); // en 2ieme parametre 
     72 
     73        //appel a runtime 
     74        //mettre une methode dans tapas service pour appel au shell system 
     75 
    6976 
    7077        final JSONObject result = new JSONObject(); 
  • tapas/web/src/com/ether/ControllerEther.java

    r423 r440  
    120120            final String defaultView = ( null != methodDescription.getDefaultView() && !"".equals( methodDescription.getDefaultView() ) ) ? methodDescription.getDefaultView() : methodDescription.getView(); 
    121121 
     122 
    122123            if( methodDescription.isRequestMandatory() ) 
    123                 params[params.length - 1] = request; 
     124                params[params.length - 1] = request; //params = parametre de la methode du Controller 
     125 
    124126 
    125127            if( methodDescription.isLoginMandatory() ) 
     
    128130                if( null == user ) 
    129131                    return new ModelAndView( defaultView, "errors", "login.error.unknown" ); 
     132            } 
     133 
     134            if (methodDescription.isUserMandatory()) { 
     135                final User user = (User) request.getSession().getAttribute( "SES_USER" ); 
     136 
     137                if( null == user ) 
     138                    return new ModelAndView( defaultView, "errors", "login.error.unknown" ); 
     139                else 
     140                    params[params.length - 1] = user; 
     141 
    130142            } 
    131143 
Note: See TracChangeset for help on using the changeset viewer.