use of org.openrdf.model.Value in project vcell by virtualcell.
the class VCMetaDataMiriamManager method getDublinCoreDateMap.
// this is not yet cached.
public Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> getDublinCoreDateMap() {
Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> map = new HashMap<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>>();
Set<Entry> allEntries = vcMetaData.getRegistry().getAllEntries();
Graph rdfData = vcMetaData.getRdfData();
for (Entry entry : allEntries) {
Resource resource = entry.getResource();
if (resource != null) {
Identifiable identifiable = entry.getIdentifiable();
Map<DateQualifier, Set<DublinCoreDate>> qualifierDateMap = new HashMap<DateQualifier, Set<DublinCoreDate>>();
for (DublinCoreQualifier.DateQualifier dateQualifier : AnnotationQualifiers.DC_date_all) {
Set<DublinCoreDate> dateStrings = new HashSet<DublinCoreDate>();
Iterator<Statement> stmtIter = rdfData.match(resource, dateQualifier.getProperty(), null);
while (stmtIter.hasNext()) {
Statement statement = stmtIter.next();
Value dateObject = statement.getObject();
if (dateObject instanceof Literal) {
Literal dateLiteral = (Literal) dateObject;
String dateString = dateLiteral.stringValue();
dateStrings.add(new DublinCoreDate(dateString));
}
}
if (!dateStrings.isEmpty()) {
qualifierDateMap.put(dateQualifier, dateStrings);
}
}
if (!qualifierDateMap.isEmpty()) {
map.put(identifiable, qualifierDateMap);
}
}
}
return map;
}
use of org.openrdf.model.Value in project vcell by virtualcell.
the class IndexedGraph method match.
public Iterator<Statement> match(Resource subject, URI predicate, Value object, Resource... contexts) {
Iterator<Statement> iterator = new RDFGraphMatchIterator(this, subject, predicate, object);
if (subject != null) {
if (predicate != null) {
if (object != null) {
Statement statement = getValueFactory().createStatement(subject, predicate, object);
if (statements.contains(statement)) {
iterator = new IndexedGraphIterator(this, new IterOfOne<Statement>(statement));
} else {
iterator = new IterOfNone<Statement>();
}
} else {
Set<Statement> matches = spMap.get(new ListOfTwo<Value>(subject, predicate));
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
}
} else {
if (object != null) {
Set<Statement> matches = soMap.get(new ListOfTwo<Value>(subject, object));
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
} else {
Set<Statement> matches = sMap.get(subject);
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
}
}
} else {
if (predicate != null) {
if (object != null) {
Set<Statement> matches = poMap.get(new ListOfTwo<Value>(predicate, object));
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
} else {
Set<Statement> matches = pMap.get(predicate);
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
}
} else {
if (object != null) {
Set<Statement> matches = oMap.get(object);
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
} else {
iterator = new IndexedGraphIterator(this, statements.iterator());
}
}
}
return iterator;
}
use of org.openrdf.model.Value in project vcell by virtualcell.
the class OntologyInfo method writeHasObjectProperty.
public static void writeHasObjectProperty(Graph graph, PrintStream out, Resource resource, URI property, String intro) {
Iterator<Statement> iter = graph.match(resource, property, null);
Set<Resource> resources = new HashSet<Resource>();
while (iter.hasNext()) {
Value superClassNode = iter.next().getObject();
if (superClassNode instanceof Resource) {
resources.add((Resource) superClassNode);
}
}
if (resources.size() > 0) {
out.println(" " + intro + ": " + resourcesToString(resources));
}
}
use of org.openrdf.model.Value in project vcell by virtualcell.
the class OntologyInfo method writeComments.
public static void writeComments(Graph graph, PrintStream out, Resource resource) {
Iterator<Statement> iter = graph.match(resource, RDFS.COMMENT, null);
while (iter.hasNext()) {
Value commentNode = iter.next().getObject();
if (commentNode instanceof Literal) {
Literal commentLiteral = (Literal) commentNode;
String comment = commentLiteral.stringValue();
if (comment != null && comment != "") {
out.println(" Comment: " + comment);
}
}
}
}
use of org.openrdf.model.Value in project vcell by virtualcell.
the class OntologyInfo method writeSuperClasses.
public static void writeSuperClasses(Graph graph, PrintStream out, Resource resource) {
Iterator<Statement> iter = graph.match(resource, RDFS.SUBCLASSOF, null);
Set<Resource> resources = new HashSet<Resource>();
while (iter.hasNext()) {
Value superClassNode = iter.next().getObject();
if (superClassNode instanceof Resource) {
resources.add((Resource) superClassNode);
}
}
if (resources.size() > 0) {
out.println(" Is sub class of: " + resourcesToString(resources));
}
}
Aggregations