Package org.apache.metamodel

Examples of org.apache.metamodel.UpdateScript


        file.delete();
        assertFalse(file.exists());

        final CsvDataContext dc = new CsvDataContext(file, new CsvConfiguration(
                CsvConfiguration.DEFAULT_COLUMN_NAME_LINE, "UTF8", '|', '?', '!'));
        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback cb) {
                Table table = cb.createTable(dc.getDefaultSchema(), "table").withColumn("id").withColumn("name")
                        .execute();
                cb.insertInto(table).value("id", 1).value("name", "Kasper").execute();
View Full Code Here


    public void testCannotWriteToReadOnly() throws Exception {
        final CsvDataContext dc = new CsvDataContext(new FileInputStream("src/test/resources/empty_file.csv"),
                new CsvConfiguration());
        try {
            dc.executeUpdate(new UpdateScript() {
                @Override
                public void run(UpdateCallback cb) {
                    cb.createTable(dc.getDefaultSchema(), "foo");
                }
            });
View Full Code Here

        _sourceTableName = sourceTableName;
    }

    public void copy() {
        final MongoDbDataContext targetDataContext = new MongoDbDataContext(_mongoDb);
        targetDataContext.executeUpdate(new UpdateScript() {

            @Override
            public void run(UpdateCallback callback) {
                final Table sourceTable = getSourceTable();
                final Table targetTable = callback.createTable(targetDataContext.getDefaultSchema(), _collectionName)
View Full Code Here

        final File tempFile = FileHelper.createTempFile("metamodel_deletion", "csv");

        final CsvConfiguration configuration = _updateCallback.getConfiguration();

        final CsvDataContext copyDataContext = new CsvDataContext(tempFile, configuration);
        copyDataContext.executeUpdate(new UpdateScript() {

            @Override
            public void run(UpdateCallback callback) {
                final Table originalTable = getTable();
                final Table copyTable = callback.createTable(copyDataContext.getDefaultSchema(), originalTable.getName())
View Full Code Here

                && _rowDeletionInterceptors.isEmpty()) {
            delegate.executeUpdate(update);
            return;
        }

        UpdateScript interceptableUpdateScript = new InterceptableUpdateScript(this, update,
                _tableCreationInterceptors, _tableDropInterceptors, _rowInsertionInterceptors,
                _rowUpdationInterceptors, _rowDeletionInterceptors);
        delegate.executeUpdate(interceptableUpdateScript);
    }
View Full Code Here

                + "Column[name=baz,columnNumber=3,type=INTEGER,nullable=null,nativeType=null,columnSize=null], "
                + "Column[name=foo,columnNumber=4,type=VARCHAR,nullable=null,nativeType=null,columnSize=null]]",
                Arrays.toString(table.getColumns()));

        // first delete the manually created database!
        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                callback.dropTable(databaseName).execute();
            }
        });

        table = dc.getDefaultSchema().getTableByName(databaseName);
        assertNull(table);

        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                Table table = callback.createTable(dc.getDefaultSchema(), databaseName).withColumn("foo")
                        .ofType(ColumnType.VARCHAR).withColumn("greeting").ofType(ColumnType.VARCHAR).execute();
                assertEquals("[_id, _rev, foo, greeting]", Arrays.toString(table.getColumnNames()));
            }
        });

        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                callback.insertInto(databaseName).value("foo", "bar").value("greeting", "hello").execute();
                callback.insertInto(databaseName).value("foo", "baz").value("greeting", "hi").execute();
            }
        });

        DataSet ds = dc.query().from(databaseName).select("_id", "foo", "greeting").execute();
        assertTrue(ds.next());
        assertNotNull(ds.getRow().getValue(0));
        assertEquals("bar", ds.getRow().getValue(1));
        assertEquals("hello", ds.getRow().getValue(2));
        assertTrue(ds.next());
        assertNotNull(ds.getRow().getValue(0));
        assertEquals("baz", ds.getRow().getValue(1));
        assertEquals("hi", ds.getRow().getValue(2));
        assertFalse(ds.next());
        ds.close();

        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                callback.update(databaseName).value("greeting", "howdy").where("foo").isEquals("baz").execute();

                callback.update(databaseName).value("foo", "foo").where("foo").isEquals("bar").execute();
View Full Code Here

        assertTrue(ds.next());
        assertEquals(0, ((Number) ds.getRow().getValue(0)).intValue());
        assertFalse(ds.next());
        ds.close();

        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                callback.insertInto(getDatabaseName()).value("name", "foo").value("gender", 'M').execute();
                callback.insertInto(getDatabaseName()).value("name", "bar").value("age", 32).execute();
            }
View Full Code Here

    public void testCreateLikeExistingStructure() throws Exception {
        dc.createTable(schema, "foo").like(table).withColumn("bar").like(col).nullable(false).execute();
    }

    public void testCreateTableClass() throws Exception {
        UpdateScript ct = new CreateTable(schema, "table").withColumn("foo").ofType(ColumnType.VARCHAR)
                .withColumn("bar").withColumn("baz");
        assertNotNull(ct);
    }
View Full Code Here

      public RowInsertionBuilder intercept(RowInsertionBuilder input) {
        return input.value("foobar", "elite!");
      }
    });

    dc.executeUpdate(new UpdateScript() {
      @Override
      public void run(UpdateCallback callback) {
        Table table = callback
            .createTable(dc.getDefaultSchema(), "table")
            .withColumn("col1").withColumn("col2").execute();
View Full Code Here

        assertTrue(file.exists());

        ExcelDataContext dc = new ExcelDataContext(file);
        final Table table = dc.getDefaultSchema().getTables()[0];
        final Column nameColumn = table.getColumnByName("name");
        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback cb) {
                Style clownStyle = new StyleBuilder().bold().foreground(255, 0, 0).background(0, 0, 255).create();

                Style thirtyStyle = new StyleBuilder().italic().underline().centerAligned().foreground(10, 10, 200)
View Full Code Here

TOP

Related Classes of org.apache.metamodel.UpdateScript

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.