use of org.apache.jena.sparql.util.TypeNotUniqueException in project jena by apache.
the class ExTDB3 method main.
public static void main(String... argv) {
String assemblerFile = "Store/tdb-assembler.ttl";
// Find a particular description in the file where there are several:
Model spec = RDFDataMgr.loadModel(assemblerFile);
// Find the right starting point for the description in some way.
Resource root = null;
if (false)
// If you know the Resource URI:
root = spec.createResource("http://example/myChoiceOfURI");
else {
// Alternatively, look for the a single resource of the right type.
try {
// Find the required description - the file can contain descriptions of many different types.
root = GraphUtils.findRootByType(spec, VocabTDB.tDatasetTDB);
if (root == null)
throw new JenaException("Failed to find a suitable root");
} catch (TypeNotUniqueException ex) {
throw new JenaException("Multiple types for: " + DatasetAssemblerVocab.tDataset);
}
}
Dataset ds = (Dataset) Assembler.general.open(root);
}
use of org.apache.jena.sparql.util.TypeNotUniqueException in project jena by apache.
the class ExTDB3 method main.
public static void main(String... argv) {
String assemblerFile = "Store/tdb-assembler.ttl";
// Find a particular description in the file where there are several:
Model spec = RDFDataMgr.loadModel(assemblerFile);
// Find the right starting point for the description in some way.
Resource root = null;
if (false)
// If you know the Resource URI:
root = spec.createResource("http://example/myChoiceOfURI");
else {
// Alternatively, look for the a single resource of the right type.
try {
// Find the required description - the file can contain descriptions of many different types.
root = GraphUtils.findRootByType(spec, VocabTDB.tDatasetTDB);
if (root == null)
throw new JenaException("Failed to find a suitable root");
} catch (TypeNotUniqueException ex) {
throw new JenaException("Multiple types for: " + DatasetAssemblerVocab.tDataset);
}
}
Dataset ds = (Dataset) Assembler.general.open(root);
}
use of org.apache.jena.sparql.util.TypeNotUniqueException in project jena by apache.
the class GraphUtils method getResourceByType.
public static Resource getResourceByType(Model model, Resource type) {
ResIterator sIter = model.listSubjectsWithProperty(RDF.type, type);
if (!sIter.hasNext())
return null;
Resource r = sIter.next();
if (sIter.hasNext())
throw new TypeNotUniqueException(r);
return r;
}
Aggregations