Example #1
0
  /* ------------------------------------------------------------------ */
  private void createSampleDocument() throws com.sun.star.uno.Exception, java.lang.Exception {

    m_document = DocumentHelper.blankTextDocument(m_orb);
    m_formLayer = new FormLayer(m_document);

    // insert some controls
    XPropertySet xIDField = m_formLayer.insertControlLine("DatabaseNumericField", "ID", "", 3);
    m_formLayer.insertControlLine("DatabaseFormattedField", "f_integer", "", 11);
    m_formLayer.insertControlLine("DatabaseTextField", "f_text", "", 19);
    XPropertySet xReqField =
        m_formLayer.insertControlLine("DatabaseTextField", "f_required_text", "", 27);
    m_formLayer.insertControlLine("DatabaseNumericField", "f_decimal", "", 35);
    m_formLayer.insertControlLine("DatabaseDateField", "f_date", "", 43);
    XPropertySet xTimeField = m_formLayer.insertControlLine("DatabaseTimeField", "f_time", "", 51);
    m_formLayer.insertControlLine("DatabaseDateField", "f_timestamp", "_date", 59);
    m_formLayer.insertControlLine("DatabaseTimeField", "f_timestamp", "_time", 67);
    XPropertySet xImageField =
        m_formLayer.insertControlLine("DatabaseImageControl", "f_blob", "", 2, 75, 40);
    m_formLayer.insertControlLine("DatabaseTextField", "f_text_enum", "_text", 80, 25, 6);
    XPropertySet xCheckBox =
        m_formLayer.insertControlLine("DatabaseCheckBox", "f_tinyint", "", 80, 33, 6);
    m_formLayer.insertControlLine("DatabaseFormattedField", "f_tinyint", "_format", 80, 41, 6);
    m_formLayer.insertControlLine("DatabaseTextField", "dummy", "", 150);

    xIDField.setPropertyValue("DecimalAccuracy", new Short((short) 0));
    xImageField.setPropertyValue("ScaleImage", new Boolean(true));
    xImageField.setPropertyValue("Tabstop", new Boolean(true));
    xCheckBox.setPropertyValue("TriState", new Boolean(true));
    xCheckBox.setPropertyValue("DefaultState", new Short((short) 2));
    xTimeField.setPropertyValue("TimeFormat", new Short((short) 1));
    xTimeField.setPropertyValue("TimeMax", new Integer(23595999));
    xReqField.setPropertyValue("ConvertEmptyToNull", new Boolean(false));

    // the logical form
    m_masterForm = (XPropertySet) dbfTools.getParent(xIDField, XPropertySet.class);
    m_masterForm.setPropertyValue("DataSourceName", m_dataSourceProps.getPropertyValue("Name"));
    m_masterForm.setPropertyValue("CommandType", new Integer(CommandType.TABLE));
    m_masterForm.setPropertyValue("Command", s_tableName);

    insertRadio(3, "none", "none");
    insertRadio(10, "normal", "normal");
    insertRadio(17, "important", "important");

    // switch the forms into data entry mode
    m_document.getCurrentView().toggleFormDesignMode();

    m_masterFormController = m_document.getCurrentView().getFormController(m_masterForm);
    XSQLErrorBroadcaster errorBroadcaster =
        UnoRuntime.queryInterface(XSQLErrorBroadcaster.class, m_masterFormController);
    errorBroadcaster.addSQLErrorListener(this);

    // set the focus to the ID control
    m_document.getCurrentView().grabControlFocus(xIDField);
  }
Example #2
0
  /** simulates a user's text input into a control given by model name */
  private void userTextInput(String modelName, String text, boolean withCommit)
      throws com.sun.star.uno.Exception, java.lang.Exception {
    XPropertySet controlModel = getControlModel(modelName);
    // the form runtime environment (namely the form controller) rely on focus events for
    // recognizing
    // control content changes ...
    if (withCommit) m_document.getCurrentView().grabControlFocus(controlModel);

    m_formLayer.userTextInput(controlModel, text);

    // focus back to a dummy control model so the content of the model we just changed will
    // be committed to the underlying database column
    if (withCommit) m_document.getCurrentView().grabControlFocus(getControlModel("dummy"));
  }
Example #3
0
 /// post-test cleanup
 public void after() throws com.sun.star.uno.Exception, java.lang.Exception {
   // close our document
   if (m_document != null) {
     XCloseable closeDoc = UnoRuntime.queryInterface(XCloseable.class, m_document.getDocument());
     closeDoc.close(true);
   }
 }
Example #4
0
 public Document createDocument(String source) {
   Document document = null;
   try {
     document = DocumentHelper.parseText(source);
   } catch (DocumentException e) {
     e.printStackTrace(); // To change body of catch statement use File |
     // Settings | File Templates.
   }
   return document;
 }
