示例#1
0
  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
  /**
   * 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
  /**
   * 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
 /**
  * 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
  /**
   * 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
  /**
   * 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
  /**
   * 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
  /** @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$
  }