@Test public void getFromPrimitiveCollectionDouble() { Container container = ContainerUtils.getFromPrimitiveCollection(Arrays.asList(new Double[] {1d, 2d, 3d})); assertNotNull(container); assertEquals(3, container.size()); for (Object object : container.getItemIds()) { assertTrue(object instanceof Double); } }
@Test public void getFromPrimitiveCollectionInteger() { Container container = ContainerUtils.getFromPrimitiveCollection(Arrays.asList(new Integer[] {1, 2, 3})); assertNotNull(container); assertEquals(3, container.size()); for (Object object : container.getItemIds()) { assertTrue(object instanceof Integer); } }
@Test public void getFromPrimitiveCollectionString() { Container container = ContainerUtils.getFromPrimitiveCollection(Arrays.asList(new String[] {"a", "b", "c"})); assertNotNull(container); assertEquals(3, container.size()); for (Object object : container.getItemIds()) { assertTrue(object instanceof String); } }
public void displayReport(Filter filter, Map<String, Object> parameters) { // TODO make the report generation asynchronous and display the first page when it is ready // and not after last // page is ready currentParameters = parameters; // Load template ReportDefinition rd = (ReportDefinition) getReportSelection().getValue(); String path = getFullPath(rd); jasperReport = reportGenerator.loadTemplate(path); // Set parameters Map<String, Object> params = JRUtils.createParametersFromFilter(jasperReport, filter); params.putAll(currentParameters); currentParameters.putAll(params); // Set datasource jrDataSource = null; if (!rd.requiresDatabaseConnection()) { if (container instanceof Indexed) { jrDataSource = new JRIndexedContainerDataSource((Indexed) container); } else { jrDataSource = new JRContainerDataSource(container); } } // Generate report reportGenerator.setShowMargins(showMargins.getValue()); String html = reportGenerator.executeReportAsHtml( jasperReport, params, jrDataSource, ((WrappedHttpSession) VaadinSession.getCurrent().getSession()).getHttpSession(), VaadinSession.getCurrent().getLocale()); if (html == null || "".equals(html) || (container != null && container.size() <= 0)) { reportArea.setValue(getMessageService().getMessage(NO_DATA_FOUND_KEY)); exportPDF.setEnabled(false); } else { if (rd.requiresExternalScript()) { VaadinUtils.loadScript(REPORT_AREA_ID, html, rd.requiresExternalScript(), alreadyLoaded); // only load external script for the map alreadyLoaded = true; } else { reportArea.setValue(html); } exportPDF.setEnabled(true); } }
@Test public void getFromPrimitiveCollectionEmpty() { Container container = ContainerUtils.getFromPrimitiveCollection(Arrays.asList(new String[] {})); assertNotNull(container); assertEquals(0, container.size()); }