Methods Summary |
---|
private void | addAttributeWithFetchJoins(oracle.toplink.essentials.queryframework.ReportQuery reportQuery, oracle.toplink.essentials.expressions.Expression expression, oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
Add the variable as ReportQuery item. The method checks for any JOIN
FETCH nodes of the current variable and adds them as part of the
ReportQuery item.
String name = getCanonicalVariableName();
List fetchJoinNodes = context.getParseTreeContext().getFetchJoins(name);
if (fetchJoinNodes == null) {
reportQuery.addAttribute(name, expression);
} else {
List fetchJoinExprs = new ArrayList(fetchJoinNodes.size());
for (Iterator i = fetchJoinNodes.iterator(); i.hasNext(); ) {
Node node = (Node)i.next();
fetchJoinExprs.add(node.generateExpression(context));
}
reportQuery.addItem(name, expression, fetchJoinExprs);
}
|
private void | addFetchJoins(oracle.toplink.essentials.queryframework.ObjectLevelReadQuery theQuery, oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
Check for any JOIN FETCH nodes of the current variable and add them as
joined attributes. This method is called in case of a non ReportQuery
instance.
String name = getCanonicalVariableName();
List fetchJoinNodes = context.getParseTreeContext().getFetchJoins(name);
if (fetchJoinNodes != null) {
for (Iterator i = fetchJoinNodes.iterator(); i.hasNext(); ) {
Node node = (Node)i.next();
theQuery.addJoinedAttribute(node.generateExpression(context));
}
}
|
public void | applyToQuery(oracle.toplink.essentials.queryframework.ObjectLevelReadQuery theQuery, oracle.toplink.essentials.internal.parsing.GenerationContext generationContext)INTERNAL
Apply this node to the passed query
String name = getCanonicalVariableName();
ParseTreeContext context = generationContext.getParseTreeContext();
if (theQuery instanceof ReportQuery) {
ReportQuery reportQuery = (ReportQuery)theQuery;
Expression expression = generationContext.expressionFor(name);
if (expression == null) {
expression = generateExpression(generationContext);
}
addAttributeWithFetchJoins(reportQuery, expression, generationContext);
} else {
addFetchJoins(theQuery, generationContext);
}
|
public oracle.toplink.essentials.expressions.Expression | generateBaseBuilderExpression(oracle.toplink.essentials.internal.parsing.GenerationContext context)
//create builder, and add it, and answer it
//BUG 3106877: Need to create builder using the actual class (if using parallel expressions)
if (context.useParallelExpressions()) {
return new ExpressionBuilder(this.resolveClass(context));
} else {
return new ExpressionBuilder();
}
|
public oracle.toplink.essentials.expressions.Expression | generateExpression(oracle.toplink.essentials.internal.parsing.GenerationContext generationContext)
Expression myExpression = null;
String name = getCanonicalVariableName();
//is there a cached Expression?
myExpression = generationContext.expressionFor(name);
if (myExpression != null) {
return myExpression;
}
//Either I have an alias type, or I'm an IN declaration
if (generationContext.getParseTreeContext().isRangeVariable(name)) {
myExpression = generateBaseBuilderExpression(generationContext);
} else {
myExpression = generateExpressionForAlias(generationContext);
}
generationContext.addExpression(myExpression, name);
return myExpression;
|
public oracle.toplink.essentials.expressions.Expression | generateExpressionForAlias(oracle.toplink.essentials.internal.parsing.GenerationContext context)
// BUG 3105651: Verify if we need to resolve this alias, or just use
// an empty ExpressionBuilder. See OrderByItemNode.generateExpression()
// for more details
if (context.getParseTree().getQueryNode().isSelectNode() && context.shouldCheckSelectNodeBeforeResolving() && (((SelectNode)context.getParseTree().getQueryNode()).isSelected(this.getCanonicalVariableName()))) {
return new ExpressionBuilder();
}
Node nodeForAlias = getNodeForAlias(context);
//assume that if there is no node available for the given variable, then
//there must be an alias mismatch. Assume they know their attribute names better
//than their alias names. - JGL
if (nodeForAlias == null) {
throw EJBQLException.aliasResolutionException(
context.getParseTreeContext().getQueryInfo(),
getLine(), getColumn(), getVariableName());
}
//create builder, and answer it
return nodeForAlias.generateExpression(context);
|
public java.lang.String | getAsString()INTERNAL
Get the string representation of this node.
return getVariableName();
|
public java.lang.String | getCanonicalVariableName()
return canonicalName;
|
public oracle.toplink.essentials.internal.parsing.Node | getNodeForAlias(oracle.toplink.essentials.internal.parsing.GenerationContext context)
//Node node = context.getParseTreeContext().nodeForIdentifier(getCanonicalVariableName());
//return node != null ? ((IdentificationVariableDeclNode)node).getPath() : null;
return context.getParseTreeContext().pathForVariable(getCanonicalVariableName());
|
public java.lang.String | getVariableName()
return variableName;
|
public boolean | isAlias(oracle.toplink.essentials.internal.parsing.GenerationContext context)isAlias: Answer true if this variable represents an alias in the FROM clause.
i.e. "FROM Employee emp" declares "emp" as an alias
return isAlias(context.getParseTreeContext());
|
public boolean | isAlias(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
String classNameForAlias = context.schemaForVariable(getCanonicalVariableName());
return classNameForAlias != null;
|
public boolean | isVariableNode()INTERNAL
Is this node a VariableNode
return true;
|
public oracle.toplink.essentials.internal.parsing.Node | qualifyAttributeAccess(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)INTERNAL
This node represent an unqualified field access in the case the method
is called and the variableName is not defined as identification variable.
The method returns a DotNode representing a qualified field access with
the base variable as left child node. The right child node is an
AttributeNode using the variableName as field name.
return context.isVariable(variableName) ? this :
(Node)context.getNodeFactory().newQualifiedAttribute(
getLine(), getColumn(), context.getBaseVariable(), variableName);
|
public java.lang.Class | resolveClass(oracle.toplink.essentials.internal.parsing.GenerationContext generationContext)resolveClass: Answer the class which corresponds to my variableName. This is the class for
an alias, where the variableName is registered to an alias.
Class clazz = null;
String name = getCanonicalVariableName();
ParseTreeContext context = generationContext.getParseTreeContext();
if (context.isRangeVariable(name)) {
String schema = context.schemaForVariable(name);
clazz = context.classForSchemaName(schema, generationContext);
} else {
DotNode path = (DotNode)context.pathForVariable(name);
if (path == null) {
throw EJBQLException.aliasResolutionException(
context.getQueryInfo(), getLine(), getColumn(), name);
} else {
clazz = path.resolveClass(generationContext);
}
}
return clazz;
|
public void | setVariableName(java.lang.String newVariableName)
variableName = newVariableName;
canonicalName = IdentificationVariableDeclNode.calculateCanonicalName(newVariableName);
|
public java.lang.String | toString(int indent)
StringBuffer buffer = new StringBuffer();
toStringIndent(indent, buffer);
buffer.append(toStringDisplayName() + "[" + getVariableName() + "]");
return buffer.toString();
|
public void | validate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)INTERNAL
Validate node and calculate its type.
TypeHelper typeHelper = context.getTypeHelper();
String name = getCanonicalVariableName();
if (context.isRangeVariable(name)) {
String schema = context.schemaForVariable(name);
setType(typeHelper.resolveSchema(schema));
} else {
Node path = context.pathForVariable(name);
if (path == null) {
throw EJBQLException.aliasResolutionException(
context.getQueryInfo(), getLine(), getColumn(), name);
} else {
setType(path.getType());
}
}
context.usedVariable(name);
if (context.isDeclaredInOuterScope(name)) {
context.registerOuterScopeVariable(name);
}
|