Java Code Examples for org.apache.jena.query.DatasetFactory#create()

The following examples show how to use org.apache.jena.query.DatasetFactory#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SparqlJenaEngineTest.java    From zeppelin with Apache License 2.0 7 votes vote down vote up
@BeforeClass
public static void setUp() {
  port = Fuseki.choosePort();

  Model model = ModelFactory.createDefaultModel();
  model.read(DATA_FILE);
  Dataset ds = DatasetFactory.create(model);

  server = FusekiServer
    .create()
    .port(port)
    .add(DATASET, ds)
    .build();
  DataAccessPointRegistry registry = server.getDataAccessPointRegistry();
  assertTrue(registry.isRegistered(DATASET));
  assertEquals(1, registry.size());
  server.start();
}
 
Example 2
Source File: PredicateMappingsDataSet.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
public PredicateMappingsDataSet(int numberOfHashFunctions,
		int numberOfColorFunctions) {
	this.numberOfColorFunctions = numberOfColorFunctions;
	this.numberOfHashFunctions = numberOfHashFunctions;

	Model defModel = ModelFactory.createDefaultModel();
	dataset = DatasetFactory.create(defModel);
	dataset.getDefaultModel()
			.getGraph()
			.add(new Triple(NodeFactory.createURI(Constants.ibmns
					+ Constants.NUM_COL_FUNCTION),
					NodeFactory.createURI(Constants.ibmns
							+ Constants.VALUE_PREDICATE), intToNode(numberOfColorFunctions)));

	dataset.getDefaultModel()
			.getGraph()
			.add(new Triple(NodeFactory.createURI(Constants.ibmns
					+ Constants.NUM_HASH_FUNCTION),
					NodeFactory.createURI(Constants.ibmns
							+ Constants.VALUE_PREDICATE), intToNode(numberOfHashFunctions)));
}
 
Example 3
Source File: RdfStreamReaderDatasetTest.java    From RDFUnit with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    Model defaultModel = ModelFactory.createDefaultModel();
    defaultModel.add(
            ResourceFactory.createResource("http://rdfunit.aksw.org"),
            OWL.sameAs,
            ResourceFactory.createResource("http://dbpedia.org/resource/Cool")
    );

    Model namedModel = ModelFactory.createDefaultModel();
    namedModel.add(
            ResourceFactory.createResource("http://rdfunit.aksw.org"),
            OWL.sameAs,
            ResourceFactory.createResource("http://dbpedia.org/resource/Super")
    );
    dataset = DatasetFactory.create(defaultModel);

    dataset.addNamedModel("http://rdfunit.aksw.org", namedModel);
}
 
Example 4
Source File: SPARQLExtCli.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
private static Dataset getDataset(File dir, FileConfigurations request) {
	try {
		return request.loadDataset(dir);
	} catch (Exception ex) {
		LOG.warn("Error while loading the dataset, no dataset will be used.");
		return DatasetFactory.create();
	}
}
 
Example 5
Source File: Item.java    From Processor with Apache License 2.0 5 votes vote down vote up
@Override
public Response post(Dataset dataset)
{
    if (log.isDebugEnabled()) log.debug("POST GRAPH {} to GraphStore {}", getURI());
    
    Dataset newDataset = DatasetFactory.create();
    newDataset.addNamedModel(getURI().toString(), dataset.getDefaultModel()); // put request entity graph into a named graph
    
    return super.post(newDataset);
}
 
Example 6
Source File: RdfReader.java    From RDFUnit with Apache License 2.0 5 votes vote down vote up
default Dataset readDataset() throws RdfReaderException {
    try {
        Dataset dataset = DatasetFactory.create();
        readDataset(dataset);
        return dataset;
    } catch (Exception e) {
        throw new RdfReaderException(e);
    }
}
 
Example 7
Source File: ContextUtils.java    From sparql-generate with Apache License 2.0 4 votes vote down vote up
public Builder setInputModel(Model inputModel) {
	Dataset inputDataset = DatasetFactory.create(inputModel);
	context.set(DATASET, inputDataset);
	return this;
}
 
Example 8
Source File: DatasetTestSource.java    From RDFUnit with Apache License 2.0 4 votes vote down vote up
DatasetTestSource(SourceConfig sourceConfig, QueryingConfig queryingConfig, Collection<SchemaSource> referenceSchemata, RdfReader dumpReader) {
    this(sourceConfig, queryingConfig, referenceSchemata, dumpReader, DatasetFactory.create());  //OntModelSpec.RDFS_MEM_RDFS_INF
}
 
Example 9
Source File: ARQFactory.java    From shacl with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a QueryExecution for a given Query in a given Model, with
 * some given initial bindings.
 * The implementation basically uses Jena's QueryExecutionFactory
 * but with the option to use different Dataset as specified by
 * <code>getDataset(model)</code>.
 * @param query  the Query
 * @param model  the Model to query
 * @param initialBinding  the initial variable bindings or null
 * @return a QueryExecution
 */
public QueryExecution createQueryExecution(Query query, Model model, QuerySolution initialBinding) {
	Dataset dataset = getDataset(model);
	if(dataset == null) {
	    dataset = DatasetFactory.create(model);
	}
       return createQueryExecution(query, dataset, initialBinding);
}