コード例 #1
0
ファイル: Regression_145465.java プロジェクト: lukehan/birt
  public void test_regression_145465() throws Exception {
    openDesign(REPORT);

    String outputLib = getTempFolder() + File.separator + INPUT_FOLDER + File.separator + LIB;

    DesignEngine engine = new DesignEngine(new DesignConfig());
    SessionHandle session = engine.newSessionHandle(ULocale.ENGLISH);
    session.setResourceFolder(getTempFolder() + File.separator + OUTPUT_FOLDER); // $NON-NLS-1$

    // session.setResourceFolder(this.getFullQualifiedClassName( ) //$NON-NLS-1$
    //		+ File.separator + OUTPUT_FOLDER );
    ReportDesignHandle designHandle =
        session.openDesign(getTempFolder() + "/" + INPUT_FOLDER + "/" + REPORT);
    LibraryHandle libHandle = designHandle.getLibrary("regression_145465_lib"); // $NON-NLS-1$
    LabelHandle label = (LabelHandle) libHandle.findElement("NewLabel"); // $NON-NLS-1$

    ElementFactory factory = designHandle.getElementFactory();
    LabelHandle extendsLabel =
        (LabelHandle) factory.newElementFrom(label, "extendsLabel"); // $NON-NLS-1$

    designHandle.getBody().add(extendsLabel);
    designHandle.save();

    // remove the library from resource folder.

    boolean deleted = new File(outputLib).delete();

    assertTrue(deleted);

    // refresh the report, make sure no exception is throwed out.

    designHandle.reloadLibraries();
  }
コード例 #2
0
ファイル: BaseTestCase.java プロジェクト: lukehan/birt
  /**
   * Opens library file with given file name and locale.
   *
   * @param fileName the library file name
   * @param locale the user locale
   * @param inSingleJarMode <code>true</code> if open the design that is in the single jar.
   *     Otherwise <code>false</code>.
   * @throws DesignFileException if any exception
   */
  protected void openLibrary(String fileName, ULocale locale, boolean inSingleJarMode)
      throws DesignFileException {
    if (inSingleJarMode) fileName = INPUT_FOLDER + fileName;

    if (engine == null) {
      engine = new DesignEngine(new DesignConfig());
      resetMetadata();
    }
    sessionHandle = engine.newSessionHandle(locale);
    assertNotNull(sessionHandle);

    if (inSingleJarMode)
      libraryHandle =
          sessionHandle.openLibrary(getResource(fileName).toString(), getResourceAStream(fileName));
    else libraryHandle = sessionHandle.openLibrary(fileName);
  }
コード例 #3
0
ファイル: BaseTestCase.java プロジェクト: lukehan/birt
  /**
   * Opens design file providing the file name and the locale.
   *
   * @param fileName the design file to be opened
   * @param locale the user locale
   * @param inSingleJarMode <code>true</code> if open the design that is in the single jar.
   *     Otherwise <code>false</code>.
   * @throws DesignFileException if any exception.
   */
  protected void openDesign(String fileName, ULocale locale, boolean inSingleJarMode)
      throws DesignFileException {
    if (inSingleJarMode) fileName = INPUT_FOLDER + fileName;

    if (engine == null) {
      engine = new DesignEngine(new DesignConfig());
      resetMetadata();
    }
    sessionHandle = engine.newSessionHandle(locale);
    assertNotNull(sessionHandle);

    if (inSingleJarMode) designHandle = sessionHandle.openDesign(getResource(fileName).toString());
    else designHandle = sessionHandle.openDesign(fileName);

    design = (ReportDesign) designHandle.getModule();
  }
コード例 #4
0
ファイル: BaseTestCase.java プロジェクト: lukehan/birt
 /**
  * Opens a design file.
  *
  * @param fileName the design file name
  * @param is the input stream of the design file.
  * @param locale the user locale.
  * @throws DesignFileException if any exception.
  */
 protected void openDesign(String fileName, InputStream is, ULocale locale)
     throws DesignFileException {
   if (engine == null) {
     engine = new DesignEngine(new DesignConfig());
     resetMetadata();
   }
   sessionHandle = engine.newSessionHandle(locale);
   designHandle = sessionHandle.openDesign(fileName, is);
   design = (ReportDesign) designHandle.getModule();
 }
コード例 #5
0
ファイル: BaseTestCase.java プロジェクト: lukehan/birt
  /**
   * Creates library with given locale.
   *
   * @param locale the user locale
   * @return the handle for new library
   */
  protected LibraryHandle createLibrary(ULocale locale) {
    if (engine == null) {
      engine = new DesignEngine(new DesignConfig());
      resetMetadata();
    }
    sessionHandle = engine.newSessionHandle(locale);
    libraryHandle = sessionHandle.createLibrary();

    return libraryHandle;
  }
コード例 #6
0
ファイル: BaseTestCase.java プロジェクト: lukehan/birt
  /**
   * Opend a module given file name and locale.
   *
   * @param fileName the module file name
   * @param locale the user locale
   * @throws DesignFileException
   */
  protected void openModule(String fileName, ULocale locale) throws DesignFileException {
    if (engine == null) {
      engine = new DesignEngine(new DesignConfig());
      resetMetadata();
    }
    fileName = INPUT_FOLDER + fileName;
    sessionHandle = engine.newSessionHandle(locale);
    assertNotNull(sessionHandle);

    moduleHandle =
        sessionHandle.openModule(getResource(fileName).toString(), getResourceAStream(fileName));
  }
コード例 #7
0
ファイル: BaseTestCase.java プロジェクト: lukehan/birt
  /**
   * Creates a new report with given locale.
   *
   * @param locale the user locale
   * @return the handle for new report
   */
  protected ReportDesignHandle createDesign(ULocale locale) {
    if (engine == null) {
      engine = new DesignEngine(new DesignConfig());
      resetMetadata();
    }
    sessionHandle = engine.newSessionHandle(locale);
    designHandle = sessionHandle.createDesign();
    design = (ReportDesign) designHandle.getModule();

    removeExtensionStyles(design);
    return designHandle;
  }
コード例 #8
0
ファイル: Regression_121857.java プロジェクト: cwichoski/birt
  /** @throws Exception */
  public void test_regression_121857() throws Exception {
    SessionHandle session = new DesignEngine(new DesignConfig()).newSessionHandle(ULocale.ENGLISH);
    ReportDesignHandle designHandle = session.createDesign();
    ElementFactory factory = designHandle.getElementFactory();
    OdaDataSourceHandle datasource =
        factory.newOdaDataSource(
            "dsource", //$NON-NLS-1$
            "org.eclipse.birt.report.data.oda.jdbc"); //$NON-NLS-1$
    OdaDataSetHandle dataset =
        factory.newOdaDataSet(
            "dset", //$NON-NLS-1$
            "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet"); //$NON-NLS-1$
    dataset.setDataSource("dsource"); // $NON-NLS-1$

    designHandle.getDataSources().add(datasource);
    designHandle.getDataSets().add(dataset);

    datasource.drop();
    assertNull(designHandle.findDataSource("dsource")); // $NON-NLS-1$
    assertNull(dataset.getDataSource());
    assertEquals("dsource", dataset.getDataSourceName()); // $NON-NLS-1$
  }