Exemple #1
0
  /* ------------------------------------------------------------------ */
  private boolean ensureDataSource() throws Exception {
    m_orb = (XMultiServiceFactory) param.getMSF();

    XNameAccess databaseContext =
        UnoRuntime.queryInterface(
            XNameAccess.class, m_orb.createInstance("com.sun.star.sdb.DatabaseContext"));
    XNamingService namingService = UnoRuntime.queryInterface(XNamingService.class, databaseContext);

    // revoke the data source, if it previously existed
    if (databaseContext.hasByName(m_dataSourceName)) namingService.revokeObject(m_dataSourceName);

    // // create a new ODB file, and register it with its URL
    m_databaseDocument = new HsqlDatabase(m_orb);
    String documentURL = m_databaseDocument.getDocumentURL();
    namingService.registerObject(m_dataSourceName, databaseContext.getByName(documentURL));

    m_dataSource =
        UnoRuntime.queryInterface(XDataSource.class, databaseContext.getByName(m_dataSourceName));
    m_dataSourceProps = dbfTools.queryPropertySet(m_dataSource);

    XPropertySet dataSourceSettings =
        UnoRuntime.queryInterface(
            XPropertySet.class, m_dataSourceProps.getPropertyValue("Settings"));
    dataSourceSettings.setPropertyValue("FormsCheckRequiredFields", new Boolean(false));

    return m_dataSource != null;
  }
  /**
   * Test calls the method and checks that no exceptions were thrown.
   *
   * <p>Has <b> OK </b> status if the method successfully returns and no exceptions were thrown.
   *
   * <p>The following method tests are to be completed successfully before :
   */
  public void _registerObject() throws StatusException {
    try {
      oObj.registerObject("MyFactory", regObject);
    } catch (com.sun.star.uno.Exception e) {
      log.println("Exception while registering object :" + e);
      tRes.tested("registerObject()", false);
      return;
    }

    tRes.tested("registerObject()", true);
  }