Java Code Examples for org.eclipse.rdf4j.model.impl.SimpleValueFactory#createIRI()

The following examples show how to use org.eclipse.rdf4j.model.impl.SimpleValueFactory#createIRI() . 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: KnowledgeBaseProfile.java    From inception with Apache License 2.0 6 votes vote down vote up
public KnowledgeBaseProfile(@JsonProperty("name") String aName,
        @JsonProperty("disabled") boolean aDisabled,
        @JsonProperty("type") RepositoryType aType,
        @JsonProperty("access") KnowledgeBaseAccess aAccess,
        @JsonProperty("mapping") KnowledgeBaseMapping aMapping,
        @JsonProperty("root-concepts") List<String> aRootConcepts,
        @JsonProperty("info") KnowledgeBaseInfo aInfo,
        @JsonProperty("reification") Reification aReification,
        @JsonProperty("default-language") String aDefaultLanguage,
        @JsonProperty("default-dataset") String aDefaultDataset)
{
    name = aName;
    disabled = aDisabled;
    type = aType;
    access = aAccess;
    mapping = aMapping;
    rootConcepts = aRootConcepts;
    info = aInfo;
    reification = aReification;
    defaultLanguage = aDefaultLanguage;
    
    SimpleValueFactory vf = SimpleValueFactory.getInstance();
    if (aDefaultDataset != null) {
        defaultDataset = vf.createIRI(aDefaultDataset);
    }
}
 
Example 2
Source File: KnowledgeBaseMapping.java    From inception with Apache License 2.0 6 votes vote down vote up
@JsonCreator public KnowledgeBaseMapping(@JsonProperty("class") String aClassIri,
    @JsonProperty("subclass-of") String aSubclassIri,
    @JsonProperty("instance-of") String aTypeIri,
    @JsonProperty("subproperty-of") String aSubPropertyIri,
    @JsonProperty("description") String aDescriptionIri,
    @JsonProperty("label") String aLabelIri,
    @JsonProperty("property-type") String aPropertyTypeIri,
    @JsonProperty("property-label") String aPropertyLabelIri,
    @JsonProperty("property-description") String aPropertyDescriptionIri)

{
    SimpleValueFactory vf = SimpleValueFactory.getInstance();
    classIri = vf.createIRI(aClassIri);
    subclassIri = vf.createIRI(aSubclassIri);
    typeIri = vf.createIRI(aTypeIri);
    subPropertyIri = vf.createIRI(aSubPropertyIri);
    descriptionIri = vf.createIRI(aDescriptionIri);
    labelIri = vf.createIRI(aLabelIri);
    propertyTypeIri = vf.createIRI(aPropertyTypeIri);
    propertyLabelIri = vf.createIRI(aPropertyLabelIri);
    propertyDescriptionIri = vf.createIRI(aPropertyDescriptionIri);
}
 
Example 3
Source File: DatatypeBenchmarkLinear.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Setup(Level.Iteration)
public void setUp() {
	Logger root = (Logger) LoggerFactory.getLogger(ShaclSailConnection.class.getName());
	root.setLevel(ch.qos.logback.classic.Level.INFO);

	allStatements = new ArrayList<>(NUMBER_OF_TRANSACTIONS);

	SimpleValueFactory vf = SimpleValueFactory.getInstance();

	for (int j = 0; j < NUMBER_OF_TRANSACTIONS; j++) {
		List<Statement> statements = new ArrayList<>(BenchmarkConfigs.STATEMENTS_PER_TRANSACTION);
		allStatements.add(statements);
		for (int i = 0; i < BenchmarkConfigs.STATEMENTS_PER_TRANSACTION; i++) {
			IRI iri = vf.createIRI("http://example.com/" + i + "_" + j);
			statements.add(vf.createStatement(iri, RDF.TYPE, RDFS.RESOURCE));
			statements.add(vf.createStatement(iri, FOAF.AGE,
					vf.createLiteral(i)));
		}
	}
	System.gc();

}
 
