Changeset 572
- Timestamp:
- 10/09/12 14:50:26 (12 years ago)
- Location:
- ether_statistics
- Files:
-
- 47 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_statistics/Statistics.iml
r569 r572 6 6 <orderEntry type="inheritedJdk" /> 7 7 <orderEntry type="sourceFolder" forTests="false" /> 8 <orderEntry type="library" name="lib_hibernate" level="project" /> 8 9 </component> 9 10 </module> -
ether_statistics/Statistics.ipr
r569 r572 3 3 <component name="AntConfiguration"> 4 4 <defaultAnt bundledAnt="true" /> 5 </component> 6 <component name="ArtifactManager"> 7 <artifact type="exploded-war" build-on-make="true" name="statistics"> 8 <output-path>$PROJECT_DIR$/web</output-path> 9 <root id="root" /> 10 </artifact> 5 11 </component> 6 12 <component name="CompilerConfiguration"> … … 28 34 </component> 29 35 <component name="Encoding" useUTFGuessing="false" native2AsciiForPropertiesFiles="false" /> 36 <component name="EntryPointsManager"> 37 <entry_points version="2.0" /> 38 </component> 30 39 <component name="Git.Settings"> 31 40 <option name="CHECKOUT_INCLUDE_TAGS" value="false" /> … … 2183 2192 <component name="ProjectModuleManager"> 2184 2193 <modules> 2194 <module fileurl="file://$PROJECT_DIR$/common/Common.iml" filepath="$PROJECT_DIR$/common/Common.iml" /> 2195 <module fileurl="file://$PROJECT_DIR$/domain/Domain.iml" filepath="$PROJECT_DIR$/domain/Domain.iml" /> 2196 <module fileurl="file://$PROJECT_DIR$/persistence/Persistence.iml" filepath="$PROJECT_DIR$/persistence/Persistence.iml" /> 2197 <module fileurl="file://$PROJECT_DIR$/service/Service.iml" filepath="$PROJECT_DIR$/service/Service.iml" /> 2185 2198 <module fileurl="file://$PROJECT_DIR$/Statistics.iml" filepath="$PROJECT_DIR$/Statistics.iml" /> 2199 <module fileurl="file://$PROJECT_DIR$/web/Web.iml" filepath="$PROJECT_DIR$/web/Web.iml" /> 2186 2200 </modules> 2187 2201 </component> … … 2233 2247 </component> 2234 2248 <component name="WebServicesPlugin" addRequiredLibraries="true" /> 2249 <component name="libraryTable"> 2250 <library name="lib_common"> 2251 <CLASSES> 2252 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-discovery-0.4.jar!/" /> 2253 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-collections-3.2.jar!/" /> 2254 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/aopalliance.jar!/" /> 2255 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-collections-3.1.jar!/" /> 2256 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-digester-1.8.jar!/" /> 2257 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/annotations-7.0.2.jar!/" /> 2258 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/antlr-2.7.6.jar!/" /> 2259 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-logging-1.1.1.jar!/" /> 2260 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-lang-2.2.jar!/" /> 2261 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/dom4j-1.6.1.jar!/" /> 2262 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/asm-1.5.3.jar!/" /> 2263 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-validator.jar!/" /> 2264 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-codec-1.3.jar!/" /> 2265 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/cglib-2.2.jar!/" /> 2266 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-beanutils-1.7.0.jar!/" /> 2267 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/ezmorph.jar!/" /> 2268 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/myfaces-api-1.2.6.jar!/" /> 2269 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/javassist-3.9.0.GA.jar!/" /> 2270 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/jstl-1.1.2.jar!/" /> 2271 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/jstl-2.4.jar.zip!/" /> 2272 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/jta-1.1.jar!/" /> 2273 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/netcdfAll.jar!/" /> 2274 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/postgresql-8.2-504.jdbc3.jar!/" /> 2275 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/slf4j-api-1.5.8.jar!/" /> 2276 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/slf4j-simple-1.5.8.jar!/" /> 2277 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/jakarta-taglibs-standard-1.0.6.zip!/" /> 2278 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/log4j-1.2.15.jar!/" /> 2279 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/jdom.jar!/" /> 2280 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/myfaces-impl-1.2.6.jar!/" /> 2281 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/servlet-api.jar!/" /> 2282 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/mail.jar!/" /> 2283 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/junit-3.8.2.jar!/" /> 2284 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/jasper-6.0.18.jar!/" /> 2285 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/json-lib-2.2.1-jdk15.jar!/" /> 2286 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/standard-1.1.2.jar!/" /> 2287 </CLASSES> 2288 <JAVADOC /> 2289 <SOURCES /> 2290 </library> 2291 <library name="lib_hibernate"> 2292 <CLASSES> 2293 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/hibernate2.jar!/" /> 2294 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/hibernate-3.3.2.GA.jar!/" /> 2295 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/hibernate-all.jar!/" /> 2296 </CLASSES> 2297 <JAVADOC /> 2298 <SOURCES /> 2299 </library> 2300 <library name="lib_spring"> 2301 <CLASSES> 2302 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring.jar!/" /> 2303 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-web.jar!/" /> 2304 <root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/spring-webmvc.jar!/" /> 2305 </CLASSES> 2306 <JAVADOC /> 2307 <SOURCES /> 2308 </library> 2309 </component> 2235 2310 </project> 2236 2311 -
ether_statistics/common/Common.iml
r569 r572 22 22 </library> 23 23 </orderEntry> 24 <orderEntry type="library" name="lib_ether" level="project" /> 24 <orderEntry type="library" name="lib_common" level="project" /> 25 <orderEntry type="library" name="lib_spring" level="project" /> 25 26 <orderEntry type="library" name="lib_hibernate" level="project" /> 26 27 </component> -
ether_statistics/domain/Domain.iml
r569 r572 11 11 <orderEntry type="sourceFolder" forTests="false" /> 12 12 <orderEntry type="module" module-name="Common" /> 13 <orderEntry type="library" name="lib_ether" level="project" />14 13 </component> 15 14 </module> -
ether_statistics/persistence/Persistence.iml
r569 r572 27 27 <orderEntry type="module" module-name="Common" /> 28 28 <orderEntry type="module" module-name="Domain" /> 29 <orderEntry type="library" name="lib_ether" level="project" />30 29 <orderEntry type="library" name="lib_hibernate" level="project" /> 30 <orderEntry type="library" name="lib_common" level="project" /> 31 <orderEntry type="library" name="lib_spring" level="project" /> 31 32 </component> 32 33 </module> -
ether_statistics/persistence/implementation/hibernate-domain.cfg.xml
r569 r572 7 7 <session-factory> 8 8 9 <mapping resource="com/medias/objects/Adresse.hbm.xml"/> 10 <mapping resource="com/medias/objects/Bilan.hbm.xml"/> 11 <mapping resource="com/medias/objects/Capteur.hbm.xml"/> 12 <mapping resource="com/medias/objects/Categorie.hbm.xml"/> 13 <mapping resource="com/medias/objects/CategorieParam.hbm.xml"/> 14 <mapping resource="com/medias/objects/Commentaire.hbm.xml"/> 15 <mapping resource="com/medias/objects/DeltaMesure.hbm.xml"/> 16 <mapping resource="com/medias/objects/Fabriquant.hbm.xml"/> 17 <mapping resource="com/medias/objects/Fichier.hbm.xml"/> 18 <mapping resource="com/medias/objects/Flag.hbm.xml"/> 19 <mapping resource="com/medias/objects/Jeu.hbm.xml"/> 20 <mapping resource="com/medias/objects/Langue.hbm.xml"/> 21 <mapping resource="com/medias/objects/Localisation.hbm.xml"/> 22 <mapping resource="com/medias/objects/Mesure.hbm.xml"/> 23 <mapping resource="com/medias/objects/Organisme.hbm.xml"/> 24 <mapping resource="com/medias/objects/Parametre.hbm.xml"/> 25 <mapping resource="com/medias/objects/Plateforme.hbm.xml"/> 26 <mapping resource="com/medias/objects/RequeteNbvalsJeu.hbm.xml"/> 27 <mapping resource="com/medias/objects/RequetePlatLoc.hbm.xml"/> 28 <mapping resource="com/medias/objects/Sequence.hbm.xml"/> 29 <mapping resource="com/medias/objects/TypeCapteur.hbm.xml"/> 30 <mapping resource="com/medias/objects/TypePlateforme.hbm.xml"/> 31 <mapping resource="com/medias/objects/Unite.hbm.xml"/> 32 <mapping resource="com/medias/objects/Valeur.hbm.xml"/> 33 <mapping resource="com/medias/objects/Zone.hbm.xml"/> 34 35 <mapping resource="com/ether/dao/user/User.hbm.xml"/> 36 <mapping resource="com/ether/dao/person/Personne.hbm.xml"/> 37 <mapping resource="com/ether/dao/mco/Mco.hbm.xml"/> 38 <mapping resource="com/ether/dao/simulation/Dimension.hbm.xml"/> 39 <mapping resource="com/ether/dao/simulation/Attribute.hbm.xml"/> 40 <mapping resource="com/ether/dao/simulation/Variable.hbm.xml"/> 41 <mapping resource="com/ether/dao/simulation/Simulation.hbm.xml"/> 9 <!--<mapping resource="com/ether/dao/user/User.hbm.xml"/>--> 10 <!--<mapping resource="com/ether/dao/person/Personne.hbm.xml"/>--> 11 <!--<mapping resource="com/ether/dao/mco/Mco.hbm.xml"/>--> 12 <!--<mapping resource="com/ether/dao/simulation/Dimension.hbm.xml"/>--> 13 <!--<mapping resource="com/ether/dao/simulation/Attribute.hbm.xml"/>--> 14 <!--<mapping resource="com/ether/dao/simulation/Variable.hbm.xml"/>--> 15 <!--<mapping resource="com/ether/dao/simulation/Simulation.hbm.xml"/>--> 42 16 43 17 <!--<mapping resource="com/ether/dao/Query.hbm.xml"/>--> -
ether_statistics/service/Service.iml
r569 r572 24 24 </library> 25 25 </orderEntry> 26 <orderEntry type="library" name="lib_medias_insert" level="project" />27 <orderEntry type="library" name="lib_ether" level="project" />28 26 <orderEntry type="library" name="lib_hibernate" level="project" /> 27 <orderEntry type="library" name="lib_spring" level="project" /> 28 <orderEntry type="library" name="lib_common" level="project" /> 29 29 </component> 30 30 </module> -
ether_statistics/service/implementation/com/ether/BouchonHelper.java
r569 r572 1 1 package com.ether; 2 2 3 import com.medias.database.objects.Parametre;4 import com.medias.database.objects.Plateforme;5 import com.medias.database.objects.TypePlateforme;6 import com.medias.database.objects.Unite;7 import org.jetbrains.annotations.NotNull;8 import org.jetbrains.annotations.Nullable;9 10 import java.util.ArrayList;11 3 import java.util.Arrays; 12 import java.util.Calendar;13 import java.util.Date;14 import java.util.GregorianCalendar;15 4 import java.util.List; 16 import java.util.TimeZone;17 5 18 6 /** … … 22 10 public class BouchonHelper 23 11 { 24 public static Plateforme createPlateform()25 {26 final Plateforme plateform = new Plateforme();27 plateform.setPlateformeId( 3 );28 plateform.setPlateformeNom( "LHVP" );29 plateform.setTypePlateforme( new TypePlateforme( 1, "FIXE" ) );30 return plateform;31 }32 33 public static List<Plateforme> createPlateforms()34 {35 final List<Plateforme> plateforms = new ArrayList<Plateforme>();36 final Plateforme pf = createPlateform();37 plateforms.add( pf );38 39 final Plateforme pf2 = new Plateforme();40 pf2.setPlateformeId( 1 );41 pf2.setPlateformeNom( "SIRTA" );42 pf2.setTypePlateforme( new TypePlateforme( 1, "FIXE" ) );43 plateforms.add( pf2 );44 45 final Plateforme pf3 = new Plateforme();46 pf3.setPlateformeId( 4 );47 pf3.setPlateformeNom( "ATR-42" );48 pf3.setTypePlateforme( new TypePlateforme( 1, "MOBILE" ) );49 plateforms.add( pf3 );50 51 final Plateforme pf4 = new Plateforme();52 pf4.setPlateformeId( 6 );53 pf4.setPlateformeNom( "Piper-Aztec" );54 pf4.setTypePlateforme( new TypePlateforme( 1, "MOBILE" ) );55 plateforms.add( pf4 );56 57 return plateforms;58 }59 60 public static Plateforme getPlateformById( @NotNull final Integer plateformId )61 {62 if( null != plateformId && plateformId == 1 )63 {64 final Plateforme pf2 = new Plateforme();65 pf2.setPlateformeId( 1 );66 pf2.setPlateformeNom( "SIRTA" );67 pf2.setTypePlateforme( new TypePlateforme( 1, "FIXE" ) );68 return pf2;69 }70 else if( null != plateformId && plateformId == 3 )71 {72 return createPlateform();73 }74 else if( null != plateformId && plateformId == 4 )75 {76 final Plateforme pf3 = new Plateforme();77 pf3.setPlateformeId( 4 );78 pf3.setPlateformeNom( "ATR-42" );79 pf3.setTypePlateforme( new TypePlateforme( 1, "MOBILE" ) );80 return pf3;81 }82 else if( null != plateformId && plateformId == 6 )83 {84 final Plateforme pf4 = new Plateforme();85 pf4.setPlateformeId( 6 );86 pf4.setPlateformeNom( "Piper-Aztec" );87 pf4.setTypePlateforme( new TypePlateforme( 1, "MOBILE" ) );88 return pf4;89 }90 else return null;91 }92 93 public static Parametre createParameter()94 {95 final Parametre parametre = new Parametre();96 parametre.setParametreId( 3 );97 parametre.setParametreNom( "Ozone" );98 parametre.setParametreCode( "O3" );99 100 final Unite unit = new Unite();101 unit.setUniteCode( "ppbv" );102 parametre.setUnite( unit );103 104 return parametre;105 }106 107 public static List<Parametre> createParameters( @Nullable final Integer plateformId )108 {109 final Unite unitPpbv = new Unite();110 unitPpbv.setUniteCode( "ppbv" );111 final Unite units_1 = new Unite();112 units_1.setUniteCode( "s-1" );113 final Unite unitMbar = new Unite();114 unitMbar.setUniteCode( "mbar" );115 final Unite unitC = new Unite();116 unitC.setUniteCode( "°C" );117 118 119 final List<Parametre> parameters = new ArrayList<Parametre>();120 121 final Parametre pOzone = createParameter();122 123 final Parametre pJNO2 = new Parametre();124 pJNO2.setParametreId( 1 );125 pJNO2.setParametreNom( "Photolysis Frequency JNO2" );126 pJNO2.setParametreCode( "JNO2" );127 pJNO2.setUnite( units_1 );128 129 final Parametre pPressure = new Parametre();130 pPressure.setParametreId( 9 );131 pPressure.setParametreNom( "Pressure" );132 pPressure.setParametreCode( "P" );133 pPressure.setUnite( unitMbar );134 135 final Parametre pTemperature = new Parametre();136 pTemperature.setParametreId( 10 );137 pTemperature.setParametreNom( "Temperature" );138 pTemperature.setParametreCode( "T" );139 pTemperature.setUnite( unitC );140 141 final Parametre pNO = new Parametre();142 pNO.setParametreId( 4 );143 pNO.setParametreNom( "Nitrogen Monoxide" );144 pNO.setParametreCode( "NO" );145 pNO.setUnite( unitPpbv );146 147 final Parametre pNOx = new Parametre();148 pNOx.setParametreId( 23 );149 pNOx.setParametreNom( "Nitrogen Oxides" );150 pNOx.setParametreCode( "NOx" );151 pNOx.setUnite( unitPpbv );152 153 154 if( null != plateformId && plateformId == 1 )155 {156 // SIRTA157 parameters.add( pOzone );158 parameters.add( pJNO2 );159 parameters.add( pPressure );160 parameters.add( pTemperature );161 parameters.add( pNO );162 163 }164 else if( null != plateformId && plateformId == 3 )165 {166 // LHVP167 parameters.add( pOzone );168 parameters.add( pNO );169 parameters.add( pNOx );170 }171 else if( null != plateformId && plateformId == 4 )172 {173 // ATR-42174 parameters.add( pPressure );175 parameters.add( pTemperature );176 }177 else if( null != plateformId && plateformId == 6 )178 {179 // Piper-Aztec180 }181 else182 {183 parameters.add( pOzone );184 parameters.add( pJNO2 );185 parameters.add( pPressure );186 parameters.add( pTemperature );187 parameters.add( pNO );188 parameters.add( pNOx );189 }190 191 return parameters;192 }193 194 public static Parametre getParameterById( @NotNull final Integer parameterId )195 {196 if( parameterId == 3 )197 return createParameter();198 199 else if( parameterId == 1 )200 {201 final Parametre pJNO2 = new Parametre();202 pJNO2.setParametreId( 1 );203 pJNO2.setParametreNom( "Photolysis Frequency JNO2" );204 pJNO2.setParametreCode( "JNO2" );205 final Unite units_1 = new Unite();206 units_1.setUniteCode( "s-1" );207 pJNO2.setUnite( units_1 );208 return pJNO2;209 }210 else if( parameterId == 9 )211 {212 final Parametre pPressure = new Parametre();213 pPressure.setParametreId( 9 );214 pPressure.setParametreNom( "Pressure" );215 pPressure.setParametreCode( "P" );216 final Unite unitMbar = new Unite();217 unitMbar.setUniteCode( "mbar" );218 219 pPressure.setUnite( unitMbar );220 return pPressure;221 }222 else if( parameterId == 10 )223 {224 final Parametre pTemperature = new Parametre();225 pTemperature.setParametreId( 10 );226 pTemperature.setParametreNom( "Temperature" );227 pTemperature.setParametreCode( "T" );228 final Unite unitC = new Unite();229 unitC.setUniteCode( "°C" );230 pTemperature.setUnite( unitC );231 return pTemperature;232 }233 else if( parameterId == 4 )234 {235 236 final Parametre pNO = new Parametre();237 pNO.setParametreId( 4 );238 pNO.setParametreNom( "Nitrogen Monoxide" );239 pNO.setParametreCode( "NO" );240 final Unite unitPpbv = new Unite();241 unitPpbv.setUniteCode( "ppbv" );242 pNO.setUnite( unitPpbv );243 return pNO;244 }245 else if( parameterId == 23 )246 {247 248 final Parametre pNOx = new Parametre();249 pNOx.setParametreId( 23 );250 pNOx.setParametreNom( "Nitrogen Oxides" );251 pNOx.setParametreCode( "NOx" );252 final Unite unitPpbv = new Unite();253 unitPpbv.setUniteCode( "ppbv" );254 pNOx.setUnite( unitPpbv );255 return pNOx;256 }257 else return null;258 }259 260 public static Data createValuesForTimeSerie( final Integer size, final Integer delta )261 {262 if( null == delta )263 return new Data( new double[0], new Date[0] );264 265 final double[] values = new double[size];266 final Date[] dates = new Date[size];267 // final Calendar cal = Calendar.getInstance( new SimpleTimeZone( 0, "GMT" ) );268 final Calendar cal = new GregorianCalendar( TimeZone.getTimeZone( "GMT" ) );269 cal.setTimeInMillis( Long.valueOf( "1246811160000" ) );270 271 for( int i = 0; i < size; i++ )272 {273 dates[i] = cal.getTime();274 values[i] = delta + (double) i * Math.random() * delta;275 // cal.add( Calendar.MINUTE, (int) ( 2 + i + ( Math.random() * 8 ) ) );276 cal.add( Calendar.HOUR, (int) ( 2 * i + 2 ) );277 }278 return new Data( values, dates );279 }280 281 public static Data createValuesFor2D( final Integer size )282 {283 final List<Double> latitudeValues = new ArrayList<Double>( size );284 final List<Double> longitudeValues = new ArrayList<Double>( size );285 final List<Double> parameterValues = new ArrayList<Double>( size );286 287 for( int i = 0; i < size; i++ )288 {289 latitudeValues.add( Double.valueOf( EtherHelper.getRandomBetweenTwoInteger( -90, 90 ) ) );290 longitudeValues.add( Double.valueOf( EtherHelper.getRandomBetweenTwoInteger( 0, 180 ) ) );291 parameterValues.add( Double.valueOf( EtherHelper.getRandomBetweenTwoInteger( -10, 100 ) ) );292 }293 294 return new Data( parameterValues, latitudeValues, longitudeValues );295 }296 297 12 public static Data createRealValuesFor2D() 298 13 { -
ether_statistics/service/implementation/com/ether/EtherServiceImpl.java
r569 r572 1 1 package com.ether; 2 2 3 import com.ether.dao.JeuDAO;4 import com.ether.dao.McoDAO;5 import com.ether.dao.MeasureDAO;6 import com.ether.dao.ParameterDAO;7 import com.ether.dao.PersonDAO;8 import com.ether.dao.PlateformDAO;9 import com.ether.dao.UserDAO;10 import com.ether.dao.ValueDAO;11 import com.ether.dao.simulation.AttributeDAO;12 import com.ether.dao.simulation.DimensionDAO;13 import com.ether.dao.simulation.SimulationDAO;14 import com.ether.dao.simulation.VariableDAO;15 import com.ether.mco.Mco;16 import com.ether.mco.McoFilter;17 import com.ether.simulation.Attribute;18 import com.ether.simulation.Dimension;19 import com.ether.simulation.Simulation;20 import com.ether.simulation.SimulationFilter;21 import com.ether.simulation.Variable;22 import com.ether.user.User;23 import com.ether.user.UserFilter;24 import com.ether.user.UserState;25 import com.medias.annuaire.Personne;26 import com.medias.database.objects.Jeu;27 import com.medias.database.objects.Parametre;28 import com.medias.database.objects.Plateforme;29 3 import org.apache.commons.logging.Log; 30 4 import org.apache.commons.logging.LogFactory; 31 import org.jetbrains.annotations.NotNull;32 import org.jetbrains.annotations.Nullable;33 import org.springframework.beans.factory.annotation.Required;34 import org.springframework.transaction.annotation.Transactional;35 36 import javax.xml.bind.JAXBContext;37 import javax.xml.bind.JAXBException;38 import javax.xml.bind.Marshaller;39 import javax.xml.bind.PropertyException;40 import javax.xml.bind.Unmarshaller;41 import java.io.BufferedReader;42 import java.io.File;43 import java.io.IOException;44 import java.io.InputStreamReader;45 import java.util.ArrayList;46 import java.util.Collections;47 import java.util.Date;48 import java.util.HashSet;49 import java.util.List;50 import java.util.Set;51 5 52 6 /** … … 57 11 implements EtherService 58 12 { 59 @Nullable 60 @Transactional(readOnly = true) 61 public List<Plateforme> getAllPlateforms() 62 throws ServiceException 63 { 64 try 65 { 66 return _plateformDAO.getAllPlateforms(); 67 } 68 catch( PersistenceException e ) 69 { 70 throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e ); 71 } 72 } 73 74 @Nullable 75 @Transactional(readOnly = true) 76 public Plateforme getPlateformById( @Nullable final Integer plateformId ) 77 throws ServiceException 78 { 79 if( null == plateformId ) 80 return null; 81 try 82 { 83 return _plateformDAO.getPlateformById( plateformId ); 84 } 85 catch( PersistenceException e ) 86 { 87 throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e ); 88 } 89 } 90 91 @Nullable 92 @Transactional(readOnly = true) 93 public Parametre getParameterById( @Nullable final Integer parameterId ) 94 throws ServiceException 95 { 96 if( null == parameterId ) 97 return null; 98 try 99 { 100 return _parameterDAO.getParameterById( parameterId ); 101 } 102 catch( PersistenceException e ) 103 { 104 throw new ServiceException( ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e ); 105 } 106 } 107 108 @NotNull 109 @Transactional(readOnly = true) 110 public List<Parametre> getParametersByPlateformId( @NotNull final Integer plateformId ) 111 throws ServiceException 112 { 113 try 114 { 115 return _parameterDAO.getParametersByPlateformId( plateformId ); 116 } 117 catch( PersistenceException e ) 118 { 119 throw new ServiceException( ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e ); 120 } 121 } 122 123 @NotNull 124 @Transactional(readOnly = true) 125 public <T1, T2, T3> Data<T1[], T2[], T3[]> getListsByPlateformByParameterByPeriodForTimeSerie( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd ) 126 throws ServiceException 127 { 128 try 129 { 130 return _valueDAO.getListsByPlateformByParameterByPeriodForTimeSerie( plateformId, parameterId, dateBegin, dateEnd ); 131 } 132 catch( PersistenceException e ) 133 { 134 throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e ); 135 } 136 } 137 138 @NotNull 139 @Transactional(readOnly = true) 140 public <T1, T2, T3> Data<List<T1>, List<T2>, List<T3>> getListsByPlateformByParameterByPeriodFor2D( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd ) 141 throws ServiceException 142 { 143 try 144 { 145 return _valueDAO.getListsByPlateformByParameterByPeriodFor2D( plateformId, parameterId, dateBegin, dateEnd ); 146 } 147 catch( PersistenceException e ) 148 { 149 throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e ); 150 } 151 } 152 153 @NotNull 154 @Transactional(readOnly = true) 155 public <T1, T2, T3> Data<T1[], T2[], T3[]> getArraysByPlateformByParameterByPeriodFor2D( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd ) 156 throws ServiceException 157 { 158 try 159 { 160 return _valueDAO.getArraysByPlateformByParameterByPeriodFor2D( plateformId, parameterId, dateBegin, dateEnd ); 161 } 162 catch( PersistenceException e ) 163 { 164 throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e ); 165 } 166 } 167 168 @NotNull 169 @Transactional(readOnly = true) 170 public Integer getNumberValuesByPlateformByParameterByPeriod( @NotNull final List<Pair<Integer, Integer>> pairs, @Nullable final Date beginDate, @Nullable final Date endDate ) 171 throws ServiceException 172 { 173 try 174 { 175 Integer number = 0; 176 for( final Pair pair : pairs ) 177 number += _valueDAO.getNumberValuesByPlateformByParameterByPeriod( (Integer) pair.getFirstValue(), (Integer) pair.getSecondValue(), beginDate, endDate ); 178 179 return number; 180 } 181 catch( PersistenceException e ) 182 { 183 throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e ); 184 } 185 } 186 187 @Nullable 188 @Transactional(readOnly = true) 189 public Date getFirstDate() 190 throws ServiceException 191 { 192 try 193 { 194 return _measureDAO.getFirstDate(); 195 } 196 catch( PersistenceException e ) 197 { 198 throw new ServiceException( ServiceException.ServiceCode.DATE_NOT_FOUND, e ); 199 } 200 } 201 202 @Nullable 203 @Transactional(readOnly = true) 204 public Date getLastDate() 205 throws ServiceException 206 { 207 try 208 { 209 return _measureDAO.getLastDate(); 210 } 211 catch( PersistenceException e ) 212 { 213 throw new ServiceException( ServiceException.ServiceCode.DATE_NOT_FOUND, e ); 214 } 215 } 216 217 @Nullable 218 @Transactional(readOnly = true) 219 public User getUserById( @NotNull final Integer userId ) 220 throws ServiceException 221 { 222 try 223 { 224 return _userDAO.selectByPrimaryKey( userId ); 225 } 226 catch( PersistenceException e ) 227 { 228 throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 229 } 230 } 231 232 @Nullable 233 @Transactional(readOnly = true) 234 public User getUserByEmail( @NotNull final String userEmail ) 235 throws ServiceException 236 { 237 try 238 { 239 return _userDAO.getUserByEmail( userEmail ); 240 } 241 catch( PersistenceException e ) 242 { 243 throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 244 } 245 } 246 247 @NotNull 248 @Transactional(rollbackFor = Exception.class) 249 public Integer createUser( @NotNull final User user ) 250 throws ServiceException 251 { 252 try 253 { 254 return _userDAO.insert( user ); 255 } 256 catch( PersistenceException e ) 257 { 258 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 259 } 260 } 261 262 @NotNull 263 @Transactional(readOnly = true) 264 public List<User> getAllUsers() 265 throws ServiceException 266 { 267 try 268 { 269 return _userDAO.selectAll(); 270 } 271 catch( PersistenceException e ) 272 { 273 throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 274 } 275 } 276 277 @NotNull 278 @Transactional(readOnly = true) 279 public List<User> getAllUsersByNameOrder() 280 throws ServiceException 281 { 282 try 283 { 284 return _userDAO.getAllUsersByNameOrder(); 285 } 286 catch( PersistenceException e ) 287 { 288 throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 289 } 290 } 291 292 @NotNull 293 @Transactional(readOnly = true) 294 public List<User> getUsersByState( @NotNull final UserState userState ) 295 throws ServiceException 296 { 297 try 298 { 299 return _userDAO.getUsersByState( userState ); 300 } 301 catch( PersistenceException e ) 302 { 303 throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 304 } 305 } 306 307 @Transactional(rollbackFor = Exception.class) 308 public void removeUserById( @NotNull final Integer userId ) 309 throws ServiceException 310 { 311 try 312 { 313 _userDAO.deleteByPrimaryKey( userId ); 314 } 315 catch( PersistenceException e ) 316 { 317 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 318 } 319 } 320 321 @Transactional(rollbackFor = Exception.class) 322 public void updateUser( @NotNull final User user ) 323 throws ServiceException 324 { 325 try 326 { 327 _userDAO.update( user ); 328 } 329 catch( PersistenceException e ) 330 { 331 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 332 } 333 } 334 335 @Transactional(rollbackFor = Exception.class) 336 public void acceptOrRefuseUser( @NotNull final Integer userId, final boolean isAccepted ) 337 throws ServiceException 338 { 339 try 340 { 341 final User user = _userDAO.selectByPrimaryKey( userId ); 342 if( isAccepted ) 343 user.setState( UserState.ACCEPTED ); 344 else 345 user.setState( UserState.REFUSED ); 346 _userDAO.update( user ); 347 } 348 catch( PersistenceException e ) 349 { 350 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 351 } 352 } 353 354 @Nullable 355 @Transactional(readOnly = true) 356 public Personne getPeopleByEmail( @NotNull final String email ) 357 throws ServiceException 358 { 359 try 360 { 361 return _personDAO.getPersonByEmail( email ); 362 } 363 catch( PersistenceException e ) 364 { 365 throw new ServiceException( ServiceException.ServiceCode.PERSON_NOT_FOUND, e ); 366 } 367 } 368 369 @Transactional(readOnly = true) 370 public PaginatedResult<User> searchUsers( @NotNull final UserFilter filter ) 371 throws ServiceException 372 { 373 try 374 { 375 return _userDAO.search( filter ); 376 } 377 catch( PersistenceException e ) 378 { 379 throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 380 } 381 } 382 383 @Transactional(readOnly = true) 384 public PaginatedResult<Mco> searchMcos( @NotNull final McoFilter filter ) 385 throws ServiceException 386 { 387 try 388 { 389 return _mcoDAO.search( filter ); 390 } 391 catch( PersistenceException e ) 392 { 393 throw new ServiceException( ServiceException.ServiceCode.REQUEST_NOT_FOUND, e ); 394 } 395 } 396 397 @Nullable 398 @Transactional(readOnly = true) 399 public Mco getMcoByCode( @NotNull final String code ) 400 throws ServiceException 401 { 402 try 403 { 404 return _mcoDAO.getMcoByCode( code ); 405 } 406 catch( PersistenceException e ) 407 { 408 throw new ServiceException( ServiceException.ServiceCode.REQUEST_NOT_FOUND, e ); 409 } 410 } 411 412 @NotNull 413 @Transactional(rollbackFor = Exception.class) 414 public Integer createMco( @NotNull final Mco mco ) 415 throws ServiceException 416 { 417 try 418 { 419 return _mcoDAO.insert( mco ); 420 } 421 catch( PersistenceException e ) 422 { 423 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 424 } 425 } 426 427 @Transactional(rollbackFor = Exception.class) 428 public void removeMcoById( @NotNull final Integer mcoId ) 429 throws ServiceException 430 { 431 try 432 { 433 _mcoDAO.deleteByPrimaryKey( mcoId ); 434 } 435 catch( PersistenceException e ) 436 { 437 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 438 } 439 } 440 441 @Transactional(rollbackFor = Exception.class) 442 public void updateMco( @NotNull final Mco mco ) 443 throws ServiceException 444 { 445 try 446 { 447 _mcoDAO.update( mco ); 448 } 449 catch( PersistenceException e ) 450 { 451 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 452 } 453 } 454 455 @Nullable 456 @Transactional(readOnly = true) 457 public Mco getMcoById( @NotNull final Integer requestId ) 458 throws ServiceException 459 { 460 try 461 { 462 return _mcoDAO.selectByPrimaryKey( requestId ); 463 } 464 catch( PersistenceException e ) 465 { 466 throw new ServiceException( ServiceException.ServiceCode.REQUEST_NOT_FOUND, e ); 467 } 468 } 469 470 /** 471 * This method manage the sub-menus for the list of parameters (to avoid multiple "Particle Concentration" by example) 472 * The fullParameters must be ordered with parameterName ascendant 473 * 474 * @param fullParameters 475 * @return 476 */ 477 @NotNull 478 public List<List<Parametre>> manageMenusForParameterList( @NotNull final List<Parametre> fullParameters ) 479 { 480 final List<List<Parametre>> parameterListWithMenu = new ArrayList<List<Parametre>>(); 481 482 int i = 0; 483 while( i < fullParameters.size() ) 484 { 485 final Parametre fullParameter = fullParameters.get( i ); 486 final int firstIndex = fullParameters.indexOf( fullParameter ); 487 final int lastIndex = fullParameters.lastIndexOf( fullParameter ); 488 final List<Parametre> parameters = fullParameters.subList( firstIndex, lastIndex + 1 ); 489 parameterListWithMenu.add( parameters ); 490 i += parameters.size(); 491 } 492 493 return parameterListWithMenu; 494 } 495 496 @Nullable 497 @Transactional(readOnly = true) 498 public List<Parametre> getAllParametersOrderByCategoryByName() 499 throws ServiceException 500 { 501 try 502 { 503 return _parameterDAO.getAllParametersOrderByCategoryByName(); 504 } 505 catch( PersistenceException e ) 506 { 507 throw new ServiceException( ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e ); 508 } 509 } 510 511 @Nullable 512 @Transactional(readOnly = true) 513 public List<Date> getAllMeasureDateByPlateformId( @NotNull final Integer plateformId ) 514 throws ServiceException 515 { 516 try 517 { 518 return _measureDAO.getAllMeasureDateByPlateformId( plateformId ); 519 } 520 catch( PersistenceException e ) 521 { 522 throw new ServiceException( ServiceException.ServiceCode.DATE_NOT_FOUND, e ); 523 } 524 } 525 526 @Nullable 527 @Transactional(readOnly = true) 528 public PaginatedResult<Jeu> searchJeux( @NotNull final JeuFilter filter ) 529 throws ServiceException 530 { 531 try 532 { 533 return _jeuDAO.search( filter ); 534 } 535 catch( PersistenceException e ) 536 { 537 throw new ServiceException( ServiceException.ServiceCode.JEU_NOT_FOUND, e ); 538 } 539 } 540 541 @Transactional(rollbackFor = Exception.class) 542 public void removeJeuAndDataByName( @NotNull final String datasetName ) 543 throws ServiceException 544 { 545 try 546 { 547 _jeuDAO.removeJeuAndDataByName( datasetName ); 548 } 549 catch( PersistenceException e ) 550 { 551 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 552 } 553 } 554 555 @Transactional(rollbackFor = Exception.class) 556 public void cleanLocalisationAndFlagTables() 557 throws ServiceException 558 { 559 try 560 { 561 _jeuDAO.cleanLocalisationAndFlagTables(); 562 } 563 catch( PersistenceException e ) 564 { 565 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 566 } 567 } 568 569 @Nullable 570 @Transactional(readOnly = true) 571 public Jeu getJeuById( @NotNull final Integer jeuId ) 572 throws ServiceException 573 { 574 try 575 { 576 return _jeuDAO.selectByPrimaryKey( jeuId ); 577 } 578 catch( PersistenceException e ) 579 { 580 throw new ServiceException( ServiceException.ServiceCode.JEU_NOT_FOUND, e ); 581 } 582 } 583 584 @Nullable 585 @Transactional(readOnly = true) 586 public String getDatasetNameById( @NotNull final Integer jeuId ) 587 throws ServiceException 588 { 589 try 590 { 591 return _jeuDAO.getDatasetNameById( jeuId ); 592 } 593 catch( PersistenceException e ) 594 { 595 throw new ServiceException( ServiceException.ServiceCode.JEU_NOT_FOUND, e ); 596 } 597 } 598 599 @Nullable 600 public PaginatedResult<Dimension> searchDimensions( @NotNull final SimulationFilter filter ) 601 throws ServiceException 602 { 603 try 604 { 605 return _dimensionDAO.search( filter ); 606 } 607 catch( PersistenceException e ) 608 { 609 throw new ServiceException( ServiceException.ServiceCode.DIMENSION_NOT_FOUND, e ); 610 } 611 } 612 613 @Nullable 614 public PaginatedResult<Attribute> searchAttributes( @NotNull final SimulationFilter filter ) 615 throws ServiceException 616 { 617 try 618 { 619 return _attributeDAO.search( filter ); 620 } 621 catch( PersistenceException e ) 622 { 623 throw new ServiceException( ServiceException.ServiceCode.ATTRIBUTE_NOT_FOUND, e ); 624 } 625 } 626 627 @Nullable 628 public PaginatedResult<Variable> searchVariables( @NotNull final SimulationFilter filter ) 629 throws ServiceException 630 { 631 try 632 { 633 return _variableDAO.search( filter ); 634 } 635 catch( PersistenceException e ) 636 { 637 throw new ServiceException( ServiceException.ServiceCode.VARIABLE_NOT_FOUND, e ); 638 } 639 } 640 641 @Nullable 642 public PaginatedResult<Simulation> searchSimulations( @NotNull final SimulationFilter filter ) 643 throws ServiceException 644 { 645 try 646 { 647 return _simulationDAO.search( filter ); 648 } 649 catch( PersistenceException e ) 650 { 651 throw new ServiceException( ServiceException.ServiceCode.SIMULATION_NOT_FOUND, e ); 652 } 653 } 654 655 /** 656 * This method create a directory for all ".nc" files in the simulation directory 657 * And create for each a "header_init.xml" file which contents the attributes, variables, dimensions, etc... for the simulation 658 * The second line of the "header_init.xml" file is changed by "xmlnsHeader" because of the term "xmlns" which is not ok for the "unmarshall" method 659 * The real file to work becomes "header.xml" 660 * 661 * @param simulationPath 662 */ 663 public void launchNCDumpInSimulationDirectory( @NotNull final String simulationPath ) 664 throws ServiceException 665 { 666 final File simulationsDirectory = new File( simulationPath ); 667 for( final String fileName : simulationsDirectory.list() ) 668 { 669 if( fileName.endsWith( FORMAT_FILE ) ) 670 { 671 // Create directory and move simulation file into 672 final String shortFileName = fileName.substring( 0, fileName.lastIndexOf( '.' ) ); 673 final String directoryName = simulationPath + File.separatorChar + shortFileName; 674 final File directory = new File( directoryName ); 675 final File file = new File( simulationPath + File.separatorChar + fileName ); 676 if( !directory.exists() ) 677 { 678 directory.mkdir(); 679 file.renameTo( new File( directoryName + File.separatorChar + fileName ) ); 680 try 681 { 682 final Runtime runtime = Runtime.getRuntime(); 683 final String headerInit = directoryName + File.separatorChar + "header_init.xml"; 684 final String[] argsNcdump = {"/bin/sh", "-c", "/usr/bin/ncdump -h -x " + directoryName + File.separatorChar + fileName + " > " + headerInit}; 685 runtime.exec( argsNcdump ); 686 EtherHelper.waitForFileWithMax( new File( headerInit ), 5000 ); 687 final String[] argsSed = {"/bin/sh", "-c", "sed s/xmlns/xmlnsHeader/ " + directoryName + File.separatorChar + "header_init.xml > " + directoryName + File.separatorChar + FILE_HEADER_NAME}; 688 runtime.exec( argsSed ); 689 } 690 catch( IOException e ) 691 { 692 throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS_SIMULATION_NCDUMP, e ); 693 } 694 catch( InterruptedException e ) 695 { 696 throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS_SIMULATION_NCDUMP_WAIT, e ); 697 } 698 } 699 } 700 } 701 } 702 703 /** 704 * This method insert the header and the dates (variable "Times") in database 705 * The dates are saved in database as a unique String (use to split when we need to have the real values) 706 * The new variables are separatly created in the table .... 707 * The metadata are saved in the table .... 708 * 709 * @param simulationPath 710 * @param directoryName 711 */ 712 @Transactional(rollbackFor = Exception.class) 713 public void insertHeader( @NotNull final String simulationPath, @NotNull final String directoryName ) 714 throws ServiceException 715 { 716 try 717 { 718 final String fileName = simulationPath + File.separatorChar + directoryName + File.separatorChar + FILE_HEADER_NAME; 719 720 final JAXBContext context = JAXBContext.newInstance( Simulation.class ); 721 final Marshaller marshaller = context.createMarshaller(); 722 marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true ); 723 final Unmarshaller uMarshaller = context.createUnmarshaller(); 724 final Simulation simulation = (Simulation) uMarshaller.unmarshal( new File( fileName ) ); 725 726 // Extract dates for the simulation 727 final Runtime runtime = Runtime.getRuntime(); 728 final String[] argsNcdump = {"/bin/sh", "-c", "ncdump -v Times " + simulationPath + File.separatorChar + directoryName + File.separatorChar + directoryName + FORMAT_FILE + " | sed -e '1,/data:/d' -e '1,/Times/d' -e '$d'"}; 729 final Process exec = runtime.exec( argsNcdump ); 730 731 final BufferedReader bufferedReader = new BufferedReader( new InputStreamReader( exec.getInputStream() ) ); 732 final StringBuffer stringBuffer = new StringBuffer(); 733 String line; 734 while( ( line = bufferedReader.readLine() ) != null ) 735 stringBuffer.append( line ); 736 737 final String dates = stringBuffer.toString().replaceAll( "\"", "" ).replaceAll( " ", "" ).replaceAll( ";", "" ); 738 simulation.setDates( dates ); 739 740 final Integer simulationId = insertSimulation( simulation ); 741 } 742 catch( PropertyException e ) 743 { 744 throw new ServiceException( ServiceException.ServiceCode.ERROR_PROPERTY, e ); 745 } 746 catch( JAXBException e ) 747 { 748 throw new ServiceException( ServiceException.ServiceCode.ERROR_JAXB, e ); 749 } 750 catch( IOException e ) 751 { 752 throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS_SIMULATION_NCDUMP, e ); 753 } 754 } 755 756 /** 757 * This method extract data (parameters, latitudes, longitutes) from the file corresponding to the simulation for the megapoliPlot 758 * We use ncks to extract only data for a geographic area and a date 759 * http://linux.die.net/man/1/ncks 760 * Example to see easily : ncks -H -d Time,0 -d bottom_top,0 -v APINEN out.20090701_20090705_01_SMPV4_complet.nc 761 * 762 * @param modelId 763 * @param variableName 764 * @param dateNumber : the number of the date among all the available dates 765 * @param level 766 * @param writeInTemporaryFiles : use to debug and see the result of the process 767 * @return 768 * @throws IOException 769 * @throws ServiceException 770 */ 771 @Nullable 772 @Transactional(readOnly = true) 773 public List<Double> extractValuesByModelByVariableByDateByLevelFromFile( @NotNull final Integer modelId, @NotNull final String variableName, @NotNull final Integer dateNumber, @NotNull final Integer level, final boolean writeInTemporaryFiles ) 774 throws ServiceException 775 { 776 final String filePath = getLocationByModelId( modelId ); 777 final String resultFile = filePath + '_' + variableName; 778 779 try 780 { 781 final Runtime runtime = Runtime.getRuntime(); 782 // TODO : voir pour la précision -s "%f\n" 783 final String processString = "ncks -s \"%16.30f\\n\" -d Time," + dateNumber + " -d bottom_top," + level + " -v " + variableName + ' ' + filePath + " | sed '/^" + variableName + "/d'"; 784 final String[] argsNcdump = {"/bin/sh", "-c", processString}; 785 final Process exec = runtime.exec( argsNcdump ); 786 787 if( writeInTemporaryFiles ) 788 runtime.exec( new String[]{"/bin/sh", "-c", processString + " > " + resultFile} ); 789 790 // TODO : voir avec java 7 pour utiliser le Files.readAllLines() et obtenir directement une List<>, http://adiguba.developpez.com/tutoriels/java/7/ 791 final BufferedReader bufferedReader = new BufferedReader( new InputStreamReader( exec.getInputStream() ) ); 792 final List<Double> valuesList = new ArrayList<Double>(); 793 String line; 794 while( ( line = bufferedReader.readLine() ) != null ) 795 if( !line.isEmpty() ) 796 valuesList.add( Double.valueOf( line ) ); 797 798 return valuesList; 799 } 800 catch( IOException e ) 801 { 802 if( new File( resultFile ).exists() ) 803 new File( resultFile ).delete(); 804 805 throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS_SIMULATION_NCDUMP, e ); 806 } 807 } 808 809 @Nullable 810 @Transactional(readOnly = true) 811 public Dimension getDimensionById( @NotNull final Integer dimensionId ) 812 throws ServiceException 813 { 814 try 815 { 816 return _dimensionDAO.selectByPrimaryKey( dimensionId ); 817 } 818 catch( PersistenceException e ) 819 { 820 throw new ServiceException( ServiceException.ServiceCode.DIMENSION_NOT_FOUND, e ); 821 } 822 } 823 824 @Transactional(rollbackFor = Exception.class) 825 public void removeDimension( @NotNull final Integer dimensionId ) 826 throws ServiceException 827 { 828 try 829 { 830 _dimensionDAO.deleteByPrimaryKey( dimensionId ); 831 } 832 catch( PersistenceException e ) 833 { 834 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 835 } 836 } 837 838 @Nullable 839 @Transactional(readOnly = true) 840 public Attribute getAttributeById( @NotNull final Integer attributeId ) 841 throws ServiceException 842 { 843 try 844 { 845 return _attributeDAO.selectByPrimaryKey( attributeId ); 846 } 847 catch( PersistenceException e ) 848 { 849 throw new ServiceException( ServiceException.ServiceCode.ATTRIBUTE_NOT_FOUND, e ); 850 } 851 } 852 853 @Transactional(rollbackFor = Exception.class) 854 public void removeAttribute( @NotNull final Integer attributeId ) 855 throws ServiceException 856 { 857 try 858 { 859 _attributeDAO.deleteByPrimaryKey( attributeId ); 860 } 861 catch( PersistenceException e ) 862 { 863 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 864 } 865 } 866 867 @Nullable 868 @Transactional(readOnly = true) 869 public Variable getVariableById( @NotNull final Integer variableId ) 870 throws ServiceException 871 { 872 try 873 { 874 return _variableDAO.selectByPrimaryKey( variableId ); 875 } 876 catch( PersistenceException e ) 877 { 878 throw new ServiceException( ServiceException.ServiceCode.VARIABLE_NOT_FOUND, e ); 879 } 880 } 881 882 @Transactional(rollbackFor = Exception.class) 883 public void removeVariable( @NotNull final Integer variableId ) 884 throws ServiceException 885 { 886 try 887 { 888 _variableDAO.deleteByPrimaryKey( variableId ); 889 } 890 catch( PersistenceException e ) 891 { 892 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 893 } 894 } 895 896 @Nullable 897 @Transactional(readOnly = true) 898 public Simulation getSimulationById( @NotNull final Integer simulationId ) 899 throws ServiceException 900 { 901 try 902 { 903 return _simulationDAO.selectByPrimaryKey( simulationId ); 904 } 905 catch( PersistenceException e ) 906 { 907 throw new ServiceException( ServiceException.ServiceCode.SIMULATION_NOT_FOUND, e ); 908 } 909 } 910 911 @Transactional(rollbackFor = Exception.class) 912 public void removeSimulation( @NotNull final Integer simulationId ) 913 throws ServiceException 914 { 915 try 916 { 917 _simulationDAO.deleteByPrimaryKey( simulationId ); 918 } 919 catch( PersistenceException e ) 920 { 921 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 922 } 923 } 924 925 @Nullable 926 @Transactional(readOnly = true) 927 public List<Simulation> getAllSimulations() 928 throws ServiceException 929 { 930 try 931 { 932 return _simulationDAO.selectAll(); 933 } 934 catch( PersistenceException e ) 935 { 936 throw new ServiceException( ServiceException.ServiceCode.SIMULATION_NOT_FOUND, e ); 937 } 938 } 939 940 @Nullable 941 @Transactional(readOnly = true) 942 public List<List<String>> getAllModels() 943 throws ServiceException 944 { 945 try 946 { 947 return _simulationDAO.getAllModels(); 948 } 949 catch( PersistenceException e ) 950 { 951 throw new ServiceException( ServiceException.ServiceCode.MODEL_NOT_FOUND, e ); 952 } 953 } 954 955 @Nullable 956 @Transactional(readOnly = true) 957 public List<Variable> getVariablesByModelId( @NotNull final Integer modelId ) 958 throws ServiceException 959 { 960 try 961 { 962 return _variableDAO.getVariablesByModelId( modelId ); 963 } 964 catch( PersistenceException e ) 965 { 966 throw new ServiceException( ServiceException.ServiceCode.VARIABLE_NOT_FOUND, e ); 967 } 968 } 969 970 @Nullable 971 @Transactional(readOnly = true) 972 public String getLocationByModelId( @NotNull final Integer modelId ) 973 throws ServiceException 974 { 975 try 976 { 977 return _simulationDAO.getLocationByModelId( modelId ); 978 } 979 catch( PersistenceException e ) 980 { 981 throw new ServiceException( ServiceException.ServiceCode.SIMULATION_NOT_FOUND, e ); 982 } 983 } 984 985 @Nullable 986 @Transactional(readOnly = true) 987 public List<Plateforme> getPlateformsByParameter( @NotNull final String parameterCode ) 988 throws ServiceException 989 { 990 try 991 { 992 return _plateformDAO.getPlateformsByParameter( parameterCode ); 993 } 994 catch( PersistenceException e ) 995 { 996 throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e ); 997 } 998 } 999 1000 @Nullable 1001 @Transactional(readOnly = true) 1002 public Integer getParameterByCode( @NotNull final String parameterCode ) 1003 throws ServiceException 1004 { 1005 try 1006 { 1007 return _parameterDAO.getParameterByCode( parameterCode ); 1008 } 1009 catch( PersistenceException e ) 1010 { 1011 throw new ServiceException( ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e ); 1012 } 1013 } 1014 1015 /** 1016 * This method reduce the geographic map of the simulated data to the geographic map of the real data 1017 * We extract only the simulated data which are in the geographic map of the real data 1018 * 1019 * @param allParameterValues 1020 * @param allLatitudeValues 1021 * @param allLongitudeValues 1022 * @param realData 1023 * @return 1024 */ 1025 @NotNull 1026 public Data makeZoom( @NotNull final List<Double> allParameterValues, @NotNull final List<Double> allLatitudeValues, @NotNull final List<Double> allLongitudeValues, @Nullable final Data realData ) 1027 { 1028 if( null == realData ) 1029 return new Data( allParameterValues, allLatitudeValues, allLongitudeValues ); 1030 else 1031 { 1032 final Double minRealLat = Collections.min( (List<Double>) realData.getSecondArray() ); 1033 final Double maxRealLat = Collections.max( (List<Double>) realData.getSecondArray() ); 1034 final Double minRealLon = Collections.min( (List<Double>) realData.getThirdArray() ); 1035 final Double maxRealLon = Collections.max( (List<Double>) realData.getThirdArray() ); 1036 1037 final Integer indexMinLat = getNearestIndex( allLatitudeValues, minRealLat, true ); 1038 final Integer indexMaxLat = getNearestIndex( allLatitudeValues, maxRealLat, false ); 1039 final Integer indexMinLon = getNearestIndex( allLongitudeValues, minRealLon, true ); 1040 final Integer indexMaxLon = getNearestIndex( allLongitudeValues, maxRealLon, false ); 1041 1042 final Double borneMinLat = allLatitudeValues.get( indexMinLat ); 1043 final Double borneMaxLat = allLatitudeValues.get( indexMaxLat ); 1044 1045 final Double borneMinLon = allLongitudeValues.get( indexMinLon ); 1046 final Double borneMaxLon = allLongitudeValues.get( indexMaxLon ); 1047 1048 final List<Double> parameterValues = new ArrayList<Double>(); 1049 final List<Double> latitudeValues = new ArrayList<Double>(); 1050 final List<Double> longitudeValues = new ArrayList<Double>(); 1051 for( int i = 0; i < allParameterValues.size(); i++ ) 1052 { 1053 final Double latitude = allLatitudeValues.get( i ); 1054 final Double longitude = allLongitudeValues.get( i ); 1055 if( borneMinLat <= latitude && latitude <= borneMaxLat && borneMinLon <= longitude && longitude <= borneMaxLon ) 1056 { 1057 latitudeValues.add( latitude ); 1058 longitudeValues.add( longitude ); 1059 parameterValues.add( allParameterValues.get( i ) ); 1060 } 1061 } 1062 1063 return new Data( parameterValues, latitudeValues, longitudeValues ); 1064 } 1065 } 1066 1067 /** 1068 * This method flip the list 1069 * We need this operation because the ploting is lon0[lat0,lat1,lat2], lon1[lat0,lat1,lat2]... and the values extract from the file are given as lat0[lon0,lon1], lat1[lon0, lon1], lat2[lon0,lon1]... 1070 * 1071 * @param list 1072 * @param sizeLatitude 1073 * @param sizeLongitude 1074 * @return 1075 */ 1076 @NotNull 1077 public List<Double> flipList( @NotNull final List<Double> list, @NotNull final Integer sizeLatitude, @NotNull final Integer sizeLongitude ) 1078 { 1079 final List<Double> flipedList = new ArrayList<Double>( list.size() ); 1080 for( int lon = 0; lon < sizeLongitude; lon++ ) 1081 for( int lat = 0; lat < sizeLatitude; lat++ ) 1082 { 1083 flipedList.add( list.get( lon + lat * sizeLongitude ) ); 1084 } 1085 return flipedList; 1086 } 1087 1088 @Nullable 1089 private Integer getNearestIndex( @NotNull final List<Double> list, @NotNull final Double value, final boolean isForMinimum ) 1090 { 1091 boolean findValue = false; 1092 int i = 0; 1093 while( !findValue && i < list.size() ) 1094 { 1095 if( value > list.get( i ) ) 1096 i++; 1097 else 1098 findValue = true; 1099 } 1100 if( findValue && i > 1 ) 1101 return isForMinimum ? i - 1 : i; 1102 else 1103 return 0; 1104 } 1105 1106 /** 1107 * This method insert in database the new dimensions, attributes, variables and simulation 1108 * We use HashSet to avoid doublon ( no new insertion for a parameter already in DB ) 1109 * 1110 * @param simulation 1111 * @return 1112 * @throws ServiceException 1113 */ 1114 private Integer insertSimulation( final Simulation simulation ) 1115 throws ServiceException 1116 { 1117 try 1118 { 1119 // Insert dimensions 1120 final Set<Dimension> dimensionsInDB = new HashSet<Dimension>( _dimensionDAO.selectAll() ); 1121 final Set<Dimension> dimensionsInSimulation = simulation.getDimension(); 1122 final Set<Dimension> dimensionsInDBAndSimulation = new HashSet<Dimension>( dimensionsInDB ); 1123 dimensionsInDBAndSimulation.retainAll( dimensionsInSimulation ); 1124 _dimensionDAO.updateAll( dimensionsInDBAndSimulation ); 1125 final Set<Dimension> dimensionsToAdd = new HashSet<Dimension>( dimensionsInSimulation ); 1126 dimensionsToAdd.removeAll( dimensionsInDB ); 1127 _dimensionDAO.insertAll( dimensionsToAdd ); 1128 dimensionsInDBAndSimulation.addAll( dimensionsToAdd ); 1129 simulation.setDimension( dimensionsInDBAndSimulation ); 1130 1131 // Insert Attributes 1132 final Set<Attribute> attributesInDB = new HashSet<Attribute>( _attributeDAO.selectAll() ); 1133 final Set<Attribute> attributesInSimulation = simulation.getAttribute(); 1134 final Set<Attribute> attributesInDBAndSimulation = new HashSet<Attribute>( attributesInDB ); 1135 attributesInDBAndSimulation.retainAll( attributesInSimulation ); 1136 _attributeDAO.updateAll( attributesInDBAndSimulation ); 1137 final Set<Attribute> attributesToAdd = new HashSet<Attribute>( attributesInSimulation ); 1138 attributesToAdd.removeAll( attributesInDB ); 1139 _attributeDAO.insertAll( attributesToAdd ); 1140 attributesInDBAndSimulation.addAll( attributesToAdd ); 1141 simulation.setAttribute( attributesInDBAndSimulation ); 1142 1143 // Insert variables 1144 final Set<Variable> variablesInDB = new HashSet<Variable>( _variableDAO.selectAll() ); 1145 final Set<Variable> variablesInSimulation = simulation.getVariable(); 1146 final Set<Variable> variablesInDBAndSimulation = new HashSet<Variable>( variablesInDB ); 1147 variablesInDBAndSimulation.retainAll( variablesInSimulation ); 1148 _variableDAO.updateAll( variablesInDBAndSimulation ); 1149 final Set<Variable> variablesToAdd = new HashSet<Variable>( variablesInSimulation ); 1150 variablesToAdd.removeAll( variablesInDB ); 1151 _variableDAO.insertAll( variablesToAdd ); 1152 variablesInDBAndSimulation.addAll( variablesToAdd ); 1153 simulation.setVariable( variablesInDBAndSimulation ); 1154 1155 // Insert header 1156 final Simulation simulationInDB = _simulationDAO.getSimulationByLocation( simulation.getLocation() ); 1157 if( null != simulationInDB ) 1158 { 1159 simulationInDB.setXmlnsHeader( simulation.getXmlnsHeader() ); 1160 simulationInDB.setDimension( simulation.getDimension() ); 1161 simulationInDB.setAttribute( simulation.getAttribute() ); 1162 simulationInDB.setVariable( simulation.getVariable() ); 1163 _simulationDAO.update( simulationInDB ); 1164 return simulationInDB.getId(); 1165 } 1166 else 1167 return _simulationDAO.insert( simulation ); 1168 } 1169 catch( PersistenceException e ) 1170 { 1171 throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 1172 } 1173 } 1174 1175 @Required 1176 public void setPlateformDAO( final PlateformDAO plateformDAO ) 1177 { 1178 _plateformDAO = plateformDAO; 1179 } 1180 1181 @Required 1182 public void setParameterDAO( final ParameterDAO parameterDAO ) 1183 { 1184 _parameterDAO = parameterDAO; 1185 } 1186 1187 @Required 1188 public void setValueDAO( final ValueDAO valueDAO ) 1189 { 1190 _valueDAO = valueDAO; 1191 } 1192 1193 @Required 1194 public void setMeasureDAO( final MeasureDAO measureDAO ) 1195 { 1196 _measureDAO = measureDAO; 1197 } 1198 1199 @Required 1200 public void setUserDAO( final UserDAO userDAO ) 1201 { 1202 _userDAO = userDAO; 1203 } 1204 1205 @Required 1206 public void setPersonDAO( final PersonDAO personDAO ) 1207 { 1208 _personDAO = personDAO; 1209 } 1210 1211 @Required 1212 public void setMcoDAO( final McoDAO mcoDAO ) 1213 { 1214 _mcoDAO = mcoDAO; 1215 } 1216 1217 @Required 1218 public void setJeuDAO( final JeuDAO jeuDAO ) 1219 { 1220 _jeuDAO = jeuDAO; 1221 } 1222 1223 @Required 1224 public void setDimensionDAO( final DimensionDAO dimensionDAO ) 1225 { 1226 _dimensionDAO = dimensionDAO; 1227 } 1228 1229 @Required 1230 public void setAttributeDAO( final AttributeDAO attributeDAO ) 1231 { 1232 _attributeDAO = attributeDAO; 1233 } 1234 1235 @Required 1236 public void setVariableDAO( final VariableDAO variableDAO ) 1237 { 1238 _variableDAO = variableDAO; 1239 } 1240 1241 @Required 1242 public void setSimulationDAO( final SimulationDAO simulationDAO ) 1243 { 1244 _simulationDAO = simulationDAO; 1245 } 13 // @Nullable 14 // @Transactional(readOnly = true) 15 // public List<Plateforme> getAllPlateforms() 16 // throws ServiceException 17 // { 18 // try 19 // { 20 // return _plateformDAO.getAllPlateforms(); 21 // } 22 // catch( PersistenceException e ) 23 // { 24 // throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e ); 25 // } 26 // } 27 // 28 // @NotNull 29 // @Transactional(rollbackFor = Exception.class) 30 // public Integer createUser( @NotNull final User user ) 31 // throws ServiceException 32 // { 33 // try 34 // { 35 // return _userDAO.insert( user ); 36 // } 37 // catch( PersistenceException e ) 38 // { 39 // throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 40 // } 41 // } 1246 42 1247 43 private static final Log LOGGER = LogFactory.getLog( EtherServiceImpl.class ); 1248 1249 private static String FILE_HEADER_NAME = "header.xml";1250 private static String FORMAT_FILE = ".nc";1251 1252 private PlateformDAO _plateformDAO;1253 private ParameterDAO _parameterDAO;1254 private ValueDAO _valueDAO;1255 private MeasureDAO _measureDAO;1256 private UserDAO _userDAO;1257 private PersonDAO _personDAO;1258 private McoDAO _mcoDAO;1259 private JeuDAO _jeuDAO;1260 private DimensionDAO _dimensionDAO;1261 private AttributeDAO _attributeDAO;1262 private VariableDAO _variableDAO;1263 private SimulationDAO _simulationDAO;1264 44 } -
ether_statistics/service/interface/com/ether/EtherService.java
r569 r572 1 1 package com.ether; 2 3 import com.ether.mco.Mco;4 import com.ether.mco.McoFilter;5 import com.ether.simulation.Attribute;6 import com.ether.simulation.Dimension;7 import com.ether.simulation.Simulation;8 import com.ether.simulation.SimulationFilter;9 import com.ether.simulation.Variable;10 import com.ether.user.User;11 import com.ether.user.UserFilter;12 import com.ether.user.UserState;13 import com.medias.annuaire.Personne;14 import com.medias.database.objects.Jeu;15 import com.medias.database.objects.Parametre;16 import com.medias.database.objects.Plateforme;17 import org.jetbrains.annotations.NotNull;18 import org.jetbrains.annotations.Nullable;19 20 import java.util.Date;21 import java.util.List;22 2 23 3 /** … … 28 8 extends Service 29 9 { 30 @Nullable 31 List<Plateforme> getAllPlateforms() 32 throws ServiceException; 33 34 @Nullable 35 Plateforme getPlateformById( @Nullable final Integer plateformId ) 36 throws ServiceException; 37 38 @Nullable 39 Parametre getParameterById( @Nullable final Integer parameterId ) 40 throws ServiceException; 41 42 @NotNull 43 List<Parametre> getParametersByPlateformId( @NotNull final Integer plateformId ) 44 throws ServiceException; 45 46 @NotNull 47 <T1, T2, T3> Data<T1[], T2[], T3[]> getListsByPlateformByParameterByPeriodForTimeSerie( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd ) 48 throws ServiceException; 49 50 @NotNull 51 <T1, T2, T3> Data<List<T1>, List<T2>, List<T3>> getListsByPlateformByParameterByPeriodFor2D( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd ) 52 throws ServiceException; 53 54 @NotNull 55 <T1, T2, T3> Data<T1[], T2[], T3[]> getArraysByPlateformByParameterByPeriodFor2D( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd ) 56 throws ServiceException; 57 58 @NotNull 59 Integer getNumberValuesByPlateformByParameterByPeriod( @NotNull final List<Pair<Integer, Integer>> pairs, @Nullable final Date beginDate, @Nullable final Date endDate ) 60 throws ServiceException; 61 62 @Nullable 63 Date getFirstDate() 64 throws ServiceException; 65 66 @Nullable 67 Date getLastDate() 68 throws ServiceException; 69 70 @Nullable 71 User getUserById( @NotNull final Integer userId ) 72 throws ServiceException; 73 74 @Nullable 75 User getUserByEmail( @NotNull final String userEmail ) 76 throws ServiceException; 77 78 @NotNull 79 Integer createUser( @NotNull User user ) 80 throws ServiceException; 81 82 @NotNull 83 List<User> getAllUsers() 84 throws ServiceException; 85 86 @NotNull 87 List<User> getAllUsersByNameOrder() 88 throws ServiceException; 89 90 @NotNull 91 List<User> getUsersByState( @NotNull UserState userState ) 92 throws ServiceException; 93 94 void removeUserById( @NotNull final Integer userId ) 95 throws ServiceException; 96 97 void updateUser( @NotNull final User user ) 98 throws ServiceException; 99 100 void acceptOrRefuseUser( @NotNull final Integer userId, final boolean isAccepted ) 101 throws ServiceException; 102 103 @Nullable 104 Personne getPeopleByEmail( @NotNull final String email ) 105 throws ServiceException; 106 107 PaginatedResult<User> searchUsers( @NotNull final UserFilter filter ) 108 throws ServiceException; 109 110 PaginatedResult<Mco> searchMcos( @NotNull final McoFilter filter ) 111 throws ServiceException; 112 113 @Nullable 114 Mco getMcoByCode( @NotNull final String code ) 115 throws ServiceException; 116 117 @NotNull 118 Integer createMco( @NotNull Mco mco ) 119 throws ServiceException; 120 121 void removeMcoById( @NotNull final Integer mcoId ) 122 throws ServiceException; 123 124 void updateMco( @NotNull final Mco mco ) 125 throws ServiceException; 126 127 @Nullable 128 Mco getMcoById( @NotNull final Integer requestId ) 129 throws ServiceException; 130 131 @NotNull 132 List<List<Parametre>> manageMenusForParameterList( @NotNull final List<Parametre> fullParameters ); 133 134 @Nullable 135 List<Parametre> getAllParametersOrderByCategoryByName() 136 throws ServiceException; 137 138 @Nullable 139 List<Date> getAllMeasureDateByPlateformId( @NotNull final Integer plateformId ) 140 throws ServiceException; 141 142 @Nullable 143 PaginatedResult<Jeu> searchJeux( @NotNull final JeuFilter filter ) 144 throws ServiceException; 145 146 void removeJeuAndDataByName( @NotNull final String datasetName ) 147 throws ServiceException; 148 149 void cleanLocalisationAndFlagTables() 150 throws ServiceException; 151 152 @Nullable 153 Jeu getJeuById( @NotNull final Integer jeuId ) 154 throws ServiceException; 155 156 @Nullable 157 String getDatasetNameById( @NotNull final Integer jeuId ) 158 throws ServiceException; 159 160 @Nullable 161 PaginatedResult<Dimension> searchDimensions( @NotNull final SimulationFilter filter ) 162 throws ServiceException; 163 164 @Nullable 165 PaginatedResult<Attribute> searchAttributes( @NotNull final SimulationFilter filter ) 166 throws ServiceException; 167 168 @Nullable 169 PaginatedResult<Variable> searchVariables( @NotNull final SimulationFilter filter ) 170 throws ServiceException; 171 172 @Nullable 173 PaginatedResult<Simulation> searchSimulations( @NotNull final SimulationFilter filter ) 174 throws ServiceException; 175 176 public void launchNCDumpInSimulationDirectory( @NotNull final String simulationPath ) 177 throws ServiceException; 178 179 void insertHeader( @NotNull final String simulationPath, @NotNull final String directoryName ) 180 throws ServiceException; 181 182 @Nullable 183 List<Double> extractValuesByModelByVariableByDateByLevelFromFile( @NotNull final Integer modelId, @NotNull final String variableName, @NotNull final Integer dateNumber, @NotNull final Integer level, final boolean writeInTemporaryFiles ) 184 throws ServiceException; 185 186 @Nullable 187 Dimension getDimensionById( @NotNull final Integer dimensionId ) 188 throws ServiceException; 189 190 public void removeDimension( @NotNull final Integer dimensionId ) 191 throws ServiceException; 192 193 @Nullable 194 Attribute getAttributeById( @NotNull final Integer attributeId ) 195 throws ServiceException; 196 197 public void removeAttribute( @NotNull final Integer attributeId ) 198 throws ServiceException; 199 200 @Nullable 201 Variable getVariableById( @NotNull final Integer variableId ) 202 throws ServiceException; 203 204 public void removeVariable( @NotNull final Integer variableId ) 205 throws ServiceException; 206 207 @Nullable 208 Simulation getSimulationById( @NotNull final Integer simulationId ) 209 throws ServiceException; 210 211 public void removeSimulation( @NotNull final Integer simulationId ) 212 throws ServiceException; 213 214 @Nullable 215 List<Simulation> getAllSimulations() 216 throws ServiceException; 217 218 @Nullable 219 List<List<String>> getAllModels() 220 throws ServiceException; 221 222 @Nullable 223 List<Variable> getVariablesByModelId( @NotNull final Integer modelId ) 224 throws ServiceException; 225 226 @Nullable 227 String getLocationByModelId( @NotNull final Integer modelId ) 228 throws ServiceException; 229 230 @Nullable 231 List<Plateforme> getPlateformsByParameter( @NotNull final String parameterCode ) 232 throws ServiceException; 233 234 @Nullable 235 Integer getParameterByCode( @NotNull final String parameterCode ) 236 throws ServiceException; 237 238 @NotNull 239 Data makeZoom( @NotNull final List<Double> allParameterValues, @NotNull final List<Double> allLatitudeValues, @NotNull final List<Double> allLongitudeValues, @Nullable final Data realData ); 240 241 @NotNull 242 List<Double> flipList( @NotNull final List<Double> list, @NotNull final Integer sizeLatitude, @NotNull final Integer sizeLongitude ); 10 // @Nullable 11 // List<Plateforme> getAllPlateforms() 12 // throws ServiceException; 243 13 } -
ether_statistics/service/test/com/ether/EtherTest.java
r569 r572 1 1 package com.ether; 2 2 3 import gov.noaa.pmel.sgt.LineAttribute;4 import gov.noaa.pmel.util.GeoDateArray;5 3 import org.jetbrains.annotations.NotNull; 6 import org.jetbrains.annotations.Nullable;7 import org.junit.Test;8 4 9 import javax.imageio.ImageIO;10 import javax.swing.*;11 import java.awt.*;12 import java.awt.image.BufferedImage;13 import java.io.File;14 5 import java.io.Serializable; 15 import java.text.ParseException;16 import java.util.Date;17 6 18 7 /** … … 47 36 // } 48 37 49 /**50 * @param day : jour au format yyyy-MM-dd51 */52 @NotNull53 protected GeoDateArray createTimeArray( @NotNull final Integer size, @Nullable String day )54 throws ParseException55 {56 if( null == day )57 day = "2009-07-13";58 59 final Date[] dates = new Date[size];60 for( int i = 0; i < size; i++ )61 {62 final String dateString = day + ' ' + i + ":32";63 final Date date = DateHelper.parseDate( dateString, DateHelper.ENGLISH_DATE_PATTERN );64 dates[i] = date;65 }66 return new GeoDateArray( dates );67 }68 69 @NotNull70 protected double[] createDataArray( @NotNull final Integer size, @NotNull final Integer begin )71 throws ParseException72 {73 final double[] datas = new double[size];74 for( int i = 0; i < size; i++ )75 {76 datas[i] = Double.valueOf( i + begin );77 }78 return datas;79 }80 81 protected void copyToFile( @NotNull final JFrame frame, @NotNull final String fileName )82 {83 final BufferedImage image = new BufferedImage( frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_RGB );84 85 final Graphics2D g2 = image.createGraphics();86 frame.paint( g2 );87 g2.dispose();88 89 try90 {91 final File out = new File( fileName );92 ImageIO.write( image, "JPEG", out );93 }94 catch( Exception e )95 {96 }97 }98 99 38 protected <T extends Serializable> void displayArray( @NotNull final T[] objectsArray ) 100 39 { -
ether_statistics/service/test/com/ether/ServiceEtherTest.java
r569 r572 1 1 package com.ether; 2 3 import com.medias.database.objects.Plateforme;4 import com.medias.database.objects.TypePlateforme;5 2 6 3 /** -
ether_statistics/service/test/com/ether/ServiceTestHelper.java
r569 r572 1 1 package com.ether; 2 2 3 import com.medias.database.objects.Parametre;4 import com.medias.database.objects.Plateforme;5 import com.medias.database.objects.TypePlateforme;6 import com.medias.database.objects.Valeur;7 3 import org.apache.commons.logging.Log; 8 4 import org.apache.commons.logging.LogFactory; … … 33 29 public static Class[] getAllKnownDomainClasses() 34 30 { 35 return new Class[]{ 36 Plateforme.class, 37 Parametre.class, 38 Valeur.class,}; 31 return new Class[]{}; 39 32 } 40 33 -
ether_statistics/web/Web.iml
r569 r572 54 54 <orderEntry type="module" module-name="Domain" /> 55 55 <orderEntry type="module" module-name="Persistence" /> 56 <orderEntry type="library" name="lib_medias_insert" level="project" />57 <orderEntry type="library" name="lib_ether" level="project" />58 56 <orderEntry type="library" name="lib_hibernate" level="project" /> 59 57 </component>
Note: See TracChangeset
for help on using the changeset viewer.