/**
  * @param value the query literal; must not be null or the empty literal.
  * @return a list of ids of issue types represented by this literal; never null.
  */
 List<String> getIds(final QueryLiteral value) {
   if (value.getStringValue() != null) {
     return resolver.getIndexedValues(value.getStringValue());
   } else if (value.getLongValue() != null) {
     return resolver.getIndexedValues(value.getLongValue());
   } else {
     throw new IllegalStateException("Invalid query literal.");
   }
 }
  public ClauseContext getClauseContext(final User searcher, final TerminalClause terminalClause) {
    final Operator operator = terminalClause.getOperator();
    if (!handlesOperator(operator)) {
      return ClauseContextImpl.createGlobalClauseContext();
    }

    final List<QueryLiteral> values =
        jqlOperandResolver.getValues(searcher, terminalClause.getOperand(), terminalClause);
    Set<String> issueTypeIds = new HashSet<String>();
    if (values != null) {
      for (QueryLiteral value : values) {
        // if we have an empty literal, the Global context will not impact on any existing contexts,
        // so do nothing
        if (!value.isEmpty()) {
          issueTypeIds.addAll(getIds(value));
        }
      }
    }

    if (!issueTypeIds.isEmpty() && isNegationOperator(operator)) {
      final Set<String> allIssueTypes = new HashSet<String>(constantsManager.getAllIssueTypeIds());
      allIssueTypes.removeAll(issueTypeIds);
      issueTypeIds = allIssueTypes;
    }

    if (issueTypeIds.isEmpty()) {
      return ClauseContextImpl.createGlobalClauseContext();
    }

    final Set<ProjectIssueTypeContext> contexts = new HashSet<ProjectIssueTypeContext>();
    for (String issueTypeId : issueTypeIds) {
      contexts.add(
          new ProjectIssueTypeContextImpl(
              AllProjectsContext.INSTANCE, new IssueTypeContextImpl(issueTypeId)));
    }

    return new ClauseContextImpl(contexts);
  }
 /**
  * @param searcher the user performing the search
  * @param clause the clause
  * @return a set of Strings representing the ids of the statuses; never null.
  */
 Set<String> getIds(final User searcher, final TerminalClause clause) {
   final List<QueryLiteral> literals =
       jqlOperandResolver.getValues(searcher, clause.getOperand(), clause);
   Set<String> ids = new HashSet<String>();
   if (literals != null) {
     for (QueryLiteral literal : literals) {
       if (literal.getLongValue() != null) {
         ids.addAll(issueConstantInfoResolver.getIndexedValues(literal.getLongValue()));
       } else if (literal.getStringValue() != null) {
         ids.addAll(issueConstantInfoResolver.getIndexedValues(literal.getStringValue()));
       } else if (literal.isEmpty()) {
         // empty literals would generate a Global context, but this does not impact on other
         // contexts
       }
     }
   }
   return ids;
 }
  private List<IssueSecurityLevel> _getIssueSecurityLevels(
      User searcher, boolean overrideSecurity, List<QueryLiteral> rawValues) {
    notNull("rawValues", rawValues);
    List<IssueSecurityLevel> matchingLevels = new ArrayList<IssueSecurityLevel>();

    for (QueryLiteral rawValue : rawValues) {
      notNull("rawValue", rawValue);
      if (rawValue.getStringValue() != null) {
        matchingLevels.addAll(
            getIssueSecurityLevelsForString(searcher, overrideSecurity, rawValue.getStringValue()));
      } else if (rawValue.getLongValue() != null) {
        matchingLevels.addAll(
            getIssueSecurityLevelsForLong(searcher, overrideSecurity, rawValue.getLongValue()));
      } else if (rawValue.isEmpty()) {
        // we somehow got an Empty literal - use null to represent this
        matchingLevels.add(null);
      }
    }

    return matchingLevels;
  }
 public MessageSet validateValues(User searcher, String fieldName, List<QueryLiteral> rawValues) {
   final PossibleValuesHolder possibleValuesHolder = new PossibleValuesHolder();
   final MessageSet messages = new MessageSetImpl();
   for (QueryLiteral rawValue : rawValues) {
     if (rawValue.getStringValue() != null) {
       if (!stringValueExists(
           possibleValuesHolder, searcher, fieldName, rawValue.getStringValue())) {
         if (operandResolver.isFunctionOperand(rawValue.getSourceOperand())) {
           messages.addErrorMessage(
               getI18n(searcher)
                   .getText(
                       "jira.jql.clause.no.value.for.name.from.function",
                       rawValue.getSourceOperand().getName(),
                       fieldName));
         } else {
           messages.addErrorMessage(
               getI18n(searcher)
                   .getText(
                       "jira.jql.clause.no.value.for.name", fieldName, rawValue.getStringValue()));
         }
       }
     } else if (rawValue.getLongValue() != null) {
       if (stringValueExists(
           possibleValuesHolder, searcher, fieldName, rawValue.getLongValue().toString())) {
         return messages;
       }
       if (!configurationManager.supportsIdSearching(fieldName.toLowerCase())) {
         if (operandResolver.isFunctionOperand(rawValue.getSourceOperand())) {
           messages.addErrorMessage(
               getI18n(searcher)
                   .getText(
                       "jira.jql.clause.no.value.for.name.from.function",
                       rawValue.getSourceOperand().getName(),
                       fieldName));
         } else {
           messages.addErrorMessage(
               getI18n(searcher)
                   .getText(
                       "jira.jql.history.clause.not.string",
                       rawValue.getSourceOperand().getName(),
                       fieldName));
         }
       } else {
         if (!longValueExists(searcher, fieldName, rawValue.getLongValue())) {
           if (operandResolver.isFunctionOperand(rawValue.getSourceOperand())) {
             messages.addErrorMessage(
                 getI18n(searcher)
                     .getText(
                         "jira.jql.clause.no.value.for.name.from.function",
                         rawValue.getSourceOperand().getName(),
                         fieldName));
           } else {
             messages.addErrorMessage(
                 getI18n(searcher)
                     .getText(
                         "jira.jql.clause.no.value.for.id",
                         fieldName,
                         rawValue.getLongValue().toString()));
           }
         }
       }
     }
   }
   return messages;
 }