private Pair findBottom(final Attribute value, final PairList points) { Pair bottom = null; for (Pair point : points) { // Check if the point is NOT after the value if (HelperCOM.evaluateExpression(point.getFirst(), ExpressionOperator.LESS, value)) { if (bottom == null) { bottom = point; continue; } if (HelperCOM.evaluateExpression(point.getFirst(), ExpressionOperator.GREATER, bottom.getFirst())) { bottom = point; } } } return bottom; }
private Pair findTop(final Attribute value, final PairList points) { Pair top = null; for (Pair point : points) { // Check if the point is after the value if (HelperCOM.evaluateExpression(point.getFirst(), ExpressionOperator.GREATER, value)) { if (top == null) { top = point; continue; } if (HelperCOM.evaluateExpression(point.getFirst(), ExpressionOperator.LESS, top.getFirst())) { top = point; } } } return top; }
/** * * @param checkDef * @param value * @param evaluationResult * @return if the evaluation was successfull then the * evaluationResult.result is null, if upper limit is exeeced: true, if * lower limit exceeded: false; OR if violateInRange = true then if it * violates, it returns true */ public static EvaluationResult evaluateLimitCheck(LimitCheckDefinition checkDef, Attribute value, EvaluationResult evaluationResult) { //NULL = successful, true is violating upper limit, false violating lower limit Boolean result = null; if (checkDef.getUpperLimit() != null && !HelperCOM.evaluateExpression(value, ExpressionOperator.LESS_OR_EQUAL, checkDef.getUpperLimit())) { result = true; } if (checkDef.getLowerLimit() != null && !HelperCOM.evaluateExpression(value, ExpressionOperator.GREATER_OR_EQUAL, checkDef.getLowerLimit())) { result = false; } //requirement: 3.5.3.dd if (checkDef.getViolateInRange()) { //in range? -> result is NOT_OK result = (result == null ? true : null); } evaluationResult.setCheckedValue(value); evaluationResult.setEvaluationResult(result); return evaluationResult; }
private Attribute applyRangeConversion(final RangeConversionDetails conversionDetails, final Attribute value) { //requirement: 3.8.3.f => no entry in the points-list returns null // Do we have a direct hit? final PairList points = conversionDetails.getPoints(); for (Pair point : points) { if (HelperCOM.evaluateExpression(point.getFirst(), ExpressionOperator.EQUAL, value)) { // If we get a hit, then return it right away return point.getSecond(); } } Pair bottom = findBottom(value, points); if (bottom == null) { return null; } return bottom.getSecond(); }
Boolean evaluation = HelperCOM.evaluateExpression(leftHandSide, compositeFilter.getType(), compositeFilter.getFieldValue());
/** * evaluates the given parameterExpression * * @param expression the parameterExpression to be evaluated * @return The boolean value of the evaluation. Null if not evaluated. */ public Boolean evaluateParameterExpression(ParameterExpression expression) { if (expression == null) { return true; // No test is required } //TODO: contains the expression defintion or identity-id? -> issue #132, #179 final Long paramIdentityId = expression.getParameterId().getInstId(); ParameterDefinitionDetails pDef = this.getParameterDefinition(paramIdentityId); Attribute value; try { value = parametersMonitoring.onGetValue(super.getName(paramIdentityId), pDef.getRawType()); } catch (IOException ex) { Logger.getLogger(ParameterManager.class.getName()).log(Level.SEVERE, null, ex); return false; } if (expression.getUseConverted()) { // Is the validity checking for the converted or for the raw value? value = conversionService.generateConvertedValue(value, pDef.getConversion()); } return HelperCOM.evaluateExpression(value, expression.getOperator(), expression.getValue()); }
/** * * @param checkDef * @param value * @param evaluationResult * @return if the evaluation was successfull then the * evaluationResult.result is null otherwise false */ public static EvaluationResult evaluateConstantCheck(ConstantCheckDefinition checkDef, Attribute value, EvaluationResult evaluationResult) { //pass one of the evaluations req. 3.5.2.e.a //requirement: 3.5.2.e.a Boolean result = false; for (AttributeValue possibleValue : checkDef.getValues()) { if (HelperCOM.evaluateExpression(possibleValue.getValue(), checkDef.getOperator(), value)) { //requirement: 3.5.3.cc: the parameter value passed the check against the evaluation: return successful! result = null; break; } } evaluationResult.setEvaluationResult(result); evaluationResult.setCheckedValue(value); return evaluationResult; }
/** * Evaluates the state of the Parameter expression. * * @param expression The Parameter Expression * @return The state of the expression * @throws org.ccsds.moims.mo.mal.MALInteractionException The parameter in * the expression does not exist and therefore the state of the expression * could not be evaluated. */ protected Boolean evaluateParameterExpression(ParameterExpression expression) throws MALInteractionException { if (expression == null) { return true; // No test is required } ParameterValue parameterValue = manager.getParameterValue(expression.getParameterId().getInstId()); Attribute param = expression.getUseConverted() ? parameterValue.getConvertedValue() : parameterValue.getRawValue(); return HelperCOM.evaluateExpression(param, expression.getOperator(), expression.getValue()); }
/** * * @param referenceCheckDefinition * @param value * @param currCheckLinkEvaluation * @param newEvaluationResult * @return if the evaluation was successful then the evaluationResult.result * is null otherwise: false; * @throws MALInteractionException */ public static EvaluationResult evaluateReferenceCheck(ReferenceCheckDefinition referenceCheckDefinition, Attribute value, final CheckLinkEvaluation currCheckLinkEvaluation, EvaluationResult newEvaluationResult) throws MALInteractionException { //requirement: 3.5.3.x, y ReferenceValue reference = referenceCheckDefinition.getCheckReference(); HashMap<Long, Attribute> sampleTimes = reference.getDeltaTime().getValue() == 0 ? null : currCheckLinkEvaluation.getSampleTimes(); // manageBeforeRefCheck(referenceValue, checkLinkEvaluation, sampleTimes, useConverted); //evaluate param + refValue Boolean eval = HelperCOM.evaluateExpression(value, referenceCheckDefinition.getOperator(), currCheckLinkEvaluation.getRefParamValue()); if (reference.getParameterId() == null) { manageAfterRefCheck(reference, currCheckLinkEvaluation, sampleTimes, value); } newEvaluationResult.setCheckedValue(value); newEvaluationResult.setEvaluationResult(eval == true ? null : false); return newEvaluationResult; }
private StatisticValue generateStatisticValueMinimum(long paramIdentityId, TimeList times, AttributeValueList values) { StatisticValue statValue = this.newStatisticValue(paramIdentityId, times, values); if (statValue == null) { return null; } int minimum = 0; // Go through all the data sets and find the maximum value... for (int i = 0; i < values.size(); i++) { if (values.get(i) == null) { continue; } // Comparison must be done here //requirement: 3.6.3.i report first occurance of min value if (HelperCOM.evaluateExpression(values.get(i).getValue(), ExpressionOperator.LESS, values.get(minimum).getValue())) { minimum = i; } } statValue.setValue(values.get(minimum).getValue()); statValue.setValueTime(times.get(minimum)); return statValue; }
private StatisticValue generateStatisticValueMaximum(long paramIdentityId, TimeList times, AttributeValueList values) { StatisticValue statValue = this.newStatisticValue(paramIdentityId, times, values); if (statValue == null) { return null; } int maximum = 0; // Go through all the data sets and find the maximum value... for (int i = 0; i < values.size(); i++) { if (values.get(i) == null) { continue; } // Comparison must be done here //requirement: 3.6.3.h report first occurance of max value if (HelperCOM.evaluateExpression(values.get(i).getValue(), ExpressionOperator.GREATER, values.get(maximum).getValue())) { maximum = i; } } statValue.setValue(values.get(maximum).getValue()); statValue.setValueTime(times.get(maximum)); return statValue; }
if (HelperCOM.evaluateExpression(point.getFirst(), ExpressionOperator.EQUAL, value)) { // If we get a hit, then return it right away return point.getSecond();
&& !HelperCOM.evaluateExpression(new Union(delta), ExpressionOperator.LESS_OR_EQUAL, upperThreshold)) { result = true; } else { if (deltaCheckDefinition.getLowerThreshold() != null && !HelperCOM.evaluateExpression(new Union(delta), ExpressionOperator.GREATER_OR_EQUAL, lowerThreshold)) { result = false;