Example #5
0
  /** some tests with updating the table via our controls */
  public void checkRowUpdates() throws com.sun.star.uno.Exception, java.lang.Exception {
    // start with inserting a new record
    moveToInsertRow();
    assure("insert row not in expected clean state", verifyCleanInsertRow());

    userTextInput("ID", "3", true);
    userTextInput("f_integer", "729", true);
    userTextInput("f_text", "test", true);
    userTextInput("f_decimal", "152343", true);
    userTextInput("f_date", "31.12.1999", true);
    userTextInput("f_time", "23:59:59", true);

    // move to the next row, this should automatically commit the changes we made
    nextRecordByUI();
    // and back to the row we just inserted
    previousRecordByUI();

    if (!checkDoubleValue(3, "ID", "Value")
        || !checkDoubleValue(729, "f_integer", "EffectiveValue")
        || !checkStringValue("test", "f_text", "Text")
        || !checkDoubleValue(152343, "f_decimal", "Value")
        || !checkIntValue(19991231, "f_date", "Date")
        || !checkIntValue(23595900, "f_time", "Time")) {
      failed("the changes we made on the insert row have not been committed");
      return;
    }

    // now change the data, to see if regular updates work, too
    userTextInput("ID", "4", true);
    userTextInput("f_integer", "618", true);
    userTextInput("f_text", "yet another stupid, meaningless text", true);
    userTextInput("f_required_text", "this must not be NULL", true);
    userTextInput("f_decimal", "4562", true);
    userTextInput("f_date", "26.03.2004", true);
    userTextInput("f_time", "17:05:00", true);

    // move to the next row, this should automatically commit the changes we made
    nextRecordByUI();
    // and back to the row we just inserted
    previousRecordByUI();

    if (!checkDoubleValue(4, "ID", "Value")
        || !checkDoubleValue(618, "f_integer", "EffectiveValue")
        || !checkStringValue("yet another stupid, meaningless text", "f_text", "Text")
        || !checkDoubleValue(4562, "f_decimal", "Value")
        || !checkIntValue(20040326, "f_date", "Date")
        || !checkIntValue(17050000, "f_time", "Time")) {
      failed("the changes we made on the insert row have not been committed");
      return;
    }

    m_document.getCurrentView().grabControlFocus(getControlModel("ID"));
  }
