/**
   * addParam
   *
   * @param parmName a {@link java.lang.String} object.
   * @param val a {@link java.lang.String} object.
   * @return a {@link org.opennms.netmgt.model.events.EventBuilder} object.
   */
  public EventBuilder addParam(final String parmName, final boolean val) {
    if (parmName != null) {
      final Value value = new Value();
      value.setContent(val ? "true" : "false");

      final Parm parm = new Parm();
      parm.setParmName(parmName);
      parm.setValue(value);

      this.addParam(parm);
    }

    return this;
  }
  /**
   * setParam
   *
   * @param parmName a {@link java.lang.String} object.
   * @param val a {@link java.lang.String} object.
   * @return a {@link org.opennms.netmgt.model.events.EventBuilder} object.
   */
  public EventBuilder setParam(final String parmName, final String val) {
    if (m_event.getParmCollection().size() < 1) {
      return addParam(parmName, val);
    }

    for (final Parm parm : m_event.getParmCollection()) {
      if (parm.getParmName().equals(val)) {
        final Value value = new Value();
        value.setContent(val);
        parm.setValue(value);
        return this;
      }
    }

    return addParam(parmName, val);
  }
Esempio n. 3
0
 private void sendRearmForTriggeredStates() {
   for (String instance : m_thresholdEvaluatorStates.keySet()) {
     for (ThresholdEvaluatorState state : m_thresholdEvaluatorStates.get(instance)) {
       if (state.isTriggered()) {
         Event e = state.getEventForState(Status.RE_ARMED, new Date(), Double.NaN, null);
         Parm p = new Parm();
         p.setParmName("reason");
         Value v = new Value();
         v.setContent("Configuration has been changed");
         p.setValue(v);
         e.addParm(p);
         log().info("sendRearmForTriggeredStates: sending rearm for " + e);
         ThresholdingEventProxyFactory.getFactory().getProxy().add(e);
         state.clearState();
       }
     }
   }
 }
  public EventBuilder addParam(
      final String parmName, final String val, final String type, final String encoding) {
    if (parmName != null) {
      Value value = new Value();
      value.setContent(val);

      if (type != null) {
        value.setType(type);
      }

      if (encoding != null) {
        value.setEncoding(encoding);
      }

      Parm parm = new Parm();
      parm.setParmName(parmName);
      parm.setValue(value);

      addParam(parm);
    }

    return this;
  }
Esempio n. 5
0
  /**
   * decode
   *
   * @param eventparms an event parm string
   * @return a list of parameters
   */
  public static List<Parm> decode(final String eventparms) {
    if (eventparms == null) return null;
    final List<Parm> parms = new ArrayList<Parm>();

    String[] paramslistString = eventparms.split(Character.toString(Constants.MULTIPLE_VAL_DELIM));
    if (paramslistString != null) {
      for (int i = 0; i < paramslistString.length; i++) {
        String[] paramEncoded =
            paramslistString[i].split(Character.toString(Constants.NAME_VAL_DELIM));
        if (paramEncoded != null && paramEncoded.length == 2) {
          Parm parm = new Parm();
          parm.setParmName(paramEncoded[0]);
          Value value = new Value();
          int startParamType = paramEncoded[1].lastIndexOf('(');
          if (startParamType == -1) {
            value.setContent(paramEncoded[1]);
            value.setType("string");
            value.setEncoding("text");
          } else {
            value.setContent(paramEncoded[1].substring(0, startParamType));
            String paramType = paramEncoded[1].substring(startParamType + 1);
            String[] typeAndEncode = paramType.split(Character.toString(Constants.DB_ATTRIB_DELIM));
            if (typeAndEncode != null && typeAndEncode.length == 2) {
              value.setType(typeAndEncode[0]);
              value.setEncoding(typeAndEncode[1].split("\\)")[0]);
            } else {
              value.setType("string");
              value.setEncoding("text");
            }
          }
          parm.setValue(value);
          parms.add(parm);
        }
      }
    }
    return parms;
  }