Add very first code to verify jena is working
This commit is contained in:
parent
124c403688
commit
3762eead8c
|
@ -12,12 +12,12 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
|
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
|
# Eclipse stuff
|
||||||
.settings
|
.settings
|
||||||
|
|
||||||
|
# Compile artifacts
|
||||||
*.class
|
*.class
|
||||||
|
*.jar
|
||||||
|
|
||||||
|
# Target stuff
|
||||||
|
target/classes/META-INF/
|
||||||
|
target/maven-archiver/
|
||||||
|
target/maven-status/
|
||||||
|
target/surefire-reports/
|
||||||
|
|
||||||
|
# Own files
|
||||||
|
test.ttl
|
||||||
|
|
||||||
|
|
16
pom.xml
16
pom.xml
|
@ -21,11 +21,25 @@
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.jena/apache-jena -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jena</groupId>
|
||||||
|
<artifactId>apache-jena</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.jena/jena-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jena</groupId>
|
||||||
|
<artifactId>jena-core</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.jena/apache-jena-libs -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.jena</groupId>
|
<groupId>org.apache.jena</groupId>
|
||||||
<artifactId>apache-jena-libs</artifactId>
|
<artifactId>apache-jena-libs</artifactId>
|
||||||
<type>pom</type>
|
|
||||||
<version>3.5.0</version>
|
<version>3.5.0</version>
|
||||||
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
package hsh.ins_jena;
|
package hsh.ins_jena;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
|
import org.apache.jena.rdf.model.Model;
|
||||||
|
import org.apache.jena.rdf.model.ModelFactory;
|
||||||
|
import org.apache.jena.rdf.model.Property;
|
||||||
|
import org.apache.jena.rdf.model.Resource;
|
||||||
|
import org.apache.jena.rdf.model.Statement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hello world!
|
* Hello world!
|
||||||
*
|
*
|
||||||
|
@ -7,5 +16,26 @@ package hsh.ins_jena;
|
||||||
public class App {
|
public class App {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("Hello World!");
|
System.out.println("Hello World!");
|
||||||
|
String familyUri = "http://family/";
|
||||||
|
String relationshipUri = "http://purl.org/vocab/relationship/";
|
||||||
|
|
||||||
|
Model model = ModelFactory.createDefaultModel();
|
||||||
|
Resource donald = model.createResource(familyUri + "donald");
|
||||||
|
Resource tick = model.createResource(familyUri + "tick");
|
||||||
|
|
||||||
|
Property childOf = model.createProperty(relationshipUri, "childOf");
|
||||||
|
Property knows = model.createProperty(relationshipUri, "knows");
|
||||||
|
tick.addProperty(childOf, donald);
|
||||||
|
|
||||||
|
Statement st1 = model.createStatement(donald, knows, tick);
|
||||||
|
model.add(st1);
|
||||||
|
FileOutputStream outfile;
|
||||||
|
try {
|
||||||
|
outfile = new FileOutputStream("./test.ttl");
|
||||||
|
model.write(outfile, "TURTLE");
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/META-INF/
|
/hsh/
|
||||||
|
|
Loading…
Reference in New Issue