use of org.apache.jena.rdf.model.Model in project jena by apache.
the class sdbdump method execCmd.
@Override
protected void execCmd(List<String> args) {
// This is a streamable syntax.
String syntax = "N-QUADS";
if (contains(argDeclSyntax))
syntax = getArg(argDeclSyntax).getValue();
Lang lang = RDFLanguages.nameToLang(syntax);
try {
if (modGraph.getGraphName() == null) {
if (!RDFLanguages.isQuads(lang))
cmdError("Not a 'quads' language (try 'N-Quads' or 'TriG')", true);
Dataset dataset = getModStore().getDataset();
RDFDataMgr.write(System.out, dataset, lang);
} else {
Model model = modGraph.getModel(getStore());
RDFDataMgr.write(System.out, model, lang);
}
} catch (CmdException ex) {
throw ex;
} catch (Exception ex) {
System.err.println("Exception: " + ex + " :: " + ex.getMessage());
ex.printStackTrace(System.err);
}
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class sdbload method loadOne.
private void loadOne(String filename, boolean replace) {
Model model = null;
Dataset dataset = null;
PrefixMapping pmap;
Lang lang = RDFLanguages.filenameToLang(filename);
if (lang == null)
throw new CmdException("Data syntax not recognized: " + filename);
// --graph or not
if (modGraph.getGraphName() != null) {
model = modGraph.getModel(getStore());
pmap = model;
} else {
dataset = SDBFactory.connectDataset(getStore());
pmap = dataset.asDatasetGraph().getDefaultGraph().getPrefixMapping();
}
// For monitoring only.
Graph monitorGraph = (model == null) ? null : model.getGraph();
if (replace) {
if (model != null)
model.removeAll();
else
dataset.asDatasetGraph().clear();
}
boolean showProgress = isVerbose() || getModTime().timingEnabled();
if (showProgress)
output.print("Start load: %s", filename);
StreamRDF stream = streamToStore(pmap, getStore());
if (modGraph.getGraphName() != null) {
Node gn = NodeFactory.createURI(modGraph.getGraphName());
stream = StreamRDFLib.extendTriplesToQuads(gn, stream);
}
ProgressMonitor progress = null;
if (showProgress) {
progress = new ProgressMonitor(filename, 100_000, 10, output);
stream = new ProgressStreamRDF(stream, progress);
}
if (progress != null)
progress.start();
// Load!
RDFDataMgr.parse(stream, filename, lang);
if (progress != null) {
progress.finish();
progress.finishMessage();
}
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class ScriptDesc method read.
public static ScriptDesc read(String filename) {
AssemblerVocab.init();
Model m = FileManager.get().loadModel(filename);
return worker(m);
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class sdbmeta method execPut.
private void execPut(StoreConfig conf, String tag, List<String> positionalArgs) {
if (positionalArgs.size() == 0)
throw new CmdException("No file to load");
Model model = conf.getModel(tag);
if (model == null)
model = ModelFactory.createDefaultModel();
for (String filename : positionalArgs) FileManager.get().readModel(model, filename);
conf.setModel(tag, model);
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class StoreUtils method load.
public static void load(Store store, String graphIRI, String filename) {
Model model = SDBFactory.connectNamedModel(store, graphIRI);
FileManager.get().readModel(model, filename);
}
Aggregations