@Override public Index getPrimaryKeyIndex() { return wrapped.getPrimaryKeyIndex(); }
/** * Creates an indexed cursor for the primary key cursor of the given table. * @param table the table over which this cursor will traverse */ public static IndexCursor createPrimaryKeyCursor(Table table) throws IOException { return createCursor(table.getPrimaryKeyIndex()); }
/** * Convenience method for finding a specific row by the primary key of the * table. See {@link IndexCursor#findRowByEntry(Object...)} for details on * the entryValues. * * @param table the table to search * @param entryValues the column values for the table's primary key columns. * @return the matching row or {@code null} if a match could not be found. */ public static Row findRowByPrimaryKey(Table table, Object... entryValues) throws IOException { return findRowByEntry(table.getPrimaryKeyIndex(), entryValues); }
public BlobKey(Table _table, String _columnName, Row _row) { this.tableName = _table.getName(); this.columnName = _columnName; if (hasPrimaryKey(_table)) { List<? extends Index.Column> cl = _table.getPrimaryKeyIndex().getColumns(); HashMap<String, Object> keyMap = new HashMap<String, Object>(); for (Index.Column c : cl) { keyMap.put(c.getName(), _row.get(c.getName())); } this.key = keyMap; } }
public BlobAction(Table _table, Object[] newValues) throws SQLException { this.table = _table; if (!BlobKey.hasPrimaryKey(_table)) { return; } Index pk = _table.getPrimaryKeyIndex(); HashSet<String> hsKey = new HashSet<String>(); for (Index.Column icl : pk.getColumns()) { hsKey.add(icl.getName()); } HashSet<String> hsBlob = new HashSet<String>(); int i = 0; HashMap<String, Object> keyMap = new HashMap<String, Object>(); for (Column cl : _table.getColumns()) { if (cl.getType().equals(DataType.OLE) && newValues[i] != null) { containsBlob = true; hsBlob.add(cl.getName()); } if (hsKey.contains(cl.getName())) { keyMap.put(cl.getName(), newValues[i]); } ++i; } for (String cln : hsBlob) { keys.add(new BlobKey(keyMap, table.getName(), cln)); } }
@Override protected Schema getMainSchema() throws MetaModelException { MutableSchema schema = new MutableSchema(_file.getName()); Database db = getDatabase(); for (com.healthmarketscience.jackcess.Table mdbTable : db) { final MutableTable table = new MutableTable(mdbTable.getName(), TableType.TABLE, schema); try { int i = 0; for (com.healthmarketscience.jackcess.Column mdbColumn : mdbTable.getColumns()) { final ColumnType columnType = ColumnType.convertColumnType(mdbColumn.getSQLType()); final MutableColumn column = new MutableColumn(mdbColumn.getName(), columnType, table, i, null); column.setColumnSize((int) mdbColumn.getLength()); column.setNativeType(mdbColumn.getType().name()); table.addColumn(column); i++; } final Index primaryKeyIndex = mdbTable.getPrimaryKeyIndex(); final List<ColumnDescriptor> columnDescriptors = primaryKeyIndex.getColumns(); for (ColumnDescriptor columnDescriptor : columnDescriptors) { final String name = columnDescriptor.getColumn().getName(); final MutableColumn column = (MutableColumn) table.getColumnByName(name); column.setPrimaryKey(true); } schema.addTable(table); } catch (Exception e) { throw new MetaModelException(e); } } return schema; }