Package org.apache.metamodel.schema

Examples of org.apache.metamodel.schema.Schema


        PreparedStatement statement = _updateCallback.getPreparedStatement(sql, false);
        try {
            _updateCallback.executePreparedStatement(statement, false);

            // remove the table reference from the schema
            final Schema schema = getTable().getSchema();
            if (schema instanceof JdbcSchema) {
                ((JdbcSchema) schema).refreshTables();
            }
        } catch (SQLException e) {
            throw JdbcUtils.wrapException(e, "execute drop table statement: " + sql);
View Full Code Here


    return super.getColumnsInternal();
  }

  @Override
  protected List<Relationship> getRelationshipsInternal() {
    Schema schema = getSchema();
    if (schema instanceof JdbcSchema) {
      ((JdbcSchema) schema).loadRelations();
    }
    return super.getRelationshipsInternal();
  }
View Full Code Here

            return;
        }

        SalesforceDataContext dc = new SalesforceDataContext("https://test.salesforce.com/services/Soap/u/28.0", getUsername(), getPassword(), getSecurityToken());

        Schema schema = dc.getDefaultSchema();
        assertNotNull(schema);
    }
View Full Code Here

            return;
        }

        SalesforceDataContext dc = new SalesforceDataContext(getUsername(), getPassword(), getSecurityToken());

        Schema schema = dc.getDefaultSchema();

        assertEquals("Salesforce", schema.getName());

        String[] tableNames = schema.getTableNames();

        System.out.println("All tables:\n" + Arrays.toString(tableNames));

        Table accountTable = schema.getTableByName("Account");
        assertNotNull(accountTable);

        String[] columnNames = accountTable.getColumnNames();
        System.out.println("Account table columns: " + Arrays.toString(columnNames));
View Full Code Here

  private String createSqlStatement(Table table) {
    final IQueryRewriter queryRewriter = getUpdateCallback().getDataContext().getQueryRewriter();
    final StringBuilder sb = new StringBuilder();
    sb.append("CREATE TABLE ");
    final Schema schema = getSchema();
    if (schema != null && schema.getName() != null) {
      sb.append(schema.getQualifiedLabel());
      sb.append(".");
    }
    sb.append(getUpdateCallback().quoteIfNescesary(table.getName()));
    sb.append(" (");
    final Column[] columns = table.getColumns();
View Full Code Here

        }
    }

    @Override
    protected Schema getMainSchema() throws MetaModelException {
        Schema schema = new SugarCrmSchema(getMainSchemaName(), _service, _sessionId);
        return schema;
    }
View Full Code Here

    }

    private DataContext getDataContext(Table table) {
        DataContext result = null;
        if (table != null) {
            Schema schema = table.getSchema();

            if (schema != null) {
                for (DataContext dc : _delegates) {
                    Schema dcSchema = dc.getSchemaByName(schema.getName());
                    if (dcSchema != null) {

                        // first round = try with schema identity match
                        if (dcSchema == schema) {
                            logger.debug("DataContext for '{}' resolved (using identity) to: '{}'", table, dcSchema);
                            result = dc;
                            break;
                        }
                    }
                }

                if (result == null) {
                    for (DataContext dc : _delegates) {
                        Schema dcSchema = dc.getSchemaByName(schema.getName());
                        if (dcSchema != null) {
                            // second round = try with schema equals method
                            if (dcSchema.equals(schema)) {
                                logger.debug("DataContext for '{}' resolved (using equals) to: '{}'", table, dcSchema);
                                result = dc;
                                break;
                            }
                        }
View Full Code Here

    }

    @Override
    public String getDefaultSchemaName() throws MetaModelException {
        for (DataContext dc : _delegates) {
            Schema schema = dc.getDefaultSchema();
            if (schema != null) {
                return schema.getName();
            }
        }
        return null;
    }
View Full Code Here

        if (compositeSchema != null) {
            return compositeSchema;
        }
        List<Schema> matchingSchemas = new ArrayList<Schema>();
        for (DataContext dc : _delegates) {
            Schema schema = dc.getSchemaByName(name);
            if (schema != null) {
                matchingSchemas.add(schema);
            }
        }
        if (matchingSchemas.size() == 1) {
View Full Code Here

    public void testDefaultSchema() throws Exception {
        if (!isConfigured()) {
            return;
        }
        JdbcDataContext dc = new JdbcDataContext(getConnection());
        Schema schema = dc.getDefaultSchema();
        assertEquals(getUsername().toUpperCase(), schema.getName());

        Table countryTable = schema.getTableByName("COUNTRY");
        assertNotNull(countryTable);

        DataSet ds = dc.query().from(countryTable).selectCount().execute();
        assertTrue(ds.next());
        assertEquals("Row[values=[1008]]", ds.getRow().toString());
View Full Code Here

TOP

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

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.