Example #6
0
  /** simulates pressing a toolbox button with the given URL */
  private void executeSlot(String slotURL) throws java.lang.Exception {
    XDispatch xDispatch = m_document.getCurrentView().getDispatcher(slotURL);

    URL[] url = new URL[] {new URL()};
    url[0].Complete = slotURL;
    XURLTransformer xTransformer =
        UnoRuntime.queryInterface(
            XURLTransformer.class, m_orb.createInstance("com.sun.star.util.URLTransformer"));
    xTransformer.parseStrict(url);

    PropertyValue[] aArgs = new PropertyValue[0];
    xDispatch.dispatch(url[0], aArgs);
  }
  private synchronized void doConfigClearspace() throws UnauthorizedException {

    Log.debug("Starting Clearspace configuration.");

    List<String> bindInterfaces = getServerInterfaces();
    if (bindInterfaces.size() == 0) {
      // We aren't up and running enough to tell Clearspace what interfaces to bind to.
      Log.debug("No bind interfaces found to config Clearspace");
      throw new IllegalStateException("There are no binding interfaces.");
    }

    try {

      XMPPServerInfo serverInfo = XMPPServer.getInstance().getServerInfo();

      String path = IM_URL_PREFIX + "configureComponent/";

      // Creates the XML with the data
      Document groupDoc = DocumentHelper.createDocument();
      Element rootE = groupDoc.addElement("configureComponent");
      Element domainE = rootE.addElement("domain");
      domainE.setText(serverInfo.getXMPPDomain());
      for (String bindInterface : bindInterfaces) {
        Element hostsE = rootE.addElement("hosts");
        hostsE.setText(bindInterface);
      }
      Element portE = rootE.addElement("port");
      portE.setText(String.valueOf(ExternalComponentManager.getServicePort()));

      Log.debug(
          "Trying to configure Clearspace with: Domain: "
              + serverInfo.getXMPPDomain()
              + ", hosts: "
              + bindInterfaces.toString()
              + ", port: "
              + port);

      executeRequest(POST, path, rootE.asXML());

      // Done, Clearspace was configured correctly, clear the task
      Log.debug("Clearspace was configured, stopping the task.");
      TaskEngine.getInstance().cancelScheduledTask(configClearspaceTask);
      configClearspaceTask = null;

    } catch (UnauthorizedException ue) {
      throw ue;
    } catch (Exception e) {
      // It is not supported exception, wrap it into an UnsupportedOperationException
      throw new UnsupportedOperationException("Unexpected error", e);
    }
  }
  private void updateClearspaceSharedSecret(String newSecret) {

    try {
      String path = IM_URL_PREFIX + "updateSharedSecret/";

      // Creates the XML with the data
      Document groupDoc = DocumentHelper.createDocument();
      Element rootE = groupDoc.addElement("updateSharedSecret");
      rootE.addElement("newSecret").setText(newSecret);

      executeRequest(POST, path, groupDoc.asXML());
    } catch (UnauthorizedException ue) {
      Log.error("Error updating the password of Clearspace", ue);
    } catch (Exception e) {
      Log.error("Error updating the password of Clearspace", e);
    }
  }
  private void updateClearspaceClientSettings() {
    String xmppBoshSslPort = "0";
    String xmppBoshPort = "0";
    String xmppPort =
        String.valueOf(XMPPServer.getInstance().getConnectionManager().getClientListenerPort());
    if (JiveGlobals.getBooleanProperty(
        HttpBindManager.HTTP_BIND_ENABLED, HttpBindManager.HTTP_BIND_ENABLED_DEFAULT)) {
      int boshSslPort = HttpBindManager.getInstance().getHttpBindSecurePort();
      int boshPort = HttpBindManager.getInstance().getHttpBindUnsecurePort();
      try {
        if (HttpBindManager.getInstance().isHttpsBindActive()
            && LocalClientSession.getTLSPolicy()
                != org.jivesoftware.openfire.Connection.TLSPolicy.disabled) {
          xmppBoshSslPort = String.valueOf(boshSslPort);
        }
      } catch (Exception e) {
        // Exception while working with certificate
        Log.debug(
            "Error while checking SSL certificate.  Instructing Clearspace not to use SSL port.");
      }
      if (HttpBindManager.getInstance().isHttpBindActive() && boshPort > 0) {
        xmppBoshPort = String.valueOf(boshPort);
      }
    }

    try {
      String path = CHAT_URL_PREFIX + "updateClientSettings/";

      // Creates the XML with the data
      Document groupDoc = DocumentHelper.createDocument();
      Element rootE = groupDoc.addElement("updateClientSettings");
      rootE.addElement("boshSslPort").setText(xmppBoshSslPort);
      rootE.addElement("boshPort").setText(xmppBoshPort);
      rootE.addElement("tcpPort").setText(xmppPort);

      executeRequest(POST, path, groupDoc.asXML());
    } catch (UnauthorizedException ue) {
      Log.error("Error updating the client settings of Clearspace", ue);
    } catch (Exception e) {
      Log.error("Error updating the client settings of Clearspace", e);
    }
  }
  private void generateMetadataRegion(Workbook wb, StringBuilder sb) {
    // Get the Home Sheet
    Sheet sheet = wb.getSheet("Home");
    sb.append("PolicyMetadata {");
    sb.append("\n");
    Iterator<Row> rowIt = sheet.rowIterator();
    // Ignore the Header row
    rowIt.next();

    Row row = rowIt.next();
    Cell cellName = row.getCell(1);
    String name = cellName.getStringCellValue().replaceAll("\"", "'");
    row = rowIt.next();
    Cell cellDescription = row.getCell(1);
    String description = cellDescription.getStringCellValue().replaceAll("\"", "'");
    row = rowIt.next();
    Cell cellAuthors = row.getCell(1);
    String authors = cellAuthors.getStringCellValue();
    row = rowIt.next();
    Cell cellOrgs = row.getCell(1);
    String orgs = cellOrgs.getStringCellValue();
    row = rowIt.next();
    Cell cellDate = row.getCell(1);
    String date = DocumentHelper.getRSLILDate(cellDate.getDateCellValue());
    row = rowIt.next();
    Cell cellVersion = row.getCell(1);
    String version = cellVersion.getStringCellValue();

    sb.append("\tPolicyName \"" + name + "\"");
    sb.append("\n");
    sb.append("\tDescription \"" + description + "\"");
    sb.append("\n");
    sb.append("\tAuthor(s) \"" + authors + "\"");
    sb.append("\n");
    sb.append("\tOrganization(s) \"" + orgs + "\"");
    sb.append("\n");
    sb.append("\tDate " + date);
    sb.append("\n");
    sb.append("\tVersion \"" + version + "\"");
    sb.append("\n}");
    sb.append("\n\n");
  }
