Package org.apache.metamodel.schema

Examples of org.apache.metamodel.schema.MutableColumn


                rs = metaData.getPrimaryKeys(_dataContext.getCatalogName(), schema.getName(), table.getName());
            }
            while (rs.next()) {
                String columnName = rs.getString(4);
                if (columnName != null) {
                    MutableColumn column = (MutableColumn) table.getColumnByName(columnName);
                    if (column != null) {
                        column.setPrimaryKey(true);
                    } else {
                        logger.error("Indexed column \"{}\" could not be found in table: {}", columnName, table);
                    }
                }
            }
View Full Code Here


                        true);
            }
            while (rs.next()) {
                String columnName = rs.getString(9);
                if (columnName != null) {
                    MutableColumn column = (MutableColumn) table.getColumnByName(columnName);
                    if (column != null) {
                        column.setIndexed(true);
                    } else {
                        logger.error("Indexed column \"{}\" could not be found in table: {}", columnName, table);
                    }
                }
            }
View Full Code Here

            for (int i = 0; i < offset; i++) {
                sequence.next();
            }

            for (int j = offset; j < row.getLastCellNum(); j++) {
                Column column = new MutableColumn(sequence.next(), ColumnType.STRING, table, j, true);
                table.addColumn(column);
            }
        } else {

            boolean hasColumns = true;
View Full Code Here

            Cell cell = row.getCell(j);
            String columnName = ExcelUtils.getCellValue(wb, cell);
            if (columnName == null || "".equals(columnName)) {
                columnName = "[Column " + (j + 1) + "]";
            }
            Column column = new MutableColumn(columnName, ColumnType.VARCHAR, table, j, true);
            table.addColumn(column);
        }
    }
View Full Code Here

        MutableTable columnsTable = new MutableTable("columns", TableType.TABLE, informationSchema);
        MutableTable relationshipsTable = new MutableTable("relationships", TableType.TABLE, informationSchema);
        informationSchema.addTable(tablesTable).addTable(columnsTable).addTable(relationshipsTable);

        // Create "tables" table: name, type, num_columns, remarks
        tablesTable.addColumn(new MutableColumn("name", ColumnType.VARCHAR, tablesTable, 0, false));
        tablesTable.addColumn(new MutableColumn("type", ColumnType.VARCHAR, tablesTable, 1, true));
        tablesTable.addColumn(new MutableColumn("num_columns", ColumnType.INTEGER, tablesTable, 2, true));
        tablesTable.addColumn(new MutableColumn("remarks", ColumnType.VARCHAR, tablesTable, 3, true));

        // Create "columns" table: name, type, native_type, size, nullable,
        // indexed, table, remarks
        columnsTable.addColumn(new MutableColumn("name", ColumnType.VARCHAR, columnsTable, 0, false));
        columnsTable.addColumn(new MutableColumn("type", ColumnType.VARCHAR, columnsTable, 1, true));
        columnsTable.addColumn(new MutableColumn("native_type", ColumnType.VARCHAR, columnsTable, 2, true));
        columnsTable.addColumn(new MutableColumn("size", ColumnType.INTEGER, columnsTable, 3, true));
        columnsTable.addColumn(new MutableColumn("nullable", ColumnType.BOOLEAN, columnsTable, 4, true));
        columnsTable.addColumn(new MutableColumn("indexed", ColumnType.BOOLEAN, columnsTable, 5, true));
        columnsTable.addColumn(new MutableColumn("table", ColumnType.VARCHAR, columnsTable, 6, false));
        columnsTable.addColumn(new MutableColumn("remarks", ColumnType.VARCHAR, columnsTable, 7, true));

        // Create "relationships" table: primary_table, primary_column,
        // foreign_table, foreign_column
        relationshipsTable.addColumn(new MutableColumn("primary_table", ColumnType.VARCHAR, relationshipsTable, 0,
                false));
        relationshipsTable.addColumn(new MutableColumn("primary_column", ColumnType.VARCHAR, relationshipsTable, 1,
                false));
        relationshipsTable.addColumn(new MutableColumn("foreign_table", ColumnType.VARCHAR, relationshipsTable, 2,
                false));
        relationshipsTable.addColumn(new MutableColumn("foreign_column", ColumnType.VARCHAR, relationshipsTable, 3,
                false));

        MutableRelationship.createRelationship(tablesTable.getColumnByName("name"),
                columnsTable.getColumnByName("table"));
        MutableRelationship.createRelationship(tablesTable.getColumnByName("name"),
View Full Code Here

            if (columnNameLineNumber == CsvConfiguration.NO_COLUMN_NAME_LINE) {
                columnName = sequence.next();
            } else {
                columnName = columnNames[i];
            }
            Column column = new MutableColumn(columnName, ColumnType.STRING, this, i, null, null, nullable, null,
                    false, null);
            columns[i] = column;
        }
        return columns;
    }
