Changeset 400
- Timestamp:
- 03/08/12 15:19:16 (12 years ago)
- Location:
- tapas
- Files:
-
- 7 added
- 1 deleted
- 6 edited
- 1 copied
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
tapas/common/implementation/com/ether/JSONHelperImpl.java
r399 r400 13 13 import org.springframework.beans.factory.InitializingBean; 14 14 15 import java.util.AbstractCollection;16 import java.util.ArrayList;17 15 import java.util.Collection; 18 16 import java.util.Collections; 19 import java.util.List;20 17 import java.util.Map; 21 18 … … 78 75 public <T> T fromJSON( @NotNull final JSON json, @NotNull final Class<T> beanClass ) 79 76 { 80 if( json.isArray() )81 {82 final JSONArray jsonArray = JSONArray.fromObject( json, _jsonConfig );83 final Class<? super T> superclass = beanClass.getSuperclass();84 if( superclass.isAssignableFrom( AbstractCollection.class ) )85 {86 final Tapas tapas = new Tapas();87 final List<Request> requests = new ArrayList<Request>();88 for( final Object jsonElement : jsonArray )89 {90 final Request request = fromJSON( (JSON) jsonElement, Request.class );91 requests.add( request );92 }93 tapas.setRequests( requests );94 return (T) tapas;95 }96 //97 // if( beanClass.isArray() )98 // {99 // final Class<?> componentType = beanClass.getComponentType();100 // //json.sf.net does not support Long[] or long[]101 // if( Long.class.equals( componentType ) || Long.TYPE.equals( componentType ) )102 // {103 // final Integer[] integers = (Integer[]) JSONArray.toArray( jsonArray, Integer.class );104 // if( Long.class.equals( componentType ) )105 // {106 // final Long[] resultArray = new Long[integers.length];107 // for( int i = 0; i < integers.length; ++i )108 // resultArray[i] = integers[i].longValue();109 // return (T) resultArray;110 // }111 // if( Long.TYPE.equals( componentType ) )112 // {113 // final long[] resultArray = new long[integers.length];114 // for( int i = 0; i < integers.length; ++i )115 // resultArray[i] = integers[i].longValue();116 // return (T) resultArray;117 // }118 // }119 // return (T) JSONArray.toArray( jsonArray, componentType );120 // }121 // if( beanClass.isAssignableFrom( Collection.class ) )122 // {123 // final TypeVariable<Class<T>>[] typeParameters = beanClass.getTypeParameters();124 // if( null == typeParameters || typeParameters.length != 1 || null == typeParameters[0] )125 // return (T) JSONArray.toCollection( jsonArray );126 // return (T) JSONArray.toCollection( jsonArray, typeParameters[0].getGenericDeclaration() );127 // }128 }129 77 final JSONObject jsonObject = JSONObject.fromObject( json, _jsonConfig ); 130 return (T) JSONObject.toBean( jsonObject, beanClass ); 131 // return (T) JSONObject.toBean( jsonObject, beanClass, _mapClassesForDeserialization.get( beanClass ) ); 78 return (T) JSONObject.toBean( jsonObject, beanClass, _mapClassesForDeserialization.get( beanClass ) ); 132 79 } 133 80 -
tapas/common/implementation/log4j.xml
r376 r400 10 10 11 11 <appender name="file" class="org.apache.log4j.FileAppender"> 12 <param name="file" value="/home_local/workspace /tapas/web/log4j.log"/>12 <param name="file" value="/home_local/workspaces/log4j_tapas.log"/> 13 13 <layout class="org.apache.log4j.PatternLayout"> 14 14 <param name="ConversionPattern" value="LOG4J %p %d{ISO8601} - %c{1} - %m%n"/> -
tapas/service/interface/com/ether/tapas/Observation.java
r399 r400 1 package com.ether; 1 package com.ether.tapas; 2 3 import org.jetbrains.annotations.NotNull; 2 4 3 5 import java.util.Date; 4 6 7 /** 8 * @author vmipsl 9 * @date 08 march 2012 10 */ 5 11 public class Observation 6 12 { 7 13 @NotNull 8 14 public Date getDate() 9 15 { … … 11 17 } 12 18 13 public void setDate( final Date date )19 public void setDate( @NotNull final Date date ) 14 20 { 15 21 _date = date; 16 22 } 17 23 24 @NotNull 25 public Observatory getObservatory() 26 { 27 return _observatory; 28 } 29 30 public void setObservatory( @NotNull final Observatory observatory ) 31 { 32 _observatory = observatory; 33 } 34 35 @NotNull 36 public Los getLos() 37 { 38 return _los; 39 } 40 41 public void setLos( @NotNull final Los los ) 42 { 43 _los = los; 44 } 45 46 @NotNull 47 public Instrument getInstrument() 48 { 49 return _instrument; 50 } 51 52 public void setInstrument( @NotNull final Instrument instrument ) 53 { 54 _instrument = instrument; 55 } 56 57 @NotNull 18 58 private Date _date; 59 @NotNull 60 private Observatory _observatory; 61 @NotNull 62 private Los _los; 63 @NotNull 64 private Instrument _instrument; 19 65 } -
tapas/service/interface/com/ether/tapas/Preference.java
r399 r400 1 package com.ether ;1 package com.ether.tapas; 2 2 3 import com.ether.Pair; 3 4 import org.jetbrains.annotations.NotNull; 4 5 6 /** 7 * @author vmipsl 8 * @date 08 march 2012 9 */ 5 10 public class Preference 6 11 { 7 12 @NotNull 8 public StringgetFormat()13 public Pair<String, String> getFormat() 9 14 { 10 15 return _format; 11 16 } 12 17 13 public void setFormat( @NotNull final Stringformat )18 public void setFormat( @NotNull final Pair<String, String> format ) 14 19 { 15 20 _format = format; … … 17 22 18 23 @NotNull 19 public StringgetRayleighExtinction()24 public Pair<String, String> getRayleighExtinction() 20 25 { 21 26 return _rayleighExtinction; 22 27 } 23 28 24 public void setRayleighExtinction( @NotNull final StringrayleighExtinction )29 public void setRayleighExtinction( @NotNull final Pair<String, String> rayleighExtinction ) 25 30 { 26 31 _rayleighExtinction = rayleighExtinction; … … 28 33 29 34 @NotNull 30 public StringgetH2oExtinction()35 public Pair<String, String> getH2oExtinction() 31 36 { 32 37 return _h2oExtinction; 33 38 } 34 39 35 public void setH2oExtinction( @NotNull final Stringh2oExtinction )40 public void setH2oExtinction( @NotNull final Pair<String, String> h2oExtinction ) 36 41 { 37 42 _h2oExtinction = h2oExtinction; … … 39 44 40 45 @NotNull 41 public StringgetO3Extinction()46 public Pair<String, String> getO3Extinction() 42 47 { 43 48 return _o3Extinction; 44 49 } 45 50 46 public void setO3Extinction( @NotNull final Stringo3Extinction )51 public void setO3Extinction( @NotNull final Pair<String, String> o3Extinction ) 47 52 { 48 53 _o3Extinction = o3Extinction; … … 50 55 51 56 @NotNull 52 public StringgetO2Extinction()57 public Pair<String, String> getO2Extinction() 53 58 { 54 59 return _o2Extinction; 55 60 } 56 61 57 public void setO2Extinction( @NotNull final Stringo2Extinction )62 public void setO2Extinction( @NotNull final Pair<String, String> o2Extinction ) 58 63 { 59 64 _o2Extinction = o2Extinction; … … 61 66 62 67 @NotNull 63 public StringgetCo2Extinction()68 public Pair<String, String> getCo2Extinction() 64 69 { 65 70 return _co2Extinction; 66 71 } 67 72 68 public void setCo2Extinction( @NotNull final Stringco2Extinction )73 public void setCo2Extinction( @NotNull final Pair<String, String> co2Extinction ) 69 74 { 70 75 _co2Extinction = co2Extinction; … … 72 77 73 78 @NotNull 74 private String_format;79 private Pair<String, String> _format; 75 80 @NotNull 76 private String_rayleighExtinction;81 private Pair<String, String> _rayleighExtinction; 77 82 @NotNull 78 private String_h2oExtinction;83 private Pair<String, String> _h2oExtinction; 79 84 @NotNull 80 private String_o3Extinction;85 private Pair<String, String> _o3Extinction; 81 86 @NotNull 82 private String_o2Extinction;87 private Pair<String, String> _o2Extinction; 83 88 @NotNull 84 private String_co2Extinction;89 private Pair<String, String> _co2Extinction; 85 90 } -
tapas/service/interface/com/ether/tapas/Request.java
r399 r400 1 package com.ether ;1 package com.ether.tapas; 2 2 3 3 import org.jetbrains.annotations.NotNull; 4 4 5 /** 6 * @author vmipsl 7 * @date 08 march 2012 8 */ 5 9 public class Request 6 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 7 22 @NotNull 8 23 public Preference getPreference() … … 28 43 29 44 @NotNull 30 public StringgetAtmosphere()45 public Atmosphere getAtmosphere() 31 46 { 32 47 return _atmosphere; 33 48 } 34 49 35 public void setAtmosphere( @NotNull final Stringatmosphere )50 public void setAtmosphere( @NotNull final Atmosphere atmosphere ) 36 51 { 37 52 _atmosphere = atmosphere; … … 39 54 40 55 @NotNull 56 private String _id; 57 @NotNull 41 58 private Preference _preference; 42 59 @NotNull 43 60 private Observation _observation; 44 61 @NotNull 45 private String_atmosphere;62 private Atmosphere _atmosphere; 46 63 } -
tapas/service/interface/com/ether/tapas/Tapas.java
r399 r400 1 package com.ether ;1 package com.ether.tapas; 2 2 3 3 import org.jetbrains.annotations.NotNull; … … 5 5 import java.util.List; 6 6 7 /** 8 * @author vmipsl 9 * @date 08 march 2012 10 */ 7 11 public class Tapas 8 12 { 13 @NotNull 14 public String getId() 15 { 16 return _id; 17 } 18 19 public void setId( @NotNull final String id ) 20 { 21 _id = id; 22 } 23 9 24 @NotNull 10 25 public List<Request> getRequests() … … 19 34 20 35 @NotNull 36 private String _id; 37 @NotNull 21 38 private List<Request> _requests; 22 39 } -
tapas/web/init.jsp
r396 r400 2 2 <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 3 3 <%@ taglib prefix="tiles" uri="/WEB-INF/tlds/struts-tiles.tld" %> 4 <%@ taglib prefix="ether" tagdir="/WEB-INF/tags" %>5 4 6 5 <tiles:insert page="/resources/templates/templateEther.jsp" flush="true"> 7 6 8 7 <tiles:put name="insertCss" type="string"/> 9 <tiles:put name="insertJsOrJsp" type="string"> 10 <ether:htmlJs jsFile="library/jquery.json-2.3"/> 11 <ether:htmlJsp jspFile="init_script"/> 12 </tiles:put> 8 <tiles:put name="insertJsOrJsp" type="string"/> 13 9 14 <tiles:put name="title" type="string"><spring:message code="app.title"/> - <spring:message 15 code="title.home"/></tiles:put> 10 <tiles:put name="title" type="string"><spring:message code="app.title"/> - <spring:message code="title.home"/></tiles:put> 16 11 <tiles:put name="nav" type="string"><a href=""><spring:message code="label.home"/></a></tiles:put> 17 12 … … 21 16 22 17 <tiles:put name="body" type="string"> 23 24 <div id="formulaire"> 25 26 </div> 27 28 <script type="text/javascript"> 29 var initTexts = $A( "" ); 30 31 initTexts["label.submitButton"] = '<spring:message code="label.submitButton"/>'; 32 33 34 var interfaceInit = new InterfaceInit(); 35 </script> 36 18 PAGE ACCUEIL TAPAS 37 19 </tiles:put> 38 20 -
tapas/web/project/formTapas.jsp
r396 r400 1 <%@ page import="com.ether.Context" %> 1 2 <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 3 <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> … … 9 10 <tiles:put name="insertJsOrJsp" type="string"> 10 11 <ether:htmlJs jsFile="library/jquery.json-2.3"/> 11 <ether:htmlJsp jspFile=" init_script"/>12 <ether:htmlJsp jspFile="formTapas_script"/> 12 13 </tiles:put> 13 14 14 <tiles:put name="title" type="string"><spring:message code="app.title"/> - <spring:message 15 code="title.home"/></tiles:put> 15 <tiles:put name="title" type="string"><spring:message code="app.title"/> - <spring:message code="title.home"/></tiles:put> 16 16 <tiles:put name="nav" type="string"><a href=""><spring:message code="label.home"/></a></tiles:put> 17 17 … … 26 26 </div> 27 27 28 29 <BR/> 30 <%=Context.getPageURI( request )%><BR/> 31 <%=Context.getRelativePageURI( request )%><BR/> 32 <%=Context.getRelativePath( request )%><BR/> 33 <%=Context.getWebroot( request )%><BR/> 34 <%=request.getQueryString()%><BR/> 35 <%=request.getContextPath()%><BR/> 36 <%=request.getPathInfo()%><BR/> 37 <%=request.getServletPath()%><BR/> 38 <%=request.getRequestURL()%><BR/> 39 40 28 41 <script type="text/javascript"> 29 42 var initTexts = $A( "" ); … … 32 45 33 46 34 var interface Init = new InterfaceInit();47 var interfaceTapas = new InterfaceTapas(); 35 48 </script> 36 49 -
tapas/web/project/formTapas_script.jsp
r399 r400 1 1 <script type="text/javascript"> 2 var Interface Init= Class.create( {2 var InterfaceTapas = Class.create( { 3 3 4 4 initialize: function() … … 31 31 requestCreateXML: function() 32 32 { 33 var bob = new Object(); 34 bob.input1 = "eee"; 35 bob.input2 = "rr"; 36 var jsonBob = $.toJSON( bob ); 33 var tapasForm = this.createTapasForm(); 34 var jsonTapasForm = $.toJSON( tapasForm ); 37 35 38 var jsonFormXml = this.serializeFormXMLToJson(); 39 if( jsonFormXml ) 36 if( jsonTapasForm ) 40 37 $.ajax( { 41 url: "project?methodName=createUserRequest&json FormXml=" + jsonBob + "&jsonTapas=" + jsonFormXml,38 url: "project?methodName=createUserRequest&jsonTapas=" + jsonTapasForm, 42 39 success:jQuery.proxy( this.handleCreateXML, this ) 43 40 } ); … … 48 45 { 49 46 var bob = jQuery.parseJSON( result ).result; 50 alert( bob );47 // alert( bob ); 51 48 }, 52 49 … … 59 56 60 57 // OTHERS ******************************************************** 61 serializeFormXMLToJson: function()58 createTapasForm: function() 62 59 { 63 var formXML = new Array();64 var requestXML= new Object();60 // PREFERENCE 61 var preference = new Object(); 65 62 66 var preference = new Object(); 67 preference.format = $( "#1" ).val(); 68 preference.rayleigh_extinction = $( "#2" ).val(); 69 preference.h2o_extinction = "h2o_extinction"; 70 preference.o3_extinction = "o3_extinction"; 71 preference.o2_extinction = "o2_extinction"; 72 preference.co2_extinction = "co2_extinction"; 63 preference.format = new Object(); 64 preference.format.firstValue = $( "#1" ).val(); 65 preference.format.secondValue = $( "#2" ).val(); 66 67 var pair = new Object(); 68 pair.firstValue = "YES,NO"; 69 pair.secondValue = "YES"; 70 71 preference.rayleighExtinction = pair; 72 preference.h2oExtinction = pair; 73 preference.o3Extinction = pair; 74 preference.o2Extinction = pair; 75 preference.co2Extinction = pair; 76 77 // OBSERVATION 78 // Observatory 79 var observatory = new Object(); 80 observatory.name = "SanFernandoObs.RSanFernando"; 81 82 observatory.longitude = new Object(); 83 observatory.longitude.min = "-180"; 84 observatory.longitude.max = "180"; 85 observatory.longitude.value = -118.491666666667; 86 87 observatory.latitude = new Object(); 88 observatory.latitude.min = "-90"; 89 observatory.latitude.max = "90"; 90 observatory.latitude.value = 34.3083333333333; 91 92 observatory.altitude = new Object(); 93 observatory.altitude.min = "0"; 94 observatory.altitude.max = "10000"; 95 observatory.altitude.value = 371; 96 97 // Los 98 var los = new Object(); 99 los.raJ2000 = "04:32:43"; 100 los.decJ2000 = "-43:12:10.22"; 101 102 los.zenithAngle = new Object(); 103 los.zenithAngle.min = "0"; 104 los.zenithAngle.max = "90"; 105 los.zenithAngle.value = 60; 106 107 // Instrument 108 var instrument = new Object(); 109 110 instrument.spectralChoice = new Object(); 111 instrument.spectralChoice.firstValue = "Vacuum Wavelength (nm),Standard Wavelength (nm),Wavenumber (cm-1)"; 112 instrument.spectralChoice.secondValue = "Standard Wavelength (nm)"; 113 instrument.spectralRange = "1180 1200"; 114 instrument.ilsfChoice = new Object(); 115 instrument.ilsfChoice.firstValue = "-1,0,1"; 116 instrument.ilsfChoice.secondValue = 0; 117 instrument.ilsfPath = "/home/ferron/tmp/tapas/ilsf.txt"; 118 instrument.resolvingPower = new Object(); 119 instrument.resolvingPower.firstValue = "0"; 120 instrument.resolvingPower.secondValue = 1000000; 121 instrument.samplingRatio = new Object(); 122 instrument.samplingRatio.firstValue = "0"; 123 instrument.samplingRatio.secondValue = 3; 73 124 74 125 var observation = new Object(); 75 126 observation.date = "2012-02-24"; 127 observation.observatory = observatory; 128 observation.los = los; 129 observation.instrument = instrument; 76 130 77 requestXML.preference = preference; 78 requestXML.observation = observation; 79 requestXML.atmosphere = "atmosphereZZZZ"; 131 // ATMOSPHERE 132 var atmosphere = new Object(); 133 atmosphere.reference = new Object(); 134 atmosphere.reference.firstValue = "0,1,2,3,4,5,6"; 135 atmosphere.reference.secondValue = 6; 80 136 81 formXML[0] = requestXML; 137 atmosphere.arlettyFile = new Array(); 138 atmosphere.arlettyFile[0] = "/home/ferron/tmp/tapas/Reims_070402.ARL.txt"; 139 atmosphere.arlettyFile[1] = "/home/ferron/tmp/tapas/Reims_070402.ARL.txt22"; 82 140 83 return $.toJSON( formXML ); 141 atmosphere.ecmwfFile = new Array(); 142 atmosphere.ecmwfFile[0] = "/home/ferron/tmp/tapas/ecmwf12.txt"; 143 144 // REQUEST 145 var request = new Object(); 146 request.id = "1"; 147 request.preference = preference; 148 request.observation = observation; 149 request.atmosphere = atmosphere; 150 151 var requests = new Array(); 152 requests[0] = request; 153 154 // TAPAS 155 var tapas = new Object(); 156 tapas.id = "Ether_TAPAS_0000001"; 157 tapas.requests = requests; 158 159 return tapas; 84 160 } 85 161 -
tapas/web/resources/templates/templateEther.jsp
r396 r400 67 67 <div id="menu" class="containerMenu"> 68 68 <ul class="menu"> 69 <li><a href=" #" class="parent"><span>Home</span></a>69 <li><a href="project?methodName=viewForm" class="parent"><span>Formulaire</span></a> 70 70 71 71 <div> … … 116 116 <div id="containerCenter" class="containerTapas containerCenter"> 117 117 <tiles:insert attribute="body"/> 118 119 <BR/>120 <%=Context.getPageURI( request )%><BR/>121 <%=Context.getRelativePageURI( request )%><BR/>122 <%=Context.getRelativePath( request )%><BR/>123 <%=Context.getWebroot( request )%><BR/>124 <%=request.getQueryString()%><BR/>125 <%=request.getContextPath()%><BR/>126 <%=request.getPathInfo()%><BR/>127 <%=request.getServletPath()%><BR/>128 <%=request.getRequestURL()%><BR/>129 118 </div> 130 119 -
tapas/web/src/com/ether/Controller.java
r399 r400 5 5 import com.ether.annotation.ParamName; 6 6 import com.ether.annotation.UseJSON; 7 import com.ether. Tapas;7 import com.ether.tapas.Tapas; 8 8 import net.sf.json.JSONObject; 9 9 import org.apache.commons.logging.Log; … … 33 33 } 34 34 35 @ControllerMethod(view = VIEW_FORM_TAPAS) 36 public Map<String, Object> viewForm() 37 throws WebException 38 { 39 return new HashMap<String, Object>(); 40 } 35 41 36 42 /** *********************************************************** **/ … … 38 44 /** *********************************************************** **/ 39 45 @ControllerMethod(jsonResult = true) 40 public JSONObject createUserRequest( @ParamName("jsonFormXml") @Mandatory @UseJSON final FormXML jsonFormXML, 41 @ParamName("jsonTapas") @Mandatory @UseJSON final Tapas jsonTapas ) 46 public JSONObject createUserRequest( @ParamName("jsonTapas") @Mandatory @UseJSON final Tapas jsonTapas ) 42 47 throws ServiceException 43 48 { … … 60 65 61 66 private static final String VIEW_INIT = "init"; 67 private static final String VIEW_FORM_TAPAS = "project/formTapas"; 62 68 63 69 private TapasService _tapasService; -
tapas/web/src/json/json-context.xml
r378 r400 11 11 </map> 12 12 </property> 13 14 <property name="mapClassesForDeserialization"> 15 <map> 16 <entry key="com.ether.tapas.Tapas"> 17 <map> 18 <entry key="requests" value="com.ether.tapas.Request"/> 19 </map> 20 </entry> 21 <entry key="com.ether.tapas.Request"> 22 <map> 23 <entry key="preference" value="com.ether.tapas.Preference"/> 24 <entry key="observation" value="com.ether.tapas.Observation"/> 25 <entry key="atmosphere" value="com.ether.tapas.Atmosphere"/> 26 </map> 27 </entry> 28 <entry key="com.ether.tapas.Preference"> 29 <map> 30 <entry key="format" value="com.ether.Pair"/> 31 <entry key="rayleighExtinction" value="com.ether.Pair"/> 32 <entry key="h2oExtinction" value="com.ether.Pair"/> 33 <entry key="o3Extinction" value="com.ether.Pair"/> 34 <entry key="o2Extinction" value="com.ether.Pair"/> 35 <entry key="co2Extinction" value="com.ether.Pair"/> 36 </map> 37 </entry> 38 39 <entry key="com.ether.tapas.Observation"> 40 <map> 41 <entry key="observatory" value="com.ether.tapas.Observatory"/> 42 <entry key="los" value="com.ether.tapas.Los"/> 43 <entry key="instrument" value="com.ether.tapas.Instrument"/> 44 </map> 45 </entry> 46 <entry key="com.ether.tapas.Observatory"> 47 <map> 48 <entry key="longitude" value="com.ether.tapas.Coordinate"/> 49 <entry key="latitude" value="com.ether.tapas.Coordinate"/> 50 <entry key="altitude" value="com.ether.tapas.Coordinate"/> 51 </map> 52 </entry> 53 <entry key="com.ether.tapas.Los"> 54 <map> 55 <entry key="zenithAngle" value="com.ether.tapas.Coordinate"/> 56 </map> 57 </entry> 58 <entry key="com.ether.tapas.Instrument"> 59 <map> 60 <entry key="spectralChoice" value="com.ether.Pair"/> 61 <entry key="ilsfChoice" value="com.ether.Pair"/> 62 <entry key="resolvingPower" value="com.ether.Pair"/> 63 <entry key="samplingRatio" value="com.ether.Pair"/> 64 </map> 65 </entry> 66 <entry key="com.ether.tapas.Atmosphere"> 67 <map> 68 <entry key="reference" value="com.ether.Pair"/> 69 </map> 70 </entry> 71 </map> 72 </property> 13 73 </bean> 14 74
Note: See TracChangeset
for help on using the changeset viewer.