예제 #1
0
  /** Initializes Query name from string. */
  void setQueryName(String newName) {
    if (newName != null && newName.trim().length() == 0) {
      newName = null;
    }

    AbstractQuery query = getQuery();

    if (query == null) {
      return;
    }

    if (Util.nullSafeEquals(newName, query.getName())) {
      return;
    }

    if (newName == null) {
      throw new ValidationException("SelectQuery name is required.");
    }

    DataMap map = mediator.getCurrentDataMap();
    Query matchingQuery = map.getQuery(newName);

    if (matchingQuery == null) {
      // completely new name, set new name for entity
      QueryEvent e = new QueryEvent(this, query, query.getName());
      ProjectUtil.setQueryName(map, query, newName);
      mediator.fireQueryEvent(e);
    } else if (matchingQuery != query) {
      // there is a query with the same name
      throw new ValidationException(
          "There is another query named '" + newName + "'. Use a different name.");
    }
  }
예제 #2
0
  /** Initializes Query qualifier from string. */
  void setQueryQualifier(String text) {
    if (text != null && text.trim().length() == 0) {
      text = null;
    }

    Expression qualifier = createQualifier(text);
    if (qualifier != null) {
      // getQuery() is not null if we reached here
      getQuery().setQualifier(qualifier);
      mediator.fireQueryEvent(new QueryEvent(this, getQuery()));
    }
  }