/** * Call this when done with the table model. It closes the ResultSet and the * Statement object used to create it. */ public void close() { stopFetching = true; if(rowFetcher != null) rowFetcher.interrupt(); try { results.close(); } catch (OWLException e) { // TODO: Handle this in a reasonable manner System.out.println(e); } }
@Override public String getColumnName(int column) { try { java.util.List<String> signature = results.getSignature(); if (signature != null && column < signature.size()) { return results.getSignature().get(column); } else { return ""; } } catch (Exception e) { e.printStackTrace(); return "ERROR"; } }
public static void printResult(OutputStream out, TupleOWLResultSet result) throws Exception { BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(out, "utf8")); /* * Printing the header */ int columns = result.getColumnCount(); for (int c = 0; c < columns; c++) { String value = result.getSignature().get(c); wr.append(value); if (c + 1 < columns) wr.append(","); } wr.newLine(); while (result.hasNext()) { final OWLBindingSet bindingSet = result.next(); for (int c = 0; c < columns; c++) { String value = ToStringRenderer.getInstance().getRendering(bindingSet.getOWLObject(c + 1)); wr.append(value); if (c + 1 < columns) wr.append(","); } wr.newLine(); } wr.flush(); result.close(); }
if (tabularData == null) { tabularData = new ArrayList<>(); String[] columnName = results.getSignature().toArray(new String[numcols]); while (!stopFetching && results.hasNext()) { final OWLBindingSet bindingSet = results.next(); String[] crow = new String[numcols]; for (int j = 0; j < numcols; j++) {
private void fetchRows(int size) throws OWLException, InterruptedException { if (results == null) { return; } for (int rows_fetched = 0; results.hasNext() && !stopFetching && (isFetchingAll() || rows_fetched < size); rows_fetched++) { String[] crow = new String[numcols]; final OWLBindingSet bindingSet = results.next(); for (int j = 0; j < numcols; j++) { if(stopFetching) break; OWLPropertyAssertionObject constant = bindingSet.getOWLPropertyAssertionObject(j + 1); if (constant != null) { crow[j] = ToStringRenderer.getInstance().getRendering(constant); } else { crow[j] = ""; } } if(!stopFetching){ SwingUtilities.invokeLater(new RowAdder(crow)); } } isFetching = false; }
private boolean nextEmptyEntity(IRI entity, int arity) { String query =getQuery(arity, entity); //execute next query try (OWLStatement stm = questConn.createStatement()){ try (TupleOWLResultSet rs = stm.executeSelectQuery(query)) { if (!rs.hasNext()) { nextConcept = entity; log.debug( "Empty " + entity ); hasNext = true; return true; } return false; } } catch (OWLException e) { e.printStackTrace(); } return false; }
/** * This constructor creates a TableModel from a ResultSet. It is package * private because it is only intended to be used by * ResultSetTableModelFactory, which is what you should use to obtain a * ResultSetTableModel */ public OWLResultSetTableModel(TupleOWLResultSet results, PrefixManager prefixman, boolean hideUri, boolean fetchAll, int fetchSizeLimit) throws OWLException { this.results = results; this.prefixman = prefixman; this.isHideUri = hideUri; this.isFetchAll = fetchAll; this.fetchSizeLimit = fetchSizeLimit; this.isFetching = true; this.stopFetching = false; numcols = results.getColumnCount(); numrows = 0; resultsTable = new ArrayList<>(); listeners = new ArrayList<>(); fetchRowsAsync(); }