【问题标题】:how to copy OdadataSourceHandle from one design report to another design report?如何将 OdadataSourceHandle 从一个设计报告复制到另一个设计报告?
【发布时间】:2018-10-25 03:30:03
【问题描述】:

String targetRptFile = System.getenv("LOCAL_BIRT_INPUT") + "/"+report.getMergeRptTemplates().getTargetTemplate()+".rptdesign"; 字符串 attachRptFile = System.getenv("LOCAL_BIRT_INPUT") + "/"+report.getMergeRptTemplates() .getAttachTemplate()+".rptdesign";

    DesignConfig dConfig = new DesignConfig();
    IDesignEngineFactory factory = (IDesignEngineFactory) Platform.createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY);
    IDesignEngine dEngine = factory.createDesignEngine(dConfig);
    SessionHandle session = dEngine.newSessionHandle(null);
    ReportDesignHandle targetRptDesignHandle = null;
    ReportDesignHandle attachRptDesignHandle = null;
    try {
        targetRptDesignHandle = session.openDesign(targetRptFile);
        attachRptDesignHandle = session.openDesign(attachRptFile);
    } catch (DesignFileException e) {
        e.printStackTrace();
    }


    OdaDataSourceHandle attachOdaDataSourceHandle = (OdaDataSourceHandle)attachRptDesignHandle.getAllDataSources()
            .get(0);
    targetRptDesignHandle.getAllDataSources().add(attachOdaDataSourceHandle);


    String newTargetRptFile = System.getenv("LOCAL_BIRT_INPUT") + "/"+report
            .getMergeRptTemplates().getTargetTemplate()+"-merge"+".rptdesign";

    try {
        targetRptDesignHandle.saveAs(newTargetRptFile);
        targetRptDesignHandle.close();
        attachRptDesignHandle.close();
        session.closeAll(true);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

【问题讨论】:

  • 两个设计文件都有 birtpojodatasource

标签: birt birt-deapi


【解决方案1】:

从来没有这样做过,但是当我想复制一个 JDBCDataSource 时,我记得有一个类似的问题。我通过手动设置所有属性而不是尝试复制整个 DS 来解决这个问题。

【讨论】:

    猜你喜欢
    • 2013-12-04
    • 2016-12-23
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多