Changeset 419


Ignore:
Timestamp:
03/19/12 17:06:58 (12 years ago)
Author:
rboipsl
Message:

creation listes dans form
creation class Observatory

Location:
tapas
Files:
2 added
1 deleted
11 edited
1 copied
3 moved

Legend:

Unmodified
Added
Removed
  • tapas/Tapas.iml

    r385 r419  
    1919          <root url="file://$MODULE_DIR$/web" relative="/" /> 
    2020        </webroots> 
     21        <sourceRoots> 
     22          <root url="file://$MODULE_DIR$/work" /> 
     23        </sourceRoots> 
    2124      </configuration> 
    2225    </facet> 
     
    2427  <component name="NewModuleRootManager" inherit-compiler-output="true"> 
    2528    <exclude-output /> 
    26     <content url="file://$MODULE_DIR$"> 
    27       <sourceFolder url="file://$MODULE_DIR$/work" isTestSource="false" /> 
    28     </content> 
     29    <content url="file://$MODULE_DIR$" /> 
    2930    <orderEntry type="inheritedJdk" /> 
    3031    <orderEntry type="sourceFolder" forTests="false" /> 
  • tapas/domain/Domain.iml

    r385 r419  
    1111    <orderEntry type="sourceFolder" forTests="false" /> 
    1212    <orderEntry type="library" name="lib_common" level="project" /> 
     13    <orderEntry type="module" module-name="Common" /> 
    1314  </component> 
    1415</module> 
  • tapas/domain/interface/com/ether/FileFormat.java

    r416 r419  
    1 package com.ether.user; 
     1package com.ether; 
    22 
    33/** 
    4  * User: vmipsl 
    5  * Date: 12 march 2012 
     4 * User: rboipsl 
     5 * Date: 16 march 2012 
    66 */ 
    7 public enum UserRole 
     7public enum FileFormat 
    88{ 
    9     USER, 
    10     ADMINISTRATOR, 
     9    ASCII, 
     10    FITS, 
     11    NETCDF 
    1112} 
  • tapas/domain/interface/com/ether/tapas/Observatory.java

    r400 r419  
    44 
    55/** 
    6  * @author vmipsl 
    7  * @date 08 march 2012 
     6 * @author rboipsl 
     7 * @date 19 march 2012 
    88 */ 
    99public class Observatory 
    1010{ 
     11    @NotNull 
     12    public String getId() 
     13    { 
     14        return _id; 
     15    } 
     16 
     17    public void setId( @NotNull final String id ) 
     18    { 
     19        _id = id; 
     20    } 
     21 
    1122    @NotNull 
    1223    public String getName() 
     
    5465 
    5566    @NotNull 
     67    private String _id; 
     68    @NotNull 
    5669    private String _name; 
    5770    @NotNull 
  • tapas/persistence/implementation/com/ether/dao/Observatory.hbm.xml

    r418 r419  
    44<hibernate-mapping default-cascade="save-update" auto-import="false"> 
    55 
    6         <class name="com.ether.Plateform" table="plateforme"> 
     6        <class name="com.ether.tapas.Observatory" table="observatory"> 
    77 
    88                <id name="id"> 
    9                         <column name="plateforme_id" /> 
     9                        <column name="observatory_id" /> 
    1010                        <generator class="increment" /> 
    1111 
     
    1616 
    1717                <property name="name"> 
    18                         <column name="plateforme_nom"/> 
     18                        <column name="observatory_name"/> 
    1919                </property> 
     20 
     21        <property name="latitude"> 
     22            <column name="observatory_latitude"/> 
     23        </property> 
     24 
     25        <property name="longitude"> 
     26             <column name="observatory_longitude"/> 
     27        </property> 
     28 
     29        <property name="altitude"> 
     30              <column name="observatory_altitude"/> 
     31        </property> 
    2032 
    2133        </class> 
  • tapas/persistence/implementation/com/ether/dao/ObservatoryDAOImpl.java

    r418 r419  
    33import com.ether.PersistenceException; 
    44import com.ether.Plateform; 
     5import com.ether.tapas.Observatory; 
    56import org.hibernate.criterion.DetachedCriteria; 
    67import org.hibernate.criterion.Restrictions; 
     
    1516 * Example for a DAO 
    1617 */ 
    17 public class PlateformDAOImpl 
    18         extends DomainAccessObjectImpl<Plateform, Integer> 
    19         implements PlateformDAO 
     18public class ObservatoryDAOImpl 
     19        extends DomainAccessObjectImpl<Observatory, Integer> 
     20        implements ObservatoryDAO 
    2021{ 
    21     protected PlateformDAOImpl() 
     22    protected ObservatoryDAOImpl() 
    2223    { 
    23         super( Plateform.class ); 
     24        super( Observatory.class ); 
    2425    } 
    2526 
    26     @Nullable 
    27     public Plateform getPlateformById( @NotNull final Integer plateformId ) 
     27//    @Nullable 
     28//    public Observatory getPlateformById( @NotNull final Integer plateformId ) 
     29//            throws PersistenceException 
     30//    { 
     31//        final DetachedCriteria criteria = DetachedCriteria.forClass( Plateform.class ) 
     32//                .add( Restrictions.idEq( plateformId ) ); 
     33// 
     34//        return selectByCriteria( Plateform.class, criteria ); 
     35//    } 
     36 
     37 
     38    @NotNull 
     39    public List<Observatory> getAllObservatories() 
    2840            throws PersistenceException 
    2941    { 
    30         final DetachedCriteria criteria = DetachedCriteria.forClass( Plateform.class ) 
    31                 .add( Restrictions.idEq( plateformId ) ); 
    32  
    33         return selectByCriteria( Plateform.class, criteria ); 
    34     } 
    35  
    36     @NotNull 
    37     public List<Plateform> getAllPlateforms() 
    38             throws PersistenceException 
    39     { 
    40         final DetachedCriteria criteria = DetachedCriteria.forClass( Plateform.class ); 
    41         return selectAllByCriteria( Plateform.class, criteria ); 
     42        final DetachedCriteria criteria = DetachedCriteria.forClass( Observatory.class ); 
     43        return selectAllByCriteria( Observatory.class, criteria ); 
    4244    } 
    4345} 
  • tapas/persistence/implementation/dao-context.xml

    r412 r419  
    44<!-- Application context DAO layer --> 
    55<beans> 
    6     <bean id="refPlateformDAO" class="com.ether.dao.PlateformDAOImpl"> 
     6    <bean id="refPlateformDAO" class="com.ether.dao.ObservatoryDAOImpl"> 
    77        <property name="sessionFactory"> 
    88            <ref bean="sessionFactory"/> 
  • tapas/service/implementation/com/ether/TapasServiceImpl.java

    r412 r419  
    11package com.ether; 
    22 
    3 import com.ether.dao.PlateformDAO; 
     3import com.ether.dao.ObservatoryDAO; 
     4import com.ether.tapas.Observatory; 
    45import com.ether.tapas.Request; 
    56import com.ether.tapas.Tapas; 
     
    8485    } 
    8586 
    86     // TODO : supprimer cette méthode --> EXEMPLE 
     87    // list tous observatoires 
    8788    @Nullable 
    8889    @Transactional(readOnly = true) 
    89     public List<Plateform> getAllPlateforms() 
     90    public List<Observatory> getAllObservatories() 
    9091            throws ServiceException 
    9192    { 
    9293        try 
    9394        { 
    94             return _plateformDAO.getAllPlateforms(); 
     95            return _observatoryDAO.getAllObservatories(); 
    9596        } 
    9697        catch( PersistenceException e ) 
    9798        { 
    98             throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e ); 
     99            throw new ServiceException( ServiceException.ServiceCode.OBSERVATORY_NOT_FOUND, e ); 
    99100        } 
    100101    } 
    101102 
    102     // TODO : supprimer cette méthode --> EXEMPLE 
    103     @Nullable 
    104     @Transactional(readOnly = true) 
    105     public Plateform getPlateformById( @Nullable final Integer plateformId ) 
    106             throws ServiceException 
     103 
     104    @Required 
     105    public void setObservatoryDAO( final ObservatoryDAO observatoryDAO ) 
    107106    { 
    108         if( null == plateformId ) 
    109             return null; 
    110         try 
    111         { 
    112             return _plateformDAO.getPlateformById( plateformId ); 
    113         } 
    114         catch( PersistenceException e ) 
    115         { 
    116             throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e ); 
    117         } 
    118     } 
    119  
    120     // TODO : supprimer cette méthode --> EXEMPLE 
    121     @Required 
    122     public void setPlateformDAO( final PlateformDAO plateformDAO ) 
    123     { 
    124         _plateformDAO = plateformDAO; 
     107        _observatoryDAO = observatoryDAO; 
    125108    } 
    126109 
    127110    private static final Log LOGGER = LogFactory.getLog( TapasServiceImpl.class ); 
    128111 
    129     // TODO : supprimer ces DAO --> EXEMPLES 
    130     private PlateformDAO _plateformDAO; 
     112    private ObservatoryDAO _observatoryDAO; 
    131113} 
  • tapas/service/interface/com/ether/ServiceException.java

    r410 r419  
    2121    { 
    2222 
    23         PERSISTENCE,  
    24         PLATEFORM_NOT_FOUND, 
     23        PERSISTENCE, 
     24        OBSERVATORY_NOT_FOUND, 
    2525        USER_NOT_FOUND, 
    2626    } 
  • tapas/service/interface/com/ether/TapasService.java

    r412 r419  
    11package com.ether; 
    22 
     3import com.ether.tapas.Observatory; 
    34import com.ether.tapas.Tapas; 
    45import org.jdom.Document; 
     
    1819 
    1920    public void createXMLFile( final String fichier, final Document document ); 
     21 
     22    public List<Observatory> getAllObservatories() throws ServiceException; 
    2023} 
  • tapas/web/project/formTapas.jsp

    r406 r419  
    77<tiles:insert page="/resources/templates/templateEther.jsp" flush="true"> 
    88 
    9     <tiles:put name="insertCss" type="string"/> 
     9    <tiles:put name="insertCss" type="string"> 
     10        <ether:htmlCss cssFile="select"/> 
     11    </tiles:put> 
    1012    <tiles:put name="insertJsOrJsp" type="string"> 
    1113        <ether:htmlJs jsFile="library/jquery.json-2.3"/> 
     14        <ether:htmlJs jsFile="classesForJQuery/Select"/> 
    1215        <ether:htmlJsp jspFile="formTapas_script"/> 
    1316    </tiles:put> 
     
    3336            tapasTexts["<%=WebException.WebCode.ERROR_JSON_TAPAS_IS_NULL%>"] = "<spring:message code="error.ERROR_JSON_TAPAS_IS_NULL"/>"; 
    3437 
    35             var interfaceTapas = new InterfaceTapas(); 
     38            var interfaceTapas = new InterfaceTapas(${jSonFileFormats},${jSonYesNos}); 
    3639        </script> 
    3740 
  • tapas/web/project/formTapas_script.jsp

    r415 r419  
    22    var InterfaceTapas = Class.create( { 
    33 
    4         initialize: function() 
     4        initialize: function(jsonFileFormats,jsonYesNos) 
    55        { 
    66            /** *********** CONTAINERS *********** **/ 
     
    88            this.containerErrors = $( "#errors" ); 
    99 
     10            this.jsonFileFormats = jsonFileFormats || null; 
     11            this.jsonYesNos = jsonYesNos || null; 
     12 
    1013            this.containerErrors.hide(); 
     14 
    1115            this.createForm(); 
    1216        }, 
    1317 
     18 
     19 
    1420        // CREATES ******************************************************** 
     21        createTr: function(texte, inputId, container) 
     22        { 
     23            var tr=$( document.createElement("tr") ); 
     24            var td1=$( document.createElement("td") ); 
     25            var td2=$( document.createElement("td") ); 
     26            var input=$( document.createElement("input") ); 
     27 
     28 
     29            input.attr({id: inputId}); 
     30            td1.html(texte); 
     31            tr.append(td1); 
     32            td2.append(input); 
     33            tr.append(td2); 
     34            container.append(tr); 
     35        }, 
     36 
     37 
     38        createTrList: function(texte, inputId, container, type) 
     39                { 
     40                    var tr=$( document.createElement("tr") ); 
     41                    var td1=$( document.createElement("td") ); 
     42                    var td2=$( document.createElement("td") ); 
     43                    var input=$( document.createElement("input") ); 
     44 
     45 
     46                    input.attr({id: inputId}); 
     47                    td1.html(texte); 
     48                    tr.append(td1); 
     49                    if (type == 'format') this.displayFileFormats(td2); 
     50                    else if (type == 'yesno') this.displayYesNo(td2); 
     51 
     52                    tr.append(td2); 
     53                    container.append(tr); 
     54                }, 
     55 
     56 
    1557        createForm: function() 
    1658        { 
    17             // Create button elements 
    18             this.input1 = $( document.createElement( "input" ) ); 
    19             var input2 = $( document.createElement( "input" ) ); 
    20  
    21             this.input1.attr( {id:"1"} ); 
    22             this.containerForm.append( this.input1 ); 
    23  
    24             input2.attr( {id:"2"} ); 
    25             this.containerForm.append( input2 ); 
    26  
     59 
     60            //Creation div 
     61            var divPreference=$( document.createElement("div") ); 
     62            var tabPreference=$( document.createElement("table") ); 
     63 
     64            this.createTrList("File format", "p1", tabPreference, 'format'); 
     65            this.createTr("Rayleigh extinction", "p2", tabPreference); 
     66            this.createTrList("H20 extinction", "p3", tabPreference, 'yesno'); 
     67            this.createTrList("O3 extinction", "p4", tabPreference, 'yesno'); 
     68            this.createTrList("O2 extinction", "p5", tabPreference, 'yesno'); 
     69            this.createTrList("CO2 extinction", "p6", tabPreference, 'yesno'); 
     70 
     71            divPreference.append( tabPreference ); 
     72            this.containerForm.append( divPreference ); 
     73 
     74            //jQuery.proxy permet d'envoyer le contexte this courant 
    2775            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 )} ); 
    2876 
    2977        }, 
     78 
     79 
    3080 
    3181        // REQUESTS ******************************************************** 
     
    59109        }, 
    60110 
     111 
    61112        // OTHERS ******************************************************** 
     113        displayFileFormats: function(container) 
     114        { 
     115            var paramSelect = new Object(); 
     116            paramSelect.id = "select_formats"; 
     117            paramSelect.parent = container; 
     118            this.selectFormats = new Select( paramSelect ); 
     119            jQuery.each( this.jsonFileFormats, jQuery.proxy( function ( i, jsonFileFormat ) 
     120            { 
     121                this.selectFormats.add( jsonFileFormat.value, jsonFileFormat.text ); 
     122            }, this ) ); 
     123            this.selectFormats.selectFirst( false ); 
     124        }, 
     125 
     126 
     127        displayYesNo: function(container,name) 
     128        { 
     129            var paramSelect = new Object(); 
     130            paramSelect.id = "select_"+name; 
     131            paramSelect.parent = container; 
     132            this.selectYesNos = new Select( paramSelect ); 
     133            jQuery.each( this.jsonYesNos, jQuery.proxy( function ( i, jsonYesNo ) 
     134            { 
     135                this.selectYesNos.add( jsonYesNo.value, jsonYesNo.text ); 
     136            }, this ) ); 
     137            this.selectYesNos.selectFirst( false ); 
     138        }, 
     139 
     140 
    62141        showErrors: function( result ) 
    63142        { 
  • tapas/web/src/com/ether/Controller.java

    r416 r419  
    55import com.ether.annotation.ParamName; 
    66import com.ether.annotation.UseJSON; 
     7import com.ether.tapas.Observatory; 
    78import com.ether.tapas.Tapas; 
     9import com.ether.user.UserRole; 
    810import net.sf.json.JSONObject; 
    911import org.apache.commons.logging.Log; 
    1012import org.apache.commons.logging.LogFactory; 
    1113 
     14import java.util.ArrayList; 
    1215import java.util.HashMap; 
     16import java.util.List; 
    1317import java.util.Map; 
    1418 
     
    2529    /** *********************************************************** **/ 
    2630    @ControllerMethod(view = VIEW_FORM_TAPAS, loginMandatory = true, defaultView = VIEW_INDEX) 
    27     public Map<String, Object> viewForm() 
     31    public JSONObject viewForm() 
    2832            throws WebException 
    2933    { 
    30         return new HashMap<String, Object>(); 
     34 
     35        try 
     36        { 
     37            final List<Observatory> allObservatories = getTapasService().getAllObservatories(); 
     38 
     39            final JSONObject jsonObject = new JSONObject(); 
     40            jsonObject.put( "jSonFileFormats", getJSONFileFormat() ); 
     41            jsonObject.put( "jSonYesNos", getJSONYesNo() ); 
     42            jsonObject.put( "jSonObservatories", allObservatories ); 
     43            return jsonObject; 
     44        } 
     45        catch( ServiceException e ) 
     46        { 
     47            throw new WebException( WebException.WebCode.ERROR_NO_OBSERVATORY_FOUND, e ); 
     48        } 
     49 
    3150    } 
     51 
     52 
     53 
     54 
    3255 
    3356    /** *********************************************************** **/ 
     
    4972    } 
    5073 
     74    private List<JSONObject> getJSONFileFormat() 
     75    { 
     76        final FileFormat[] fileFormats = FileFormat.values(); 
     77 
     78        final List<JSONObject> jsonFileFormats = new ArrayList<JSONObject>( fileFormats.length ); 
     79 
     80        for( final FileFormat fileFormat : fileFormats ) 
     81        { 
     82            final JSONObject jsonFileFormat = new JSONObject(); 
     83            jsonFileFormat .put( "text", fileFormat.name() ); 
     84            jsonFileFormat .put( "value", fileFormat.name() ); 
     85            jsonFileFormats.add( jsonFileFormat  ); 
     86        } 
     87        return jsonFileFormats; 
     88    } 
     89 
     90    private List<JSONObject> getJSONYesNo() 
     91    { 
     92        final YesNo[] yesNos = YesNo.values(); 
     93 
     94        final List<JSONObject> jsonYesNos = new ArrayList<JSONObject>( yesNos.length ); 
     95 
     96        for( final YesNo yesNo : yesNos ) 
     97        { 
     98            final JSONObject jsonYesNo = new JSONObject(); 
     99            jsonYesNo .put( "text", yesNo.name() ); 
     100            jsonYesNo .put( "value", yesNo.name() ); 
     101            jsonYesNos.add( jsonYesNo ); 
     102        } 
     103        return jsonYesNos; 
     104    } 
     105 
    51106    private static final Log LOGGER = LogFactory.getLog( Controller.class ); 
    52107 
  • tapas/web/src/com/ether/WebException.java

    r416 r419  
    4444        USER_ALREADY_EXISTS, 
    4545        ERROR_ENCRYPT_PASSWORD, 
    46         ERROR_EMAIL_CANNOT_BE_SEND 
     46        ERROR_EMAIL_CANNOT_BE_SEND, 
     47        ERROR_NO_OBSERVATORY_FOUND 
    4748    } 
    4849 
Note: See TracChangeset for help on using the changeset viewer.