Пример #1
0
 /**
  * Return an updated condition that do not contain a condition on the scoringId anymore it's
  * remove the unnecessary boolean condition (if a condition is the only one of a boolean the
  * boolean will be remove and the subcondition returned) it's return null when there is no more
  * condition after (if the condition passed was only a scoring condition on the scoringId)
  *
  * @param condition the condition to update
  * @param scoringId the scoring id to remove in the condition
  * @return updated condition
  */
 private Condition updateScoringDependentCondition(Condition condition, String scoringId) {
   if ("booleanCondition".equals(condition.getConditionTypeId())) {
     @SuppressWarnings("unchecked")
     final List<Condition> subConditions =
         (List<Condition>) condition.getParameter("subConditions");
     List<Condition> updatedSubConditions = new LinkedList<>();
     for (Condition subCondition : subConditions) {
       Condition updatedCondition = updateScoringDependentCondition(subCondition, scoringId);
       if (updatedCondition != null) {
         updatedSubConditions.add(updatedCondition);
       }
     }
     if (!updatedSubConditions.isEmpty()) {
       if (updatedSubConditions.size() == 1) {
         return updatedSubConditions.get(0);
       } else {
         condition.setParameter("subConditions", updatedSubConditions);
         return condition;
       }
     } else {
       return null;
     }
   } else if ("scoringCondition".equals(condition.getConditionTypeId())
       && scoringId.equals(condition.getParameter("scoringPlanId"))) {
     return null;
   }
   return condition;
 }
Пример #2
0
 /**
  * Return an updated condition that do not contain a condition on the segmentId anymore it's
  * remove the unnecessary boolean condition (if a condition is the only one of a boolean the
  * boolean will be remove and the subcondition returned) it's return null when there is no more
  * condition after (if the condition passed was only a segment condition on the segmentId)
  *
  * @param condition the condition to update
  * @param segmentId the segment id to remove in the condition
  * @return updated condition
  */
 private Condition updateSegmentDependentCondition(Condition condition, String segmentId) {
   if ("booleanCondition".equals(condition.getConditionTypeId())) {
     @SuppressWarnings("unchecked")
     final List<Condition> subConditions =
         (List<Condition>) condition.getParameter("subConditions");
     List<Condition> updatedSubConditions = new LinkedList<>();
     for (Condition subCondition : subConditions) {
       Condition updatedCondition = updateSegmentDependentCondition(subCondition, segmentId);
       if (updatedCondition != null) {
         updatedSubConditions.add(updatedCondition);
       }
     }
     if (!updatedSubConditions.isEmpty()) {
       if (updatedSubConditions.size() == 1) {
         return updatedSubConditions.get(0);
       } else {
         condition.setParameter("subConditions", updatedSubConditions);
         return condition;
       }
     } else {
       return null;
     }
   } else if ("profileSegmentCondition".equals(condition.getConditionTypeId())) {
     @SuppressWarnings("unchecked")
     final List<String> referencedSegmentIds = (List<String>) condition.getParameter("segments");
     if (referencedSegmentIds.indexOf(segmentId) >= 0) {
       referencedSegmentIds.remove(segmentId);
       if (referencedSegmentIds.isEmpty()) {
         return null;
       } else {
         condition.setParameter("segments", referencedSegmentIds);
       }
     }
   }
   return condition;
 }