Skip to content

Commit

Permalink
Added a method to get the objects of a particular predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Jul 2, 2012
1 parent a8df352 commit b90fc5d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Expand Up @@ -275,4 +275,12 @@ public void addPrefix(IRDFStore store, String prefix, String namespace)
)
public List<String> allOwlSameAs(IRDFStore store, String resourceURI)
throws IOException, BioclipseException, CoreException;

@Recorded
@PublishedMethod(
params = "IRDFStore store, String resourceURI, String predicate",
methodSummary = "Lists all resources or literals for the resource and predicate."
)
public List<String> getForPredicate(IRDFStore store, String resourceURI, String predicate)
throws IOException, BioclipseException, CoreException;
}
Expand Up @@ -492,6 +492,28 @@ public List<String> allPredicates(IRDFStore store) throws BioclipseException {
}
}

public List<String> getForPredicate(IRDFStore store, String resourceURI, String predicate) throws BioclipseException {
try {
StringMatrix results = sparql(store,
"SELECT DISTINCT ?object WHERE {" +
" <" + resourceURI + "> <" + predicate + "> ?object" +
"}"
);
if (results.getRowCount() == 0) return Collections.emptyList();
return results.getColumn("object");
} catch (IOException exception) {
throw new BioclipseException(
"Could not query to store: " + exception.getMessage(),
exception
);
} catch (CoreException exception) {
throw new BioclipseException(
"Could not query to store: " + exception.getMessage(),
exception
);
}
}

public List<String> allOwlSameAs(IRDFStore store, String resourceURI)
throws IOException, BioclipseException, CoreException {
Set<String> resources = new HashSet<String>();
Expand Down

0 comments on commit b90fc5d

Please sign in to comment.