Skip to content
This repository was archived by the owner on Jun 29, 2021. It is now read-only.

Commit 1daa5bd

Browse files
committed
Code cleanup
1 parent 764d985 commit 1daa5bd

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed

marklogic-rdf4j/src/main/java/com/marklogic/semantics/rdf4j/MarkLogicRepositoryConnection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ public void add(Iterable<? extends Statement> statements, Resource... contexts)
10731073
Iterator <? extends Statement> iter = statements.iterator();
10741074
while(iter.hasNext()){
10751075
Statement st = iter.next();
1076-
add(st, mergeResource(st.getContext(), contexts));
1076+
add(st, contexts);
10771077
}
10781078
}
10791079

marklogic-rdf4j/src/main/java/com/marklogic/semantics/rdf4j/client/TripleWriteCache.java

+13-24
Original file line numberDiff line numberDiff line change
@@ -53,51 +53,40 @@ public TripleWriteCache(MarkLogicClient client, long cacheSize) {
5353

5454
protected synchronized void flush() throws RepositoryException, MalformedQueryException, UpdateExecutionException, IOException {
5555
if (cache.isEmpty()) { return; }
56-
StringBuffer entireQuery = new StringBuffer();
56+
StringBuilder entireQuery = new StringBuilder();
5757
SPARQLQueryBindingSet bindingSet = new SPARQLQueryBindingSet();
5858

5959
for (Namespace ns :cache.getNamespaces()){
60-
entireQuery.append("PREFIX "+ns.getPrefix()+": <"+ns.getName()+">. ");
60+
entireQuery.append("PREFIX ").append(ns.getPrefix()).append(": <").append(ns.getName()).append(">. ");
6161
}
6262
entireQuery.append("INSERT DATA { ");
6363

64-
Set<Resource> distinctCtx = new HashSet<Resource>();
65-
for (Resource context :cache.contexts()) {
66-
distinctCtx.add(context);
67-
}
64+
Set<Resource> distinctCtx = new HashSet<>();
65+
distinctCtx.addAll(cache.contexts());
6866

6967
for (Resource ctx : distinctCtx) {
7068
if (ctx != null) {
71-
entireQuery.append(" GRAPH <" + ctx + "> { ");
69+
entireQuery.append(" GRAPH <").append(ctx).append("> { ");
7270
}
7371
for (Statement stmt : cache.filter(null, null, null, ctx)) {
74-
if (stmt.getSubject() instanceof org.eclipse.rdf4j.model.BNode) {
75-
entireQuery.append("<http://marklogic.com/semantics/blank/" + stmt.getSubject().stringValue() + "> ");
76-
}else {
77-
entireQuery.append("<" + stmt.getSubject().stringValue() + "> ");
78-
}
79-
if (stmt.getPredicate() instanceof org.eclipse.rdf4j.model.BNode) {
80-
entireQuery.append("<http://marklogic.com/semantics/blank/" + stmt.getPredicate().stringValue() + "> ");
81-
}else{
82-
entireQuery.append("<" + stmt.getPredicate().stringValue() + "> ");
83-
}
72+
73+
entireQuery.append("<").append(stmt.getSubject().stringValue()).append("> ");
74+
75+
entireQuery.append("<").append(stmt.getPredicate().stringValue()).append("> ");
76+
8477
Value object=stmt.getObject();
8578
if (object instanceof Literal) {
8679
Literal lit = (Literal) object;
8780
entireQuery.append("\"");
8881
entireQuery.append(SPARQLUtil.encodeString(lit.getLabel()));
8982
entireQuery.append("\"");
9083
if(null == lit.getLanguage().orElse(null)) {
91-
entireQuery.append("^^<" + lit.getDatatype().stringValue() + ">");
84+
entireQuery.append("^^<").append(lit.getDatatype().stringValue()).append(">");
9285
}else{
93-
entireQuery.append("@" + lit.getLanguage().orElse(null));
86+
entireQuery.append("@").append(lit.getLanguage().orElse(null));
9487
}
9588
} else {
96-
if (stmt.getObject() instanceof org.eclipse.rdf4j.model.BNode) {
97-
entireQuery.append("<http://marklogic.com/semantics/blank/" + stmt.getObject().stringValue() + "> ");
98-
}else {
99-
entireQuery.append("<" + object.stringValue() + "> ");
100-
}
89+
entireQuery.append("<").append(object.stringValue()).append("> ");
10190
}
10291
entireQuery.append(".");
10392
}

marklogic-rdf4j/src/test/java/com/marklogic/semantics/rdf4j/MarkLogicRepositoryConnectionTest.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@
5050
import org.slf4j.Logger;
5151
import org.slf4j.LoggerFactory;
5252

53-
import java.io.ByteArrayOutputStream;
54-
import java.io.File;
55-
import java.io.FileInputStream;
56-
import java.io.IOException;
53+
import java.io.*;
5754
import java.net.URL;
5855
import java.util.ArrayList;
5956
import java.util.Arrays;
@@ -1562,6 +1559,7 @@ public void testConnectionWithMLConnectionVariablesWithoutDatabase()
15621559
con.clear();
15631560
}
15641561

1562+
@Deprecated
15651563
@Test
15661564
public void testConnectionWithMLConnectionVariablesWithDatabase()
15671565
{

0 commit comments

Comments
 (0)