Example 4
Source File: KnowledgeBaseAccess.java    From inception with Apache License 2.0 5 votes vote down vote up
@JsonCreator public KnowledgeBaseAccess(@JsonProperty("access-url") String aAccessUrl,
    @JsonProperty("full-text-search") String aFullTestSearchIri)
{
    SimpleValueFactory vf = SimpleValueFactory.getInstance();
    accessUrl = aAccessUrl;
    fullTextSearchIri = vf.createIRI(aFullTestSearchIri);
}
 
Example 5
Source File: FunctionModel.java    From rmlmapper-java with MIT License 5 votes vote down vote up
private IRI getDataType(Map<String, Object> args) {
    SimpleValueFactory vf = SimpleValueFactory.getInstance();
    String type = null;
    if (this.outputs.size() > 0) {
        if (this.outputs.get(0).getValue().startsWith("xsd:")) {
            type = this.outputs.get(0).getValue().replace("xsd:", "http://www.w3.org/2001/XMLSchema#");
        }
        if (this.outputs.get(0).getValue().startsWith("owl:")) {
            type = this.outputs.get(0).getValue().replace("owl:", "http://www.w3.org/2002/07/owl#");
        }
    }
    if ((type == null) && args.containsKey("http://dbpedia.org/function/unitParameter")) {
        type = "http://dbpedia.org/datatype/" + args.get("http://dbpedia.org/function/unitParameter");
    }
    if ((type == null) && args.containsKey("http://dbpedia.org/function/dataTypeParameter")) {
        if (args.get("http://dbpedia.org/function/dataTypeParameter").toString().equals("owl:Thing")) {
            type = "http://www.w3.org/2001/XMLSchema#anyURI";
        }
    }
    if ((type == null) && args.containsKey("http://dbpedia.org/function/equals/valueParameter")) {
        type = "http://www.w3.org/2001/XMLSchema#boolean";
    }
    if (type == null) {
        type = "http://www.w3.org/2001/XMLSchema#string";
    }

    return vf.createIRI(type);
}
 
Example 6
Source File: SHACLManifestTestSuiteFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private IRI readTurtle(Model manifests, URL url, String baseURI, String... excludedSubdirs)
		throws IOException, RDFParseException {
	if (baseURI == null) {
		baseURI = url.toExternalForm();
	}
	ParsedIRI baseIRI = ParsedIRI.create(baseURI);
	SimpleValueFactory vf = SimpleValueFactory.getInstance();
	IRI manifest = vf.createIRI(baseIRI.toString());
	int before = manifests.size();

	try (InputStream in = url.openStream()) {
		RDFParser rdfParser = new TurtleParser();

		ContextStatementCollector collection = new ContextStatementCollector(manifests, vf, manifest);
		rdfParser.setRDFHandler(collection);

		rdfParser.parse(in, baseIRI.toString());
		for (Map.Entry<String, String> e : collection.getNamespaces().entrySet()) {
			manifests.setNamespace(e.getKey(), e.getValue());
		}
	}
	if (before < manifests.size()) {
		for (Value included : new LinkedHashSet<>(
				manifests.filter(manifest, vf.createIRI(MF_INCLUDE), null).objects())) {
			String subManifestFile = included.stringValue();
			if (includeSubManifest(subManifestFile, excludedSubdirs)) {
				readTurtle(manifests, new URL(subManifestFile), subManifestFile, excludedSubdirs);
			}
		}
	}
	return manifest;
}
 
Example 7
Source File: MemTripleTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Before
public void setUp() throws Exception {

	SimpleValueFactory svf = SimpleValueFactory.getInstance();

	s1 = svf.createIRI("foo:s1");
	p1 = svf.createIRI("foo:p1");
	o1 = svf.createIRI("foo:o1");

	subject = new MemIRI(this, s1.getNamespace(), s1.getLocalName());
	predicate = new MemIRI(this, p1.getNamespace(), p1.getLocalName());
	object = new MemIRI(this, o1.getNamespace(), o1.getLocalName());
	triple = new MemTriple(this, subject, predicate, object);
}
 