Example #11
0
  /**
   * very similar to checkCrossUpdates_checkBox - does nearly the same for the radio buttons. See
   * there for more explanations.
   */
  public void checkCrossUpdates_radioButton()
      throws com.sun.star.uno.Exception, java.lang.Exception {
    // move to the first record
    moveToFirst();
    if (!checkRadios((short) 1, (short) 0, (short) 0)
        || !checkStringValue("none", "f_text_enum_text", "Text")) {
      failed("huh? inconsistence in the test!");
      return;
    }

    XPropertySet radioModel = getRadioModel("radio_group", "normal");
    radioModel.setPropertyValue("State", new Short((short) 1));

    // setting the state of the radio button needs to be reflected in the formatted field
    // immediately
    if (!checkStringValue("normal", "f_text_enum_text", "Text")) {
      failed(
          "cross-update failed: updating the radio button should result in updating the same-bound text field (1)!");
      return;
    }

    // same for the "indetermined" state of the check box
    getRadioModel("radio_group", "important").setPropertyValue("State", new Short((short) 1));
    if (!checkStringValue("important", "f_text_enum_text", "Text")) {
      failed(
          "cross-update failed: updating the radio button should result in updating the same-bound text field (2)!");
      return;
    }

    // undo the changes done so far
    undoRecordByUI();
    // and see if this is properly reflected in the controls
    if (!checkRadios((short) 1, (short) 0, (short) 0)
        || !checkStringValue("none", "f_text_enum_text", "Text")) {
      failed("either the radio button or the text field failed to recognize the UNDO!");
      return;
    }

    // the other way round - when changing the formatted field - the change should *not*
    // be reflected to the check box, since the formatted field needs an explicit commit
    XPropertySet textModel = getControlModel("f_text_enum_text");
    m_document.getCurrentView().grabControlFocus(textModel);
    m_formLayer.userTextInput(textModel, "normal");
    if (!checkRadios((short) 1, (short) 0, (short) 0)) {
      failed(
          "the radio buttons should not be updated here! (did the formatted model commit immediately?)");
      return;
    }

    // set the focus to *any* other control (since we just have it at hand, we use the check box
    // control)
    // this should result in the formatted control being committed, and thus in the check box
    // updating
    m_document.getCurrentView().grabControlFocus(radioModel);
    if (!checkRadios((short) 0, (short) 1, (short) 0)) {
      failed("text field did not commit (or radio button did not update)");
      return;
    }

    // undo the changes done so far, so we leave the document in a clean state for the next test
    undoRecordByUI();
  }
