Package org.apache.metamodel.schema

Examples of org.apache.metamodel.schema.Column


                q.toString());
    }

    public void testAddOrderBy() throws Exception {
        Table contributorTable = _schema.getTableByName(TABLE_CONTRIBUTOR);
        Column nameColumn = contributorTable.getColumnByName(COLUMN_CONTRIBUTOR_NAME);
        Column countryColumn = contributorTable.getColumnByName(COLUMN_CONTRIBUTOR_COUNTRY);
        FromItem fromContributor = new FromItem(contributorTable);
        fromContributor.setAlias("a");

        Query q = new Query();
        q.select(nameColumn, countryColumn).from(fromContributor).orderBy(nameColumn)
View Full Code Here


        Table contributorTable = _schema.getTableByName(TABLE_CONTRIBUTOR);
        Table roleTable = _schema.getTableByName(TABLE_ROLE);
        FromItem fromItem = new FromItem(JoinType.INNER, contributorTable.getRelationships(roleTable)[0]);
        q1.from(fromItem);

        Column nameColumn = contributorTable.getColumnByName(COLUMN_CONTRIBUTOR_NAME);
        Column countryColumn = contributorTable.getColumnByName(COLUMN_CONTRIBUTOR_COUNTRY);
        Column roleNameColumn = roleTable.getColumnByName(COLUMN_ROLE_ROLE_NAME);
        q1.select(nameColumn, countryColumn, roleNameColumn);
        q1.orderBy(roleNameColumn);
        String q1string = q1.toString();
        assertEquals(
                "SELECT contributor.name, contributor.country, role.name FROM MetaModelSchema.contributor INNER JOIN MetaModelSchema.role ON contributor.contributor_id = role.contributor_id ORDER BY role.name ASC",
View Full Code Here

    public void testEqualsAndHashCode() throws Exception {
        MutableSchema schema = new MutableSchema("schema");
        MutableTable table = new MutableTable("table").setSchema(schema);
        schema.addTable(table);

        Column col1 = new MutableColumn("col1").setTable(table);
        Column col2 = new MutableColumn("col2").setTable(table);
        Column col3 = new MutableColumn("col3").setTable(table);
        table.addColumn(col1);
        table.addColumn(col2);
        table.addColumn(col3);

        Query q1 = new Query().select(col1, col2).from(table).where(col3, OperatorType.EQUALS_TO, "m'jello");
View Full Code Here

  public void testSubQueryJoinToString() throws Exception {
    Table projectTable = _schema.getTableByName(TABLE_PROJECT);
    Table roleTable = _schema.getTableByName(TABLE_ROLE);

    Column projectIdColumn = projectTable
        .getColumnByName(COLUMN_PROJECT_PROJECT_ID);

    FromItem leftSide = new FromItem(projectTable);
    leftSide.setAlias("a");
    SelectItem[] leftOn = new SelectItem[] { new SelectItem(projectIdColumn) };
View Full Code Here

public class SelectClauseTest extends TestCase {

  public void testDistinctAddition() throws Exception {
    Table table = new MutableTable("foo");
    Column col = new MutableColumn("bar").setTable(table);

    Query q = new Query();
    q.selectDistinct();
    q.from(table);
    q.select(col);
View Full Code Here

            fail("Exception should have been thrown");
        } catch (Exception e) {
            assertEquals("Expression-based filters cannot be manually evaluated", e.getMessage());
        }

        Column col1 = new MutableColumn("Col1", ColumnType.VARCHAR);
        assertEquals("SELECT Col1 WHERE foobar", new Query().select(col1).where(filterItem).toString());

        assertEquals("SELECT Col1 WHERE YEAR(Col1) = 2008", new Query().select(col1).where("YEAR(Col1) = 2008")
                .toString());
    }
View Full Code Here

        assertEquals("Col1 = 423426235423.42", c.toString());

        c = new FilterItem(selectItem, OperatorType.EQUALS_TO, true);
        assertEquals("Col1 = 1", c.toString());

        Column timeColumn = new MutableColumn("TimeCol", ColumnType.TIME);
        selectItem = new SelectItem(timeColumn);
        c = new FilterItem(selectItem, OperatorType.GREATER_THAN, "02:30:05.000");
        assertEquals("TimeCol > TIME '02:30:05'", c.toString());

        Column dateColumn = new MutableColumn("DateCol", ColumnType.DATE);
        c = new FilterItem(new SelectItem(dateColumn), OperatorType.GREATER_THAN, "2000-12-31");
        assertEquals("DateCol > DATE '2000-12-31'", c.toString());
    }
View Full Code Here

        c = new FilterItem(new SelectItem(dateColumn), OperatorType.GREATER_THAN, "2000-12-31");
        assertEquals("DateCol > DATE '2000-12-31'", c.toString());
    }

    public void testToStringTimeStamp() throws Exception {
        Column timestampColumn = new MutableColumn("TimestampCol", ColumnType.TIMESTAMP);
        FilterItem c = new FilterItem(new SelectItem(timestampColumn), OperatorType.LESS_THAN,
                "2000-12-31 02:30:05.007");
        assertEquals("TimestampCol < TIMESTAMP '2000-12-31 02:30:05'", c.toString());

        c = new FilterItem(new SelectItem(timestampColumn), OperatorType.LESS_THAN, "2000-12-31 02:30:05");
        assertEquals("TimestampCol < TIMESTAMP '2000-12-31 02:30:05'", c.toString());

        Column dateColumn = new MutableColumn("DateCol", ColumnType.DATE);
        c = new FilterItem(new SelectItem(timestampColumn), OperatorType.GREATER_THAN, new SelectItem(dateColumn));
        assertEquals("TimestampCol > DateCol", c.toString());
    }
View Full Code Here

        c = new FilterItem(new SelectItem(timestampColumn), OperatorType.GREATER_THAN, new SelectItem(dateColumn));
        assertEquals("TimestampCol > DateCol", c.toString());
    }

    public void testEvaluateStrings() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.VARCHAR);
        Column col2 = new MutableColumn("Col2", ColumnType.VARCHAR);
        SelectItem s1 = new SelectItem(col1);
        SelectItem s2 = new SelectItem(col2);
        SelectItem[] selectItems = new SelectItem[] { s1, s2 };
        SimpleDataSetHeader header = new SimpleDataSetHeader(selectItems);
        Row row;
View Full Code Here

        row = new DefaultRow(header, new Object[] { "foobbdbafsdfr", "fo%b%r" });
        assertTrue(c.evaluate(row));
    }

    public void testEvaluateNull() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.INTEGER);
        Column col2 = new MutableColumn("Col2", ColumnType.DECIMAL);
        SelectItem s1 = new SelectItem(col1);
        SelectItem s2 = new SelectItem(col2);
        SelectItem[] selectItems = new SelectItem[] { s1, s2 };
        CachingDataSetHeader header = new CachingDataSetHeader(selectItems);
View Full Code Here

TOP

Related Classes of org.apache.metamodel.schema.Column

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.