private void checkConnection() throws ProcessingException {
    if (m_mqttClient == null) {
      throw new ProcessingException(TEXTS.get("noClient"));
    }

    if (!m_mqttClient.isConnected()) {
      throw new ProcessingException(TEXTS.get("noConnection"));
    }
  }
  @Override
  public void unsubscribe(String topicFilter) throws ProcessingException {
    checkConnection();

    try {
      m_mqttClient.unsubscribe(topicFilter);
    } catch (Exception e) {
      throw new ProcessingException(TEXTS.get("unsubscribeError"), e);
    }
  }
  @Override
  public void disconnect() throws ProcessingException {
    checkConnection();

    try {
      m_mqttClient.disconnect();
      m_isConnected = false;
    } catch (MqttException e) {
      throw new ProcessingException(TEXTS.get("mqttException"), e);
    }
  }
  @Override
  public void setup(String broker, String clientId) throws ProcessingException {
    try {
      MemoryPersistence persistence = new MemoryPersistence();

      m_session = ClientSession.get();
      m_mqttClient = new MqttClient(broker, clientId, persistence);
      m_mqttClient.setCallback(this);
    } catch (Exception e) {
      throw new ProcessingException(TEXTS.get("MqttClientCreateException"), e);
    }
  }
  /** Test with LimitedResult == true */
  @Test
  public void testImportFormData2() throws Exception {
    Object[][] data =
        new Object[][] {new Object[] {I1, S1}, new Object[] {I2, S2}, new Object[] {I3, S3}};
    SimpleTablePage page = new SimpleTablePage(true, data);

    Table table = page.getTable();
    assertEquals("row count", 3, table.getRowCount());
    assertEquals("Status - severity", IStatus.WARNING, page.getTableStatus().getSeverity());
    assertEquals(
        "Status - message",
        TEXTS.get("MaxOutlineRowWarning", "3"),
        page.getTableStatus().getMessage());
  }
Beispiel #6
0
  @Override
  public AnswerFormData prepareCreate(AnswerFormData formData) throws ProcessingException {
    if (!ACCESS.check(new CreateAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

    if (formData.getQuestionNr().getValue() == null) {
      throw new ProcessingException("QuestionNr can no be null");
    }

    loadQuestion(formData);

    return formData;
  }
Beispiel #7
0
  @Override
  public void delete(Long answerNr) throws ProcessingException {
    if (!ACCESS.check(new DeleteAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

    if (answerNr == null) {
      throw new ProcessingException("AnswerNr can no be null");
    }

    SQL.delete(
        "delete from answers_choices where answer_id = :AnswerNr",
        new NVPair("AnswerNr", answerNr));
    SQL.delete("delete from answers where answer_id = :AnswerNr", new NVPair("AnswerNr", answerNr));
  }
  @Override
  public void subscribe(String topicFilter, Integer qos) throws ProcessingException {
    checkConnection();

    try {
      if (qos == null) {
        m_mqttClient.subscribe(topicFilter);
      } else {
        m_mqttClient.subscribe(topicFilter, qos);
      }
    } catch (Exception e) {
      throw new ProcessingException(TEXTS.get("subscribeError"), e);
    }

    s_logger.info("topic " + topicFilter + "' successfully subscribed");
  }
Beispiel #9
0
  @Override
  public AnswerFormData store(AnswerFormData formData) throws ProcessingException {
    if (!ACCESS.check(new UpdateAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

    if (formData.getAnswerNr() == null) {
      throw new ProcessingException("AnswerNr can no be null");
    }

    SQL.update("update answers set name = :YourName where answer_id = :AnswerNr", formData);

    SQL.delete("delete from answers_choices where answer_id = :AnswerNr", formData);

    storeAnswerChoice(formData);

    return formData;
  }
Beispiel #10
0
  @Override
  public AnswerFormData create(AnswerFormData formData) throws ProcessingException {
    if (!ACCESS.check(new CreateAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

    SQL.insert(
        " insert into answers (name, question_id) " + " values (:YourName, :QuestionNr) ",
        formData);

    SQL.selectInto(" values IDENTITY_VAL_LOCAL() " + " into  :AnswerNr", formData);

    if (formData.getAnswerNr() == null) {
      throw new ProcessingException("AnswerNr can no be null");
    }

    storeAnswerChoice(formData);
    return formData;
  }
Beispiel #11
0
  @Override
  public AnswerFormData load(AnswerFormData formData) throws ProcessingException {
    if (!ACCESS.check(new ReadAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

    if (formData.getAnswerNr() == null) {
      throw new ProcessingException("AnswerNr can no be null");
    }

    SQL.selectInto(
        " select question_id, name "
            + " from answers "
            + " where answer_id = :AnswerNr "
            + " into  :QuestionNr, :YourName",
        formData);

    if (formData.getQuestionNr().getValue() == null) {
      throw new ProcessingException("QuestionNr can no be null");
    }

    loadQuestion(formData);
    if (BooleanUtility.nvl(formData.getMultipleChoices())) {
      SQL.selectInto(
          " select choice_id "
              + " from  answers_choices "
              + " where answer_id = :AnswerNr "
              + " into  :Choices",
          formData);
    } else {
      SQL.selectInto(
          " select choice_id "
              + " from  answers_choices "
              + " where answer_id = :AnswerNr "
              + " into  :Choice",
          formData);
    }

    return formData;
  }
  @Override
  public void publish(String topic, String content, Integer qos, Boolean retained)
      throws ProcessingException {
    checkConnection();

    try {
      MqttMessage message = new MqttMessage(content.getBytes());

      if (qos != null) {
        message.setQos(qos);
      }

      if (retained != null) {
        message.setRetained(retained);
      }

      m_mqttClient.publish(topic, message);
    } catch (Exception e) {
      throw new ProcessingException(TEXTS.get("publishError"), e);
    }

    s_logger.info("message " + topic + ":'" + content + "' successfully published");
  }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("Default");
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("Examples");
 }
 @Override
 protected String getConfiguredText() {
   return TEXTS.get("DeleteFile");
 }
 @Override
 protected String getConfiguredTitle() {
   return TEXTS.get("NumberFields");
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("Grouping");
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("Styled");
 }
 @Override
 protected String getConfiguredTitle() {
   return TEXTS.get("HelloWorld");
 }
 @Override
 protected void execInitField() throws ProcessingException {
   setValue(TEXTS.get("BigIntegerField"));
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("Mandatory");
 }
 @Override
 protected String getConfiguredText() {
   return TEXTS.get("User");
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("MaximumValue");
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("SmallestValue");
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("LongFieldInput");
 }
 @Override
 protected String getConfiguredText() {
   return TEXTS.get("Administrator");
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("BigIntegerFieldInput");
 }
 @Override
 protected String getConfiguredHeaderText() {
   return TEXTS.get("ReadOnly");
 }
 @Override
 protected String getConfiguredLabel() {
   return TEXTS.get("SampleFormat");
 }
 @Override
 protected String getConfiguredHeaderText() {
   return TEXTS.get("DateModified");
 }