use of org.apache.cayenne.access.sqlbuilder.sqltree.ColumnNode in project cayenne by apache.
the class ResultNodeDescriptor method getDbAttribute.
public DbAttribute getDbAttribute() {
if (this.dbAttribute != null) {
return this.dbAttribute;
}
DbAttribute[] dbAttribute = { null };
node.visit(new SimpleNodeTreeVisitor() {
@Override
public boolean onNodeStart(Node node) {
if (node.getType() == NodeType.COLUMN) {
dbAttribute[0] = ((ColumnNode) node).getAttribute();
return false;
}
return true;
}
});
return this.dbAttribute = dbAttribute[0];
}
use of org.apache.cayenne.access.sqlbuilder.sqltree.ColumnNode in project cayenne by apache.
the class HavingTranslationStageTest method perform.
@Test
public void perform() {
HavingTranslationStage stage = new HavingTranslationStage();
stage.perform(context);
Node select = context.getSelectBuilder().build();
// Content of "select" node:
//
// Having
// |
// OpExpression
// / \
// Column Value
assertEquals(1, select.getChildrenCount());
assertThat(select.getChild(0), instanceOf(HavingNode.class));
Node op = select.getChild(0).getChild(0);
assertThat(op, instanceOf(OpExpressionNode.class));
assertEquals(">=", ((OpExpressionNode) op).getOp());
assertEquals(2, op.getChildrenCount());
assertThat(op.getChild(0), instanceOf(ColumnNode.class));
assertThat(op.getChild(1), instanceOf(ValueNode.class));
ColumnNode columnNode = (ColumnNode) op.getChild(0);
ValueNode valueNode = (ValueNode) op.getChild(1);
assertEquals("path", columnNode.getColumn());
assertEquals(10, valueNode.getValue());
}
use of org.apache.cayenne.access.sqlbuilder.sqltree.ColumnNode in project cayenne by apache.
the class OrderingStageTest method perform.
@Test
public void perform() {
OrderingStage orderingStage = new OrderingStage();
orderingStage.perform(context);
Node select = context.getSelectBuilder().build();
// Content of "select" node:
//
// OrderBy
// |
// Empty
// / \
// Column "DESC"
Node child = select.getChild(0);
assertEquals(1, select.getChildrenCount());
assertThat(child, instanceOf(OrderByNode.class));
assertEquals(1, child.getChildrenCount());
assertThat(child.getChild(0), instanceOf(EmptyNode.class));
assertEquals(2, child.getChild(0).getChildrenCount());
assertThat(child.getChild(0).getChild(0), instanceOf(ColumnNode.class));
assertThat(child.getChild(0).getChild(1), instanceOf(TextNode.class));
ColumnNode columnNode = (ColumnNode) child.getChild(0).getChild(0);
assertEquals("path", columnNode.getColumn());
assertEquals("Node { DESC}", child.getChild(0).getChild(1).toString());
}
use of org.apache.cayenne.access.sqlbuilder.sqltree.ColumnNode in project cayenne by apache.
the class GroupByStageTest method noAggregates.
// result column but no aggregates
@Test
public void noAggregates() {
context.addResultNode(new ColumnNode("t0", "column", null, null));
GroupByStage stage = new GroupByStage();
stage.perform(context);
Node node = context.getSelectBuilder().build();
assertEquals(0, node.getChildrenCount());
}
use of org.apache.cayenne.access.sqlbuilder.sqltree.ColumnNode in project cayenne by apache.
the class QualifierTranslationStageTest method perform.
@Test
public void perform() {
QualifierTranslationStage stage = new QualifierTranslationStage();
stage.perform(context);
assertNotNull(context.getQualifierNode());
// Content of "Qualifier" node:
//
// OpExpression
// / \
// Column Value
Node op = context.getQualifierNode();
assertThat(op, instanceOf(OpExpressionNode.class));
assertEquals(">=", ((OpExpressionNode) op).getOp());
assertEquals(2, op.getChildrenCount());
assertThat(op.getChild(0), instanceOf(ColumnNode.class));
assertThat(op.getChild(1), instanceOf(ValueNode.class));
ColumnNode columnNode = (ColumnNode) op.getChild(0);
ValueNode valueNode = (ValueNode) op.getChild(1);
assertEquals("path", columnNode.getColumn());
assertEquals(10, valueNode.getValue());
}
Aggregations