Example #12
0
  /**
   * This is both a test for controls which are bound to the same column (they must reflect each
   * others updates), and for the immediate updates which need to happen for both check boxes and
   * radio buttons: They must commit their content to the underlying column as soon as the change is
   * made, *not* only upon explicit commit
   */
  public void checkCrossUpdates_checkBox() throws com.sun.star.uno.Exception, java.lang.Exception {
    // move to the first record
    moveToFirst();
    if (!checkShortValue((short) 1, "f_tinyint", "State")
        || !checkDoubleValue(1, "f_tinyint_format", "EffectiveValue")) {
      failed("huh? inconsistence in the test!");
      // we created the sample data in a way that the f_tinyint field should contain a "1" at the
      // first
      // record. We already asserted the proper function of the check box in checkFirstRow, so if
      // this
      // fails here, the script became inconsistent
      return;
    }

    XPropertySet checkModel = getControlModel("f_tinyint");
    checkModel.setPropertyValue("State", new Short((short) 0));

    // setting the state of the check box needs to be reflected in the formatted field immediately
    if (!checkDoubleValue(0, "f_tinyint_format", "EffectiveValue")) {
      failed(
          "cross-update failed: updating the check box should result in updating the same-bound formatted field (1)!");
      return;
    }

    // same for the "indetermined" state of the check box
    checkModel.setPropertyValue("State", new Short((short) 2));
    if (!checkNullValue("f_tinyint_format", "EffectiveValue")) {
      failed(
          "cross-update failed: updating the check box should result in updating the same-bound formatted field (2)!");
      return;
    }

    // undo the changes done so far
    undoRecordByUI();
    // and see if this is properly reflected in the controls
    if (!checkShortValue((short) 1, "f_tinyint", "State")
        || !checkDoubleValue(1, "f_tinyint_format", "EffectiveValue")) {
      failed("either the check box or the formatted field failed to recognize the UNDO!");
      return;
    }

    // the other way round - when changing the formatted field - the change should *not*
    // be reflected to the check box, since the formatted field needs an explicit commit
    XPropertySet tinyFormattedModel = getControlModel("f_tinyint_format");
    m_document.getCurrentView().grabControlFocus(tinyFormattedModel);
    m_formLayer.userTextInput(tinyFormattedModel, "0");
    if (!checkShortValue((short) 1, "f_tinyint", "State")) {
      failed(
          "the check box should not be updated here! (did the formatted model commit immediately?)");
      return;
    }

    // set the focus to *any* other control (since we just have it at hand, we use the check box
    // control)
    // this should result in the formatted control being committed, and thus in the check box
    // updating
    m_document.getCurrentView().grabControlFocus(checkModel);
    if (!checkShortValue((short) 0, "f_tinyint", "State")) {
      failed("formatted field did not commit (or check box did not update)");
      return;
    }

    // undo the changes done so far, so we leave the document in a clean state for the next test
    undoRecordByUI();
  }
  @SuppressWarnings({"deprecation", "unused"})
  public static Document builderOpensearchResponeDocument(
      List<Geochannelmetadata> geochannelmetadataList) {

    Document document = DocumentHelper.createDocument();
    Element root = document.addElement("kml", "http://www.opengis.net/kml/2.2"); // 创建根节点
    root.addNamespace("geoww", "http://www.geoww.net/geochannel");
    root.addNamespace("geofeed", "http://www.geoww.net/geofeed");
    root.addNamespace("opensearch", "http://a9.com/-/spec/opensearch/1.1/");
    root.addNamespace("geo", "http://a9.com/-/opensearch/extensions/geo/1.0/");
    root.addNamespace("time", "http://a9.com/-/opensearch/extensions/time/1.0/");

    root.addComment("This is a test for opensearch respone!");

    Element geowwGeoChannelSearch = root.addElement("geoww:GeoChannelSearch");
    Element opensearchtotalResults = geowwGeoChannelSearch.addElement("opensearch:totalResults");
    Element opensearchstartIndex = geowwGeoChannelSearch.addElement("opensearch:startIndex");
    Element opensearchitemsPerPage = geowwGeoChannelSearch.addElement("opensearch:itemsPerPage");
    Element opensearchQuery = geowwGeoChannelSearch.addElement("opensearch:Query");
    Element geowwSearchLinks = geowwGeoChannelSearch.addElement("geoww:SearchLinks");

    for (Geochannelmetadata geochannelmetadata : geochannelmetadataList) {
      Element geowwGeoChannel = geowwGeoChannelSearch.addElement("geoww:GeoChannel");

      // geoww:GeoChannel
      Element name = geowwGeoChannel.addElement("name");
      Element description = geowwGeoChannel.addElement("description");
      Element geowwMetadata = geowwGeoChannel.addElement("geoww:Metadata");
      Element geofeedAccessFeed = geowwGeoChannel.addElement("geofeed:AccessFeed");

      // geoww:Metadata
      Element geowwtitle = geowwMetadata.addElement("geoww:title");
      Element Geometry = geowwMetadata.addElement("Geometry");
      Element geowwsMetadataList = geowwMetadata.addElement("geoww:MetadataList");

      // geoww:MetadataList//geoww:GeowwURI
      Element geowwGeowwURI = geowwsMetadataList.addElement("geoww:GeowwURI");
      Element geowwnote = geowwGeowwURI.addElement("geoww:note");
      Element geowwgeowwURI = geowwGeowwURI.addElement("geoww:geowwURI");
      if (null != geochannelmetadata.getGeowwUri()) {
        geowwgeowwURI.setText(geochannelmetadata.getGeowwUri());
      }

      //
      // geoww:MetadataList//Data
      // Title
      Element titleData = geowwsMetadataList.addElement("Data");
      titleData.addAttribute("name", "Title");
      Element titleValue = titleData.addElement("value");
      if (null != geochannelmetadata.getTitle()) {
        titleValue.setText(geochannelmetadata.getTitle());
      }

      // alternativeTitle
      Element alternativeTitleData = geowwsMetadataList.addElement("Data");
      alternativeTitleData.addAttribute("name", "AlternativeTitle");
      Element alternativeTitleValue = alternativeTitleData.addElement("value");
      if (null != geochannelmetadata.getAlternativeTitle()) {
        alternativeTitleValue.setText(geochannelmetadata.getAlternativeTitle());
      }

      // ServiceLanguage
      Element serviceLanguageData = geowwsMetadataList.addElement("Data");
      serviceLanguageData.addAttribute("name", "ServiceLanguage");
      Element serviceLanguageValue = serviceLanguageData.addElement("value");
      if (null != geochannelmetadata.getServiceLanguage()) {
        serviceLanguageValue.setText(geochannelmetadata.getServiceLanguage());
      }

      // Abstract
      Element abstractData = geowwsMetadataList.addElement("Data");
      abstractData.addAttribute("name", "Abstract");
      Element abstractValue = abstractData.addElement("value");
      if (null != geochannelmetadata.getAbstract_()) {
        abstractValue.setText(geochannelmetadata.getAbstract_());
      }

      // TopicCategory
      Element topicCategoryData = geowwsMetadataList.addElement("Data");
      topicCategoryData.addAttribute("name", "TopicCategory");
      Element topicCategoryValue = topicCategoryData.addElement("value");
      if (null != geochannelmetadata.getTopicCategory()) {
        topicCategoryValue.setText(geochannelmetadata.getTopicCategory());
      }

      // GeoChannelIdentifier
      Element geoChannelIdentifierData = geowwsMetadataList.addElement("Data");
      geoChannelIdentifierData.addAttribute("name", "GeoChannelIdentifier");
      Element geoChannelIdentifierValue = geoChannelIdentifierData.addElement("value");
      if (null != geochannelmetadata.getGeoChannelIdentifier()) {
        geoChannelIdentifierValue.setText(geochannelmetadata.getGeoChannelIdentifier());
      }

      // ResourceIdentifiers
      Element resourceIdentifiersData = geowwsMetadataList.addElement("Data");
      resourceIdentifiersData.addAttribute("name", "ResourceIdentifiers");
      Element resourceIdentifiersValue = resourceIdentifiersData.addElement("value");
      if (null != geochannelmetadata.getResourceIdentifiers()) {
        resourceIdentifiersValue.setText(geochannelmetadata.getResourceIdentifiers());
      }

      // Keyword
      Element keywordData = geowwsMetadataList.addElement("Data");
      keywordData.addAttribute("name", "Keyword");
      Element keywordValue = keywordData.addElement("value");
      if (null != geochannelmetadata.getKeyword()) {
        keywordValue.setText(geochannelmetadata.getKeyword());
      }

      // ResourceType
      Element resourceTypeData = geowwsMetadataList.addElement("Data");
      resourceTypeData.addAttribute("name", "ResourceType");
      Element resourceTypeValue = resourceTypeData.addElement("value");
      if (null != geochannelmetadata.getResourceType()) {
        resourceTypeValue.setText(geochannelmetadata.getResourceType());
      }

      // SpatialFeature
      Element SpatialFeatureData = geowwsMetadataList.addElement("Data");
      SpatialFeatureData.addAttribute("name", "SpatialFeature");
      Element SpatialFeatureValue = SpatialFeatureData.addElement("value");
      if (null != geochannelmetadata.getSpatialFeature()) {
        SpatialFeatureValue.setText(geochannelmetadata.getSpatialFeature());
      }

      // SpatialMetrics
      Element SpatialMetricsData = geowwsMetadataList.addElement("Data");
      SpatialMetricsData.addAttribute("name", "SpatialMetrics");
      Element SpatialMetricsValue = SpatialMetricsData.addElement("value");
      if (null != geochannelmetadata.getSpatialMetrics()) {
        SpatialMetricsValue.setText(geochannelmetadata.getSpatialMetrics().toString());
      }

      // BoundingBox
      Element BoundingBoxData = geowwsMetadataList.addElement("Data");
      BoundingBoxData.addAttribute("name", "BoundingBox");
      Element BoundingBoxValue = BoundingBoxData.addElement("value");
      if (null != geochannelmetadata.getBoundingBox()) {
        BoundingBoxValue.setText(geochannelmetadata.getBoundingBox());
      }

      // SpatialExtent
      Element SpatialExtentData = geowwsMetadataList.addElement("Data");
      SpatialExtentData.addAttribute("name", "SpatialExtent");
      Element SpatialExtentValue = SpatialExtentData.addElement("value");
      if (null != geochannelmetadata.getSpatialExtent()) {
        SpatialExtentValue.setText(geochannelmetadata.getSpatialExtent());
      }

      // VerticalExtentLow
      Element verticalExtentLowData = geowwsMetadataList.addElement("Data");
      verticalExtentLowData.addAttribute("name", "VerticalExtentLow");
      Element verticalExtentLowValue = verticalExtentLowData.addElement("value");
      if (null != geochannelmetadata.getVerticalExtentLow()) {
        verticalExtentLowValue.setText(geochannelmetadata.getVerticalExtentLow().toString());
      }

      // VerticalExtentHigh
      Element verticalExtentHighData = geowwsMetadataList.addElement("Data");
      verticalExtentHighData.addAttribute("name", "VerticalExtentHigh");
      Element verticalExtentHighValue = verticalExtentHighData.addElement("value");
      if (null != geochannelmetadata.getVerticalExtentHigh()) {
        verticalExtentHighValue.setText(geochannelmetadata.getVerticalExtentHigh().toString());
      }

      // SpatialReferenceSystem
      Element SpatialReferenceSystemData = geowwsMetadataList.addElement("Data");
      SpatialReferenceSystemData.addAttribute("name", "SpatialReferenceSystem");
      Element SpatialReferenceSystemValue = SpatialReferenceSystemData.addElement("value");
      if (null != geochannelmetadata.getSpatialReferenceSystem()) {
        SpatialReferenceSystemValue.setText(geochannelmetadata.getSpatialReferenceSystem());
      }

      // SpatialResolution
      Element SpatialResolutionData = geowwsMetadataList.addElement("Data");
      SpatialResolutionData.addAttribute("name", "SpatialResolution");
      Element SpatialResolutionValue = SpatialResolutionData.addElement("value");
      if (null != geochannelmetadata.getSpatialResolution()) {
        SpatialResolutionValue.setText(geochannelmetadata.getSpatialResolution().toString());
      }

      // TemporalExtentStart
      Element TemporalExtentStartData = geowwsMetadataList.addElement("Data");
      TemporalExtentStartData.addAttribute("name", "TemporalExtentStart");
      Element TemporalExtentStartValue = TemporalExtentStartData.addElement("value");
      if (null != geochannelmetadata.getTemporalExtentStart()) {
        TemporalExtentStartValue.setText(geochannelmetadata.getTemporalExtentStart().toGMTString());
      }
      // TemporalExtentEnd
      Element TemporalExtentEndData = geowwsMetadataList.addElement("Data");
      TemporalExtentEndData.addAttribute("name", "TemporalExtentEnd");
      Element TemporalExtentEndValue = TemporalExtentEndData.addElement("value");
      if (null != geochannelmetadata.getTemporalExtentEnd()) {
        TemporalExtentEndValue.setText(geochannelmetadata.getTemporalExtentEnd().toGMTString());
      }

      // PublicationDate
      Element PublicationDateData = geowwsMetadataList.addElement("Data");
      PublicationDateData.addAttribute("name", "PublicationDate");
      Element PublicationDateValue = PublicationDateData.addElement("value");
      if (null != geochannelmetadata.getPublicationDate()) {
        PublicationDateValue.setText(geochannelmetadata.getPublicationDate().toGMTString());
      }

      // DataFormat
      Element DataFormatData = geowwsMetadataList.addElement("Data");
      DataFormatData.addAttribute("name", "DataFormat");
      Element DataFormatValue = DataFormatData.addElement("value");
      if (null != geochannelmetadata.getDataFormat()) {
        DataFormatValue.setText(geochannelmetadata.getDataFormat());
      }

      // ResponsibleOrganisation
      Element ResponsibleOrganisationData = geowwsMetadataList.addElement("Data");
      ResponsibleOrganisationData.addAttribute("name", "ResponsibleOrganisation");
      Element ResponsibleOrganisationValue = ResponsibleOrganisationData.addElement("value");
      if (null != geochannelmetadata.getResponsibleOrganisation()) {
        ResponsibleOrganisationValue.setText(geochannelmetadata.getResponsibleOrganisation());
      }

      // FrequencyOfUpdata
      Element FrequencyOfUpdataData = geowwsMetadataList.addElement("Data");
      FrequencyOfUpdataData.addAttribute("name", "FrequencyOfUpdata");
      Element FrequencyOfUpdataValue = FrequencyOfUpdataData.addElement("value");
      if (null != geochannelmetadata.getFrequencyOfUpdata()) {
        FrequencyOfUpdataValue.setText(geochannelmetadata.getFrequencyOfUpdata());
      }

      // LimitationOnPublicAccess
      Element LimitationOnPublicAccessData = geowwsMetadataList.addElement("Data");
      LimitationOnPublicAccessData.addAttribute("name", "LimitationOnPublicAccess");
      Element LimitationOnPublicAccessValue = LimitationOnPublicAccessData.addElement("value");
      if (null != geochannelmetadata.getLimitationOnPublicAccess()) {
        LimitationOnPublicAccessValue.setText(geochannelmetadata.getLimitationOnPublicAccess());
      }

      // UseConstraints
      Element UseConstraintsData = geowwsMetadataList.addElement("Data");
      UseConstraintsData.addAttribute("name", "UseConstraints");
      Element UseConstraintsValue = UseConstraintsData.addElement("value");
      if (null != geochannelmetadata.getUseConstraints()) {
        UseConstraintsValue.setText(geochannelmetadata.getUseConstraints());
      }

      // CoupledGeoChannels
      Element CoupledGeoChannelsData = geowwsMetadataList.addElement("Data");
      CoupledGeoChannelsData.addAttribute("name", "CoupledGeoChannels");
      Element CoupledGeoChannelsValue = CoupledGeoChannelsData.addElement("value");
      if (null != geochannelmetadata.getCoupledGeoChannels()) {
        CoupledGeoChannelsValue.setText(geochannelmetadata.getCoupledGeoChannels());
      }

      // AdditionalInformation
      Element AdditionalInformationData = geowwsMetadataList.addElement("Data");
      AdditionalInformationData.addAttribute("name", "AdditionalInformation");
      Element AdditionalInformationValue = AdditionalInformationData.addElement("value");
      if (null != geochannelmetadata.getAdditionalInformation()) {
        AdditionalInformationValue.setText(geochannelmetadata.getAdditionalInformation());
      }

      // MetadataDateTime
      Element MetadataDateTimeData = geowwsMetadataList.addElement("Data");
      MetadataDateTimeData.addAttribute("name", "MetadataDateTime");
      Element MetadataDateTimeValue = MetadataDateTimeData.addElement("value");
      if (null != geochannelmetadata.getMetadataDateTime()) {
        MetadataDateTimeValue.setText(geochannelmetadata.getMetadataDateTime().toGMTString());
      }

      // MetadataLanguage
      Element MetadataLanguageData = geowwsMetadataList.addElement("Data");
      MetadataLanguageData.addAttribute("name", "MetadataLanguage");
      Element MetadataLanguageValue = MetadataLanguageData.addElement("value");
      if (null != geochannelmetadata.getMetadataLanguage()) {
        MetadataLanguageValue.setText(geochannelmetadata.getMetadataLanguage());
      }

      // MetadataContact
      Element MetadataContactData = geowwsMetadataList.addElement("Data");
      MetadataContactData.addAttribute("name", "MetadataContact");
      Element MetadataContactValue = MetadataContactData.addElement("value");
      if (geochannelmetadata.getMetadataContact() != null) {
        MetadataContactValue.setText(geochannelmetadata.getMetadataContact());
      }
    }
    return document;
  }
