Skip to content

Commit

Permalink
Added fallback for the cases where getLocalName() returns an empty st…
Browse files Browse the repository at this point in the history
…ring. Added initial dialog before reloading ontology.
  • Loading branch information
Vinícius committed Nov 12, 2019
1 parent 798d5da commit b90954f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>br.ime.usp.vbm</groupId>
<artifactId>sparqlguiwrapper</artifactId>
<version>0.1.4</version>
<version>0.1.5</version>
<name>SPARQL GUI Wrapper</name>
<dependencies>
<dependency>
Expand Down
23 changes: 20 additions & 3 deletions src/main/java/sparqlguiwrapper/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ private void showErrorDialog(String error) {
JOptionPane.showMessageDialog(this, error, "Error", JOptionPane.ERROR_MESSAGE);
}

private boolean showQuestionDialog(String question, String title) {
return JOptionPane.showConfirmDialog(this, question, title,
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
}

public static void main(String[] args) {

EventQueue.invokeLater(() -> {
Expand Down Expand Up @@ -377,9 +382,21 @@ private void readConfigFile() {
JsonReader parser = Json.createReader(new StringReader(cfg));
JsonObject o = parser.readObject();
String fn = o.getString("ontologyFileName", "");
if (fn.isEmpty())
fn = null;
setOntologyFileName(fn, true);
if (fn.isEmpty()) {
setOntologyFileName(null, true);
} else {
if (showQuestionDialog("Do you want to open the following ontology again?\n" + fn, "Reopen ontology?"))
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
setOntologyFileName(fn);
}
});

else
setOntologyFileName(null, true);
}
String lastQuery = o.getString("lastQuery", "");
qm.setLastQuery(lastQuery);
port = o.getInt("port", 8080);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/sparqlguiwrapper/QueryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public String runQuery(String queryString) throws FileNotFoundException {
Resource r = cell.asResource();
String localName = r.getLocalName();
String fullName = r.toString();
if (localName.isEmpty())
localName = fullName.substring(fullName.indexOf('#') + 1);
row.add(Json.createObjectBuilder().add("isLiteral", false).add("localName", localName)
.add("fullName", fullName));
}
Expand Down

0 comments on commit b90954f

Please sign in to comment.