diff --git a/admin-ui/src/main/java/eu/knowledge/engine/admin/Util.java b/admin-ui/src/main/java/eu/knowledge/engine/admin/Util.java index ba879ffb..3cda70b3 100644 --- a/admin-ui/src/main/java/eu/knowledge/engine/admin/Util.java +++ b/admin-ui/src/main/java/eu/knowledge/engine/admin/Util.java @@ -139,8 +139,6 @@ public static String getProperty(Model m, Resource r, String propertyURI) { public static List createConnectionObjects(RuleNode rn) { - System.out.println(rn.toString()); - Queue queue = new LinkedList(); queue.add(rn); diff --git a/admin-ui/src/test/java/eu/knowledge/engine/admin/api/TestApiRoutes.java b/admin-ui/src/test/java/eu/knowledge/engine/admin/api/TestApiRoutes.java index a0e23625..4f1b0431 100644 --- a/admin-ui/src/test/java/eu/knowledge/engine/admin/api/TestApiRoutes.java +++ b/admin-ui/src/test/java/eu/knowledge/engine/admin/api/TestApiRoutes.java @@ -155,8 +155,6 @@ public void testConnections() throws InterruptedException { ArrayList list = new ArrayList<>(); Collections.addAll(list, result); - System.out.println(list); - assertNotNull(list); assertEquals(2, list.size()); diff --git a/examples/dcat/docker-compose.yml b/examples/dcat/docker-compose.yml index 65866af7..9f7986ee 100644 --- a/examples/dcat/docker-compose.yml +++ b/examples/dcat/docker-compose.yml @@ -9,7 +9,7 @@ services: KE_RUNTIME_EXPOSED_URL: http://runtime-4:8081 KD_URL: http://knowledge-directory:8282 KE_REASONER_LEVEL: 5 - JAVA_TOOL_OPTIONS: "-Dorg.slf4j.simpleLogger.log.eu.knowledge.engine=info" + JAVA_TOOL_OPTIONS: "-Dorg.slf4j.simpleLogger.log.eu.knowledge.engine=trace" meta-kb: build: meta-kb environment: diff --git a/reasoner/src/main/java/eu/knowledge/engine/reasoner/ReasonerPlan.java b/reasoner/src/main/java/eu/knowledge/engine/reasoner/ReasonerPlan.java index 63896fbf..852c0b9e 100644 --- a/reasoner/src/main/java/eu/knowledge/engine/reasoner/ReasonerPlan.java +++ b/reasoner/src/main/java/eu/knowledge/engine/reasoner/ReasonerPlan.java @@ -327,7 +327,6 @@ public TaskBoard execute(BindingSet bindingSet) { Set changed = new HashSet<>(); do { - LOG.trace("New round."); stack.clear(); visited.clear(); changed.clear(); @@ -394,6 +393,8 @@ public TaskBoard execute(BindingSet bindingSet) { } } while (!changed.isEmpty()); + LOG.trace("Finished reasoning round with {} tasks.", taskBoard.getNrOfTasks()); + this.done = !taskBoard.hasTasks(); return taskBoard; } diff --git a/reasoner/src/main/java/eu/knowledge/engine/reasoner/TaskBoard.java b/reasoner/src/main/java/eu/knowledge/engine/reasoner/TaskBoard.java index f244f8d0..510b77dc 100644 --- a/reasoner/src/main/java/eu/knowledge/engine/reasoner/TaskBoard.java +++ b/reasoner/src/main/java/eu/knowledge/engine/reasoner/TaskBoard.java @@ -48,6 +48,10 @@ public boolean hasTasks() { public boolean hasTask(RuleNode node) { return this.tasks.contains(node); } + + public int getNrOfTasks() { + return this.tasks.size(); + } /** * Executes all tasks that are on the taskboard and returns a future that is diff --git a/reasoner/src/main/java/eu/knowledge/engine/reasoner/api/TripleVarBindingSet.java b/reasoner/src/main/java/eu/knowledge/engine/reasoner/api/TripleVarBindingSet.java index 90f4700f..fdc89b5a 100644 --- a/reasoner/src/main/java/eu/knowledge/engine/reasoner/api/TripleVarBindingSet.java +++ b/reasoner/src/main/java/eu/knowledge/engine/reasoner/api/TripleVarBindingSet.java @@ -219,7 +219,6 @@ public TripleVarBindingSet combine(TripleVarBindingSet aBindingSet) { Set vars2 = aBindingSet.getVariables(); overlappingVars.addAll(vars1); overlappingVars.retainAll(vars2); - LOG.trace("Overlapping vars found: {} - {} = {}", vars1, vars2, overlappingVars); } // Cartesian product is the base case @@ -438,7 +437,7 @@ else if (tn.nodeIdx == 2) table.append("\n"); } - System.out.println(table.toString()); + LOG.info("{}", table.toString()); } private String formatNode(Node n) { diff --git a/reasoner/src/main/java/eu/knowledge/engine/reasoner/rulenode/BindingSetStore.java b/reasoner/src/main/java/eu/knowledge/engine/reasoner/rulenode/BindingSetStore.java index 72e00392..f53afb53 100644 --- a/reasoner/src/main/java/eu/knowledge/engine/reasoner/rulenode/BindingSetStore.java +++ b/reasoner/src/main/java/eu/knowledge/engine/reasoner/rulenode/BindingSetStore.java @@ -114,15 +114,13 @@ private TripleVarBindingSet combineWithCombiMatches(Set aGraphPat someCombiMatches.stream().forEach(cMatch -> { i.incrementAndGet(); - LOG.trace("Creating binding set for combi match: {}/{}", i.get(), size); + LOG.trace("Creating binding set for combi match of {} rules: {}/{}", cMatch.size(), i.get(), size); // keep separate binding set per combi match var cMatchTVBS = new TripleVarBindingSet(aGraphPattern); for (Entry> cEntry : cMatch.entrySet()) { - BaseRule aNeighborRule = cEntry.getKey(); - Map matchToBS = someNeighborBS.get(aNeighborRule); if (matchToBS != null) { @@ -171,7 +169,7 @@ public TripleVarBindingSet get() { if (this.combiMatches != null) this.cache = this.combineWithCombiMatches(this.graphPattern, this.combiMatches, this.neighborBindingSet); else { - LOG.trace("Ignoring combi matches for binding set construction in {}."); + LOG.trace("Ignoring combi matches for binding set construction in {}.", this.graphPattern); TripleVarBindingSet combinedBS = new TripleVarBindingSet(graphPattern); for (TripleVarBindingSet bs : this.neighborBindingSet.values().stream().map(x -> x.values()) diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/BackwardTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/BackwardTest.java index 3356bd3f..7e77ed5e 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/BackwardTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/BackwardTest.java @@ -336,7 +336,7 @@ public void testRequestNonExistingData() throws InterruptedException, ExecutionE // Start reasoning ReasonerPlan root = new ReasonerPlan(aStore, requestNonExistingDataRule); - System.out.println(root); + LOG.info("{}", root); aStore.printGraphVizCode(root); @@ -353,7 +353,7 @@ public void testRequestNonExistingData() throws InterruptedException, ExecutionE } BindingSet bind = root.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertTrue(isEmpty(bind)); } @@ -385,7 +385,7 @@ public void testConverter() throws InterruptedException, ExecutionException { } BindingSet result = plan.getResults(); - System.out.println("bindings: " + result); + LOG.info("bindings: {}", result); assertFalse(result.isEmpty()); } @@ -394,7 +394,7 @@ public void testConverter() throws InterruptedException, ExecutionException { public void testMoreThanOneInputBinding() throws InterruptedException, ExecutionException { ReasonerPlan root = new ReasonerPlan(store, moreThanOneInputBindingRule); - System.out.println(root); + LOG.info("{}", root); BindingSet bs = new BindingSet(); Binding binding = new Binding(); @@ -411,7 +411,7 @@ public void testMoreThanOneInputBinding() throws InterruptedException, Execution } BindingSet bind = root.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertFalse(isEmpty(bind)); } @@ -420,7 +420,7 @@ public void testMoreThanOneInputBinding() throws InterruptedException, Execution public void testMoreThanOneInputBinding2() throws InterruptedException, ExecutionException { ReasonerPlan root = new ReasonerPlan(store, moreThanOneInputBinding2Rule); - System.out.println(root); + LOG.info("{}", root); BindingSet bs = new BindingSet(); Binding binding = new Binding(); @@ -437,7 +437,7 @@ public void testMoreThanOneInputBinding2() throws InterruptedException, Executio } BindingSet bind = root.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertFalse(bind.isEmpty()); } @@ -446,7 +446,7 @@ public void testMoreThanOneInputBinding2() throws InterruptedException, Executio public void testTwoPropsToAndFromTheSameVars() throws InterruptedException, ExecutionException { ReasonerPlan root = new ReasonerPlan(store, twoPropsToAndFromTheSameVarsRule); - System.out.println(root); + LOG.info("{}", root); BindingSet bs = new BindingSet(); // Binding binding = new Binding(); @@ -464,7 +464,7 @@ public void testTwoPropsToAndFromTheSameVars() throws InterruptedException, Exec } BindingSet bind = root.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertTrue(isEmpty(bind)); } @@ -506,7 +506,7 @@ public void testVariableMatchesLiteralInGraphPattern() throws InterruptedExcepti } BindingSet bind = root.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertTrue(!bind.isEmpty()); } @@ -514,7 +514,7 @@ public void testVariableMatchesLiteralInGraphPattern() throws InterruptedExcepti public void testVariableAsPredicate() throws InterruptedException, ExecutionException { ReasonerPlan root = new ReasonerPlan(store, variableAsPredicateRule); - System.out.println(root); + LOG.info("{}", root); BindingSet bs = new BindingSet(); Binding binding2 = new Binding(); @@ -525,9 +525,9 @@ public void testVariableAsPredicate() throws InterruptedException, ExecutionExce tb.executeScheduledTasks().get(); } BindingSet bind = root.getResults(); - System.out.println(root); + LOG.info("{}", root); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertTrue(!bind.isEmpty()); } @@ -547,16 +547,16 @@ public void testVariableAsPredicate2() throws InterruptedException, ExecutionExc } BindingSet bind = root.getResults(); - System.out.println(root); + LOG.info("{}", root); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertTrue(!bind.isEmpty()); // TODO THIS ONE SHOULD CONTAIN ONLY sensor1 } @Test public void testAllTriples() throws InterruptedException, ExecutionException { ReasonerPlan root = new ReasonerPlan(store, allTriplesRule); - System.out.println(root); + LOG.info("{}", root); // empty binding is necessary BindingSet bs = new BindingSet(); @@ -569,9 +569,9 @@ public void testAllTriples() throws InterruptedException, ExecutionException { } BindingSet bind = root.getResults(); - System.out.println(root); + LOG.info("{}", root); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertTrue(!bind.isEmpty()); } @@ -653,7 +653,7 @@ public void jenaForwardTest() throws InterruptedException, ExecutionException, P while (iter.hasNext()) { Statement st = iter.next(); - System.out.println(st); + LOG.info("{}", st); } assertEquals(7, rp.getResults().size()); // TODO make this assert more specific @@ -734,7 +734,7 @@ public void jenaForwardTest2() throws InterruptedException, ExecutionException, while (iter.hasNext()) { Statement st = iter.next(); - System.out.println(st); + LOG.info("{}", st); } assertEquals(5, rp.getResults().size()); // TODO make this assert more specific diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/DomainKnowledgeTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/DomainKnowledgeTest.java index 3a2188ca..7abf9ad2 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/DomainKnowledgeTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/DomainKnowledgeTest.java @@ -12,11 +12,9 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import eu.knowledge.engine.reasoner.ProactiveRule; -import eu.knowledge.engine.reasoner.ReasonerPlan; -import eu.knowledge.engine.reasoner.Rule; -import eu.knowledge.engine.reasoner.TaskBoard; import eu.knowledge.engine.reasoner.api.Binding; import eu.knowledge.engine.reasoner.api.BindingSet; import eu.knowledge.engine.reasoner.api.TriplePattern; @@ -36,6 +34,8 @@ public class DomainKnowledgeTest { private static RuleStore store; + private static final Logger LOG = LoggerFactory.getLogger(DomainKnowledgeTest.class); + @BeforeAll public static void setup() { store = new RuleStore(); @@ -102,7 +102,6 @@ public void testSubClassOf() throws InterruptedException, ExecutionException { Binding binding2 = new Binding(); bs.add(binding2); - TaskBoard tb; while ((tb = plan.execute(bs)).hasTasks()) { tb.executeScheduledTasks().get(); @@ -111,7 +110,7 @@ public void testSubClassOf() throws InterruptedException, ExecutionException { BindingSet bind = plan.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertFalse(bind.isEmpty()); } diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/ForwardTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/ForwardTest.java index dc104489..a65cbf78 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/ForwardTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/ForwardTest.java @@ -142,7 +142,7 @@ public void test() throws InterruptedException, ExecutionException { ReasonerPlan rp = new ReasonerPlan(store, aStartRule); - System.out.println(rp); + LOG.info("{}", rp); store.printGraphVizCode(rp); @@ -197,7 +197,7 @@ public CompletableFuture handle(BindingSet bs) { store.addRule(aStartRule); ReasonerPlan rp = new ReasonerPlan(store, aStartRule); - System.out.println(rp); + LOG.info("{}", rp); BindingSet bs = new BindingSet(); @@ -217,7 +217,7 @@ public CompletableFuture handle(BindingSet bs) { tb.executeScheduledTasks().get(); } - System.out.println("Result: " + aBindingSetHandler.getBindingSet() + " (expected null)"); + LOG.info("Result: {} (expected null)", aBindingSetHandler.getBindingSet()); assertEquals(aBindingSetHandler.getBindingSet(), null); } @@ -268,8 +268,8 @@ public void testMultipleLeafs() throws InterruptedException, ExecutionException assertFalse(aBindingSetHandler1.getBindingSet().isEmpty()); assertFalse(aBindingSetHandler2.getBindingSet().isEmpty()); - System.out.println("Result1: " + aBindingSetHandler1.getBindingSet()); - System.out.println("Result2: " + aBindingSetHandler2.getBindingSet()); + LOG.info("Result1: {}", aBindingSetHandler1.getBindingSet()); + LOG.info("Result2: {}", aBindingSetHandler2.getBindingSet()); } @Test @@ -289,7 +289,7 @@ public void testBackwardChainingDuringForwardChaining() throws InterruptedExcept store.addRule(aStartRule); ReasonerPlan rn = new ReasonerPlan(store, aStartRule); - System.out.println(rn); + LOG.info("{}", rn); BindingSet bs = new BindingSet(); @@ -313,7 +313,7 @@ public void testBackwardChainingDuringForwardChaining() throws InterruptedExcept assertNotNull(aBindingSetHandler.getBindingSet()); assertTrue(!aBindingSetHandler.getBindingSet().isEmpty()); - System.out.println("Result: " + aBindingSetHandler.getBindingSet()); + LOG.info("Result: {}", aBindingSetHandler.getBindingSet()); } /** @@ -418,7 +418,7 @@ public void testBackwardChainingDuringForwardChainingIfPartialMatch() store.printGraphVizCode(rn); - System.out.println(rn); + LOG.info("{}", rn); BindingSet bs = new BindingSet(); bs.addAll(new Table(new String[] { // @formatter:off @@ -435,7 +435,7 @@ public void testBackwardChainingDuringForwardChainingIfPartialMatch() tb.executeScheduledTasks().get(); } - System.out.println(aBindingSetHandler1.getBindingSet()); + LOG.info("{}", aBindingSetHandler1.getBindingSet()); assertTrue(!aBindingSetHandler1.getBindingSet().isEmpty()); assertEquals(aBindingSetHandler1.getBindingSet().size(), 1); } @@ -482,7 +482,7 @@ public void testBackwardChainingDuringForwardChainingIfPartialWithTwoStages() store.printGraphVizCode(rn); - System.out.println(rn); + LOG.info("{}", rn); BindingSet bs = new BindingSet(); bs.addAll(new Table(new String[] { // @formatter:off @@ -499,7 +499,7 @@ public void testBackwardChainingDuringForwardChainingIfPartialWithTwoStages() tb.executeScheduledTasks().get(); } - System.out.println(aBindingSetHandler1.getBindingSet()); + LOG.info("{}", aBindingSetHandler1.getBindingSet()); assertTrue(!aBindingSetHandler1.getBindingSet().isEmpty()); assertEquals(aBindingSetHandler1.getBindingSet().size(), 1); } @@ -644,14 +644,14 @@ public CompletableFuture handle(BindingSet bs) { store.addRule(aStartRule); ReasonerPlan rn = new ReasonerPlan(store, aStartRule); - System.out.println(rn); + LOG.info("{}", rn); TaskBoard tb; while ((tb = rn.execute(bs)).hasTasks()) { tb.executeScheduledTasks().get(); } - System.out.println(aBindingSetHandler1.getBindingSet()); + LOG.info("{}", aBindingSetHandler1.getBindingSet()); assertNotNull(aBindingSetHandler1.getBindingSet()); assertFalse(aBindingSetHandler1.getBindingSet().isEmpty()); } @@ -744,7 +744,7 @@ public void testCorrectlyCombineMultipleNeighbors() throws InterruptedException, } BindingSet bindingSet2 = aSinkBindingSetHandler.getBindingSet(); - System.out.println(bindingSet2); + LOG.info("{}", bindingSet2); Binding e1 = new Binding("o4", ""); e1.put("s4", ""); diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/FundamentalErrorTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/FundamentalErrorTest.java index d4930ada..1e3550f7 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/FundamentalErrorTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/FundamentalErrorTest.java @@ -9,6 +9,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.reasoner.ProactiveRule; import eu.knowledge.engine.reasoner.ReasonerPlan; @@ -23,13 +25,15 @@ /** * This fundamental error occurs when the matches do not contain all possible - * matches, but for example only the biggest once. + * matches, but for example only the biggest one. * * @author nouwtb * */ public class FundamentalErrorTest { + private static final Logger LOG = LoggerFactory.getLogger(FundamentalErrorTest.class); + private static RuleStore store; @BeforeAll @@ -86,7 +90,7 @@ public void testFundamentalError() throws InterruptedException, ExecutionExcepti BindingSet bind = plan.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertFalse(bind.isEmpty()); } diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/JenaRDFSRulesTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/JenaRDFSRulesTest.java index 40226a74..14f089d0 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/JenaRDFSRulesTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/JenaRDFSRulesTest.java @@ -53,7 +53,7 @@ public void test() throws InterruptedException, ExecutionException, ParseExcepti Set rdfsRules = JenaRules.convertJenaToKeRules(readRuleFile()); for (BaseRule br : rdfsRules) { - LOG.info("{}", br); + LOG.debug("{}", br); } RuleStore rs = new RuleStore(); @@ -105,7 +105,7 @@ public void test() throws InterruptedException, ExecutionException, ParseExcepti LOG.info("------------------------"); while (iter.hasNext()) { Statement st = iter.next(); - LOG.info("{}", st); + LOG.debug("{}", st); } iter.close(); diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/MinimalTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/MinimalTest.java index caee7987..6f98adb1 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/MinimalTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/MinimalTest.java @@ -12,6 +12,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.reasoner.api.Binding; import eu.knowledge.engine.reasoner.api.BindingSet; @@ -25,6 +27,8 @@ public class MinimalTest { private RuleStore store; + private static final Logger LOG = LoggerFactory.getLogger(MinimalTest.class); + @BeforeAll public void init() throws URISyntaxException { // Initialize @@ -71,7 +75,7 @@ public void testConverter() throws InterruptedException, ExecutionException { BindingSet bind = root.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertFalse(bind.isEmpty()); } @@ -89,7 +93,7 @@ public void testConverterVariableType() throws InterruptedException, ExecutionEx // Start reasoning ReasonerPlan root = new ReasonerPlan(store, startRule); - System.out.println(root); + LOG.info("{}", root); BindingSet bs = new BindingSet(); Binding binding2 = new Binding(); @@ -103,7 +107,7 @@ public void testConverterVariableType() throws InterruptedException, ExecutionEx BindingSet bind = root.getResults(); - System.out.println("bindings: " + bind); + LOG.info("bindings: {}", bind); assertFalse(bind.isEmpty()); } } diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/PruningTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/PruningTest.java index b37103fa..37b953e8 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/PruningTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/PruningTest.java @@ -229,7 +229,7 @@ public void test() throws InterruptedException, ExecutionException { /* * while (!rn.execute(bs)) { taskboard.executeScheduledTasks().get(); } */ - System.out.println("Result: " + aBindingSetHandler.getBindingSet()); + LOG.info("Result: {}", aBindingSetHandler.getBindingSet()); assertNull(aBindingSetHandler.getBindingSet()); } diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/TaskBoardTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/TaskBoardTest.java index bb120c83..ae9d9990 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/TaskBoardTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/TaskBoardTest.java @@ -117,7 +117,7 @@ public void doReasoning() throws InterruptedException, ExecutionException { } var result = plan.getResults(); - System.out.println(result); + LOG.info("{}", result); } } diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/VerySimpleBackwardTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/VerySimpleBackwardTest.java index 7a25e901..199b6ef7 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/VerySimpleBackwardTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/VerySimpleBackwardTest.java @@ -113,7 +113,7 @@ public void doReasoning() throws InterruptedException, ExecutionException { tb.executeScheduledTasks().get(); } var result = plan.getResults(); - System.out.println(result); + LOG.info("{}", result); } } diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/BindingTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/BindingTest.java index 30ed0d47..0b8bc84b 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/BindingTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/BindingTest.java @@ -12,10 +12,13 @@ import org.apache.jena.sparql.sse.SSE; import org.apache.jena.sparql.util.FmtUtils; import org.junit.jupiter.api.Test; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BindingTest { + private static final Logger LOG = LoggerFactory.getLogger(BindingTest.class); + @Test public void testGraphPatternBindingSets() { TriplePattern t1 = new TriplePattern("?a "); @@ -33,14 +36,14 @@ public void testGraphPatternBindingSets() { gbs.add(tb1); gbs.add(tb2); - System.out.println(gbs); + LOG.info("{}", gbs); BindingSet bs = gbs.toBindingSet(); - System.out.println(bs); + LOG.info("{}", bs); TripleVarBindingSet gbsReturned = bs.toTripleVarBindingSet(aGraphPattern); - System.out.println(gbsReturned); + LOG.info("{}", gbsReturned); } @Test @@ -55,7 +58,7 @@ public void testTripleVarBinding() { tvb2.put(new TripleNode(tp2, "?s", 0), ""); tvb2.put(new TripleNode(tp2, "?v", 2), "22"); - System.out.println(tvb1.merge(tvb2)); + LOG.info("{}", tvb1.merge(tvb2)); } @Test @@ -78,7 +81,7 @@ public void testTripleVarBindingComplication() { gbs2.add(tvb2); TripleVarBindingSet merge = gbs1.merge(gbs2); - System.out.println(merge); + LOG.info("{}", merge); assertTrue(!merge.isEmpty()); @@ -108,7 +111,7 @@ public void testTripleVarBindingComplication2() { gbs2.add(tvb2); TripleVarBindingSet merge = gbs1.merge(gbs2); - System.out.println(merge); + LOG.info("{}", merge); assertTrue(!merge.isEmpty()); diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/JenaRuleConversionTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/JenaRuleConversionTest.java index 7bc7fb39..69afad85 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/JenaRuleConversionTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/JenaRuleConversionTest.java @@ -9,6 +9,8 @@ import java.util.Set; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.reasoner.BaseRule; import eu.knowledge.engine.reasoner.JenaRDFSRulesTest; @@ -19,6 +21,8 @@ public class JenaRuleConversionTest { + private static final Logger LOG = LoggerFactory.getLogger(JenaRuleConversionTest.class); + /** * source * @@ -60,7 +64,7 @@ public void testTurtleToKERule() { assertEquals(6, data.size()); for (Map binding : data) { - System.out.println(binding.get("s") + " " + binding.get("p") + " " + binding.get("o")); + LOG.info("{} {} {}", binding.get("s"), binding.get("p"), binding.get("o")); } } @@ -71,7 +75,7 @@ public void testTurtleToJenaRules() { String ruleString = JenaRules.createApacheJenaRulesFromTurtle(sr); - System.out.println(ruleString); + LOG.info("{}", ruleString); List jenaRules = org.apache.jena.reasoner.rulesys.Rule .parseRules(ruleString); diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/MatchTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/MatchTest.java index c5246d36..85c64de9 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/MatchTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/MatchTest.java @@ -20,6 +20,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.reasoner.BaseRule; import eu.knowledge.engine.reasoner.BaseRule.CombiMatch; @@ -32,6 +34,8 @@ @TestInstance(Lifecycle.PER_CLASS) public class MatchTest { + private static final Logger LOG = LoggerFactory.getLogger(MatchTest.class); + private List loadTriple(String aResource) { String gp = Util.getStringFromInputStream(MatchTest.class.getResourceAsStream(aResource)); @@ -58,7 +62,7 @@ public void testGPMatcher() { Rule r = new Rule(new HashSet<>(), rhs); Set findMatchesWithConsequent = r.consequentMatches(obj, EnumSet.of(MatchFlag.ONLY_BIGGEST)); - System.out.println(findMatchesWithConsequent); + LOG.info("{}", findMatchesWithConsequent); } @Test @@ -73,7 +77,7 @@ public void testGPMatcher2() { Rule r = new Rule(new HashSet<>(), rhs); Set findMatchesWithConsequent = r.consequentMatches(obj, EnumSet.of(MatchFlag.ONLY_BIGGEST)); - System.out.println(findMatchesWithConsequent); + LOG.info("{}", findMatchesWithConsequent); } @Test @@ -90,7 +94,7 @@ public void testGPMatcher3() { Rule r = new Rule(new HashSet<>(), rhs); Set findMatchesWithConsequent = r.consequentMatches(obj, EnumSet.of(MatchFlag.ONLY_BIGGEST)); - System.out.println(findMatchesWithConsequent); + LOG.info("{}", findMatchesWithConsequent); } @Test @@ -107,7 +111,7 @@ public void testGPMatcher4() { // there should be a match, but its mapping should be empty nothing needs to // happen to translate one to the other. - System.out.println(findMatchesWithConsequent); + LOG.info("{}", findMatchesWithConsequent); } @Test @@ -124,7 +128,7 @@ public void testGPMatcher5() { // there should be a match and its mapping should be empty because nothing needs // to happen to translate one to the other. - System.out.println(findMatchesWithConsequent); + LOG.info("{}", findMatchesWithConsequent); } @Test @@ -141,7 +145,7 @@ public void testGPMatcher6() { Rule r = new Rule(new HashSet<>(), rhs); Set findMatchesWithConsequent = r.consequentMatches(obj, EnumSet.of(MatchFlag.ONLY_BIGGEST)); - System.out.println(findMatchesWithConsequent); + LOG.info("{}", findMatchesWithConsequent); } @Test @@ -169,10 +173,10 @@ public void testGPMatcher7() { Set findMatchesWithConsequent = r.antecedentMatches(obj, EnumSet.of(MatchFlag.ONLY_BIGGEST, MatchFlag.FULLY_COVERED)); - System.out.println("Size: " + findMatchesWithConsequent.size()); + LOG.info("Size: {}", findMatchesWithConsequent.size()); for (Match m : findMatchesWithConsequent) { - System.out.println(m.getMappings()); + LOG.info("{}", m.getMappings()); } } @@ -191,7 +195,7 @@ public void testGPMatcher8() { Rule r = new Rule(new HashSet<>(), tp2); Set findMatchesWithConsequent = r.consequentMatches(tp1, EnumSet.of(MatchFlag.ONLY_BIGGEST)); - System.out.println(findMatchesWithConsequent); + LOG.info("{}", findMatchesWithConsequent); } @Test @@ -209,7 +213,7 @@ public void testGPMatcher9() { Rule r = new Rule(new HashSet<>(), tp2); Set findMatchesWithConsequent = r.consequentMatches(tp1, EnumSet.of(MatchFlag.ONLY_BIGGEST)); - System.out.println(findMatchesWithConsequent); + LOG.info("{}", findMatchesWithConsequent); } @Test @@ -237,12 +241,12 @@ public void testMatchObjects() { // should correctly create a combined match (because no conflict) Match m3 = m1.merge(m2); - System.out.println("Match: " + m3); + LOG.info("Match: {}", m3); // should correctly create the same combined match as previous merge (because // merge should be symmetrical) Match m4 = m2.merge(m1); - System.out.println("Match: " + m4); + LOG.info("Match: {}", m4); Map mapping3 = new HashMap(); mapping3.put(new TripleNode(tp1_1, SSE.parseNode("?p"), 0), new TripleNode(tp2_3, SSE.parseNode("?s"), 0)); @@ -252,7 +256,7 @@ public void testMatchObjects() { // conflict, so should be null Match m6 = m5.merge(m1); - System.out.println("Match: " + m6); + LOG.info("Match: {}", m6); } @Test @@ -277,15 +281,15 @@ public void testGPMatcher10OrderingWithinGraphPatternsShouldNotMatter() { Set findMatchesWithConsequent2 = r2.consequentMatches(obj2, EnumSet.of(MatchFlag.ONE_TO_ONE, MatchFlag.ONLY_BIGGEST)); - System.out.println("Size 1: " + findMatchesWithConsequent.size()); - System.out.println(findMatchesWithConsequent); - System.out.println("Size 2: " + findMatchesWithConsequent2.size()); - System.out.println(findMatchesWithConsequent2); + LOG.info("Size 1: {}", findMatchesWithConsequent.size()); + LOG.info("{}", findMatchesWithConsequent); + LOG.info("Size 2: {}", findMatchesWithConsequent2.size()); + LOG.info("{}", findMatchesWithConsequent2); assertTrue(findMatchesWithConsequent.size() == findMatchesWithConsequent2.size()); for (Match m : findMatchesWithConsequent) { - System.out.println(m.getMappings()); + LOG.info("{}", m.getMappings()); } } @@ -312,15 +316,15 @@ public void testGPMatcher11VariableNamesMatter() { Set findMatchesWithConsequent2 = r2.consequentMatches(obj2, EnumSet.of(MatchFlag.ONE_TO_ONE, MatchFlag.ONLY_BIGGEST)); - System.out.println("Size 1: " + findMatchesWithConsequent.size()); - System.out.println(findMatchesWithConsequent); - System.out.println("Size 2: " + findMatchesWithConsequent2.size()); - System.out.println(findMatchesWithConsequent2); + LOG.info("Size 1: {}", findMatchesWithConsequent.size()); + LOG.info("{}", findMatchesWithConsequent); + LOG.info("Size 2: {}", findMatchesWithConsequent2.size()); + LOG.info("{}", findMatchesWithConsequent2); assertTrue(findMatchesWithConsequent.size() == findMatchesWithConsequent2.size()); for (Match m : findMatchesWithConsequent) { - System.out.println(m.getMappings()); + LOG.info("{}", m.getMappings()); } } @@ -346,19 +350,14 @@ public void testGPMatcher12() { new HashSet<>(Arrays.asList(/* t1, */ t5, t9, t8, t7, t6, t4, t3)), EnumSet.of(MatchFlag.ONLY_BIGGEST, MatchFlag.FULLY_COVERED, MatchFlag.ONE_TO_ONE)); - System.out.println("Size: " + findMatchesWithAntecedent.size()); -// System.out.println(findMatchesWithConsequent); - + LOG.info("Size: {}", findMatchesWithAntecedent.size()); int count = 0; for (Match m : findMatchesWithAntecedent) { -// System.out.println(m.getMatchingPatterns()); if (m.getMatchingPatterns().size() == 3) { count++; } } -// System.out.println("Number of 3 size matches: " + count); - } @Test @@ -434,8 +433,8 @@ public void testGPMatcherCardinalityTest() { Set findMatchesWithConsequent = r.consequentMatches(new HashSet<>(Arrays.asList(graphPattern)), EnumSet.of(MatchFlag.ONE_TO_ONE)); - System.out.println("graph pattern size " + gpSize + " gives matches size " - + findMatchesWithConsequent.size() + "-" + getNumberOfMatches(gpSize)); + LOG.info("graph pattern size {} gives matches size {} - {}", + + gpSize, findMatchesWithConsequent.size(), getNumberOfMatches(gpSize)); assertEquals(findMatchesWithConsequent.size(), getNumberOfMatches(gpSize)); } } @@ -490,7 +489,7 @@ public void testBugTranslate() { var nBs = tvbs.translate(rhs, findMatchesWithConsequent).values().iterator().next(); - System.out.println(nBs); + LOG.info("{}", nBs); assertTrue(nBs.isEmpty()); } @@ -513,7 +512,7 @@ public void testOtherBugTranslate() { var nBs = tvbs.translate(rhs, findMatchesWithConsequent); - System.out.println(nBs); + LOG.info("{}", nBs); assertTrue(!nBs.isEmpty()); } @@ -555,7 +554,7 @@ public void testTranslateEmptyBindingSet() { tvbs1 = tvbs1.merge(aBS); } - System.out.println("BindingSet: " + tvbs1); + LOG.info("BindingSet: {}", tvbs1); assertTrue(tvbs1.isEmpty()); } @@ -595,17 +594,17 @@ public void testPloutosGPMatcher() { @Override public CompletableFuture handle(BindingSet aBindingSet) { - System.out.println("bla"); + LOG.info("bla"); return null; } }); - System.out.println("NrOfMatches with " + obj.size() + " triple patterns: " + getNumberOfMatches(obj.size())); + LOG.info("NrOfMatches with {} triple patterns: {}", obj.size(), getNumberOfMatches(obj.size())); Set findMatchesWithAntecedent = r.antecedentMatches(obj, EnumSet.of(MatchFlag.ONLY_BIGGEST, MatchFlag.FULLY_COVERED)); - System.out.println("Size: " + findMatchesWithAntecedent.size()); + LOG.info("Size: {}", findMatchesWithAntecedent.size()); } @@ -672,12 +671,12 @@ public void testPloutosGPMatcher2() { BaseRule r2 = new Rule(new HashSet<>(), obj2); - System.out.println("NrOfMatches with " + obj.size() + " triple patterns: " + getNumberOfMatches(obj.size())); + LOG.info("NrOfMatches with {} triple patterns: {}", obj.size(), getNumberOfMatches(obj.size())); var findMatchesWithConsequent = BaseRule.getMatches(r1, new HashSet<>(Arrays.asList(r2)), true, EnumSet.of(MatchFlag.ONE_TO_ONE, MatchFlag.ONLY_BIGGEST, MatchFlag.FULLY_COVERED)); - System.out.println("Size: " + findMatchesWithConsequent.size()); + LOG.info("Size: {}", findMatchesWithConsequent.size()); assertEquals(1, findMatchesWithConsequent.size()); } @@ -699,7 +698,7 @@ public void testNewGPMatcher1() { var matches = BaseRule.getMatches(r1, new HashSet<>(Arrays.asList(r2)), true, EnumSet.of(MatchFlag.ONE_TO_ONE, MatchFlag.ONLY_BIGGEST)); - System.out.println(matches); + LOG.info("{}", matches); assertEquals(matches.size(), 2); } @@ -720,7 +719,7 @@ public void testNewGPMatcherTransitivity() { var matches = BaseRule.getMatches(r1, new HashSet<>(Arrays.asList(r2)), true, EnumSet.of(MatchFlag.ONLY_BIGGEST)); - System.out.println(matches); + LOG.info("{}", matches); assertEquals(1, matches.size()); } @@ -741,7 +740,7 @@ public void testNewGPMatcher2() { var matches = BaseRule.getMatches(r1, new HashSet<>(Arrays.asList(r2)), true, EnumSet.noneOf(MatchFlag.class)); - System.out.println(matches); + LOG.info("{}", matches); assertEquals(7, matches.size()); } @@ -790,7 +789,7 @@ public java.util.concurrent.CompletableFuture handle(BindingSet aBindingSe Set combiMatches = BaseRule.getMatches(target, someCandidateRules, false, EnumSet.of(MatchFlag.ONE_TO_ONE, MatchFlag.ONLY_BIGGEST, MatchFlag.SINGLE_RULE)); - System.out.println("Size: " + combiMatches.size()); + LOG.info("Size: {}", combiMatches.size()); assertEquals(2, combiMatches.size()); } diff --git a/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/ReasoningPlanTest.java b/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/ReasoningPlanTest.java index 701849cd..04966689 100644 --- a/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/ReasoningPlanTest.java +++ b/reasoner/src/test/java/eu/knowledge/engine/reasoner/api/ReasoningPlanTest.java @@ -9,6 +9,8 @@ import java.util.concurrent.ExecutionException; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.reasoner.BaseRule; import eu.knowledge.engine.reasoner.ProactiveRule; @@ -23,6 +25,8 @@ public class ReasoningPlanTest { private static final String TEST_RULES = "/reasoningplantest.rls"; + private static final Logger LOG = LoggerFactory.getLogger(ReasoningPlanTest.class); + @Test public void test() throws IOException, InterruptedException, ExecutionException { @@ -89,7 +93,7 @@ public void test() throws IOException, InterruptedException, ExecutionException BindingSet bs = plan.getResults(); - System.out.println(bs); + LOG.info("{}", bs); assertEquals(2, bs.size()); } diff --git a/smart-connector-api/src/main/java/eu/knowledge/engine/smartconnector/api/GraphPattern.java b/smart-connector-api/src/main/java/eu/knowledge/engine/smartconnector/api/GraphPattern.java index 3ad05085..1b85b5fc 100644 --- a/smart-connector-api/src/main/java/eu/knowledge/engine/smartconnector/api/GraphPattern.java +++ b/smart-connector-api/src/main/java/eu/knowledge/engine/smartconnector/api/GraphPattern.java @@ -130,9 +130,6 @@ public ElementPathBlock getGraphPattern() { } private ElementPathBlock parseGraphPattern(PrefixMapping prefixes, String pattern) throws ParseException { - - LOG.trace("prefixes: {}- pattern: {}", prefixes, pattern); - ElementGroup eg; String queryString = "SELECT * {" + pattern + "}"; @@ -141,7 +138,6 @@ private ElementPathBlock parseGraphPattern(PrefixMapping prefixes, String patter QueryFactory.parse(query, queryString, null, Syntax.defaultQuerySyntax); Element e = query.getQueryPattern(); - LOG.trace("parsed knowledge: {}", e); eg = (ElementGroup) e; Element last = eg.getLast(); diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerIncludeMetaKIs.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerIncludeMetaKIs.java index 63bf6036..4d8bf01c 100644 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerIncludeMetaKIs.java +++ b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerIncludeMetaKIs.java @@ -14,6 +14,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.rest.RestServerHelper; import eu.knowledge.engine.test_utils.AsyncTester; @@ -28,6 +30,8 @@ public class TestAskAnswerIncludeMetaKIs { private final RestServerHelper rsh = new RestServerHelper(); private static int PORT = 8280; + private static final Logger LOG = LoggerFactory.getLogger(TestAskAnswerIncludeMetaKIs.class); + @BeforeAll public void setUpServer() { rsh.start(PORT); @@ -99,7 +103,7 @@ public void run() { Map.of("Knowledge-Base-Id", "https://www.example.org/example/metadataAsker", "Knowledge-Interaction-Id", "https://www.example.org/example/metadataAsker/interaction/askMetadataWithIncludeMetaKIs", "Content-Type", "application/json", "Accept", "*/*")); - System.out.println("Result is:" + askAskKiWithIncludeMetaKIs.getBody()); + LOG.info("Result is: {}", askAskKiWithIncludeMetaKIs.getBody()); JsonReader jsonReader = Json.createReader(new StringReader(askAskKiWithIncludeMetaKIs.getBody())); JsonObject jsonRoot = jsonReader.readObject(); @@ -111,7 +115,7 @@ public void run() { Map.of("Knowledge-Base-Id", "https://www.example.org/example/metadataAsker", "Knowledge-Interaction-Id", "https://www.example.org/example/metadataAsker/interaction/askMetadataWithoutIncludeMetaKIs", "Content-Type", "application/json", "Accept", "*/*")); - System.out.println("Result is:" + askAskKiWithoutIncludeMetaKIs.getBody()); + LOG.info("Result is: {}", askAskKiWithoutIncludeMetaKIs.getBody()); jsonReader = Json.createReader(new StringReader(askAskKiWithoutIncludeMetaKIs.getBody())); jsonRoot = jsonReader.readObject(); jsonBindingSet = jsonRoot.getJsonArray("bindingSet"); @@ -122,7 +126,7 @@ public void run() { Map.of("Knowledge-Base-Id", "https://www.example.org/example/metadataAsker", "Knowledge-Interaction-Id", "https://www.example.org/example/metadataAsker/interaction/askMetadataWithIncludeMetaKIsDisabled", "Content-Type", "application/json", "Accept", "*/*")); - System.out.println("Result is:" + askAskKiWithIncludeMetaKIsDisabled.getBody()); + LOG.info("Result is: {}", askAskKiWithIncludeMetaKIsDisabled.getBody()); jsonReader = Json.createReader(new StringReader(askAskKiWithIncludeMetaKIsDisabled.getBody())); jsonRoot = jsonReader.readObject(); jsonBindingSet = jsonRoot.getJsonArray("bindingSet"); diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerReactWithGapsEnabled.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerReactWithGapsEnabled.java index 9e8bcccc..15fb0fd9 100644 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerReactWithGapsEnabled.java +++ b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerReactWithGapsEnabled.java @@ -16,6 +16,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.rest.RestServerHelper; import eu.knowledge.engine.test_utils.AsyncTester; @@ -32,6 +34,8 @@ public class TestAskAnswerReactWithGapsEnabled { private final RestServerHelper rsh = new RestServerHelper(); private static int PORT = 8280; + + private static final Logger LOG = LoggerFactory.getLogger(TestAskAnswerReactWithGapsEnabled.class); @BeforeAll public void setUpServer() { @@ -99,7 +103,7 @@ public void run() { builder.add("bindingSet", bs); JsonObject jo2 = builder.build(); String body = jo2.toString(); - System.out.println("Handle an answer to a request with body: " + body); + LOG.info("Handle an answer to a request with body: {}", body); // fire the POST handle to execute the answer var test2 = new HttpTester(new URL(url.toString() + "/sc/handle"), "POST", body, @@ -141,7 +145,7 @@ public void run() { KBReady.countDown(); - System.out.println("Getting the handle for the reactKBId"); + LOG.info("Getting the handle for the reactKBId"); // get the handle for the reactKB to see if there are requests to be handled => // NOTE: it should never exit/return this handle for this test var test = new HttpTester(new URL(url.toString() + "/sc/handle"), "GET", null, Map @@ -159,7 +163,7 @@ public void run() { builder.add("bindingSet", JsonObject.EMPTY_JSON_ARRAY); JsonObject jo2 = builder.build(); String body = jo2.toString(); - System.out.println("Handle a react to a request with body: " + body); + LOG.info("Handle a react to a request with body: {}", body); // fire the POST handle to execute the react var test2 = new HttpTester(new URL(url.toString() + "/sc/handle"), "POST", body, @@ -201,7 +205,7 @@ public void run() { "https://www.example.org/example/relationAsker/interaction/askRelations", "Content-Type", "application/json", "Accept", "*/*")); var result = askKiWithoutGapsEnabled.getBody(); - System.out.println("Result is:" + result); + LOG.info("Result is: {}", result); JsonObject jsonObject = Json.createReader(new StringReader(result)).readObject(); JsonArray knowledgeGapsArray = jsonObject.getJsonArray("knowledgeGaps"); diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerWithGapsEnabled.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerWithGapsEnabled.java index d9c625ce..af7b4272 100644 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerWithGapsEnabled.java +++ b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerWithGapsEnabled.java @@ -14,6 +14,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.rest.RestServerHelper; import eu.knowledge.engine.test_utils.AsyncTester; @@ -29,6 +31,8 @@ public class TestAskAnswerWithGapsEnabled { private final RestServerHelper rsh = new RestServerHelper(); private static int PORT = 8280; + private static final Logger LOG = LoggerFactory.getLogger(TestAskAnswerWithGapsEnabled.class); + @BeforeAll public void setUpServer() { rsh.start(PORT); @@ -85,7 +89,7 @@ public void run() { builder.add("bindingSet", bs); JsonObject jo2 = builder.build(); String body = jo2.toString(); - System.out.println("Handle an answer to a request with body: " + body); + LOG.info("Handle an answer to a request with body: {}", body); // fire the POST handle to execute the answer var test2 = new HttpTester(new URL(url.toString() + "/sc/handle"), "POST", body, @@ -122,7 +126,7 @@ public void run() { "https://www.example.org/example/relationAsker/interaction/askRelations", "Content-Type", "application/json", "Accept", "*/*")); var result = askKiWithoutGapsEnabled.getBody(); - System.out.println("Result is:" + result); + LOG.info("Result is: {}", result); assertTrue(result.contains("\"knowledgeGaps\":[[\"?a ?c\"]]")); } diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerWithGapsEnabledNoGaps.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerWithGapsEnabledNoGaps.java index 2c4e0490..5710e4a3 100644 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerWithGapsEnabledNoGaps.java +++ b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskAnswerWithGapsEnabledNoGaps.java @@ -14,6 +14,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.rest.RestServerHelper; import eu.knowledge.engine.test_utils.AsyncTester; @@ -29,6 +31,8 @@ public class TestAskAnswerWithGapsEnabledNoGaps { private final RestServerHelper rsh = new RestServerHelper(); private static int PORT = 8280; + private static final Logger LOG = LoggerFactory.getLogger(TestAskAnswerWithGapsEnabledNoGaps.class); + @BeforeAll public void setUpServer() { rsh.start(PORT); @@ -85,7 +89,7 @@ public void run() { builder.add("bindingSet", bs); JsonObject jo2 = builder.build(); String body = jo2.toString(); - System.out.println("Handle an answer to a request with body: " + body); + LOG.info("Handle an answer to a request with body: {}", body); // fire the POST handle to execute the answer var test2 = new HttpTester(new URL(url.toString() + "/sc/handle"), "POST", body, @@ -122,7 +126,7 @@ public void run() { "https://www.example.org/example/relationAsker/interaction/askRelations", "Content-Type", "application/json", "Accept", "*/*")); var result = askKiWithoutGapsEnabled.getBody(); - System.out.println("Result is:" + result); + LOG.info("Result is: {}", result); assertTrue(result.contains("\"knowledgeGaps\":[]")); } diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskWithGapsEnabled.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskWithGapsEnabled.java index 424ed258..bb2aadbd 100644 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskWithGapsEnabled.java +++ b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskWithGapsEnabled.java @@ -10,6 +10,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.rest.RestServerHelper; import eu.knowledge.engine.test_utils.HttpTester; @@ -19,6 +21,8 @@ public class TestAskWithGapsEnabled { private final RestServerHelper rsh = new RestServerHelper(); private static int PORT = 8280; + private static final Logger LOG = LoggerFactory.getLogger(TestAskWithGapsEnabled.class); + @BeforeAll public void setUpServer() { rsh.start(PORT); @@ -56,7 +60,7 @@ public void testAskWithGaps() throws IOException { "https://www.example.org/example/relationAsker/interaction/askRelations", "Content-Type", "application/json", "Accept", "*/*")); var result = askKiWithoutGapsEnabled.getBody(); - System.out.println("Result is:" + result); + LOG.info("Result is: {}", result); assertTrue(result.contains("\"knowledgeGaps\":[[\"?a ?b\"]]")); } diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskWithGapsNotEnabled.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskWithGapsNotEnabled.java index 7468ce63..4044ed0f 100644 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskWithGapsNotEnabled.java +++ b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestAskWithGapsNotEnabled.java @@ -11,6 +11,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.rest.RestServerHelper; import eu.knowledge.engine.test_utils.HttpTester; @@ -20,6 +22,8 @@ public class TestAskWithGapsNotEnabled { private final RestServerHelper rsh = new RestServerHelper(); private static int PORT = 8280; + private static final Logger LOG = LoggerFactory.getLogger(TestAskWithGapsNotEnabled.class); + @BeforeAll public void setUpServer() { rsh.start(PORT); @@ -57,7 +61,7 @@ public void testAskWithoutGaps() throws IOException { "https://www.example.org/example/relationAsker/interaction/askRelations", "Content-Type", "application/json", "Accept", "*/*")); var result = askKiWithoutGapsEnabled.getBody(); - System.out.println("Result is:" + result); + LOG.info("Result is: {}", result); assertFalse(result.contains("\"knowledgeGaps\":")); } diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestDomainKnowledge.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestDomainKnowledge.java index 379ede76..2c0df2ba 100644 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestDomainKnowledge.java +++ b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestDomainKnowledge.java @@ -8,6 +8,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.rest.RestServerHelper; import eu.knowledge.engine.test_utils.HttpTester; @@ -17,6 +19,8 @@ public class TestDomainKnowledge { private final RestServerHelper rsh = new RestServerHelper(); private static int PORT = 8280; + private static final Logger LOG = LoggerFactory.getLogger(TestDomainKnowledge.class); + @BeforeAll public void setUpServer() { rsh.start(PORT); @@ -55,13 +59,13 @@ public void testDomainKnowledge() throws IOException { addDomainKnowledge = new HttpTester(new URL(url + "/sc/knowledge"), "POST", domainKnowledgeRules, Map.of("Knowledge-Base-Id", "http://example.org/kb", "Content-Type", "text/plain", "Accept", "*/*")); addDomainKnowledge.expectStatus(400); - System.out.println("Body: " + addDomainKnowledge.getBody()); + LOG.info("Body: {}", addDomainKnowledge.getBody()); // remove all domain knowledge addDomainKnowledge = new HttpTester(new URL(url + "/sc/knowledge"), "POST", null, Map.of("Knowledge-Base-Id", "http://example.org/kb", "Content-Type", "text/plain", "Accept", "*/*")); addDomainKnowledge.expectStatus(200); - System.out.println("Body: " + addDomainKnowledge.getBody()); + LOG.info("Body: {}", addDomainKnowledge.getBody()); } diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestPostMemoryLeak.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestPostMemoryLeak.java index bf1d5afe..58f3996f 100644 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestPostMemoryLeak.java +++ b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestPostMemoryLeak.java @@ -14,6 +14,8 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.knowledge.engine.rest.RestServerHelper; import eu.knowledge.engine.test_utils.AsyncTester; @@ -31,6 +33,8 @@ public class TestPostMemoryLeak { private static int PORT = 8280; private URL url; + private static final Logger LOG = LoggerFactory.getLogger(TestPostMemoryLeak.class); + @BeforeAll public void setUpServer() throws InterruptedException { rsh.start(PORT); @@ -77,7 +81,6 @@ public void run() { var test = new HttpTester(new URL(url.toString() + "/handle"), "GET", null, Map .of("Knowledge-Base-Id", kb2Id, "Content-Type", "application/json", "Accept", "*/*")); test.expectStatus(200); -// System.out.println("Body: " + test.getBody()); if (Math.random() > 0.95) { JsonReader jp = Json.createReader(new StringReader(test.getBody())); @@ -91,7 +94,7 @@ public void run() { String body = jo2.toString(); - System.out.println("Body2: " + body); + LOG.info("Body2: {}", body); var test2 = new HttpTester(new URL(url.toString() + "/handle"), "POST", body, Map.of("Knowledge-Base-Id", kb2Id, "Knowledge-Interaction-Id", kiId, "Content-Type", @@ -139,7 +142,7 @@ public void run() { while (true) { counter++; Thread.sleep(SLEEPTIME); - System.out.println("post data"); + LOG.info("post data"); new AsyncTester(new Runnable() { @Override public void run() { @@ -157,7 +160,7 @@ public void run() { """, Map.of("Content-Type", "application/json", "Accept", "*/*", "Knowledge-Base-Id", kb1Id, "Knowledge-Interaction-Id", kiId)); test.expectStatus(200); - System.out.println("finshed posting: " + test.getBody()); + LOG.info("finshed posting: {}", test.getBody()); } catch (MalformedURLException e) { fail(); } diff --git a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestSuspendedKnowledgeBase.java b/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestSuspendedKnowledgeBase.java deleted file mode 100644 index cd1da655..00000000 --- a/smart-connector-rest-dist/src/test/java/eu/knowledge/engine/rest/api/TestSuspendedKnowledgeBase.java +++ /dev/null @@ -1,137 +0,0 @@ -package eu.knowledge.engine.rest.api; - -import eu.knowledge.engine.rest.RestServerHelper; -import eu.knowledge.engine.test_utils.AsyncTester; -import eu.knowledge.engine.test_utils.HttpTester; -import org.junit.jupiter.api.*; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; -import java.util.concurrent.CountDownLatch; - -@Disabled -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class TestSuspendedKnowledgeBase { - int NUM_UNHANDLED_REQUESTS = 5; - CountDownLatch latch = new CountDownLatch(NUM_UNHANDLED_REQUESTS); - private final RestServerHelper rsh = new RestServerHelper(); - private static final int PORT = 8280; - - @BeforeAll - public void setUpServer() { - rsh.start(PORT); - } - - @Test - public void testSuspendingKnowledgeBase() throws MalformedURLException { - URL url = new URL("http://localhost:" + PORT + "/rest"); - HttpTester registerKb = new HttpTester(new URL(url + "/sc"), "POST", - "{\"knowledgeBaseId\": \"http://example.org/kb1\", " + "\"knowledgeBaseName\": \"KB1\", " - + "\"knowledgeBaseDescription\": \"KB1\"}", - Map.of("Content-Type", "application/json", "Accept", "*/*")); - registerKb.expectStatus(200); - HttpTester registerKb2 = new HttpTester(new URL(url + "/sc"), "POST", - "{\"knowledgeBaseId\": \"http://example.org/kb2\", " + "\"knowledgeBaseName\": \"KB2\", " - + "\"knowledgeBaseDescription\": \"KB2\"}", - Map.of("Content-Type", "application/json", "Accept", "*/*")); - registerKb2.expectStatus(200); - - var sc1 = new AsyncTester(() -> { - try { - HttpTester registerAsk = new HttpTester(new URL(url + "/sc/ki"), "POST", - "{\"knowledgeInteractionType\": \"AskKnowledgeInteraction\", " - + "\"knowledgeInteractionName\": \"ask\"," + "\"graphPattern\": \"?a ?b ?c.\"}", - Map.of("Knowledge-Base-Id", "http://example.org/kb1", "Content-Type", "application/json", - "Accept", "*/*")); - registerAsk.expectStatus(200); - System.out.println("Registered Ask"); - HttpTester executeAsk = new HttpTester(new URL(url + "/sc/ask"), "POST", "[{}]", - Map.of("Knowledge-Base-Id", "http://example.org/kb1", "Knowledge-Interaction-Id", - "http://example.org/kb1/interaction/ask", "Content-Type", "application/json", "Accept", - "*/*")); - System.out.println("Executing Ask"); - var body = executeAsk.getBody(); - System.out.println(body); - - for (int i = 0; i < NUM_UNHANDLED_REQUESTS; i++) { - System.out.println("Making another ask"); - new AsyncTester(() -> { - HttpTester executeAsk1; - try { - executeAsk1 = new HttpTester(new URL(url + "/sc/ask"), "POST", "[{}]", - Map.of("Knowledge-Base-Id", "http://example.org/kb1", "Knowledge-Interaction-Id", - "http://example.org/kb1/interaction/ask", "Content-Type", - "application/json", "Accept", "*/*")); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - System.out.println("Executing Ask"); - latch.countDown(); - var body1 = executeAsk1.getBody(); - System.out.println(body1); - }).start(); - } - } catch (MalformedURLException e) { - System.err.println(e.getMessage()); - } - }); - - var sc2 = new AsyncTester(() -> { - try { - HttpTester registerAnswer = new HttpTester(new URL(url + "/sc/ki"), "POST", - "{\"knowledgeInteractionType\": \"AnswerKnowledgeInteraction\", " - + "\"knowledgeInteractionName\": \"answer\"," + "\"graphPattern\": \"?a ?b ?c.\"}", - Map.of("Knowledge-Base-Id", "http://example.org/kb2", "Content-Type", "application/json", - "Accept", "*/*")); - registerAnswer.expectStatus(200); - System.out.println("Registered Answer"); - - HttpTester waitForRequest = new HttpTester(new URL(url + "/sc/handle"), "GET", null, - Map.of("Knowledge-Base-Id", "http://example.org/kb2", "Content-Type", "application/json", - "Accept", "*/*")); - var body = waitForRequest.getBody(); - System.out.println(body); - - System.out.println("Waiting for requests"); - var postAnswer = new HttpTester(new URL(url + "/sc/handle"), "POST", """ - { - "handleRequestId": 1, - "bindingSet": [{ - "a": "", - "b": "", - "c": "" - }] - } - """, - Map.of("Content-Type", "application/json", "Accept", "*/*", "Knowledge-Base-Id", - "http://example.org/kb2", "Knowledge-Interaction-Id", - "http://example.org/kb2/interaction/answer")); - postAnswer.getBody(); - System.out.println("Posted answer"); - - latch.await(); - - HttpTester deleteSC = new HttpTester(new URL(url + "/sc/"), "DELETE", "", Map.of("Knowledge-Base-Id", - "http://example.org/kb2", "Content-Type", "application/json", "Accept", "*/*")); - deleteSC.expectStatus(200); - } catch (MalformedURLException e) { - System.err.println(e.getMessage()); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - }); - - sc1.start(); - sc2.start(); - sc1.joinAndRethrow(); - sc2.joinAndRethrow(); - - } - - @AfterAll - public void cleanUp() { - TestUtil.unregisterAllKBs("http://localhost:" + PORT + "/rest"); - rsh.cleanUp(); - } -} diff --git a/smart-connector-rest-server/src/main/java/eu/knowledge/engine/rest/api/impl/ProactiveApiServiceImpl.java b/smart-connector-rest-server/src/main/java/eu/knowledge/engine/rest/api/impl/ProactiveApiServiceImpl.java index a7afc6ac..3b7ea138 100644 --- a/smart-connector-rest-server/src/main/java/eu/knowledge/engine/rest/api/impl/ProactiveApiServiceImpl.java +++ b/smart-connector-rest-server/src/main/java/eu/knowledge/engine/rest/api/impl/ProactiveApiServiceImpl.java @@ -60,14 +60,14 @@ public void scAskPost( @Parameter(description = "The keys bindings are allowed to be incomplete, but they must correspond to the binding keys that were defined in the knowledge interaction.", required = true) @NotNull @Valid JsonNode recipientAndBindingSet, @Suspended final AsyncResponse asyncResponse, @Context SecurityContext securityContext) { - LOG.debug("scAskPost called for KB {} and KI {} - {}", knowledgeBaseId, knowledgeInteractionId, + LOG.trace("scAskPost called for KB {} and KI {} - {}", knowledgeBaseId, knowledgeInteractionId, recipientAndBindingSet); RecipientAndBindingSet recipientAndBindingSetObject; try { recipientAndBindingSetObject = new RecipientAndBindingSet(recipientAndBindingSet); } catch (IllegalArgumentException e) { - LOG.debug("", e); + LOG.trace("", e); var response = new ResponseMessage(); response.setMessageType("error"); response.setMessage(e.getMessage()); @@ -126,7 +126,7 @@ public void scAskPost( askFuture.thenAccept(askResult -> { - LOG.debug("AskResult received, resuming async response: {}", askResult); + LOG.trace("AskResult received, resuming async response: {}", askResult); List infos = askResult.getExchangeInfoPerKnowledgeBase().stream() .map(aei -> new AskExchangeInfo().bindingSet(this.bindingSetToList(aei.getBindings())) .knowledgeBaseId(aei.getKnowledgeBaseId().toString()) @@ -138,15 +138,14 @@ public void scAskPost( .failedMessage(aei.getFailedMessage())) .collect(Collectors.toList()); - LOG.debug("Bindings in result is {}", askResult.getBindings()); - LOG.debug("KnowledgeGapsEnabled is {}", ki.getKnowledgeGapsEnabled()); + LOG.trace("KnowledgeGapsEnabled is {}", ki.getKnowledgeGapsEnabled()); AskResult ar = new AskResult().bindingSet(this.bindingSetToList(askResult.getBindings())) .exchangeInfo(infos); // distinguish between knowledge gaps enabled or not to produce an AskResult or // an AskResultWithGaps if (ki.getKnowledgeGapsEnabled()) { - LOG.info("Knowledge gaps in result is {}", askResult.getKnowledgeGaps()); + LOG.debug("Knowledge gaps in result is {}", askResult.getKnowledgeGaps()); ar.knowledgeGaps(this.knowledgeGapsToList(askResult.getKnowledgeGaps())); } asyncResponse.resume(Response.status(Status.OK).entity(ar).build()); @@ -221,7 +220,7 @@ public void scPostPost( @Parameter(description = "The keys bindings must be complete, and they must correspond to the binding keys that were defined in the knowledge interaction.", required = true) @NotNull @Valid JsonNode recipientAndBindingSet, @Suspended final AsyncResponse asyncResponse, @Context SecurityContext securityContext) { - LOG.debug("scPostPost called for KB {} and KI {} - {}", knowledgeBaseId, knowledgeInteractionId, + LOG.trace("scPostPost called for KB {} and KI {} - {}", knowledgeBaseId, knowledgeInteractionId, recipientAndBindingSet); RecipientAndBindingSet recipientAndBindingSetObject; @@ -288,7 +287,7 @@ public void scPostPost( postFuture.thenAccept(postResult -> { - LOG.debug("PostResult received, resuming async response: {}", postResult); + LOG.trace("PostResult received, resuming async response: {}", postResult); List infos = postResult.getExchangeInfoPerKnowledgeBase().stream() .map(pei -> new PostExchangeInfo() diff --git a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/MetaKnowledgeBaseImpl.java b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/MetaKnowledgeBaseImpl.java index 7a41691f..35d26ea5 100644 --- a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/MetaKnowledgeBaseImpl.java +++ b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/MetaKnowledgeBaseImpl.java @@ -291,14 +291,12 @@ private BindingSet fillMetaBindings(BindingSet incoming) { // then use the Knowledge Interaction as a query to retrieve the bindings. Query q = QueryFactory.create("SELECT * WHERE {" + this.convertToPattern(this.metaGraphPattern) + "}"); - LOG.trace("Query: {}", q); + QueryExecution qe = QueryExecutionFactory.create(q, m); ResultSet rs = qe.execSelect(); BindingSet bindings = new BindingSet(rs); qe.close(); - LOG.trace("BindingSet: {}", bindings); - if (incoming != null) { Util.removeRedundantBindingsAnswer(incoming, bindings); } @@ -339,7 +337,6 @@ public CompletableFuture getOtherKnowledgeBase(URI toKnowled CompletableFuture future = this.messageRouter.sendAskMessage(askMsg) .thenApply(answerMsg -> { try { - this.LOG.trace("Received message: {}", answerMsg); var answeringKi = answerMsg.getFromKnowledgeInteraction(); var itShouldBeThis = this.knowledgeBaseStore.getMetaId(toKnowledgeBaseId, KnowledgeInteractionInfo.Type.ANSWER, null); @@ -418,8 +415,6 @@ private OtherKnowledgeBase constructOtherKnowledgeBaseFromBindingSet(BindingSet assert isMeta == kiMeta.toString().contains("true") : "If the text contains 'true' (=" + kiMeta + ") then the boolean should be true."; - this.LOG.trace("meta: {} = {}", FmtUtils.stringForNode(kiMeta.asNode()), isMeta); - // retrieve acts Resource act = model.getProperty(ki, Vocab.HAS_ACT).getObject().asResource(); Resource req = model.getProperty(act, Vocab.HAS_REQ).getObject().asResource(); @@ -505,9 +500,6 @@ private OtherKnowledgeBase constructOtherKnowledgeBaseFromBindingSet(BindingSet } if (kiType.equals(Vocab.POST_KI)) { - - this.LOG.trace("{} - {}", argumentGraphPatternString, resultGraphPatternString); - PostKnowledgeInteraction postKnowledgeInteraction = new PostKnowledgeInteraction(actObject, new GraphPattern(argumentGraphPatternString), resultGraphPatternString != null ? new GraphPattern(resultGraphPatternString) : null, diff --git a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/OtherKnowledgeBaseStoreImpl.java b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/OtherKnowledgeBaseStoreImpl.java index d67b953a..5f2cb9a8 100644 --- a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/OtherKnowledgeBaseStoreImpl.java +++ b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/OtherKnowledgeBaseStoreImpl.java @@ -81,8 +81,6 @@ public CompletableFuture populate() { }); futures.add(otherKnowledgeBaseFuture); - } else { - this.LOG.trace("Skipping myself: {}", this.sc.getKnowledgeBaseId()); } } diff --git a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/ReasonerProcessor.java b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/ReasonerProcessor.java index 907af21c..7ef113d7 100644 --- a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/ReasonerProcessor.java +++ b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/ReasonerProcessor.java @@ -185,6 +185,12 @@ public CompletableFuture executeAskInteraction(BindingSet someBinding this.finalBindingSetFuture = new CompletableFuture(); // this.reasonerPlan.optimize(); + + if (this.myKnowledgeInteraction.isMeta()) + LOG.trace("Ask: {}", this.reasonerPlan); + else + LOG.debug("Ask: {}", this.reasonerPlan); + continueReasoningBackward(someBindings); return this.finalBindingSetFuture.thenApply((bs) -> { @@ -223,7 +229,6 @@ private void continueReasoningBackward(BindingSet incomingBS) { final String msg = "Executing (scheduled) tasks for the reasoner should not result in problems."; taskboard = this.reasonerPlan.execute(incomingBS); isComplete = !taskboard.hasTasks(); - LOG.trace("Ask: {}", this.reasonerPlan); taskboard.executeScheduledTasks().thenAccept(_ -> { LOG.trace("All ask tasks finished."); if (isComplete) { @@ -282,7 +287,12 @@ public CompletableFuture executePostInteraction(BindingSet someBindi this.finalBindingSetFuture = new CompletableFuture(); // this.reasonerPlan.optimize(); - + + if (this.myKnowledgeInteraction.isMeta()) + LOG.trace("Post: {}", this.reasonerPlan); + else + LOG.debug("Post: {}", this.reasonerPlan); + continueReasoningForward(someBindings, this.captureResultBindingSetHandler); return this.finalBindingSetFuture.thenApply((bs) -> { @@ -316,7 +326,6 @@ private void continueReasoningForward(BindingSet incomingBS, CaptureBindingSetHa TaskBoard taskboard; taskboard = this.reasonerPlan.execute(incomingBS); isComplete = !taskboard.hasTasks(); - LOG.trace("Post: {}", this.reasonerPlan); taskboard.executeScheduledTasks().thenAccept(_ -> { LOG.trace("All post tasks finished."); if (isComplete) { diff --git a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/Util.java b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/Util.java index 246fa7ce..c29dc1c1 100644 --- a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/Util.java +++ b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/impl/Util.java @@ -39,8 +39,6 @@ public class Util { */ public static Model generateModel(GraphPattern graphPattern, BindingSet variableBindings) throws ParseException { - LOG.trace("generating model"); - List tripleList = graphPattern.getGraphPattern().getPattern().getList(); Model m = ModelFactory.createDefaultModel(); diff --git a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnection.java b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnection.java index 83101493..f69c325f 100644 --- a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnection.java +++ b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnection.java @@ -209,7 +209,7 @@ public List getRemoteSmartConnectorIds() { } } - LOG.debug("Returning {} SCs for {}.", list.size(), this.remoteKerUri); + LOG.trace("KER '{}' has SCs: {}", this.remoteKerUri, list); return list; } diff --git a/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/AdditionForAudienceTest.java b/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/AdditionForAudienceTest.java index af568520..b3b3ce6a 100644 --- a/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/AdditionForAudienceTest.java +++ b/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/AdditionForAudienceTest.java @@ -32,7 +32,7 @@ public MyReactHandler(int aPlace) { public BindingSet react(ReactKnowledgeInteraction anRKI, ReactExchangeInfo aReactExchangeInfo) { BindingSet bs = aReactExchangeInfo.getArgumentBindings(); - System.out.println("In: " + bs); + LOG.info("In: {}", bs); BindingSet bs2 = new BindingSet(); for (Binding b : bs) { @@ -69,7 +69,7 @@ public BindingSet react(ReactKnowledgeInteraction anRKI, ReactExchangeInfo aReac } } - System.out.println("Out: " + bs2); + LOG.info("Out: {}", bs2); return bs2; } @@ -185,7 +185,7 @@ public void beforeAll() { b6.put("ad1", "\"6\""); bs.add(b6); - System.out.println(bs); + LOG.info("{}", bs); return bs; }); @@ -220,7 +220,7 @@ public void test() throws InterruptedException, ExecutionException { AskResult ar = ap.execute(new BindingSet()).get(); - System.out.println("Result: " + ar.getBindings()); + LOG.info("Result: {}", ar.getBindings()); BindingSet bs = new BindingSet(); Binding b1 = new Binding(); diff --git a/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/TestAskAnswer4.java b/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/TestAskAnswer4.java index c9631d9f..ac11d495 100644 --- a/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/TestAskAnswer4.java +++ b/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/TestAskAnswer4.java @@ -76,9 +76,8 @@ public void testAskAnswer() throws InterruptedException { AskResult result = kb2.ask(askKI, new BindingSet()).get(); bindings = result.getBindings(); - System.out.println("Bindings: " + bindings); - System.out - .println("Bindings2: " + result.getExchangeInfoPerKnowledgeBase().iterator().next().getBindings()); + LOG.info("Bindings: {}", bindings); + LOG.info("Bindings2: {}", result.getExchangeInfoPerKnowledgeBase().iterator().next().getBindings()); LOG.trace("After ask."); } catch (InterruptedException | ExecutionException e) { diff --git a/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/TestUtils.java b/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/TestUtils.java index 58ccd487..77e1423d 100644 --- a/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/TestUtils.java +++ b/smart-connector/src/test/java/eu/knowledge/engine/smartconnector/api/TestUtils.java @@ -135,7 +135,6 @@ public boolean equals(Object obj) { } RuleNode rn = plan.getStartNode(); -// System.out.println(rn.toString()); Queue queue = new LinkedList(); queue.add(rn);