private Expression extractPrimaryDatasource(final Element element) {
   final Expression originalPrimaryDataSourceExpression;
   final Object primaryDataSourceRaw =
       element.getAttribute(
           LegacyChartElementModule.NAMESPACE,
           LegacyChartElementModule.PRIMARY_DATA_COLLECTOR_FUNCTION_ATTRIBUTE);
   if (primaryDataSourceRaw instanceof Expression) {
     originalPrimaryDataSourceExpression = (Expression) primaryDataSourceRaw;
   } else {
     originalPrimaryDataSourceExpression = null;
   }
   return originalPrimaryDataSourceExpression;
 }
 private Expression extractSecondaryDatasource(final Element element) {
   final Expression originalSecondaryDataSourceExpression;
   final Object secondaryDataSource =
       element.getAttribute(
           LegacyChartElementModule.NAMESPACE,
           LegacyChartElementModule.SECONDARY_DATA_COLLECTOR_FUNCTION_ATTRIBUTE);
   if (secondaryDataSource instanceof Expression) {
     originalSecondaryDataSourceExpression = (Expression) secondaryDataSource;
   } else {
     originalSecondaryDataSourceExpression = null;
   }
   return originalSecondaryDataSourceExpression;
 }
Ejemplo n.º 3
0
  public void testLoadSaveFromDisk() throws Exception {
    final ResourceKey key = createImageKey();

    final Element element = new Element();
    element.setElementType(new ContentType());
    element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, key);
    // .. save it.
    final MasterReport report = new MasterReport();
    report.getReportHeader().addElement(element);

    saveReport(report, new File("bin/test-tmp/prd-3319-load-save-disk-1.prpt"));

    // load it to establish the context in all resource-keys ..
    final ResourceManager mgr = new ResourceManager();
    mgr.registerDefaults();
    final Resource resource =
        mgr.createDirectly(
            new File("bin/test-tmp/prd-3319-load-save-disk-1.prpt"), MasterReport.class);

    // save it once, that changes the bundle ...
    final MasterReport report2 = (MasterReport) resource.getResource();
    saveReport(report2, new File("bin/test-tmp/prd-3319-load-save-disk-2.prpt"));
    // save it twice, that triggers the crash...
    saveReport(report2, new File("bin/test-tmp/prd-3319-load-save-disk-2.prpt"));

    final ProcessingContext processingContext = new DefaultProcessingContext();
    final DebugExpressionRuntime runtime =
        new DebugExpressionRuntime(new DefaultTableModel(), 0, processingContext);

    final Element reportElement = report2.getReportHeader().getElement(0);
    Object attribute =
        reportElement.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE);

    assertTrue(attribute instanceof ResourceKey);
    ResourceKey atKey = (ResourceKey) attribute;
    assertEquals("http://127.0.0.1:65535/image.jpg", atKey.getIdentifierAsString());
  }