/** * Returns true if a problem has occurred so far. * * May evolve until the materialization completes. * */ default boolean hasEncounteredProblemsSoFar() { return !getPossiblyIncompleteRDFPropertiesAndClassesSoFar().isEmpty(); }
@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(); }
while(graphResultSet.hasNext()) setAxioms.add(graphResultSet.next()); count = graphResultSet.getTripleCountSoFar(); vocab = graphResultSet.getSelectedVocabulary().size();
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++) { OWLPropertyAssertionObject constant = bindingSet.getOWLPropertyAssertionObject(j + 1); if (constant != null) { crow[j] = constant.toString();
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; }
public void run() { try { Set<OWLAxiom> setAxioms = Sets.newHashSet(); while(graphResultSet.hasNext()) { setAxioms.add(graphResultSet.next()); } graphResultSet.close(); ontologyManager.addAxioms(currentOntology, setAxioms); latch.countDown(); if (!bCancel) { JOptionPane.showMessageDialog(cont, "Task is completed", "Done", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e) { latch.countDown(); log.error("Materialization of Abox failed", e); } catch (Error e) { latch.countDown(); log.error("Materialization of Abox failed", e); JOptionPane.showMessageDialog(null, "An error occurred. For more info, see the logs."); } } };
/** * Serializes the A-box corresponding to a predicate into one or multiple file. */ private void serializePredicate(OntopSQLOWLAPIConfiguration materializationConfig, IRI predicateIRI, PredicateType predicateType, String outputFile, String format, OWLOntology ontology, RDF rdfFactory) throws Exception { final long startTime = System.currentTimeMillis(); System.err.println("Starts writing triples into files."); int tripleCount = 0; int fileCount = 0; String outputDir = outputFile; String filePrefix = Paths.get(outputDir, predicateIRI.toString().replaceAll("[^a-zA-Z0-9]", "_") + predicateType.getCode() +"_" ).toString(); OntopOWLAPIMaterializer materializer = OntopOWLAPIMaterializer.defaultMaterializer(); MaterializationParams materializationParams = MaterializationParams.defaultBuilder() .enableDBResultsStreaming(doStreamResults) .build(); try (MaterializedGraphOWLResultSet graphResultSet = materializer.materialize(materializationConfig, ImmutableSet.of(rdfFactory.createIRI(predicateIRI.toString())), materializationParams)) { while (graphResultSet.hasNext()) { tripleCount += serializeTripleBatch(ontology, graphResultSet, filePrefix, predicateIRI.toString(), fileCount, format); fileCount++; } System.out.println("NR of TRIPLES: " + tripleCount); System.out.println("VOCABULARY SIZE (NR of QUERIES): " + graphResultSet.getSelectedVocabulary().size()); } final long endTime = System.currentTimeMillis(); final long time = endTime - startTime; System.out.println("Elapsed time to materialize: " + time + " {ms}"); }
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; }
/** * 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); } }
/** * 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(); }
@Override public void run() { Double time = execTime / 1000; String s = String.format("Execution time: %s sec - ", time); String answer; try { if(result.getValue()){ answer = "true"; lblExecutionInfo.setBackground(Color.GREEN); lblExecutionInfo.setOpaque(true); } else{ answer = "false"; lblExecutionInfo.setBackground(Color.RED); lblExecutionInfo.setOpaque(true); } lblExecutionInfo.setText(s+ title+ " "+ answer); } catch (OWLException e) { JOptionPane.showMessageDialog( QueryInterfacePanel.this, e); } }
materializerConfiguration, materializationParams)) { while (graphResults.hasNext()) manager.addAxiom(ontology, graphResults.next()); System.err.println("NR of TRIPLES: " + graphResults.getTripleCountSoFar()); System.err.println("VOCABULARY SIZE (NR of QUERIES): " + graphResults.getSelectedVocabulary().size());