public static final RowMetaInterface getLayout( Table table ) throws SQLException, KettleStepException { RowMetaInterface row = new RowMeta(); List<Column> columns = table.getColumns(); for ( int i = 0; i < columns.size(); i++ ) { Column column = columns.get( i );
private Object[] getOneRow() throws KettleException { try { if ( meta.isFileField() ) { while ( ( data.readrow == null || ( ( data.rw = data.t.getNextRow() ) == null ) ) ) { if ( !openNextFile() ) { return null; while ( ( data.file == null || ( ( data.rw = data.t.getNextRow() ) == null ) ) ) { if ( !openNextFile() ) { return null; if ( meta.isIncludeTablename() && !Utils.isEmpty( data.t.getName() ) ) { r[rowIndex++] = data.t.getName();
void addRowToTable( Object... row ) throws IOException { table.addRow( row ); }
String tableName = table.getName(); List<? extends Column> columns = table.getColumns(); xhtml.startElement("table", "name", tableName); addHeaders(columns, xhtml); xhtml.startElement("tbody"); Row r = table.getNextRow(); r = table.getNextRow();
private void setDefaultValues(Table t) throws SQLException, IOException { String tn = t.getName(); String ntn = escapeIdentifier(tn); List<? extends Column> lc = t.getColumns(); List<String> arTrigger = new ArrayList<String>(); for (Column cl : lc) { setDefaultValue(cl, ntn, arTrigger); } for (String trigger : arTrigger) { exec(trigger, true); } }
public InsertCommand(Table _table, Object[] _newRow, String _execId) { this.table = _table; this.tableName = _table.getName(); this.newRow = _newRow; this.execId = _execId; }
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 void persist(Cursor cur) throws IOException, SQLException { Object[] mr = this.modifiedRow; if (table.getDatabase().getColumnOrder().equals(ColumnOrder.DISPLAY)) { Object[] newRowReorded = new Object[this.modifiedRow.length]; int j = 0; for (Column cli : table.getColumns()) { newRowReorded[cli.getColumnIndex()] = this.modifiedRow[j]; j++; } mr = newRowReorded; } cur.updateCurrentRow(mr); }
public void insertRow(Table _table, Object[] _row) throws IOException { try { _table.addRow(newRow); } catch (ConstraintViolationException e) { List<? extends Column> lc = _table.getColumns(); boolean retry = false; for (Column cl : lc) { if (cl.isAutoNumber()) { retry = true; break; } } if (!retry) { throw e; } Database db = _table.getDatabase(); File fl = db.getFile(); DBReferenceSingleton dbsin = DBReferenceSingleton.getInstance(); DBReference ref = dbsin.getReference(fl); ref.reloadDbIO(); this.dbIO = ref.getDbIO(); _table = this.dbIO.getTable(this.tableName); _table.addRow(newRow); } }
static int export(Database db, String tableName, Writer csv, boolean withHeader, boolean applyQuotesToAll, String nullText) throws IOException{ Table table = db.getTable(tableName); String[] buffer = new String[table.getColumnCount()]; CSVWriter writer = new CSVWriter(new BufferedWriter(csv), CSVWriter.DEFAULT_SEPARATOR, CSVWriter.DEFAULT_QUOTE_CHARACTER); int rows = 0; try{ if (withHeader) { int x = 0; for(Column col : table.getColumns()){ buffer[x++] = col.getName(); } writer.writeNext(buffer, applyQuotesToAll); } for(Row row : table){ int i = 0; for (Object object : row.values()) { buffer[i++] = object == null ? nullText : object.toString(); } writer.writeNext(buffer, applyQuotesToAll); rows++; } }finally{ writer.close(); } return rows; }
private boolean matchesLinkedTable(Table table, String linkedTableName, String linkedDbName) { return (table.getName().equalsIgnoreCase(linkedTableName) && (_linkedDbs != null) && (_linkedDbs.get(linkedDbName) == table.getDatabase())); }
try { int i = 0; Iterator<Row> it = t.iterator(); if (i != t.getRowCount() && step != 1) { Logger.logParametricWarning(Messages.ROW_COUNT, t.getName(), String.valueOf(t.getRowCount()), String.valueOf(i));
for (Column cli : t.getColumns()) { ColumnImpl cl = (ColumnImpl) cli; if (cli.getType().equals(DataType.COMPLEX_TYPE) && (newR[i] == null || "".equals(newR[i]))) { if (type == Trigger.INSERT_BEFORE_ROW) { if (t.isAllowAutoNumberInsert()) { if (cl.getAutoNumberGenerator().getType().equals(DataType.LONG) && newR[i] != null) { AutoNumberManager.bump(cl, (Integer) newR[i]);
Table RESOURCES = Database.open(new File("TargetFile.mdb")).getTable("RESOURCES"); int pcount = RESOURCES.getRowCount(); String csvFilename = "C:\\STATS\\APEX\\report.csv"; CSVReader csvReader = new CSVReader(new FileReader(csvFilename)); List<String[]> content = csvReader.readAll(); Map<ValueKey, Integer> csvValuesCount = new HashMap<ValueKey, Integer>(); for (String[] rowcsv : content) { ValueKey key = new ValueKey(rowcsv[6], rowcsv[1]); Integer count = csvValuesCount.get(key); csvValuesCount.put(key,count == null ? 1: count + 1); } int count = 0; // Taking 1st resource data for (int i = 0; i < pcount; i++) { Map<String, Object> row = RESOURCES.getNextRow(); TEAM = row.get("TEAM").toString(); MDMID = row.get("MDM ID").toString(); NAME = row.get("RESOURCE NAME").toString(); PGNAME = row.get("PG NAME").toString(); PGTARGET = row.get("PG TARGET").toString(); int PGTARGETI = Integer.parseInt(PGTARGET); Integer countInteger = csvValuesCount.get(new ValueKey(MDMID, PGNAME)); count = countInteger == null ? 0: countInteger; }
int numColumns = table.getColumnCount(); table.addRows(rows); rows.clear(); table.addRows(rows); return table.getName();
mt.dropTable(t.getName()); if (!HibernateSupport.isActive()) { Cursor c = t.getDefaultCursor(); while (c.getNextRow() != null) { c.deleteCurrentRow(); Table cat = dbi.getSystemCatalog(); Map<String, Object> row; Cursor catc = cat.getDefaultCursor(); while ((row = catc.getNextRow()) != null) { String name = (String) row.get("Name"); Map<String, Object> rowtsa = new HashMap<String, Object>(); rowtsa.put("ObjectId", id); Cursor cur = tsa.getDefaultCursor(); if (cur.findNextRow(rowtsa)) { cur.deleteCurrentRow(); Cursor srsc = srs.getDefaultCursor(); while ((row = srsc.getNextRow()) != null) { String szObject = (String) row.get("szObject");
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 long[] getSize() { size[ROW] = table.getRowCount(); size[COLUMN] = table.getColumnCount(); return size; }
@Override public int getValueCount() { try { return getTable().getRowCount(); } catch (KlabIOException e) { // shouldn't happen } return 0; }