-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b69941
commit c6de59a
Showing
39 changed files
with
1,035 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> | ||
|
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); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
new_project/backend/JenaTest/src/main/java/one/Tutorial05.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,53 @@ | ||
/* | ||
* 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.util.FileManager; | ||
|
||
import java.io.*; | ||
|
||
/** Tutorial 5 - read RDF XML from a file and write it to standard out | ||
*/ | ||
public class Tutorial05 extends Object { | ||
|
||
/** | ||
NOTE that the file is loaded from the class-path and so requires that | ||
the data-directory, as well as the directory containing the compiled | ||
class, must be added to the class-path when running this and | ||
subsequent examples. | ||
*/ | ||
private static final String inputFileName = "vc-db-1.rdf"; | ||
|
||
public static void main (String[] args) { | ||
// create an empty model | ||
Model model = ModelFactory.createDefaultModel(); | ||
|
||
InputStream in = FileManager.get().open( inputFileName ); | ||
if (in == null) { | ||
throw new IllegalArgumentException( "File: " + inputFileName + " not found"); | ||
} | ||
|
||
// read the RDF/XML file | ||
model.read(in, ""); | ||
|
||
// write it to standard out | ||
model.write(System.out); | ||
} | ||
} |
Oops, something went wrong.