checkTargetGroupIsOkay method

bool checkTargetGroupIsOkay(
  1. TargetingGroup itemTargetGroup
)

Implementation

bool checkTargetGroupIsOkay(TargetingGroup itemTargetGroup) {
  for (ItemTarget itemTarget in itemTargetGroup.targetings) {
    dynamic currentContextValue = getCurrentValueFromCtx(itemTarget.tragetKey);
    // Audience value
    dynamic audienceValue = itemTarget.targetValue;

    // Create the type operator
    FSOperator opType = createOperator(itemTarget.targetOperator);
    bool isOkay = false;

    // Special treatment for array
    if ((audienceValue is List<String>) ||
        (audienceValue is List<int>) ||
        (audienceValue is List<double>) ||
        (audienceValue is List<dynamic>)) {
      isOkay = checkTargetingForList(currentContextValue, opType, audienceValue);
    } else {
      isOkay = checkCondition(currentContextValue, opType, audienceValue);
    }

    Flagship.logger(Level.DEBUG,
        "For the key \"${itemTarget.tragetKey}\" the condition: ( $currentContextValue ${opType.name} $audienceValue )${isOkay ? " is " : " is not "} satisfied");

    if (isOkay == false) {
      return false; // if false no need to check others
    }
  }
  return true;
}