Changeset 3991
- Timestamp:
- Nov 22, 2007, 2:06:17 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r3978 r3991 966 966 <pathelement location="${core.build}"/> 967 967 <pathelement location="${coreplugins.build}"/> 968 <pathelement location="${web.build}"/> 968 969 </path> 969 970 <path id="webservices.client.classpath" -
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java
r3985 r3991 32 32 import net.sf.basedb.core.DbControl; 33 33 import net.sf.basedb.core.DynamicQuery; 34 import net.sf.basedb.core.InvalidUseOfNullException; 34 35 import net.sf.basedb.core.Item; 35 36 import net.sf.basedb.core.ItemContext; … … 211 212 */ 212 213 private DbControl dc; 213 private int numExported;214 private String successMessage; 214 215 protected void begin(DbControl dc) 215 216 { 216 217 this.dc = dc; 217 this. numExported = 0;218 this.successMessage = ""; 218 219 } 219 220 … … 233 234 new ArrayList<ExportedProperty>(columns.size()); 234 235 List<String> properties = new ArrayList<String>(columns.size()); 235 boolean hasAnnotations = false;236 236 boolean annotatable = itemType.getItemClass() != null && 237 237 Annotatable.class.isAssignableFrom(itemType.getItemClass()); … … 239 239 formatter.registerFormatter(Date.class, FormatterFactory.getDateFormatter(sc)); 240 240 for (String column : columns) 241 { 242 ExportedProperty ep = ExportedProperty.parse(dc, column, annotatable, formatter); 243 hasAnnotations |= ep.annotationType != null; 241 { 242 ExportedProperty ep = ExportedProperty.parse(dc, column, annotatable, formatter); 244 243 exportedProperties.add(ep); 245 properties.add(ep.name); 246 } 247 248 // Open stream for output and set file name and MIME type 249 Writer exportStream = new OutputStreamWriter(out, "UTF-8"); 250 // Create export template for outputting the data 251 ExportTemplate template = "xml".equals(format) ? 252 new XMLTemplate(exportStream, exportedProperties, itemType) : 253 new PlainTextTemplate(exportStream, exportedProperties, itemType); 254 out.setFilename(itemType.name().toLowerCase()+".export.txt"); 255 out.setMimeType(template.getMimeType()); 256 257 // Write start of document and headers 258 template.beginDocument(); 259 template.writeHeaders(); 244 properties.add(ep.name); 245 } 260 246 261 247 // Get the query from the current context 262 248 ItemContext cc = sc.getCurrentContext(itemType, subContext); 263 249 Query query = cc.getQuery(); 264 QueryWrapper queryWrapper = null;265 ResultIterator result = null;266 250 Set<Integer>selectedItems = cc.getSelected(); 267 268 // The query wrapper allows us to get results from the query in a simplier way 269 if (query instanceof ItemQuery) 270 { 271 queryWrapper = new ItemQueryWrapper(dc, (ItemQuery<BasicItem>)query, itemType); 272 } 273 else if (query instanceof DataQuery) 274 { 275 String entityName = null; 276 if (itemType == Item.RAWDATA) 277 { 278 RawBioAssay rba = RawBioAssay.getById(dc, sc.getCurrentContext(Item.RAWBIOASSAY).getId()); 279 entityName = rba.getRawDataType().getEntityName(); 280 } 281 queryWrapper = new DataQueryWrapper(dc, (DataQuery<BasicData>)query, itemType, entityName); 282 } 283 else if (query instanceof ReporterScoreQuery) 284 { 285 queryWrapper = new ReporterScoreQueryWrapper(dc, (ReporterScoreQuery)query); 286 } 287 else if (query instanceof DynamicQuery) 288 { 289 DynamicQuery dynamicQuery = (DynamicQuery)query; 290 cc.configureQuery(dc, dynamicQuery, properties); 291 queryWrapper = new DynamicQueryWrapper(dc, dynamicQuery); 251 if (query instanceof DynamicQuery) 252 { 253 cc.configureQuery(dc, (DynamicQuery)query, properties); 292 254 } 293 255 294 256 // Configure the query with additional filters depending on which items should be exported 295 257 query.setReturnTotalCount(false); 296 boolean needToStep = false;258 //boolean needToStep = false; 297 259 int itemsPerStep = Config.getInt("export.max.items", 0); 298 260 // Which of "all", "current page", or "selected" is selected? 299 261 long totalItems = 0; 300 262 if ("all".equals(whichItems)) 301 { 302 needToStep = itemsPerStep > 0; 263 { 303 264 query.setFirstResult(0); 304 265 query.setMaxResults(itemsPerStep); … … 337 298 query.setParameter("_excludes_", Arrays.asList(Values.getInt(exclude.split(","))), Type.INT); 338 299 } 300 301 exportProperties(dc, out, format, exportedProperties, itemType, query, progress); 302 } 303 304 protected void end(boolean success) 305 { 306 this.dc = null; 307 } 308 protected String getSuccessMessage() 309 { 310 return successMessage; 311 } 312 // ------------------------------------------- 313 314 private void initGuiContexts() 315 { 316 for (Item i : Item.values()) 317 { 318 if (i.getDataClass() != null) 319 { 320 guiContexts.add(new GuiContext(i, GuiContext.Type.LIST)); 321 } 322 } 323 guiContexts.add(new GuiContext(Item.REPORTERSCORE, GuiContext.Type.LIST)); 324 guiContexts.add(new GuiContext(Item.SPOTDATA, GuiContext.Type.LIST)); 325 } 326 327 private RequestInformation getConfigureJobParameters(GuiContext context) 328 { 329 if (configureJob == null) 330 { 331 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 332 333 parameters.add(getFormatParameter()); 334 parameters.add(getWhichItemsParameter()); 335 parameters.add(getWhichPropertiesParameter()); 336 parameters.add(getSaveAsParameter(null, null, null, false)); 337 parameters.add(getOverwriteParameter(null, null)); 338 339 configureJob = new RequestInformation 340 ( 341 Request.COMMAND_CONFIGURE_JOB, 342 "Export " + context.getItem(), 343 "Set options for which items and which columns that should be exported.", 344 parameters, "simple_export.jsp" 345 ); 346 } 347 return configureJob; 348 } 349 350 private static final String FORMAT = "format"; 351 private PluginParameter<String> getFormatParameter() 352 { 353 String label = "Format"; 354 String description = "You may select to export in text or XML format."; 355 Enumeration<String, String> options = new Enumeration<String, String>(); 356 options.add("text", "Tab-separated text file"); 357 options.add("xml", "XML"); 358 PluginParameter<String> formatParameter = new PluginParameter<String> 359 ( 360 FORMAT, label, description, "text", 361 new StringParameterType(255, "text", true, 1, 0, 0, options) 362 ); 363 return formatParameter; 364 } 365 366 private static final String WHICH_ITEMS = "whichItems"; 367 private PluginParameter<String> getWhichItemsParameter() 368 { 369 String label = "Which items?"; 370 String description = "Select which items you want to export"; 371 Enumeration<String, String> options = new Enumeration<String, String>(); 372 options.add("selected", "Selected items"); 373 options.add("page", "Current page"); 374 options.add("all", "All pages"); 375 PluginParameter<String> whichItemsParameter = new PluginParameter<String> 376 ( 377 WHICH_ITEMS, label, description, "all", 378 new StringParameterType(255, "all", true, 1, 0, 0, options) 379 ); 380 return whichItemsParameter; 381 } 382 383 private static final String WHICH_PROPERTIES = "whichProperties"; 384 private PluginParameter<String> getWhichPropertiesParameter() 385 { 386 String label = "Which properties?"; 387 String description = "Enter the names of the properties you want to export. " + 388 "Use a colon to separate an optional title from the property name. For example: " + 389 "name:Name of sample"; 390 PluginParameter<String> whichPropertiesParameter = new PluginParameter<String> 391 ( 392 WHICH_PROPERTIES, label, description, null, 393 new StringParameterType(255, null, true, 0, 0, 0) 394 ); 395 return whichPropertiesParameter; 396 } 397 398 /** 399 Exports properties from a query to an output stream. 400 The export can be either tab-separated text or XML. 401 @param dc The DbControl to use when accessing the database 402 @param out Output stream to export to. 403 @param format Use 'xml' to export in XML-format. All other inputs will give a tab-separated format. 404 @param exportedProperties A list of which properties to include in the export. 405 @param itemType Kind of item the export is about 406 @param query This query is used to get the items to export. 407 @param progress Optional progress reporter to get overview of how the export is proceeding. 408 @throws IOException If anything goes wrong with export to the output stream. 409 */ 410 @SuppressWarnings("unchecked") 411 public void exportProperties(DbControl dc, ExportOutputStream out, String format, List<ExportedProperty> exportedProperties, 412 Item itemType, Query query, ProgressReporter progress) 413 throws IOException 414 { 415 if (dc == null) throw new InvalidUseOfNullException("dc"); 416 if (out == null) throw new InvalidUseOfNullException("out"); 417 if (exportedProperties == null) throw new InvalidUseOfNullException("exportedProperties"); 418 if (itemType == null) throw new InvalidUseOfNullException("itemType"); 419 if (query == null) throw new InvalidUseOfNullException("query"); 420 421 this.dc = dc; 422 boolean hasAnnotations = false; 423 int itemsPerStep = Config.getInt("export.max.items", 0); 424 boolean needToStep = query.getMaxResults() > 0 ? (itemsPerStep > 0) : false; 425 long totalItems = query.getMaxResults() == 0 ? query.count(dc) : query.getMaxResults(); 426 427 for (ExportedProperty ep : exportedProperties) 428 { 429 hasAnnotations |= ep.annotationType != null; 430 } 431 QueryWrapper queryWrapper = null; 432 // The query wrapper allows us to get results from the query in a simplier way 433 if (query instanceof ItemQuery) 434 { 435 queryWrapper = new ItemQueryWrapper(dc, (ItemQuery<BasicItem>)query, itemType); 436 } 437 else if (query instanceof DataQuery) 438 { 439 String entityName = null; 440 if (itemType == Item.RAWDATA) 441 { 442 RawBioAssay rba = RawBioAssay.getById(dc, sc.getCurrentContext(Item.RAWBIOASSAY).getId()); 443 entityName = rba.getRawDataType().getEntityName(); 444 } 445 queryWrapper = new DataQueryWrapper(dc, (DataQuery<BasicData>)query, itemType, entityName); 446 } 447 else if (query instanceof ReporterScoreQuery) 448 { 449 queryWrapper = new ReporterScoreQueryWrapper(dc, (ReporterScoreQuery)query); 450 } 451 else if (query instanceof DynamicQuery) 452 { 453 DynamicQuery dynamicQuery = (DynamicQuery)query; 454 queryWrapper = new DynamicQueryWrapper(dc, dynamicQuery); 455 } 456 457 // Open stream for output and set file name and MIME type 458 Writer exportStream = new OutputStreamWriter(out, "UTF-8"); 459 // Create export template for outputting the data 460 ExportTemplate template = "xml".equals(format) ? 461 new XMLTemplate(exportStream, exportedProperties, itemType) : 462 new PlainTextTemplate(exportStream, exportedProperties, itemType); 463 out.setFilename(itemType.name().toLowerCase()+".export.txt"); 464 out.setMimeType(template.getMimeType()); 465 466 // Write start of document and headers 467 template.beginDocument(); 468 template.writeHeaders(); 469 470 int numExported = 0; 471 ResultIterator result = null; 339 472 try 340 473 { … … 384 517 while (needToStep && (numExported % itemsPerStep == 0)); 385 518 template.endDocument(); 519 successMessage = numExported + " items were exported successfully"; 386 520 } 387 521 catch (Exception ex) … … 396 530 } 397 531 } 398 399 protected void end(boolean success)400 {401 this.dc = null;402 }403 protected String getSuccessMessage()404 {405 return numExported + " items were exported successfully";406 }407 // -------------------------------------------408 409 private void initGuiContexts()410 {411 for (Item i : Item.values())412 {413 if (i.getDataClass() != null)414 {415 guiContexts.add(new GuiContext(i, GuiContext.Type.LIST));416 }417 }418 guiContexts.add(new GuiContext(Item.REPORTERSCORE, GuiContext.Type.LIST));419 guiContexts.add(new GuiContext(Item.SPOTDATA, GuiContext.Type.LIST));420 }421 422 private RequestInformation getConfigureJobParameters(GuiContext context)423 {424 if (configureJob == null)425 {426 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();427 428 parameters.add(getFormatParameter());429 parameters.add(getWhichItemsParameter());430 parameters.add(getWhichPropertiesParameter());431 parameters.add(getSaveAsParameter(null, null, null, false));432 parameters.add(getOverwriteParameter(null, null));433 434 configureJob = new RequestInformation435 (436 Request.COMMAND_CONFIGURE_JOB,437 "Export " + context.getItem(),438 "Set options for which items and which columns that should be exported.",439 parameters, "simple_export.jsp"440 );441 }442 return configureJob;443 }444 445 private static final String FORMAT = "format";446 private PluginParameter<String> getFormatParameter()447 {448 String label = "Format";449 String description = "You may select to export in text or XML format.";450 Enumeration<String, String> options = new Enumeration<String, String>();451 options.add("text", "Tab-separated text file");452 options.add("xml", "XML");453 PluginParameter<String> formatParameter = new PluginParameter<String>454 (455 FORMAT, label, description, "text",456 new StringParameterType(255, "text", true, 1, 0, 0, options)457 );458 return formatParameter;459 }460 461 private static final String WHICH_ITEMS = "whichItems";462 private PluginParameter<String> getWhichItemsParameter()463 {464 String label = "Which items?";465 String description = "Select which items you want to export";466 Enumeration<String, String> options = new Enumeration<String, String>();467 options.add("selected", "Selected items");468 options.add("page", "Current page");469 options.add("all", "All pages");470 PluginParameter<String> whichItemsParameter = new PluginParameter<String>471 (472 WHICH_ITEMS, label, description, "all",473 new StringParameterType(255, "all", true, 1, 0, 0, options)474 );475 return whichItemsParameter;476 }477 478 private static final String WHICH_PROPERTIES = "whichProperties";479 private PluginParameter<String> getWhichPropertiesParameter()480 {481 String label = "Which properties?";482 String description = "Enter the names of the properties you want to export. " +483 "Use a colon to separate an optional title from the property name. For example: " +484 "name:Name of sample";485 PluginParameter<String> whichPropertiesParameter = new PluginParameter<String>486 (487 WHICH_PROPERTIES, label, description, null,488 new StringParameterType(255, null, true, 0, 0, 0)489 );490 return whichPropertiesParameter;491 }492 493 532 } -
trunk/src/test/TestWebservices.java
r3978 r3991 613 613 "--No extended properties were received"); 614 614 615 write("--Test of getReporterLists OK"); 615 if (listInfo.length > 0 && extPropertyInfos.length > 0) 616 { 617 System.out.print("--Download of reporters in reporterlist '" + listInfo[0].getName() +"'...." ); 618 File receivedFile = new File(listInfo[0].getName() + ".txt"); 619 OutputStream out = new FileOutputStream(receivedFile); 620 621 InputStream in = reporterClient.downloadReportersInList(listInfo[0].getId(), extPropertyInfos, new QueryOptions()); 622 623 if (in == null) 624 { 625 write ("FAILED InputStream==null"); 626 ok = false; 627 } 628 else 629 { 630 FileUtil.copy(in, out); 631 in.close(); 632 out.close(); 633 write("OK; size=" + receivedFile.length() + " bytes"); 634 receivedFile.delete(); 635 } 636 637 receivedFile = null; 638 out = null; 639 640 //Test to receive reporters from service, at most 50 reporters 641 System.out.print("--Download of reporters...."); 642 receivedFile = new File("ReporterFile.txt"); 643 out = new FileOutputStream(receivedFile); 644 in = null; 645 QueryOptions qOpt = new QueryOptions(); 646 in = reporterClient.downloadReporters(extPropertyInfos, qOpt); 647 648 if (in == null) 649 { 650 write ("FAILED InputStream==null"); 651 ok = false; 652 } 653 else 654 { 655 FileUtil.copy(in, out); 656 in.close(); 657 out.close(); 658 write("OK; size=" + receivedFile.length() + " bytes"); 659 receivedFile.delete(); 660 } 661 } 662 663 write("--Test of ReporterService OK"); 616 664 } 617 665 catch (Throwable t) -
trunk/src/webservices/client/java/net/sf/basedb/ws/client/ReporterClient.java
r3978 r3991 25 25 26 26 import net.sf.basedb.info.ExtendedPropertyInfo; 27 import net.sf.basedb.info.QueryOptions; 28 29 import java.io.IOException; 30 import java.io.InputStream; 27 31 28 32 import org.apache.axis2.AxisFault; 33 import org.apache.axis2.Constants; 34 import org.apache.axis2.client.Options; 35 import org.apache.axis2.rpc.client.RPCServiceClient; 29 36 30 37 /** … … 61 68 } 62 69 70 /** 71 Gets an input stream for a file with info about 72 reporters in a reporter list. 73 @param reporterListId Id of the reporter list to export and download. 74 @param extPropInfo An array of ExtendedPropertyInfo objects to include in the export/download. 75 @return InputStream object to the exported data. 76 @throws IOException If something goes wrong with the input stream 77 */ 78 public InputStream downloadReportersInList(int reporterListId, ExtendedPropertyInfo[] extPropInfo, QueryOptions qOpt) 79 throws IOException 80 { 81 RPCServiceClient service = getService(); 82 Options options = service.getOptions(); 83 options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); 84 options.setTimeOutInMilliSeconds(10000); 85 service.setOptions(options); 86 return invokeFileBlocking 87 ( 88 "downloadReportersInList", 89 session.getId(), 90 reporterListId, 91 extPropInfo, 92 qOpt 93 ); 94 } 95 96 public InputStream downloadReporters(ExtendedPropertyInfo[] extPropInfo, QueryOptions qOpt) 97 throws IOException 98 { 99 RPCServiceClient service = getService(); 100 Options options = service.getOptions(); 101 options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); 102 options.setTimeOutInMilliSeconds(10000); 103 service.setOptions(options); 104 return invokeFileBlocking 105 ( 106 "downloadReporters", 107 session.getId(), 108 extPropInfo, 109 qOpt 110 ); 111 } 112 63 113 } -
trunk/src/webservices/server/net/sf/basedb/ws/server/ReporterService.java
r3978 r3991 24 24 package net.sf.basedb.ws.server; 25 25 26 import net.sf.basedb.clients.web.formatter.FormatterFactory; 27 import net.sf.basedb.clients.web.plugins.ExportedProperty; 28 import net.sf.basedb.clients.web.plugins.SimpleExport; 29 import net.sf.basedb.core.DbControl; 26 30 import net.sf.basedb.core.ExtendedProperties; 27 31 import net.sf.basedb.core.ExtendedProperty; 32 import net.sf.basedb.core.Item; 33 import net.sf.basedb.core.Reporter; 34 import net.sf.basedb.core.ReporterList; 35 import net.sf.basedb.core.ReporterScoreQuery; 36 import net.sf.basedb.core.SessionControl; 37 import net.sf.basedb.core.plugin.ExportOutputStream; 38 import net.sf.basedb.core.query.Hql; 39 import net.sf.basedb.core.query.Query; 28 40 import net.sf.basedb.info.ExtendedPropertyInfo; 41 import net.sf.basedb.info.QueryOptions; 42 import net.sf.basedb.util.formatter.MultiFormatter; 43 import net.sf.basedb.util.formatter.ToStringFormatter; 29 44 45 import java.io.File; 46 import java.io.FileOutputStream; 47 import java.util.ArrayList; 48 import java.util.Date; 30 49 import java.util.List; 50 51 import javax.activation.DataSource; 52 53 import org.apache.axiom.om.OMElement; 31 54 32 55 /** … … 57 80 } 58 81 } 82 83 /** 84 Gets an input stream to exported data from a reporter list. 85 @param ID Id of an active session. 86 @param reporterListId Id of the reporter list to download reporters information from. 87 @param extPropInfos The extended property to include in the download. 88 @return java.io.InputStream object to the exported data. 89 @throws Exception If something goes wrong with the export. 90 */ 91 public OMElement downloadReportersInList(String ID, int reporterListId, ExtendedPropertyInfo[] extPropInfos, QueryOptions qOpt) 92 throws Exception 93 { 94 SessionControl sc = getSessionControl(ID); 95 DbControl dc = sc.newDbControl(); 96 97 ExportOutputStream eos = null; 98 File exportFile = null; 99 OMElement elementWithAttachment = null; 100 String elementName = "exportFile"; 101 String format = "text"; 102 Item itemType = Item.REPORTERSCORE; 103 104 boolean annotatable = false; 105 MultiFormatter formatter = new MultiFormatter(new ToStringFormatter(), true); 106 formatter.registerFormatter(Date.class, FormatterFactory.getDateFormatter(sc)); 107 List<ExportedProperty> exportedProperties = new ArrayList<ExportedProperty>(extPropInfos.length); 108 //Fill the list with properties to export, name, external id and reporter type are always included. 109 exportedProperties.add(ExportedProperty.parse(dc, "reporter.name:Name", annotatable, formatter)); 110 exportedProperties.add(ExportedProperty.parse(dc, "reporter.externalId:External ID", annotatable, formatter)); 111 exportedProperties.add(ExportedProperty.parse(dc, "reporter.reporterType.name:Reporter type", annotatable, formatter)); 112 exportedProperties.add(ExportedProperty.parse(dc, "score:Score", annotatable, formatter)); 113 for (int i=0; i<extPropInfos.length; i++) 114 { 115 String propertyString = "reporter."+extPropInfos[i].getName() + ":" + extPropInfos[i].getTitle(); 116 ExportedProperty ep = ExportedProperty.parse(dc, propertyString, annotatable, formatter); 117 exportedProperties.add(ep); 118 } 119 120 //Get and configure the query that select the reporters in the reporter list. 121 ReporterList reporterList = ReporterList.getById(dc, reporterListId); 122 ReporterScoreQuery query = reporterList.getReporterScores(); 123 if (qOpt != null && qOpt.getRestriction() != null) 124 { 125 query.restrict(Hql.restriction(qOpt.getRestriction(), qOpt.getRestrictionPrefix())); 126 } 127 128 //Do the export to a temporary file and attach this file to the message that will be returned to the client. 129 try 130 { 131 SimpleExport exporter = new SimpleExport(); 132 exportFile = File.createTempFile("ReporterListFile", null); 133 eos = new ExportOutputStream(new FileOutputStream(exportFile)); 134 exporter.exportProperties(dc, eos, format, exportedProperties, itemType, query, null); 135 eos.close(); 136 137 DataSource source = new TempFileDataSource(exportFile, "text/plain"); 138 elementWithAttachment = attachFile(source, elementName); 139 } 140 finally 141 { 142 if (dc != null) dc.close(); 143 } 144 return elementWithAttachment; 145 } 146 147 public OMElement downloadReporters(String ID, ExtendedPropertyInfo[] extPropInfos, QueryOptions qOpt) 148 throws Exception 149 { 150 SessionControl sc = getSessionControl(ID); 151 DbControl dc = sc.newDbControl(); 152 153 ExportOutputStream eos = null; 154 File exportFile = null; 155 OMElement elementWithAttachment = null; 156 String elementName = "exportFile"; 157 String format = "text"; 158 Item itemType = Item.REPORTER; 159 160 boolean annotatable = false; 161 MultiFormatter formatter = new MultiFormatter(new ToStringFormatter(), true); 162 formatter.registerFormatter(Date.class, FormatterFactory.getDateFormatter(sc)); 163 List<ExportedProperty> exportedProperties = new ArrayList<ExportedProperty>(extPropInfos.length); 164 //Fill the list with properties to export, name, external id and reporter type are always included. 165 exportedProperties.add(ExportedProperty.parse(dc, "name:Name", annotatable, formatter)); 166 exportedProperties.add(ExportedProperty.parse(dc, "externalId:External ID", annotatable, formatter)); 167 exportedProperties.add(ExportedProperty.parse(dc, "reporterType.name:Reporter type", annotatable, formatter)); 168 for (int i=0; i<extPropInfos.length; i++) 169 { 170 String propertyString = extPropInfos[i].getName() + ":" + extPropInfos[i].getTitle(); 171 ExportedProperty ep = ExportedProperty.parse(dc, propertyString, annotatable, formatter); 172 exportedProperties.add(ep); 173 } 174 175 Query query = Reporter.getQuery(); 176 if (qOpt != null && qOpt.getRestriction() != null) 177 { 178 query.restrict(Hql.restriction(qOpt.getRestriction(), qOpt.getRestrictionPrefix())); 179 } 180 181 //Do the export to a temporary file and attach this file to the message that will be returned to the client. 182 try 183 { 184 SimpleExport exporter = new SimpleExport(); 185 exportFile = File.createTempFile("ReporterFile", null); 186 eos = new ExportOutputStream(new FileOutputStream(exportFile)); 187 exporter.exportProperties(dc, eos, format, exportedProperties, itemType, query, null); 188 eos.close(); 189 DataSource source = new TempFileDataSource(exportFile, "text/plain"); 190 elementWithAttachment = attachFile(source, elementName); 191 } 192 finally 193 { 194 if (dc != null) dc.close(); 195 } 196 return elementWithAttachment; 197 } 59 198 }
Note: See TracChangeset
for help on using the changeset viewer.