while(sIter.hasNext()) { String sColName = sIter.next(); String iColName = iIter.next().getName(); if((sColName != iColName) && ((sColName == null) || !sColName.equalsIgnoreCase(iColName))) {
boolean pk = idx.isPrimaryKey(); if (!uk && !pk && idx.getColumns().size() == 1) { Column cl = idx.getColumns().get(0).getColumn(); if (this.alreadyIndexed.contains(cl)) { return; Column cl = idx.getColumns().get(0).getColumn(); DataType dt = cl.getType(); if (dt.equals(DataType.COMPLEX_TYPE)) { if (cd.getColumn().getType().equals(DataType.COMPLEX_TYPE)) { return;
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)); } }
private static void updateSecondaryValues(Joiner joiner, Object[] oldFromRow, Object[] newFromRow) throws IOException { IndexCursor toCursor = joiner.getToCursor(); List<? extends Index.Column> fromCols = joiner.getColumns(); List<? extends Index.Column> toCols = joiner.getToIndex().getColumns(); Object[] toRow = new Object[joiner.getToTable().getColumnCount()]; for(Iterator<Row> iter = joiner.findRows(oldFromRow) .setColumnNames(Collections.<String>emptySet()) .iterator(); iter.hasNext(); ) { iter.next(); // create update row for "to" table Arrays.fill(toRow, Column.KEEP_VALUE); for(int i = 0; i < fromCols.size(); ++i) { Object val = fromCols.get(i).getColumn().getRowValue(newFromRow); toCols.get(i).getColumn().setRowValue(toRow, val); } toCursor.updateCurrentRow(toRow); } }
private static void nullSecondaryValues(Joiner joiner, Object[] oldFromRow) throws IOException { IndexCursor toCursor = joiner.getToCursor(); List<? extends Index.Column> fromCols = joiner.getColumns(); List<? extends Index.Column> toCols = joiner.getToIndex().getColumns(); Object[] toRow = new Object[joiner.getToTable().getColumnCount()]; for(Iterator<Row> iter = joiner.findRows(oldFromRow) .setColumnNames(Collections.<String>emptySet()) .iterator(); iter.hasNext(); ) { iter.next(); // create update row for "to" table Arrays.fill(toRow, Column.KEEP_VALUE); for(int i = 0; i < fromCols.size(); ++i) { toCols.get(i).getColumn().setRowValue(toRow, null); } toCursor.updateCurrentRow(toRow); } }
private boolean isPrimaryColumn(String tableName, com.healthmarketscience.jackcess.Column originalColumn) throws IOException { for (Index index : jackcessDatabase.getTable(tableName).getIndexes()) { if (index.isPrimaryKey()) { for (Index.Column indexColumn : index.getColumns()) { if (indexColumn.getName().equals(originalColumn.getName())) { return true; } } } } boolean hasPrimaryKey = false; for (Index index : jackcessDatabase.getTable(tableName).getIndexes()) { if (index.isPrimaryKey()) { hasPrimaryKey = true; } } return originalColumn.isAutoNumber() && !hasPrimaryKey; }
private static boolean anyUpdates(Joiner joiner,Object[] oldRow, Object[] newRow) { Table fromTable = joiner.getFromTable(); for(Index.Column iCol : joiner.getColumns()) { Column col = iCol.getColumn(); if(!MATCHER.matches(fromTable, col.getName(), col.getRowValue(oldRow), col.getRowValue(newRow))) { return true; } } return false; }
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; } }
/** * Fills in the _entryValues with the relevant info from the given "from" * table row. */ private void toEntryValues(Object[] fromRow) { for(int i = 0; i < _entryValues.length; ++i) { _entryValues[i] = _fromCols.get(i).getColumn().getRowValue(fromRow); } }
/** * Fills in the _entryValues with the relevant info from the given "from" * table row. */ private void toEntryValues(Map<String,?> fromRow) { for(int i = 0; i < _entryValues.length; ++i) { _entryValues[i] = _fromCols.get(i).getColumn().getRowValue(fromRow); } }
private String commaSeparated(List<? extends Index.Column> columns, boolean escape) throws SQLException { String comma = ""; StringBuffer sb = new StringBuffer(" ("); for (Index.Column cd : columns) { String cl = escape ? escapeIdentifier(cd.getColumn().getName()) : cd.getColumn().getName(); sb.append(comma).append(cl); comma = ","; } return sb.append(") ").toString(); }
private static boolean areNull(Joiner joiner, Object[] row) { for(Index.Column col : joiner.getColumns()) { if(col.getColumn().getRowValue(row) != null) { return false; } } return true; }