Don't like ads? PRO users don't see any ads ;-)

getValues()

By: diegor on Jan 10th, 2012  |  syntax: Java  |  size: 1.77 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public final List<QueryLiteral> getValues(
  2.                 final QueryCreationContext queryCreationCtx,
  3.                 final FunctionOperand operand,
  4.                 final TerminalClause terminalClause) {
  5.  
  6.     LOG.debug("Calling getValues of " + this.getClass().toString() + "on the object " + this.toString());
  7.     List<QueryLiteral> literals = Collections.emptyList();
  8.     String cache_key = terminalClause.getName();
  9.  
  10.         //here I use the cache as described in https://jira.atlassian.com/browse/JRA-22256
  11.     if (!cache.containsKey(cache_key)) {
  12.             // initialise fields if first use
  13.             if (taLink == null) {
  14.             taLink = new TeamAssistDatabaseLink(); // This is a link to an external Oracle DB
  15.             final CustomFieldManager cfManager = ComponentManager.getInstance().getCustomFieldManager();
  16.             customField = cfManager.getCustomFieldObject(TeamAssistProperties.customfieldID());
  17.             }
  18.  
  19.         // get the options associated with the custom field
  20.         final JiraContextNode contextNode = GlobalIssueContext.getInstance();
  21.         final List<Option> options = (List<Option>)customField.getOptions(null, contextNode).getRootOptions();
  22.  
  23.         // build a list of "cases" (kind of customfield) as query literals
  24.         literals = new ArrayList<QueryLiteral>(options.size());
  25.         for (Option option : options) {
  26.                 final String taId = option.getValue();
  27.                         if (taLink.isCase(taId)) {
  28.                                 LOG.debug("Adding " + taId);
  29.                                 literals.add(new QueryLiteral(operand, taId));
  30.                         }
  31.  
  32.         }
  33.                 cache.put(cache_key, literals);
  34.                 LOG.debug("Create an instance into the cache with key: " + cache_key);
  35.     } else {
  36.         literals = cache.get(cache_key);
  37.                 LOG.debug("Get an instance from the cache with key: " + cache_key);
  38.     }
  39.  
  40.     LOG.debug("EXITING: " + literals.size());
  41.     return literals;
  42. }