Changeset 470 for tapas/service
- Timestamp:
- 04/06/12 17:01:41 (12 years ago)
- Location:
- tapas/service
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tapas/service/implementation/com/ether/TapasServiceImpl.java
r466 r470 6 6 import com.ether.tapas.Request; 7 7 import com.ether.tapas.Tapas; 8 import com.ether.user.User; 8 9 import org.apache.commons.logging.Log; 9 10 import org.apache.commons.logging.LogFactory; … … 18 19 import org.springframework.transaction.annotation.Transactional; 19 20 21 22 import java.io.File; 23 import java.io.FileInputStream; 20 24 import java.io.FileOutputStream; 25 import java.io.IOException; 26 import java.lang.reflect.Array; 21 27 import java.util.List; 28 import java.util.Properties; 22 29 23 30 /** … … 30 37 { 31 38 @Transactional(readOnly = true) 32 public void createXMLRequest( @NotNull final Tapas fTapas )39 public void createXMLRequest( @NotNull final Tapas fTapas, @NotNull final User user ) 33 40 throws ServiceException 34 41 { … … 67 74 final Attribute validF = new Attribute( "valid", "ACII,FITS,NETCDF" ); 68 75 format.setAttribute( validF ); 69 format.setText( iRequest.getPreference().getFormat().getSecondValue() );76 format.setText( iRequest.getPreference().getFormat().getSecondValue() ); 70 77 preferences.addContent( format ); 71 78 … … 75 82 Attribute validR = new Attribute( "valid", "YES,NO" ); 76 83 rayleighExtinction.setAttribute( validR ); 77 rayleighExtinction.setText( iRequest.getPreference().getRayleighExtinction().getSecondValue() );84 rayleighExtinction.setText( iRequest.getPreference().getRayleighExtinction().getSecondValue() ); 78 85 preferences.addContent( rayleighExtinction ); 79 86 80 87 //h2o 81 88 final Element h2oe = new Element( "h2o_extinction" ); 82 validR = new Attribute( "valid", "YES,NO" );89 validR = new Attribute( "valid", "YES,NO" ); 83 90 h2oe.setAttribute( validR ); 84 91 h2oe.setText( iRequest.getPreference().getH2oExtinction().getSecondValue() ); … … 87 94 //o2 88 95 final Element o2e = new Element( "o2_extinction" ); 89 validR = new Attribute( "valid", "YES,NO" );96 validR = new Attribute( "valid", "YES,NO" ); 90 97 o2e.setAttribute( validR ); 91 98 o2e.setText( iRequest.getPreference().getO2Extinction().getSecondValue() ); … … 94 101 //o3 95 102 final Element o3e = new Element( "o3_extinction" ); 96 validR = new Attribute( "valid", "YES,NO" );103 validR = new Attribute( "valid", "YES,NO" ); 97 104 o3e.setAttribute( validR ); 98 o3e.setText( iRequest.getPreference().getO3Extinction().getSecondValue() );105 o3e.setText( iRequest.getPreference().getO3Extinction().getSecondValue() ); 99 106 preferences.addContent( o3e ); 100 107 101 108 //co2 102 109 final Element co2e = new Element( "co2_extinction" ); 103 validR = new Attribute( "valid", "YES,NO" );110 validR = new Attribute( "valid", "YES,NO" ); 104 111 co2e.setAttribute( validR ); 105 112 co2e.setText( iRequest.getPreference().getCo2Extinction().getSecondValue() ); … … 116 123 // date mesure 117 124 final Element mdate = new Element( "date" ); 118 mdate.setText( iRequest.getObservation().getDate() );125 mdate.setText( iRequest.getObservation().getDate() ); 119 126 120 127 observation.addContent( mdate ); … … 131 138 catch( PersistenceException e ) 132 139 { 133 throw new ServiceException( ServiceException.ServiceCode.OBSERVATORY_NOT_FOUND,e);140 throw new ServiceException( ServiceException.ServiceCode.OBSERVATORY_NOT_FOUND, e ); 134 141 } 135 142 136 143 137 144 final Element name = new Element( "name" ); 138 name.setText( obs.getName());145 name.setText( obs.getName() ); 139 146 observatory.addContent( name ); 140 147 … … 148 155 149 156 final Element altitude = new Element( "altitude" ); 150 altitude.setText( obs.getAltitude().toString() );157 altitude.setText( obs.getAltitude().toString() ); 151 158 observatory.addContent( altitude ); 152 153 159 154 160 … … 161 167 los.addContent( ra_j2000 ); 162 168 163 final Element dec_j2000 169 final Element dec_j2000 = new Element( "dec_j2000" ); 164 170 dec_j2000.setText( iRequest.getObservation().getLos().getDecJ2000() ); 165 171 los.addContent( dec_j2000 ); … … 173 179 zenith_angle.setAttribute( a2 ); 174 180 175 zenith_angle.setText( iRequest.getObservation().getLos().getZenithAngle() );181 zenith_angle.setText( iRequest.getObservation().getLos().getZenithAngle() ); 176 182 177 183 los.addContent( zenith_angle ); … … 183 189 184 190 final Element spectral_choice = new Element( "spectral_choice" ); 185 Attribute a3 = new Attribute( "valid", iRequest.getObservation().getInstrument().getSpectralChoice().getFirstValue()); 191 192 193 final String[] tabMess = iRequest.getObservation().getInstrument().getSpectralChoice().getFirstValue().split( "," ); 194 195 String chValid = ""; 196 int i; 197 198 for( i = 0; i <= tabMess.length - 1; i++ ) //final String mess : tabMess ) 199 { 200 201 if( i == tabMess.length - 1 ) 202 chValid += EtherHelper.getMessage( "label.spectralUnit." + tabMess[i], null ); 203 else chValid += EtherHelper.getMessage( "label.spectralUnit." + tabMess[i], null ) + ","; 204 } 205 206 207 Attribute a3 = new Attribute( "valid", chValid ); 208 186 209 spectral_choice.setAttribute( a3 ); 187 spectral_choice.setText( iRequest.getObservation().getInstrument().getSpectralChoice().getSecondValue()); 210 final String message = EtherHelper.getMessage( "label.spectralUnit." + iRequest.getObservation().getInstrument().getSpectralChoice().getSecondValue(), null ); 211 spectral_choice.setText( message ); 188 212 instrument.addContent( spectral_choice ); 189 213 190 214 final Element spectral_range = new Element( "spectral_range" ); 215 spectral_range.setText( iRequest.getObservation().getInstrument().getSpectralRange() ); 216 instrument.addContent( spectral_range ); 217 218 219 // 220 final Element ilsfChoice = new Element( "ilsfChoice" ); 221 validR = new Attribute( "valid", iRequest.getObservation().getInstrument().getIlsfChoice().getFirstValue() ); 222 ilsfChoice.setAttribute( validR ); 223 //selectInstrumentalFunctions 224 ilsfChoice.setText( String.valueOf( iRequest.getObservation().getInstrument().getIlsfChoice().getSecondValue() ) ); 225 instrument.addContent( ilsfChoice ); 226 227 228 final Element resolvingPower = new Element( "resolving_power" ); 229 validR = new Attribute( "min", "0" ); 230 resolvingPower.setAttribute( validR ); 231 resolvingPower.setText( String.valueOf( iRequest.getObservation().getInstrument().getResolvingPower().getSecondValue() ) ); 232 instrument.addContent( resolvingPower ); 233 234 final Element samplingRatio = new Element( "sampling_ratio" ); 235 validR = new Attribute( "min", "0" ); 236 samplingRatio.setAttribute( validR ); 237 samplingRatio.setText( String.valueOf( iRequest.getObservation().getInstrument().getSamplingRatio().getSecondValue() ) ); 238 instrument.addContent( samplingRatio ); 191 239 192 240 request.addContent( observation ); 241 242 //atmosphere 243 final Element atmosphere = new Element( "atmosphere" ); 244 request.addContent( atmosphere ); 245 246 //reference 247 final Element reference = new Element( "reference" ); 248 validR = new Attribute( "valid", "0,1,2,3,4,5,6" ); 249 reference.setAttribute( validR ); 250 reference.setText( String.valueOf( iRequest.getAtmosphere().getReference().getSecondValue() ) ); 251 atmosphere.addContent( reference ); 252 253 final Properties prop = new Properties(); 254 try 255 { 256 prop.load( new FileInputStream( "/home_local/workspace/tapas.properties" ) ); 257 } 258 catch( IOException e ) 259 { 260 throw new ServiceException( ServiceException.ServiceCode.PROPERTIES_FILE_NOT_FOUND, e ); 261 } 262 263 final String rootPath = prop.getProperty( "root_file_path" ); 264 final String userPath = ""; 265 266 267 String fileArletty = "", fileECMWF = ""; 268 fileArletty = rootPath + "/" + user.getLastName() + "/" + createFileName( iRequest.getObservation().getDate(), "arletty" ); 269 fileECMWF = rootPath + "/" + user.getLastName() + "/" + createFileName( iRequest.getObservation().getDate(), "ecmwf" ); 270 271 272 final Element arlettyFile = new Element( "arletty_file" ); 273 arlettyFile.setText( fileArletty ); 274 atmosphere.addContent( arlettyFile ); 275 276 final Element ecmwfFile = new Element( "ecmwf_file" ); 277 ecmwfFile.setText( fileECMWF ); 278 atmosphere.addContent( ecmwfFile ); 279 193 280 194 281 //creer le nom des fichiers input ECMW F + ARLETTY Ã partir du nom court de l'observatoire … … 203 290 createXMLFile( fichier, document ); 204 291 } 292 293 294 /* public String findMeasureHour( String date ) 295 { 296 String heure; 297 int val; 298 299 300 val = Math.abs( Integer.parseInt( heure ) ); 301 302 return heure; 303 } */ 304 305 public String createFileName( String date, String type ) 306 { 307 308 String fileName = "test_"+type+"_"+date+".txt"; 309 310 311 /*String heure = date.substring( 4, 6 ); 312 313 int iheure = Math.abs( Integer.parseInt( heure ) ); 314 315 316 if( iheure < 3) ind = "00"; 317 else if ( iheure >= 21) { 318 ind = "00"; 319 } 320 else if( Math.abs(6-iheure) < 3) ind = "06"; 321 else if( Math.abs(12 - iheure) < 3) ind = "12"; 322 else if( Math.abs(18 - iheure) < 3 ) ind = "18"; 323 324 325 if( type == "arletty" ) fileName = "arletty_" + date + ".txt"; 326 else if( type == "ecmwf" ) fileName = "ecmwf_" + date + ".txt"; 327 */ 328 329 330 return fileName; 331 } 332 205 333 206 334 public void createXMLFile( final String fichier, final Document document ) -
tapas/service/interface/com/ether/ServiceException.java
r419 r470 24 24 OBSERVATORY_NOT_FOUND, 25 25 USER_NOT_FOUND, 26 PROPERTIES_FILE_NOT_FOUND; 26 27 } 27 28 } -
tapas/service/interface/com/ether/TapasService.java
r466 r470 3 3 import com.ether.tapas.Observatory; 4 4 import com.ether.tapas.Tapas; 5 import com.ether.user.User; 5 6 import org.jdom.Document; 6 7 import org.jetbrains.annotations.NotNull; … … 17 18 { 18 19 19 public void createXMLRequest( @NotNull final Tapas tapas )20 public void createXMLRequest( @NotNull final Tapas tapas, @NotNull final User user ) 20 21 throws ServiceException; 21 22 … … 28 29 public Long getNumRequest() throws ServiceException; 29 30 31 public String createFileName(String date, String type) throws ServiceException; 32 30 33 }
Note: See TracChangeset
for help on using the changeset viewer.