Examples of MutableSchema


Examples of org.apache.metamodel.schema.MutableSchema

        _configuration = configuration;
    }

    @Override
    public Schema createSchema(InputStream inputStream, String schemaName) {
        final MutableSchema schema = new MutableSchema(schemaName);
        final Workbook wb = ExcelUtils.readWorkbook(inputStream);

        for (int i = 0; i < wb.getNumberOfSheets(); i++) {
            final Sheet currentSheet = wb.getSheetAt(i);
            final MutableTable table = createTable(wb, currentSheet);
            table.setSchema(schema);
            schema.addTable(table);
        }

        return schema;
    }
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

        return new AbstractTableCreationBuilder<PojoUpdateCallback>(this, schema, name) {

            @Override
            public Table execute() throws MetaModelException {
                MutableTable table = getTable();
                MutableSchema schema = (MutableSchema) getSchema();
                table.setSchema(schema);
                schema.addTable(table);
                _dataContext.addTableDataProvider(new MapTableDataProvider(new SimpleTableDef(table),
                        new ArrayList<Map<String, ?>>()));
                return table;
            }
        };
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

            UnsupportedOperationException {
        return new AbstractTableDropBuilder(table) {
            @Override
            public void execute() throws MetaModelException {
                MutableTable mutableTable = (MutableTable) getTable();
                MutableSchema schema = (MutableSchema) mutableTable.getSchema();
                schema.removeTable(mutableTable);
                mutableTable.setSchema(null);
            }
        };
    }
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

        return null;
    }

    private Schema getInformationSchema() {
        // Create schema
        MutableSchema informationSchema = new MutableSchema(INFORMATION_SCHEMA_NAME);
        MutableTable tablesTable = new MutableTable("tables", TableType.TABLE, informationSchema);
        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));
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

        return dataSet;
    }

    @Override
    protected Schema getMainSchema() throws MetaModelException {
        final MutableSchema schema = new MutableSchema(getMainSchemaName());

        for (TableDataProvider<?> pojoTable : _tables.values()) {
            final SimpleTableDef tableDef = pojoTable.getTableDef();
            final MutableTable table = tableDef.toTable();
            table.setSchema(schema);
            schema.addTable(table);
        }

        return schema;
    }
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

    }

    @Override
    protected Schema getMainSchema() throws MetaModelException {
        final String schemaName = getDefaultSchemaName();
        final MutableSchema schema = new MutableSchema(schemaName);
        final String tableName = _resource.getName();
        final MutableTable table = new MutableTable(tableName, TableType.TABLE, schema);
        schema.addTable(table);

        final FixedWidthReader reader = createReader();
        final String[] columnNames;
        try {
            if (_configuration.getColumnNameLineNumber() != FixedWidthConfiguration.NO_COLUMN_NAME_LINE) {
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

                final int columnNumber = column.getColumnNumber();
                row.createCell(columnNumber).setCellValue(column.getName());
            }
        }

        final MutableSchema schema = (MutableSchema) table.getSchema();
        schema.addTable((MutableTable) table);
        return table;
    }
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

        };
    }

    @Override
    protected Schema getMainSchema() throws MetaModelException {
        final MutableSchema schema = new MutableSchema(getMainSchemaName());

        for (XmlSaxTableDef tableDef : _tableDefs) {
            final String rowXpath = tableDef.getRowXpath();
            final MutableTable table = new MutableTable(getTableName(tableDef)).setSchema(schema).setRemarks(
                    "XPath: " + rowXpath);

            final MutableColumn rowIndexColumn = new MutableColumn(COLUMN_NAME_ROW_ID, ColumnType.INTEGER)
                    .setColumnNumber(0).setNullable(false).setTable(table).setRemarks("Row/tag index (0-based)");
            table.addColumn(rowIndexColumn);

            for (String valueXpath : tableDef.getValueXpaths()) {
                final MutableColumn column = new MutableColumn(getName(tableDef, valueXpath)).setRemarks("XPath: "
                        + valueXpath);
                if (valueXpath.startsWith("index(") && valueXpath.endsWith(")")) {
                    column.setType(ColumnType.INTEGER);
                } else {
                    column.setType(ColumnType.STRING);
                }
                column.setTable(table);
                table.addColumn(column);
            }
            schema.addTable(table);
        }

        return new ImmutableSchema(schema);
    }
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

        return _admin;
    }

    @Override
    protected Schema getMainSchema() throws MetaModelException {
        final MutableSchema schema = new MutableSchema(_configuration.getSchemaName());

        try {
            SimpleTableDef[] tableDefinitions = _configuration.getTableDefinitions();
            if (tableDefinitions == null) {
                final HTableDescriptor[] tables = _admin.listTables();
                tableDefinitions = new SimpleTableDef[tables.length];
                for (int i = 0; i < tables.length; i++) {
                    SimpleTableDef emptyTableDef = new SimpleTableDef(tables[i].getNameAsString(), new String[0]);
                    tableDefinitions[i] = emptyTableDef;
                }
            }

            for (SimpleTableDef tableDef : tableDefinitions) {
                schema.addTable(new HBaseTable(tableDef, schema, _admin, _configuration.getDefaultRowKeyType()));
            }

            return schema;
        } catch (Exception e) {
            throw new MetaModelException(e);
View Full Code Here

Examples of org.apache.metamodel.schema.MutableSchema

        return buildDataSet(columns, maxRows, relationshipId, xssfReader);
    }

    @Override
    public Schema createSchema(InputStream inputStream, String schemaName) throws Exception {
        final MutableSchema schema = new MutableSchema(schemaName);
        final OPCPackage pkg = OPCPackage.open(inputStream);
        final XSSFReader xssfReader = new XSSFReader(pkg);

        final XlsxWorkbookToTablesHandler workbookToTables = new XlsxWorkbookToTablesHandler(schema,
                _tableNamesToInternalIds);
        buildTables(xssfReader, workbookToTables);

        for (Entry<String, String> entry : _tableNamesToInternalIds.entrySet()) {

            final String tableName = entry.getKey();
            final String relationshipId = entry.getValue();

            final MutableTable table = (MutableTable) schema.getTableByName(tableName);

            buildColumns(table, relationshipId, xssfReader);
        }
        return schema;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.