Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from feup-infolab/Jena-Fuseki-Middleware
Fuseki
- Loading branch information
Showing
46 changed files
with
1,345 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.3.2.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<groupId>JenaTest</groupId> | ||
<artifactId>JenaTest</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.junit.vintage</groupId> | ||
<artifactId>junit-vintage-engine</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>jena-tdb</artifactId> | ||
<version>3.16.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>jena-rdfconnection</artifactId> | ||
<version>3.16.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
</project> | ||
|
58 changes: 58 additions & 0 deletions
58
new_project/backend/JenaTest/src/main/java/cclasses/ResponseClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package cclasses; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ResponseClass { | ||
|
||
private final String id; | ||
|
||
private final String $schema; | ||
|
||
private final String description; | ||
|
||
private final String type; | ||
|
||
private final Map<String,Object> properties; | ||
|
||
|
||
|
||
|
||
|
||
public ResponseClass( Map<String,Object> properties) { | ||
this.id = "https://example.com/arrays.schema.json"; | ||
this.properties = properties; | ||
this.$schema = "http://json-schema.org/draft-07/schema#summaryDoc"; | ||
this.description = "The document summary representation."; | ||
this.type = "object"; | ||
|
||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Map<String,Object> getProperties() { | ||
return properties; | ||
} | ||
|
||
public void addContent(String key,Map<String,String> value) { | ||
properties.put(key,value); | ||
} | ||
|
||
public void addList(String key,List<Map<String,String>> value) { | ||
properties.put(key,value); | ||
} | ||
|
||
public String get$schema() { | ||
return $schema; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
new_project/backend/JenaTest/src/main/java/one/Tutorial01.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package one; | ||
|
||
import org.apache.jena.rdf.model.*; | ||
import org.apache.jena.vocabulary.*; | ||
|
||
/** Tutorial 1 creating a simple model | ||
*/ | ||
|
||
public class Tutorial01 extends Object { | ||
// some definitions | ||
static String personURI = "http://somewhere/JohnSmith"; | ||
static String fullName = "John Smith"; | ||
|
||
public static void main (String args[]) { | ||
// create an empty model | ||
Model model = ModelFactory.createDefaultModel(); | ||
|
||
// create the resource | ||
Resource johnSmith = model.createResource(personURI); | ||
|
||
// add the property | ||
johnSmith.addProperty(VCARD.FN, fullName); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
new_project/backend/JenaTest/src/main/java/one/Tutorial02.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package one; | ||
|
||
import org.apache.jena.rdf.model.*; | ||
import org.apache.jena.vocabulary.*; | ||
|
||
/** Tutorial 2 resources as property values | ||
*/ | ||
public class Tutorial02 extends Object { | ||
|
||
public static void main (String args[]) { | ||
// some definitions | ||
String personURI = "http://somewhere/JohnSmith"; | ||
String givenName = "John"; | ||
String familyName = "Smith"; | ||
String fullName = givenName + " " + familyName; | ||
|
||
// create an empty model | ||
Model model = ModelFactory.createDefaultModel(); | ||
|
||
// create the resource | ||
// and add the properties cascading style | ||
Resource johnSmith = model.createResource(personURI) | ||
.addProperty(VCARD.FN, fullName) | ||
.addProperty(VCARD.N, | ||
model.createResource() | ||
.addProperty(VCARD.Given, givenName) | ||
.addProperty(VCARD.Family, familyName)); | ||
|
||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
new_project/backend/JenaTest/src/main/java/one/Tutorial03.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package one; | ||
|
||
import org.apache.jena.rdf.model.*; | ||
import org.apache.jena.vocabulary.*; | ||
|
||
|
||
/** Tutorial 3 Statement attribute accessor methods | ||
*/ | ||
public class Tutorial03 extends Object { | ||
public static void main (String args[]) { | ||
|
||
// some definitions | ||
String personURI = "http://somewhere/JohnSmith"; | ||
String givenName = "John"; | ||
String familyName = "Smith"; | ||
String fullName = givenName + " " + familyName; | ||
// create an empty model | ||
Model model = ModelFactory.createDefaultModel(); | ||
|
||
// create the resource | ||
// and add the properties cascading style | ||
Resource johnSmith | ||
= model.createResource(personURI) | ||
.addProperty(VCARD.FN, fullName) | ||
.addProperty(VCARD.N, | ||
model.createResource() | ||
.addProperty(VCARD.Given, givenName) | ||
.addProperty(VCARD.Family, familyName)); | ||
|
||
// list the statements in the graph | ||
StmtIterator iter = model.listStatements(); | ||
|
||
// print out the predicate, subject and object of each statement | ||
while (iter.hasNext()) { | ||
Statement stmt = iter.nextStatement(); // get next statement | ||
Resource subject = stmt.getSubject(); // get the subject | ||
Property predicate = stmt.getPredicate(); // get the predicate | ||
RDFNode object = stmt.getObject(); // get the object | ||
|
||
System.out.print(subject.toString()); | ||
System.out.print(" " + predicate.toString() + " "); | ||
if (object instanceof Resource) { | ||
System.out.print(object.toString()); | ||
} else { | ||
// object is a literal | ||
System.out.print(" \"" + object.toString() + "\""); | ||
} | ||
System.out.println(" ."); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
new_project/backend/JenaTest/src/main/java/one/Tutorial04.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package one; | ||
|
||
import org.apache.jena.rdf.model.*; | ||
import org.apache.jena.vocabulary.*; | ||
|
||
/** Tutorial 4 - create a model and write it in XML form to standard out | ||
*/ | ||
public class Tutorial04 extends Object { | ||
|
||
// some definitions | ||
static String tutorialURI = "http://hostname/rdf/tutorial/"; | ||
static String briansName = "Brian McBride"; | ||
static String briansEmail1 = "brian_mcbride@hp.com"; | ||
static String briansEmail2 = "brian_mcbride@hpl.hp.com"; | ||
static String title = "An Introduction to RDF and the Jena API"; | ||
static String date = "23/01/2001"; | ||
|
||
public static void main (String args[]) { | ||
|
||
// some definitions | ||
String personURI = "http://somewhere/JohnSmith"; | ||
String givenName = "John"; | ||
String familyName = "Smith"; | ||
String fullName = givenName + " " + familyName; | ||
// create an empty model | ||
Model model = ModelFactory.createDefaultModel(); | ||
|
||
// create the resource | ||
// and add the properties cascading style | ||
Resource johnSmith | ||
= model.createResource(personURI) | ||
.addProperty(VCARD.FN, fullName) | ||
.addProperty(VCARD.N, | ||
model.createResource() | ||
.addProperty(VCARD.Given, givenName) | ||
.addProperty(VCARD.Family, familyName)); | ||
|
||
// now write the model in XML form to a file | ||
model.write(System.out); | ||
} | ||
} |
Oops, something went wrong.