private Event createBasicEvent(String uei, Date date, double dsValue, CollectionResourceWrapper resource) { Map<String,String> params = new HashMap<String,String>(); params.put("threshold", Double.toString(getThresholdConfig().getValue())); params.put("trigger", Integer.toString(getThresholdConfig().getTrigger())); params.put("rearm", Double.toString(getThresholdConfig().getRearm())); return createBasicEvent(uei, date, dsValue, resource, params); }
/** {@inheritDoc} */ @Override public boolean equals(final Object obj) { if ( this == obj ) { return true; } if (obj instanceof BaseThresholdDefConfigWrapper) { final BaseThresholdDefConfigWrapper that = (BaseThresholdDefConfigWrapper)obj; return Objects.equals(this.getType(), that.getType()) && Objects.equals(this.getDsType(), that.getDsType()) && Objects.equals(this.getDatasourceExpression(), that.getDatasourceExpression()) && Objects.equals(this.getDsLabel(), that.getDsLabel()) && Objects.equals(this.getTriggeredUEI(), that.getTriggeredUEI()) && Objects.equals(this.getRearmedUEI(), that.getRearmedUEI()) && Objects.equals(this.getValue(), that.getValue()) && Objects.equals(this.getRearm(), that.getRearm()) && Objects.equals(this.getTrigger(), that.getTrigger()) && Objects.equals(this.getBasethresholddef().getFilterOperator(), that.getBasethresholddef().getFilterOperator()) && Objects.equals(this.getBasethresholddef().getRelaxed(), that.getBasethresholddef().getRelaxed()) && Objects.equals(this.getBasethresholddef().getResourceFilters(), that.getBasethresholddef().getResourceFilters()); } return false; }
protected boolean isRearmExceeded(double dsValue) { if (ThresholdType.HIGH.equals(getThresholdConfig().getType())) { return dsValue <= getThresholdConfig().getRearm(); } else if (ThresholdType.LOW.equals(getThresholdConfig().getType())) { return dsValue >= getThresholdConfig().getRearm(); } else { throw new IllegalStateException("This thresholding strategy can only be used for thresholding types of 'high' and 'low'."); } }
/** * This method is responsible for returning a String object which represents * the content of this ThresholdEntity. Primarily used for debugging * purposes. * * @return String which represents the content of this ThresholdEntity */ @Override public String toString() { if (!hasThresholds()) { return ""; } final StringBuilder buffer = new StringBuilder("{"); buffer.append("evaluator=").append(this.getThresholdConfig().getType()); buffer.append(", dsName=").append(this.getDataSourceExpression()); buffer.append(", dsType=").append(this.getDatasourceType()); buffer.append(", evaluators=["); for (ThresholdEvaluatorState item : getThresholdEvaluatorStates(null)) { buffer.append("{ds=").append(item.getThresholdConfig().getDatasourceExpression()); buffer.append(", value=").append(item.getThresholdConfig().getValue()); buffer.append(", rearm=").append(item.getThresholdConfig().getRearm()); buffer.append(", trigger=").append(item.getThresholdConfig().getTrigger()); buffer.append("}"); } buffer.append("]}"); return buffer.toString(); }