Esempio n. 1
0
 @Override
 protected void putJoinTabalis(Map<Class, String> map) {
   if (this.joinClass != null && !map.containsKey(this.joinClass))
     map.put(joinClass, String.valueOf((char) ('b' + map.size())));
   if (this.nodes == null) return;
   for (FilterNode node : this.nodes) {
     node.putJoinTabalis(map);
   }
 }
Esempio n. 2
0
 private static CharSequence createElementSQLJoin(
     final Map<Class, String> joinTabalis, final EntityInfo info, final FilterJoinNode node) {
   if (node.joinClass == null) return null;
   StringBuilder sb = new StringBuilder();
   String[] joinColumns = node.joinColumns;
   sb.append(" INNER JOIN ")
       .append(node.joinEntity.getTable())
       .append(" ")
       .append(joinTabalis.get(node.joinClass))
       .append(" ON ")
       .append(info.getSQLColumn("a", joinColumns[0]))
       .append(" = ")
       .append(node.joinEntity.getSQLColumn(joinTabalis.get(node.joinClass), joinColumns[0]));
   for (int i = 1; i < joinColumns.length; i++) {
     sb.append(" AND ")
         .append(info.getSQLColumn("a", joinColumns[i]))
         .append(" = ")
         .append(node.joinEntity.getSQLColumn(joinTabalis.get(node.joinClass), joinColumns[i]));
   }
   return sb;
 }
Esempio n. 3
0
  public boolean matches(Criteria criteria) {
    score = 0;

    boolean kill = false;
    boolean anyMatches = false;
    for (Criterion criterion : criteria) {
      Answer answer = answers.get(criterion.getAnswer().getQuestionText());
      boolean match =
          criterion.getWeight() == Weight.DontCare || answer.match(criterion.getAnswer());
      if (!match && criterion.getWeight() == Weight.MustMatch) {
        kill = true;
      }
      if (match) {
        score += criterion.getWeight().getValue();
      }
      anyMatches |= match;
      // ...
    }
    if (kill) return false;
    return anyMatches;
  }
Esempio n. 4
0
 static <T, U> Node<U> apply(Node<T> node, Function<? super T, ? extends U> mapper) {
   final U value = mapper.apply(node.getValue());
   final List<Node<U>> children = node.getChildren().map(child -> Map.apply(child, mapper));
   return new Node<>(value, children);
 }
Esempio n. 5
0
 public List<Answer> find(Predicate<Answer> pred) {
   return answers.values().stream().filter(pred).collect(Collectors.toList());
 }
Esempio n. 6
0
 public List<Answer> classicFind(Predicate<Answer> pred) {
   List<Answer> results = new ArrayList<Answer>();
   for (Answer answer : answers.values()) if (pred.test(answer)) results.add(answer);
   return results;
 }
Esempio n. 7
0
 public void add(Answer answer) {
   answers.put(answer.getQuestionText(), answer);
 }