Skip to content

Commit

Permalink
Rename TripleFilteringFacadeXBuilder to TripleFilteringFacadeXGraphBu…
Browse files Browse the repository at this point in the history
…ilder. Move the add(n,n,n,n) method to its own interface FacadeXQuadHandler. About #190
  • Loading branch information
enridaga committed Dec 26, 2021
1 parent 49df58f commit c321c11
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.junit.Test;

import com.github.sparqlanything.bib.BibtexTriplifier;
import com.github.sparqlanything.model.BaseFacadeXBuilder;
import com.github.sparqlanything.model.BaseFacadeXGraphBuilder;
import com.github.sparqlanything.model.IRIArgument;
import com.github.sparqlanything.model.Triplifier;
import com.github.sparqlanything.model.TriplifierHTTPException;
Expand All @@ -47,7 +47,7 @@ public void testContent() throws TriplifierHTTPException {
try {
Properties p1 = new Properties();
p1.setProperty(IRIArgument.CONTENT.toString(), "@article{Knuth1984, title={Literate Programming}}");
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXBuilder("test", p1));
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXGraphBuilder("test", p1));
// RDFDataMgr.write(System.out, g1, RDFFormat.TRIG);
Graph expected = GraphFactory.createDefaultGraph();
Node n = NodeFactory.createBlankNode();
Expand All @@ -74,7 +74,7 @@ public void testBlankNodeFalse() throws TriplifierHTTPException {
Properties p1 = new Properties();
p1.setProperty(IRIArgument.CONTENT.toString(), "@article{Knuth1984, title={Literate Programming}}");
p1.setProperty(IRIArgument.BLANK_NODES.toString(), "false");
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXBuilder("test", p1));
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXGraphBuilder("test", p1));
g1.find().forEachRemaining(q->{
assertFalse(q.getGraph().isBlank());
assertFalse(q.getSubject().isBlank());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.junit.Test;

import com.github.sparqlanything.bib.BibtexTriplifier;
import com.github.sparqlanything.model.BaseFacadeXBuilder;
import com.github.sparqlanything.model.BaseFacadeXGraphBuilder;
import com.github.sparqlanything.model.IRIArgument;
import com.github.sparqlanything.model.Triplifier;

Expand All @@ -46,7 +46,7 @@ public void test1() {
Properties p1 = new Properties();
p1.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./test1.bib").toString());
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXBuilder("test", p1));
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXGraphBuilder("test", p1));

// ModelFactory.createModelForGraph(g1.getDefaultGraph()).write(System.out, "TTL");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Iterator;
import java.util.Properties;

import com.github.sparqlanything.model.BaseFacadeXBuilder;
import com.github.sparqlanything.model.BaseFacadeXGraphBuilder;
import com.github.sparqlanything.model.TriplifierHTTPException;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.NodeFactory;
Expand Down Expand Up @@ -60,7 +60,7 @@ public void testCsvNullString(String nullString) throws IOException, TriplifierH
BasicPattern bp = new BasicPattern();
bp.add(new Triple(NodeFactory.createVariable("s"), NodeFactory.createVariable("p"),
NodeFactory.createVariable("o")));
DatasetGraph graph = triplifier.triplify(properties, new BaseFacadeXBuilder(csv1.toString(), properties));
DatasetGraph graph = triplifier.triplify(properties, new BaseFacadeXGraphBuilder(csv1.toString(), properties));
// with csv.null-string set to nullString we should not see any quads with nullString in the object position
if(graph.find(Node.ANY,Node.ANY,Node.ANY,NodeFactory.createLiteral(nullString)).hasNext()){
fail("csv.null-string didn't work for: \"" + nullString + "\"");
Expand All @@ -76,7 +76,7 @@ public void test() throws IOException, TriplifierHTTPException {
BasicPattern bp = new BasicPattern();
bp.add(new Triple(NodeFactory.createVariable("s"), NodeFactory.createVariable("p"),
NodeFactory.createVariable("o")));
DatasetGraph graph = triplifier.triplify(properties, new BaseFacadeXBuilder(csv1.toString(), properties));
DatasetGraph graph = triplifier.triplify(properties, new BaseFacadeXGraphBuilder(csv1.toString(), properties));

Graph expected = GraphFactory.createGraphMem();

Expand Down Expand Up @@ -127,7 +127,7 @@ public void testWithOnDiskGraph1 () throws IOException, TriplifierHTTPException
properties.setProperty("ondisk", "/tmp");
URL csv1 = getClass().getClassLoader().getResource("./test3.csv");
properties.setProperty(IRIArgument.LOCATION.toString(), csv1.toString());
DatasetGraph graph = triplifier.triplify(properties, new BaseFacadeXBuilder(csv1.toString(), properties));
DatasetGraph graph = triplifier.triplify(properties, new BaseFacadeXGraphBuilder(csv1.toString(), properties));

// end the write txn because triplifiers don't do that, FacadeXOpExecutor does
graph.commit();
Expand All @@ -153,7 +153,7 @@ public void testWithOnDiskGraph2 () throws IOException, TriplifierHTTPException
properties.setProperty("ondisk", "/tmp");
URL csv1 = getClass().getClassLoader().getResource("./test1.csv");
properties.setProperty(IRIArgument.LOCATION.toString(), csv1.toString());
DatasetGraph graph = triplifier.triplify(properties, new BaseFacadeXBuilder(csv1.toString(), properties));
DatasetGraph graph = triplifier.triplify(properties, new BaseFacadeXGraphBuilder(csv1.toString(), properties));
// end the write txn because triplifiers don't do that, FacadeXOpExecutor does
graph.commit();
graph.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.junit.Test;

import com.github.sparqlanything.docs.DocxTriplifier;
import com.github.sparqlanything.model.BaseFacadeXBuilder;
import com.github.sparqlanything.model.BaseFacadeXGraphBuilder;
import com.github.sparqlanything.model.IRIArgument;
import com.github.sparqlanything.model.Triplifier;

Expand All @@ -54,7 +54,7 @@ public void test1() {
DatasetGraph dg;
try {
p.setProperty(IRIArgument.LOCATION.toString(), doc.toString());
dg = st.triplify(p, new BaseFacadeXBuilder(Triplifier.getLocation(p).toString(), p));
dg = st.triplify(p, new BaseFacadeXGraphBuilder(Triplifier.getLocation(p).toString(), p));

// RDFDataMgr.write(System.out, dg, RDFFormat.NQ);

Expand All @@ -74,7 +74,7 @@ public void test1() {

p.setProperty(DocxTriplifier.MERGE_PARAGRAPHS, "true");

dg = st.triplify(p, new BaseFacadeXBuilder(Triplifier.getLocation(p).toString(), p));
dg = st.triplify(p, new BaseFacadeXGraphBuilder(Triplifier.getLocation(p).toString(), p));
// RDFDataMgr.write(System.out, dg, RDFFormat.NQ);

expectedGraph = GraphFactory.createGraphMem();
Expand Down Expand Up @@ -114,7 +114,7 @@ public void testNoBlankNodes() {
try {
p.setProperty(IRIArgument.LOCATION.toString(), doc.toString());
p.setProperty(IRIArgument.BLANK_NODES.toString(), "false");
dg = st.triplify(p, new BaseFacadeXBuilder(Triplifier.getLocation(p).toString(), p));
dg = st.triplify(p, new BaseFacadeXGraphBuilder(Triplifier.getLocation(p).toString(), p));

RDFDataMgr.write(System.out, dg, RDFFormat.NQ);

Expand Down Expand Up @@ -143,7 +143,7 @@ public void test2() {
try {

p.setProperty(IRIArgument.LOCATION.toString(), doc.toString());
dg = st.triplify(p, new BaseFacadeXBuilder(Triplifier.getLocation(p).toString(), p));
dg = st.triplify(p, new BaseFacadeXGraphBuilder(Triplifier.getLocation(p).toString(), p));

RDFDataMgr.write(System.out, dg, RDFFormat.TRIG_PRETTY);

Expand Down Expand Up @@ -233,7 +233,7 @@ public void test3() {
try {
p.setProperty(IRIArgument.LOCATION.toString(), doc.toString());
p.setProperty(DocxTriplifier.TABLE_HEADERS.toString(), "true");
dg = st.triplify(p, new BaseFacadeXBuilder(Triplifier.getLocation(p).toString(), p));
dg = st.triplify(p, new BaseFacadeXGraphBuilder(Triplifier.getLocation(p).toString(), p));

// RDFDataMgr.write(System.out, dg, RDFFormat.NQ);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Map;
import java.util.Properties;

import com.github.sparqlanything.csv.CSVTriplifier;
import com.github.sparqlanything.model.filestream.FileStreamDatasetGraph;
import com.github.sparqlanything.model.filestream.FileStreamManager;
import com.github.sparqlanything.model.filestream.FileStreamTriplifier;
Expand All @@ -38,7 +37,6 @@
import org.apache.jena.graph.Triple;
import org.apache.jena.query.ARQ;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.tdb2.TDB2Factory;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
Expand Down Expand Up @@ -75,10 +73,10 @@

import com.github.sparqlanything.facadeiri.FacadeIRIParser;
import com.github.sparqlanything.metadata.MetadataTriplifier;
import com.github.sparqlanything.model.BaseFacadeXBuilder;
import com.github.sparqlanything.model.BaseFacadeXGraphBuilder;
import com.github.sparqlanything.model.FacadeXGraphBuilder;
import com.github.sparqlanything.model.IRIArgument;
import com.github.sparqlanything.model.TripleFilteringFacadeXBuilder;
import com.github.sparqlanything.model.TripleFilteringFacadeXGraphBuilder;
import com.github.sparqlanything.model.Triplifier;
import com.github.sparqlanything.model.TriplifierHTTPException;
import com.github.sparqlanything.zip.FolderTriplifier;
Expand Down Expand Up @@ -309,10 +307,10 @@ private DatasetGraph triplify(final Op op, Properties p, Triplifier t) throws IO
FacadeXGraphBuilder builder;
if (strategy == 1) {
logger.trace("Executing: {} [strategy={}]", p, strategy);
builder = new TripleFilteringFacadeXBuilder(resourceId, op, p);
builder = new TripleFilteringFacadeXGraphBuilder(resourceId, op, p);
} else {
logger.trace("Executing: {} [strategy={}]", p, strategy);
builder = new BaseFacadeXBuilder(resourceId, p);
builder = new BaseFacadeXGraphBuilder(resourceId, p);
}
dg = t.triplify(p, builder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.junit.Test;

import com.github.sparqlanything.json.JSONTriplifier;
import com.github.sparqlanything.model.BaseFacadeXBuilder;
import com.github.sparqlanything.model.BaseFacadeXGraphBuilder;
import com.github.sparqlanything.model.IRIArgument;
import com.github.sparqlanything.model.Triplifier;
import com.github.sparqlanything.model.TriplifierHTTPException;
Expand All @@ -46,7 +46,7 @@ public void testContent() throws TriplifierHTTPException {
try {
Properties p1 = new Properties();
p1.setProperty(IRIArgument.CONTENT.toString(), "{\"a\":\"b\"}");
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXBuilder("test", p1));
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXGraphBuilder("test", p1));
// RDFDataMgr.write(System.out, g1, RDFFormat.TRIG);
Graph expected = GraphFactory.createDefaultGraph();
Node n = NodeFactory.createBlankNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.github.sparqlanything.model.FacadeXGraphBuilder;
import com.github.sparqlanything.model.IRIArgument;

import com.github.sparqlanything.model.TripleFilteringFacadeXBuilder;
import com.github.sparqlanything.model.TripleFilteringFacadeXGraphBuilder;
import org.apache.jena.graph.Node_Variable;
import org.apache.jena.graph.Triple;
import org.apache.jena.rdf.model.ResourceFactory;
Expand All @@ -45,7 +45,7 @@ public class JSONTripleFilteringTest {
public static final Logger log = LoggerFactory.getLogger(JSONTripleFilteringTest.class);

protected FacadeXGraphBuilder getTripleFilteringBuilder(URL url, Op op, Properties p){
return new TripleFilteringFacadeXBuilder(url.toString(), op, p);
return new TripleFilteringFacadeXGraphBuilder(url.toString(), op, p);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.sparqlanything.model.BaseFacadeXBuilder;
import com.github.sparqlanything.model.BaseFacadeXGraphBuilder;
import com.github.sparqlanything.model.IRIArgument;
import com.github.sparqlanything.model.Triplifier;
import com.github.sparqlanything.model.TriplifierHTTPException;
Expand All @@ -56,12 +56,12 @@ public void testEmptyAndNull() throws TriplifierHTTPException {
Properties p1 = new Properties();
p1.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./emptyobject.json").toString());
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXBuilder("test", p1));
DatasetGraph g1 = jt.triplify(p1, new BaseFacadeXGraphBuilder("test", p1));

Properties p2 = new Properties();
p2.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./emptyarray.json").toString());
DatasetGraph g2 = jt.triplify(p2, new BaseFacadeXBuilder("test", p2));
DatasetGraph g2 = jt.triplify(p2, new BaseFacadeXGraphBuilder("test", p2));
assertEquals(1L, g1.getDefaultGraph().size());
assertEquals(1L, g2.getDefaultGraph().size());
} catch (IOException e1) {
Expand All @@ -81,7 +81,7 @@ public void testEmptyAndNull() throws TriplifierHTTPException {

boolean nullPointerException = false;
try {
jt.triplify(null, new BaseFacadeXBuilder("test", null));
jt.triplify(null, new BaseFacadeXGraphBuilder("test", null));
} catch (NullPointerException e) {
nullPointerException = true;
} catch (IOException e) {
Expand Down Expand Up @@ -114,7 +114,7 @@ public void testPrimitive() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./testprimitive.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));
assertTrue(m.getGraph().isIsomorphicWith(g1.getDefaultGraph()));
} catch (IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -142,7 +142,7 @@ public void testPrimitive() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./testprimitive.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));
assertTrue(mn.getGraph().isIsomorphicWith(g1.getDefaultGraph()));
} catch (IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -171,7 +171,7 @@ public void testNegative() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./testnumbers.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));
// ModelFactory.createModelForGraph(g1.getDefaultGraph()).write(System.out, "TTL");
// m.write(System.out, "TTL");
// System.out.println("\n\n\n");
Expand All @@ -196,7 +196,7 @@ public void keys() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./whitespaceKeys.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));
// ModelFactory.createModelForGraph(g1.getDefaultGraph()).write(System.out, "TTL");
// m.write(System.out,"TTL");
assertTrue(m.getGraph().isIsomorphicWith(g1.getDefaultGraph()));
Expand Down Expand Up @@ -228,7 +228,7 @@ public void testBlankNodeProperty() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./testprimitive.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));
// ModelFactory.createModelForGraph(g1.getDefaultGraph()).write(System.out, "TTL");
assertTrue(m.getGraph().isIsomorphicWith(g1.getDefaultGraph()));
} catch (IOException e) {
Expand Down Expand Up @@ -258,7 +258,7 @@ public void testBlankNodeFalse() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./testprimitive.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));
// ModelFactory.createModelForGraph(g1.getDefaultGraph()).write(System.out, "TTL");

assertTrue(mn.getGraph().isIsomorphicWith(g1.getDefaultGraph()));
Expand Down Expand Up @@ -289,7 +289,7 @@ public void testBlankNodeFalseNoRoot() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./testprimitive.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));
// ModelFactory.createModelForGraph(g1.getDefaultGraph()).write(System.out, "TTL");

assertTrue(mn.getGraph().isIsomorphicWith(g1.getDefaultGraph()));
Expand Down Expand Up @@ -324,7 +324,7 @@ public void s() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./testarray.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));

// RDFDataMgr.write(System.out, g1, RDFFormat.TRIG);
assertTrue(m.getGraph().isIsomorphicWith(g1.getDefaultGraph()));
Expand Down Expand Up @@ -360,7 +360,7 @@ public void s() throws TriplifierHTTPException {
try {
properties.setProperty(IRIArgument.LOCATION.toString(),
getClass().getClassLoader().getResource("./testarray.json").toString());
g1 = jt.triplify(properties, new BaseFacadeXBuilder("test", properties));
g1 = jt.triplify(properties, new BaseFacadeXGraphBuilder("test", properties));
Iterator<Triple> ii = g1.getDefaultGraph().find();
while (ii.hasNext()) {
log.debug("{}", ii.next());
Expand Down Expand Up @@ -408,7 +408,7 @@ public void testUTF8encoded() throws TriplifierHTTPException {
try {
Properties p = new Properties();
p.setProperty(IRIArgument.LOCATION.toString(), getClass().getClassLoader().getResource(f).toString());
jt.triplify(p, new BaseFacadeXBuilder("test", p));
jt.triplify(p, new BaseFacadeXGraphBuilder("test", p));
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -423,7 +423,7 @@ public void testContainsZerosDebug() throws TriplifierHTTPException {
try {
Properties p = new Properties();
p.setProperty(IRIArgument.LOCATION.toString(), getClass().getClassLoader().getResource(f).toString());
DatasetGraph ds = jt.triplify(p, new BaseFacadeXBuilder("test", p));
DatasetGraph ds = jt.triplify(p, new BaseFacadeXGraphBuilder("test", p));
Iterator<Quad> i = ds.find(null);
while (i.hasNext()) {
Quad q = i.next();
Expand Down
Loading

0 comments on commit c321c11

Please sign in to comment.