Example 8
Source File: BulkedExternalInnerJoinTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void gapInResultsFromQueryTest() {

	SimpleValueFactory vf = SimpleValueFactory.getInstance();
	IRI a = vf.createIRI("http://a");
	IRI b = vf.createIRI("http://b");
	IRI c = vf.createIRI("http://c");
	IRI d = vf.createIRI("http://d");

	PlanNode left = new MockInputPlanNode(
			Arrays.asList(new Tuple(Collections.singletonList(a)), new Tuple(Collections.singletonList(b)),
					new Tuple(Collections.singletonList(c)), new Tuple(Collections.singletonList(d))));

	MemoryStore sailRepository = new MemoryStore();
	sailRepository.init();

	try (SailConnection connection = sailRepository.getConnection()) {
		connection.begin();
		connection.addStatement(b, DCAT.ACCESS_URL, RDFS.RESOURCE);
		connection.addStatement(d, DCAT.ACCESS_URL, RDFS.SUBPROPERTYOF);
		connection.commit();
	}
	try (SailConnection connection = sailRepository.getConnection()) {

		BulkedExternalInnerJoin bulkedExternalInnerJoin = new BulkedExternalInnerJoin(left, connection,
				"?a <http://www.w3.org/ns/dcat#accessURL> ?c. ", false, null, "?a", "?c");

		List<Tuple> tuples = new MockConsumePlanNode(bulkedExternalInnerJoin).asList();

		tuples.forEach(System.out::println);

		assertEquals("[http://b, http://www.w3.org/2000/01/rdf-schema#Resource]",
				Arrays.toString(tuples.get(0).line.toArray()));
		assertEquals("[http://d, http://www.w3.org/2000/01/rdf-schema#subPropertyOf]",
				Arrays.toString(tuples.get(1).line.toArray()));

	}
}
 
Example 9
Source File: SES2154SubselectOptionalTest.java    From Halyard with Apache License 2.0 5 votes vote down vote up
@Test
public void testSES2154SubselectOptional() throws Exception {
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "SES2154SubselectOptionaltable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    SimpleValueFactory vf = SimpleValueFactory.getInstance();
    IRI person = vf.createIRI("http://schema.org/Person");
    for (char c = 'a'; c < 'k'; c++) {
        sail.addStatement(vf.createIRI("http://example.com/" + c), RDF.TYPE, person);
    }
    sail.commit();
    TupleQueryResult res = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "PREFIX : <http://example.com/>\n" + "PREFIX schema: <http://schema.org/>\n" + "\n" + "SELECT (COUNT(*) AS ?count)\n" + "WHERE {\n" + "  {\n" + "    SELECT ?person\n" + "    WHERE {\n" + "      ?person a schema:Person .\n" + "    }\n" + "    LIMIT 5\n" + "  }\n" + "  OPTIONAL {\n" + "    [] :nonexistent [] .\n" + "  }\n" + "}").evaluate();
    assertEquals(5, ((Literal) res.next().getBinding("count").getValue()).intValue());
    rep.shutDown();
}
 
Example 10
Source File: HalyardSummaryTest.java    From Halyard with Apache License 2.0 5 votes vote down vote up
private IRI[] generateIRIs(int num, String prefix) {
    SimpleValueFactory svf = SimpleValueFactory.getInstance();
    IRI iris[] = new IRI[num];
    for (int i = 0; i < num; i++) {
        iris[i] = svf.createIRI(prefix + i);
    }
    return iris;
}
 
