Skip to content

Commit

Permalink
1.0.2: kb ttl as resources
Browse files Browse the repository at this point in the history
  • Loading branch information
adibaba committed Jan 4, 2021
1 parent 7b5e46e commit ac1f184
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<version>1.0.2-SNAPSHOT</version>
<version>1.0.2</version>

<!-- Run with maven and goal "package" -->
<build>
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/dice_research/opal/licenses/KnowledgeBases.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.dice_research.opal.licenses;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.jena.riot.Lang;
import org.dice_research.opal.licenses.utils.CcRel;
Expand All @@ -19,6 +21,7 @@ public class KnowledgeBases {

public static final File KB_DIRECTORY = new File("src/main/resources/knowledge-bases");
public static final String KB_FILE_SUFFIX = ".ttl";
public static final String KB_SUB_DIRECTORY = "knowledge-bases";

/**
* Creative Commons licenses
Expand Down Expand Up @@ -52,8 +55,14 @@ public KnowledgeBase importEDP_Matrix() {

private KnowledgeBase importKnowledgeBase(String knowledgeBaseId, String attribueEqualityUri,
String permissionOfDerivatesUri) {
URI uri;
try {
uri = getClass().getClassLoader().getResource(KB_SUB_DIRECTORY + "/" + knowledgeBaseId + KB_FILE_SUFFIX)
.toURI();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
return new CcRel(CollectionUtil.stringToSet(attribueEqualityUri),
CollectionUtil.stringToSet(permissionOfDerivatesUri))
.importFile(new File(KB_DIRECTORY, knowledgeBaseId + KB_FILE_SUFFIX), Lang.TURTLE);
CollectionUtil.stringToSet(permissionOfDerivatesUri)).importResource(uri, Lang.TURTLE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -142,6 +143,10 @@ public KnowledgeBase importFile(File file, Lang lang) {
return importModel(RDFDataMgr.loadModel(file.toURI().toString(), lang));
}

public KnowledgeBase importResource(URI uri, Lang lang) {
return importModel(RDFDataMgr.loadModel(uri.toString(), lang));
}

public KnowledgeBase importModel(Model model) {
KnowledgeBase kb = new KnowledgeBase();
ResIterator policyIt;
Expand Down

0 comments on commit ac1f184

Please sign in to comment.