View Full Code Here

            for (int i = 0; i < columnNames.length; i++) {
                String columnName = columnNames[i];
                if (HBaseDataContext.FIELD_ID.equals(columnName)) {
                    final ColumnType type = types[i];
                    final MutableColumn idColumn = new MutableColumn(HBaseDataContext.FIELD_ID, type)
                            .setPrimaryKey(true).setColumnNumber(columnNumber).setTable(this);
                    addColumn(idColumn);
                    columnNumber++;
                }
            }

            if (columnNumber == 1) {
                // insert a default definition of the id column
                final MutableColumn idColumn = new MutableColumn(HBaseDataContext.FIELD_ID,
                        defaultRowKeyColumnType).setPrimaryKey(true).setColumnNumber(columnNumber).setTable(this);
                addColumn(idColumn);
                columnNumber++;
            }

            for (int i = 0; i < columnNames.length; i++) {
                final String columnName = columnNames[i];

                if (!HBaseDataContext.FIELD_ID.equals(columnName)) {
                    final ColumnType type = types[i];
                    final MutableColumn column = new MutableColumn(columnName, type);
                    column.setTable(this);
                    column.setColumnNumber(columnNumber);
                    columnNumber++;
                    addColumn(column);
                }
            }
        }
View Full Code Here

        if (columnsInternal.isEmpty() && _admin != null) {
            try {
                HTableDescriptor tableDescriptor = _admin.getTableDescriptor(getName().getBytes());
                int columnNumber = 1;

                final MutableColumn idColumn = new MutableColumn(HBaseDataContext.FIELD_ID,
                        _defaultRowKeyColumnType).setPrimaryKey(true).setColumnNumber(columnNumber).setTable(this);
                addColumn(idColumn);
                columnNumber++;

                // What about timestamp?

                final HColumnDescriptor[] columnFamilies = tableDescriptor.getColumnFamilies();
                for (int i = 0; i < columnFamilies.length; i++) {
                    final HColumnDescriptor columnDescriptor = columnFamilies[i];
                    final String columnFamilyName = columnDescriptor.getNameAsString();
                    // HBase column families are always unstructured maps.
                    final ColumnType type = ColumnType.MAP;
                    final MutableColumn column = new MutableColumn(columnFamilyName, type);
                    column.setTable(this);
                    column.setColumnNumber(columnNumber);
                    columnNumber++;
                    addColumn(column);
                }
            } catch (Exception e) {
                throw new MetaModelException("Could not resolve table ", e);
View Full Code Here

        }

        if (columnNames != null) {
            for (int i = 0; i < columnNames.length; i++) {
                final String columnName = columnNames[i];
                final MutableColumn column = new MutableColumn(columnName, ColumnType.STRING, table, i, true);
                column.setColumnSize(_configuration.getValueWidth(i));
                table.addColumn(column);
            }
        }

        return schema;
View Full Code Here

        assertEquals(StringToBooleanConverter.class, converters.values().iterator().next().getClass());

        dc = Converters.addTypeConverters(dc, converters);

        Table table = dc.getDefaultSchema().getTables()[0];
        MutableColumn col = (MutableColumn) table.getColumns()[0];
        Query q = dc.query().from(table).select(col).toQuery();
        assertEquals("SELECT csv_only_number_one.csv.number FROM resources.csv_only_number_one.csv", q.toSql());

        DataSet ds = dc.executeQuery(q);
        while (ds.next()) {
View Full Code Here

TOP

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

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.