Example 11
Source File: HalyardStrategyExtendedTest.java    From Halyard with Apache License 2.0 5 votes vote down vote up
@Test
public void testSES2154SubselectOptional() throws Exception {
    SimpleValueFactory vf = SimpleValueFactory.getInstance();
    IRI person = vf.createIRI("http://schema.org/Person");
    for (char c = 'a'; c < 'k'; c++) {
        con.add(vf.createIRI("http://example.com/" + c), RDF.TYPE, person);
    }
    TupleQueryResult res = con.prepareTupleQuery(QueryLanguage.SPARQL, "PREFIX : <http://example.com/>\n" + "PREFIX schema: <http://schema.org/>\n" + "\n" + "SELECT (COUNT(*) AS ?count)\n" + "WHERE {\n" + "  {\n" + "    SELECT ?person\n" + "    WHERE {\n" + "      ?person a schema:Person .\n" + "    }\n" + "    LIMIT 5\n" + "  }\n" + "  OPTIONAL {\n" + "    [] :nonexistent [] .\n" + "  }\n" + "}").evaluate();
    assertEquals(5, ((Literal) res.next().getBinding("count").getValue()).intValue());
}
 
Example 12
Source File: RyaTypeWritable.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public void readFields(final DataInput dataInput) throws IOException {
    final SimpleValueFactory vfi = SimpleValueFactory.getInstance();
    final String data = dataInput.readLine();
    final String dataTypeString = dataInput.readLine();
    final String language = dataInput.readLine();
    final IRI dataType = vfi.createIRI(dataTypeString);
    final String validatedLanguage = LiteralLanguageUtils.validateLanguage(language, dataType);
    ryatype.setData(data);
    ryatype.setDataType(dataType);
    ryatype.setLanguage(validatedLanguage);

}
 
Example 13
Source File: EntityModelWriter.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
public EntityModelWriter(
    TagService<LabeledResource, LabeledResource> tagService, SimpleValueFactory valueFactory) {
  this.valueFactory = requireNonNull(valueFactory);
  this.tagService = requireNonNull(tagService);
  this.rdfTypePredicate =
      valueFactory.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
}
 
Example 14
Source File: EvaluationStatisticsTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void testAcurracy() throws InterruptedException {
	SimpleValueFactory vf = SimpleValueFactory.getInstance();

	ExtensibleDynamicEvaluationStatistics extensibleDynamicEvaluationStatistics = new ExtensibleDynamicEvaluationStatistics(
			null);

	parse.forEach(s -> extensibleDynamicEvaluationStatistics.add(ex.fromStatement(s, false)));
	extensibleDynamicEvaluationStatistics.waitForQueue();

	ExtensibleDynamicEvaluationStatistics.ExtensibleDynamicEvaluationStatisticsCardinalityCalculator cardinalityCalculator = (ExtensibleDynamicEvaluationStatistics.ExtensibleDynamicEvaluationStatisticsCardinalityCalculator) extensibleDynamicEvaluationStatistics
			.createCardinalityCalculator();

	IRI bdbmProductType = vf.createIRI("http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/", "ProductType");
	IRI dataFromProducer1Product31 = vf
			.createIRI("http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/dataFromProducer1/", "Product31");

	StatementPattern null_rdfType_bsbmProductType = new StatementPattern(
			new Var("a", null),
			new Var("b", RDF.TYPE),
			new Var("c", bdbmProductType));

	checkPattern(cardinalityCalculator, null_rdfType_bsbmProductType, 1);

	StatementPattern null_null_null = new StatementPattern(
			new Var("a", null),
			new Var("b", null),
			new Var("c", null));

	checkPattern(cardinalityCalculator, null_null_null, 1);

	StatementPattern null_rdfType_null = new StatementPattern(
			new Var("a", null),
			new Var("b", RDF.TYPE),
			new Var("c", null));

	checkPattern(cardinalityCalculator, null_rdfType_null, 1);

	StatementPattern nonExistent = new StatementPattern(
			new Var("a", null),
			new Var("b", vf.createIRI("http://example.com/fhjerhf2uhfjkdsbf32o")),
			new Var("c", null));

	checkPattern(cardinalityCalculator, nonExistent, 1);

	// this last pattern isn't very accurate, it's actually 46 statements, but the estimate is 100.4
	StatementPattern bsbmProductType_null_null = new StatementPattern(
			new Var("a", dataFromProducer1Product31),
			new Var("b", null),
			new Var("c", null));

	checkPattern(cardinalityCalculator, bsbmProductType_null_null, 120);

}