Example #14
0
  /**
   * creates a control in the document
   *
   * <p>Note that <em>control<em> here is an incorrect terminology. What the method really does is
   * it creates a control shape, together with a control model, and inserts them into the document
   * model. This will result in every view to this document creating a control described by the
   * model-shape pair.
   *
   * @param sFormComponentService the service name of the form component to create, e.g. "TextField"
   * @param nXPos the abscissa of the position of the newly inserted shape
   * @param nXPos the ordinate of the position of the newly inserted shape
   * @param nWidth the width of the newly inserted shape
   * @param nHeight the height of the newly inserted shape
   * @param xParentForm the form to use as parent for the newly create form component. May be null,
   *     in this case a default parent is chosen by the implementation
   * @return the property access to the control's model
   */
  protected XPropertySet createControlAndShape(
      String sFormComponentService,
      int nXPos,
      int nYPos,
      int nWidth,
      int nHeight,
      XIndexContainer xParentForm)
      throws java.lang.Exception {
    // let the document create a shape
    XMultiServiceFactory xDocAsFactory =
        UnoRuntime.queryInterface(XMultiServiceFactory.class, m_document.getDocument());
    XControlShape xShape =
        UnoRuntime.queryInterface(
            XControlShape.class, xDocAsFactory.createInstance("com.sun.star.drawing.ControlShape"));

    // position and size of the shape
    xShape.setSize(new Size(nWidth * 100, nHeight * 100));
    xShape.setPosition(new Point(nXPos * 100, nYPos * 100));

    // adjust the anchor so that the control is tied to the page
    XPropertySet xShapeProps = UNO.queryPropertySet(xShape);
    TextContentAnchorType eAnchorType = TextContentAnchorType.AT_PARAGRAPH;
    xShapeProps.setPropertyValue("AnchorType", eAnchorType);

    // create the form component (the model of a form control)
    String sQualifiedComponentName = "com.sun.star.form.component." + sFormComponentService;
    XControlModel xModel =
        UnoRuntime.queryInterface(
            XControlModel.class, m_document.getOrb().createInstance(sQualifiedComponentName));

    // insert the model into the form component hierarchy, if the caller gave us a location
    if (null != xParentForm) {
      xParentForm.insertByIndex(xParentForm.getCount(), xModel);
    }

    // knitt them
    xShape.setControl(xModel);

    // add the shape to the shapes collection of the document
    XDrawPage pageWhereToInsert =
        (m_insertPage != -1) ? m_document.getDrawPage(m_insertPage) : m_document.getMainDrawPage();

    XShapes xDocShapes = UnoRuntime.queryInterface(XShapes.class, pageWhereToInsert);
    xDocShapes.add(xShape);

    // some initializations which are the same for all controls
    XPropertySet xModelProps = UNO.queryPropertySet(xModel);
    try {
      XPropertySetInfo xPSI = xModelProps.getPropertySetInfo();
      if (xPSI.hasPropertyByName("Border")) {
        if (((Short) xModelProps.getPropertyValue("Border")).shortValue()
            == com.sun.star.awt.VisualEffect.LOOK3D)
          xModelProps.setPropertyValue("Border", Short.valueOf(com.sun.star.awt.VisualEffect.FLAT));
      }
      if (xPSI.hasPropertyByName("VisualEffect"))
        xModelProps.setPropertyValue(
            "VisualEffect", Short.valueOf(com.sun.star.awt.VisualEffect.FLAT));
      if (m_document.classify() != DocumentType.CALC)
        if (xPSI.hasPropertyByName("BorderColor"))
          xModelProps.setPropertyValue("BorderColor", Integer.valueOf(0x00C0C0C0));
    } catch (com.sun.star.uno.Exception e) {
      System.err.println(e);
      e.printStackTrace(System.err);
    }
    return xModelProps;
  }
Example #15
0
 public Dom4jXmlElement(String name, Element parent) {
   if (parent == null) {
     Document document = DocumentHelper.createDocument();
     internal = document.addElement(name);
   } else internal = parent.addElement(name);
 }