Changeset 419
- Timestamp:
- 03/19/12 17:06:58 (12 years ago)
- Location:
- tapas
- Files:
-
- 2 added
- 1 deleted
- 11 edited
- 1 copied
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
tapas/Tapas.iml
r385 r419 19 19 <root url="file://$MODULE_DIR$/web" relative="/" /> 20 20 </webroots> 21 <sourceRoots> 22 <root url="file://$MODULE_DIR$/work" /> 23 </sourceRoots> 21 24 </configuration> 22 25 </facet> … … 24 27 <component name="NewModuleRootManager" inherit-compiler-output="true"> 25 28 <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$" /> 29 30 <orderEntry type="inheritedJdk" /> 30 31 <orderEntry type="sourceFolder" forTests="false" /> -
tapas/domain/Domain.iml
r385 r419 11 11 <orderEntry type="sourceFolder" forTests="false" /> 12 12 <orderEntry type="library" name="lib_common" level="project" /> 13 <orderEntry type="module" module-name="Common" /> 13 14 </component> 14 15 </module> -
tapas/domain/interface/com/ether/FileFormat.java
r416 r419 1 package com.ether .user;1 package com.ether; 2 2 3 3 /** 4 * User: vmipsl5 * Date: 1 2march 20124 * User: rboipsl 5 * Date: 16 march 2012 6 6 */ 7 public enum UserRole7 public enum FileFormat 8 8 { 9 USER, 10 ADMINISTRATOR, 9 ASCII, 10 FITS, 11 NETCDF 11 12 } -
tapas/domain/interface/com/ether/tapas/Observatory.java
r400 r419 4 4 5 5 /** 6 * @author vmipsl7 * @date 08march 20126 * @author rboipsl 7 * @date 19 march 2012 8 8 */ 9 9 public class Observatory 10 10 { 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 11 22 @NotNull 12 23 public String getName() … … 54 65 55 66 @NotNull 67 private String _id; 68 @NotNull 56 69 private String _name; 57 70 @NotNull -
tapas/persistence/implementation/com/ether/dao/Observatory.hbm.xml
r418 r419 4 4 <hibernate-mapping default-cascade="save-update" auto-import="false"> 5 5 6 <class name="com.ether. Plateform" table="plateforme">6 <class name="com.ether.tapas.Observatory" table="observatory"> 7 7 8 8 <id name="id"> 9 <column name=" plateforme_id" />9 <column name="observatory_id" /> 10 10 <generator class="increment" /> 11 11 … … 16 16 17 17 <property name="name"> 18 <column name=" plateforme_nom"/>18 <column name="observatory_name"/> 19 19 </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> 20 32 21 33 </class> -
tapas/persistence/implementation/com/ether/dao/ObservatoryDAOImpl.java
r418 r419 3 3 import com.ether.PersistenceException; 4 4 import com.ether.Plateform; 5 import com.ether.tapas.Observatory; 5 6 import org.hibernate.criterion.DetachedCriteria; 6 7 import org.hibernate.criterion.Restrictions; … … 15 16 * Example for a DAO 16 17 */ 17 public class PlateformDAOImpl18 extends DomainAccessObjectImpl< Plateform, Integer>19 implements PlateformDAO18 public class ObservatoryDAOImpl 19 extends DomainAccessObjectImpl<Observatory, Integer> 20 implements ObservatoryDAO 20 21 { 21 protected PlateformDAOImpl()22 protected ObservatoryDAOImpl() 22 23 { 23 super( Plateform.class );24 super( Observatory.class ); 24 25 } 25 26 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() 28 40 throws PersistenceException 29 41 { 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 ); 42 44 } 43 45 } -
tapas/persistence/implementation/dao-context.xml
r412 r419 4 4 <!-- Application context DAO layer --> 5 5 <beans> 6 <bean id="refPlateformDAO" class="com.ether.dao. PlateformDAOImpl">6 <bean id="refPlateformDAO" class="com.ether.dao.ObservatoryDAOImpl"> 7 7 <property name="sessionFactory"> 8 8 <ref bean="sessionFactory"/> -
tapas/service/implementation/com/ether/TapasServiceImpl.java
r412 r419 1 1 package com.ether; 2 2 3 import com.ether.dao.PlateformDAO; 3 import com.ether.dao.ObservatoryDAO; 4 import com.ether.tapas.Observatory; 4 5 import com.ether.tapas.Request; 5 6 import com.ether.tapas.Tapas; … … 84 85 } 85 86 86 // TODO : supprimer cette méthode --> EXEMPLE87 // list tous observatoires 87 88 @Nullable 88 89 @Transactional(readOnly = true) 89 public List< Plateform> getAllPlateforms()90 public List<Observatory> getAllObservatories() 90 91 throws ServiceException 91 92 { 92 93 try 93 94 { 94 return _ plateformDAO.getAllPlateforms();95 return _observatoryDAO.getAllObservatories(); 95 96 } 96 97 catch( PersistenceException e ) 97 98 { 98 throw new ServiceException( ServiceException.ServiceCode. PLATEFORM_NOT_FOUND, e );99 throw new ServiceException( ServiceException.ServiceCode.OBSERVATORY_NOT_FOUND, e ); 99 100 } 100 101 } 101 102 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 ) 107 106 { 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; 125 108 } 126 109 127 110 private static final Log LOGGER = LogFactory.getLog( TapasServiceImpl.class ); 128 111 129 // TODO : supprimer ces DAO --> EXEMPLES 130 private PlateformDAO _plateformDAO; 112 private ObservatoryDAO _observatoryDAO; 131 113 } -
tapas/service/interface/com/ether/ServiceException.java
r410 r419 21 21 { 22 22 23 PERSISTENCE, 24 PLATEFORM_NOT_FOUND,23 PERSISTENCE, 24 OBSERVATORY_NOT_FOUND, 25 25 USER_NOT_FOUND, 26 26 } -
tapas/service/interface/com/ether/TapasService.java
r412 r419 1 1 package com.ether; 2 2 3 import com.ether.tapas.Observatory; 3 4 import com.ether.tapas.Tapas; 4 5 import org.jdom.Document; … … 18 19 19 20 public void createXMLFile( final String fichier, final Document document ); 21 22 public List<Observatory> getAllObservatories() throws ServiceException; 20 23 } -
tapas/web/project/formTapas.jsp
r406 r419 7 7 <tiles:insert page="/resources/templates/templateEther.jsp" flush="true"> 8 8 9 <tiles:put name="insertCss" type="string"/> 9 <tiles:put name="insertCss" type="string"> 10 <ether:htmlCss cssFile="select"/> 11 </tiles:put> 10 12 <tiles:put name="insertJsOrJsp" type="string"> 11 13 <ether:htmlJs jsFile="library/jquery.json-2.3"/> 14 <ether:htmlJs jsFile="classesForJQuery/Select"/> 12 15 <ether:htmlJsp jspFile="formTapas_script"/> 13 16 </tiles:put> … … 33 36 tapasTexts["<%=WebException.WebCode.ERROR_JSON_TAPAS_IS_NULL%>"] = "<spring:message code="error.ERROR_JSON_TAPAS_IS_NULL"/>"; 34 37 35 var interfaceTapas = new InterfaceTapas( );38 var interfaceTapas = new InterfaceTapas(${jSonFileFormats},${jSonYesNos}); 36 39 </script> 37 40 -
tapas/web/project/formTapas_script.jsp
r415 r419 2 2 var InterfaceTapas = Class.create( { 3 3 4 initialize: function( )4 initialize: function(jsonFileFormats,jsonYesNos) 5 5 { 6 6 /** *********** CONTAINERS *********** **/ … … 8 8 this.containerErrors = $( "#errors" ); 9 9 10 this.jsonFileFormats = jsonFileFormats || null; 11 this.jsonYesNos = jsonYesNos || null; 12 10 13 this.containerErrors.hide(); 14 11 15 this.createForm(); 12 16 }, 13 17 18 19 14 20 // 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 15 57 createForm: function() 16 58 { 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 27 75 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 )} ); 28 76 29 77 }, 78 79 30 80 31 81 // REQUESTS ******************************************************** … … 59 109 }, 60 110 111 61 112 // 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 62 141 showErrors: function( result ) 63 142 { -
tapas/web/src/com/ether/Controller.java
r416 r419 5 5 import com.ether.annotation.ParamName; 6 6 import com.ether.annotation.UseJSON; 7 import com.ether.tapas.Observatory; 7 8 import com.ether.tapas.Tapas; 9 import com.ether.user.UserRole; 8 10 import net.sf.json.JSONObject; 9 11 import org.apache.commons.logging.Log; 10 12 import org.apache.commons.logging.LogFactory; 11 13 14 import java.util.ArrayList; 12 15 import java.util.HashMap; 16 import java.util.List; 13 17 import java.util.Map; 14 18 … … 25 29 /** *********************************************************** **/ 26 30 @ControllerMethod(view = VIEW_FORM_TAPAS, loginMandatory = true, defaultView = VIEW_INDEX) 27 public Map<String, Object>viewForm()31 public JSONObject viewForm() 28 32 throws WebException 29 33 { 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 31 50 } 51 52 53 54 32 55 33 56 /** *********************************************************** **/ … … 49 72 } 50 73 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 51 106 private static final Log LOGGER = LogFactory.getLog( Controller.class ); 52 107 -
tapas/web/src/com/ether/WebException.java
r416 r419 44 44 USER_ALREADY_EXISTS, 45 45 ERROR_ENCRYPT_PASSWORD, 46 ERROR_EMAIL_CANNOT_BE_SEND 46 ERROR_EMAIL_CANNOT_BE_SEND, 47 ERROR_NO_OBSERVATORY_FOUND 47 48 } 48 49
Note: See TracChangeset
for help on using the changeset viewer.