public final List<QueryLiteral> getValues(
final QueryCreationContext queryCreationCtx,
final FunctionOperand operand,
final TerminalClause terminalClause) {
LOG.debug("Calling getValues of " + this.getClass().toString() + "on the object " + this.toString());
List<QueryLiteral> literals = Collections.emptyList();
String cache_key = terminalClause.getName();
//here I use the cache as described in https://jira.atlassian.com/browse/JRA-22256
if (!cache.containsKey(cache_key)) {
// initialise fields if first use
if (taLink == null) {
taLink = new TeamAssistDatabaseLink(); // This is a link to an external Oracle DB
final CustomFieldManager cfManager = ComponentManager.getInstance().getCustomFieldManager();
customField = cfManager.getCustomFieldObject(TeamAssistProperties.customfieldID());
}
// get the options associated with the custom field
final JiraContextNode contextNode = GlobalIssueContext.getInstance();
final List<Option> options = (List<Option>)customField.getOptions(null, contextNode).getRootOptions();
// build a list of "cases" (kind of customfield) as query literals
literals = new ArrayList<QueryLiteral>(options.size());
for (Option option : options) {
final String taId = option.getValue();
if (taLink.isCase(taId)) {
LOG.debug("Adding " + taId);
literals.add(new QueryLiteral(operand, taId));
}
}
cache.put(cache_key, literals);
LOG.debug("Create an instance into the cache with key: " + cache_key);
} else {
literals = cache.get(cache_key);
LOG.debug("Get an instance from the cache with key: " + cache_key);
}
LOG.debug("EXITING: " + literals.size());
return literals;
}