protected List<Row> getRowsToUpdate() { final DataContext dc = _updateCallback.getDataContext(); final Table table = getTable(); final List<FilterItem> whereItems = getWhereItems(); final DataSet dataSet = dc.query() .from(table) .select(table.getColumns()) .where(whereItems).execute(); final List<Row> rows = dataSet.toRows(); return rows; }
public static List<LicensedProject> getLicensedProjects() { final List<LicensedProject> result = new ArrayList<>(); final URL url = resourceManager.getUrl("licenses/dependency-licenses.csv"); if (url == null) { throw new IllegalStateException("Could not find dependencies file"); } try { final DataContext dc = DataContextFactory.createCsvDataContext(url.openStream(), ',', '"'); final Table table = dc.getDefaultSchema().getTable(0); final Column projectColumn = table.getColumnByName("Project"); final Column websiteColumn = table.getColumnByName("Website"); final Column licenseColumn = table.getColumnByName("License"); final Query q = dc.query().from(table).select(table.getColumns()).orderBy(projectColumn).asc().toQuery(); final DataSet ds = dc.executeQuery(q); while (ds.next()) { final LicensedProject licensedProject = new LicensedProject(); final Row row = ds.getRow(); final String licenseName = row.getValue(licenseColumn).toString(); licensedProject.name = row.getValue(projectColumn).toString(); licensedProject.websiteUrl = row.getValue(websiteColumn).toString(); licensedProject.license = getLicense(licenseName); result.add(licensedProject); } } catch (final IOException e) { throw new IllegalStateException("Error occurred while reading dependencies file", e); } return result; }
protected List<Row> getRowsToUpdate() { final DataContext dc = _updateCallback.getDataContext(); final Table table = getTable(); final List<FilterItem> whereItems = getWhereItems(); final DataSet dataSet = dc.query() .from(table) .select(table.getColumns()) .where(whereItems).execute(); final List<Row> rows = dataSet.toRows(); return rows; }
@Override public boolean containsValue(final String value) { final DataContext dataContext = _datastoreConnection.getDataContext(); final Column column = _dictionary.getColumn(_datastoreConnection); try (DataSet dataSet = dataContext.query().from(column.getTable()).select(column).where(column).eq(value) .maxRows(1).execute()) { if (dataSet.next()) { return true; } return false; } }
final DataSet dataSet = dc.query().from(table).select(table.getColumns()).where(getWhereItems()).execute(); try { while (dataSet.next()) {
@Override public void execute() throws MetaModelException { Table table = getTable(); List<FilterItem> whereItems = getWhereItems(); CouchDbConnector connector = _updateCallback.getConnector(table.getName()); CouchDbDataContext dataContext = _updateCallback.getDataContext(); DataSet dataSet = dataContext.query().from(table) .select(CouchDbDataContext.FIELD_ID, CouchDbDataContext.FIELD_REV).where(whereItems).execute(); try { while (dataSet.next()) { Row row = dataSet.getRow(); String id = (String) row.getValue(0); String revision = (String) row.getValue(1); connector.delete(id, revision); } } finally { dataSet.close(); } }