@Override public final T asPrimaryKey() { _column.setPrimaryKey(true); return getReturnObject(); }
@Override public final T asPrimaryKey() { _column.setPrimaryKey(true); return getReturnObject(); }
private void addTable(final MutableSchema theSchema, final SimpleTableDef tableDef) { final MutableTable table = tableDef.toTable().setSchema(theSchema); final Column idColumn = table.getColumnByName(ElasticSearchUtils.FIELD_ID); if (idColumn != null && idColumn instanceof MutableColumn) { final MutableColumn mutableColumn = (MutableColumn) idColumn; mutableColumn.setPrimaryKey(true); } theSchema.addTable(table); }
public static Map<String, ?> getMappingSource(final MutableTable table) { if (table.getColumnByName(FIELD_ID) == null) { final MutableColumn idColumn = new MutableColumn(FIELD_ID, ColumnType.STRING).setTable(table).setPrimaryKey( true); table.addColumn(0, idColumn); } final Map<String, Map<String, String>> propertiesMap = new LinkedHashMap<>(); for (Column column : table.getColumns()) { final String columnName = column.getName(); if (FIELD_ID.equals(columnName)) { // do nothing - the ID is a client-side construct continue; } final String fieldName = getValidatedFieldName(columnName); final Map<String, String> propertyMap = new HashMap<>(); final String type = getType(column); propertyMap.put("type", type); propertiesMap.put(fieldName, propertyMap); } HashMap<String, Map<String, Map<String, String>>> docTypeMap = new HashMap<>(); docTypeMap.put("properties", propertiesMap); final Map<String, Map<String, Map<String, Map<String, String>>>> mapping = new HashMap<>(); mapping.put(table.getName(), docTypeMap); return mapping; }
public static Map<String, ?> getMappingSource(final MutableTable table) { if (table.getColumnByName(FIELD_ID) == null) { final MutableColumn idColumn = new MutableColumn(FIELD_ID, ColumnType.STRING).setTable(table).setPrimaryKey( true); table.addColumn(0, idColumn); } final Map<String, Map<String, String>> propertiesMap = new LinkedHashMap<>(); for (Column column : table.getColumns()) { final String columnName = column.getName(); if (FIELD_ID.equals(columnName)) { // do nothing - the ID is a client-side construct continue; } final String fieldName = getValidatedFieldName(columnName); final Map<String, String> propertyMap = new HashMap<>(); final String type = getType(column); propertyMap.put("type", type); propertiesMap.put(fieldName, propertyMap); } HashMap<String, Map<String, Map<String, String>>> docTypeMap = new HashMap<>(); docTypeMap.put("properties", propertiesMap); final Map<String, Map<String, Map<String, Map<String, String>>>> mapping = new HashMap<>(); mapping.put(table.getName(), docTypeMap); return mapping; }
private void loadPrimaryKeys(JdbcTable table, DatabaseMetaData metaData) throws MetaModelException { Schema schema = table.getSchema(); try (ResultSet rs = metaData.getPrimaryKeys(getCatalogName(schema), getJdbcSchemaName(schema), 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); } } } } catch (SQLException e) { throw JdbcUtils.wrapException(e, "retrieve primary keys for " + table.getName(), JdbcActionType.METADATA); } }
private void loadPrimaryKeys(JdbcTable table, DatabaseMetaData metaData) throws MetaModelException { Schema schema = table.getSchema(); try (ResultSet rs = metaData.getPrimaryKeys(getCatalogName(schema), getJdbcSchemaName(schema), 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); } } } } catch (SQLException e) { throw JdbcUtils.wrapException(e, "retrieve primary keys for " + table.getName(), JdbcActionType.METADATA); } }
private void addTable(final MutableSchema theSchema, final SimpleTableDef tableDef) { final MutableTable table = tableDef.toTable().setSchema(theSchema); final Column idColumn = table.getColumnByName(ElasticSearchUtils.FIELD_ID); if (idColumn != null && idColumn instanceof MutableColumn) { final MutableColumn mutableColumn = (MutableColumn) idColumn; mutableColumn.setPrimaryKey(true); } theSchema.addTable(table); }
private void addColumnFromKeySchema(String indexName, List<KeySchemaElement> keySchema, MutableTable table, boolean primaryKey) { for (final KeySchemaElement keySchemaElement : keySchema) { final String attributeName = keySchemaElement.getAttributeName(); if (table.getColumnByName(attributeName) == null) { final String keyType = keySchemaElement.getKeyType(); final MutableColumn column = new MutableColumn(attributeName, table).setPrimaryKey(primaryKey); appendRemarks(column, indexName + " member ('" + keyType + "' type)"); table.addColumn(column); } } }
public Column toColumn() { final String name = _nameTextField.getText(); final ColumnType columnType = _columnTypeComboBox.getSelectedItem(); final Integer size = getColumnSize(); final boolean primaryKey = _primaryKeyCheckBox.isSelected(); return new MutableColumn(name, columnType).setColumnSize(size).setPrimaryKey(primaryKey).setNullable(_notNull); }
@Override protected Schema getMainSchema() throws MetaModelException { if (_schema == null) { MutableSchema schema = new MutableSchema(getMainSchemaName()); for (SimpleTableDef tableDef : _tableDefs) { MutableTable table = tableDef.toTable().setSchema(schema); for (Column column : table.getColumnsOfType(ColumnType.ROWID)) { if (column instanceof MutableColumn) { ((MutableColumn) column).setPrimaryKey(true); } } schema.addTable(table); } _schema = schema; } return _schema; }
@Override protected Schema getMainSchema() throws MetaModelException { if (_schema == null) { MutableSchema schema = new MutableSchema(getMainSchemaName()); for (SimpleTableDef tableDef : _tableDefs) { MutableTable table = tableDef.toTable().setSchema(schema); for (Column column : table.getColumnsOfType(ColumnType.ROWID)) { if (column instanceof MutableColumn) { ((MutableColumn) column).setPrimaryKey(true); } } schema.addTable(table); } _schema = schema; } return _schema; }
@Override protected Schema getMainSchema() throws MetaModelException { if (_schema == null) { MutableSchema schema = new MutableSchema(getMainSchemaName()); for (SimpleTableDef tableDef : _tableDefs) { MutableTable table = tableDef.toTable().setSchema(schema); List<Column> rowIdColumns = table.getColumnsOfType(ColumnType.ROWID); for (Column column : rowIdColumns) { if (column instanceof MutableColumn) { ((MutableColumn) column).setPrimaryKey(true); } } schema.addTable(table); } _schema = schema; } return _schema; }
@Override protected Schema getMainSchema() throws MetaModelException { final MutableSchema schema = new MutableSchema(getMainSchemaName()); final Collection<String> topics = topicSupplier.get(); for (String topic : topics) { final MutableTable table = new MutableTable(topic, schema); table.addColumn(new MutableColumn(COLUMN_PARTITION, ColumnType.INTEGER, table).setPrimaryKey(true)); table.addColumn(new MutableColumn(COLUMN_OFFSET, ColumnType.BIGINT, table).setPrimaryKey(true)); table.addColumn(new MutableColumn(COLUMN_TIMESTAMP, ColumnType.TIMESTAMP, table)); table.addColumn(new MutableColumn(COLUMN_KEY, ColumnTypeImpl.convertColumnType(keyClass), table)); table.addColumn(new MutableColumn(COLUMN_VALUE, ColumnTypeImpl.convertColumnType(valueClass), table)); schema.addTable(table); } return schema; }
@Override protected Schema getMainSchema() throws MetaModelException { if (_schema == null) { MutableSchema schema = new MutableSchema(getMainSchemaName()); for (SimpleTableDef tableDef : _tableDefs) { MutableTable table = tableDef.toTable().setSchema(schema); List<Column> rowIdColumns = table.getColumnsOfType(ColumnType.ROWID); for (Column column : rowIdColumns) { if (column instanceof MutableColumn) { ((MutableColumn) column).setPrimaryKey(true); } } schema.addTable(table); } _schema = schema; } return _schema; }
@Override protected Schema getMainSchema() throws MetaModelException { final MutableSchema schema = new MutableSchema(getMainSchemaName()); final Collection<String> topics = topicSupplier.get(); for (String topic : topics) { final MutableTable table = new MutableTable(topic, schema); table.addColumn(new MutableColumn(COLUMN_PARTITION, ColumnType.INTEGER, table).setPrimaryKey(true)); table.addColumn(new MutableColumn(COLUMN_OFFSET, ColumnType.BIGINT, table).setPrimaryKey(true)); table.addColumn(new MutableColumn(COLUMN_TIMESTAMP, ColumnType.TIMESTAMP, table)); table.addColumn(new MutableColumn(COLUMN_KEY, ColumnTypeImpl.convertColumnType(keyClass), table)); table.addColumn(new MutableColumn(COLUMN_VALUE, ColumnTypeImpl.convertColumnType(valueClass), table)); schema.addTable(table); } return schema; }
@Override public final T like(Column column) { _column.setColumnSize(column.getColumnSize()); _column.setNativeType(column.getNativeType()); _column.setType(column.getType()); _column.setNullable(column.isNullable()); _column.setPrimaryKey(column.isPrimaryKey()); return getReturnObject(); }
@Override public final T like(Column column) { _column.setColumnSize(column.getColumnSize()); _column.setNativeType(column.getNativeType()); _column.setType(column.getType()); _column.setNullable(column.isNullable()); _column.setPrimaryKey(column.isPrimaryKey()); return getReturnObject(); }
@Override protected Schema getMainSchema() throws MetaModelException { final MutableSchema theSchema = new MutableSchema(getMainSchemaName()); for (final SimpleTableDef tableDef : tableDefs) { final MutableTable table = tableDef.toTable().setSchema(theSchema); final TableMetadata cassandraTable = cassandraCluster.getMetadata().getKeyspace(keySpaceName).getTable(table .getName()); if (cassandraTable != null) { final List<ColumnMetadata> primaryKeys = cassandraTable.getPrimaryKey(); for (ColumnMetadata primaryKey : primaryKeys) { final MutableColumn column = (MutableColumn) table.getColumnByName(primaryKey.getName()); if (column != null) { column.setPrimaryKey(true); } column.setNativeType(primaryKey.getType().getName().name()); } } theSchema.addTable(table); } return theSchema; }
@Override protected Schema getMainSchema() throws MetaModelException { final MutableSchema theSchema = new MutableSchema(getMainSchemaName()); for (final SimpleTableDef tableDef : tableDefs) { final MutableTable table = tableDef.toTable().setSchema(theSchema); final TableMetadata cassandraTable = cassandraCluster.getMetadata().getKeyspace(keySpaceName).getTable(table .getName()); if (cassandraTable != null) { final List<ColumnMetadata> primaryKeys = cassandraTable.getPrimaryKey(); for (ColumnMetadata primaryKey : primaryKeys) { final MutableColumn column = (MutableColumn) table.getColumnByName(primaryKey.getName()); if (column != null) { column.setPrimaryKey(true); } column.setNativeType(primaryKey.getType().getName().name()); } } theSchema.addTable(table); } return theSchema; }