This is an automated email from the ASF dual-hosted git repository. erobinet pushed a commit to branch feature/scraper in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit f8b13037427db0e042ee9163ed1a88db0dbfdb19 Author: Etienne Robinet <etienne1995robi...@gmail.com> AuthorDate: Fri May 15 12:36:25 2020 +0200 Reading with Scraper or Writing using Map<String,Map<String,Object>> --- .../src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java | 1 + .../src/main/java/org/apache/plc4x/camel/Plc4XProducer.java | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plc4j/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java b/plc4j/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java index c67f288..c81fe66 100644 --- a/plc4j/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java +++ b/plc4j/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java @@ -119,6 +119,7 @@ public class Plc4XConsumer extends DefaultConsumer { try { ScraperConfiguration configuration = getScraperConfig(validateTags()); TriggerCollector collector = new TriggerCollectorImpl(plc4XEndpoint.getPlcDriverManager()); + TriggeredScraperImpl scraper = new TriggeredScraperImpl(configuration, (job, alias, response) -> { try { Exchange exchange = plc4XEndpoint.createExchange(); diff --git a/plc4j/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XProducer.java b/plc4j/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XProducer.java index 151d83b..2325d3a 100644 --- a/plc4j/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XProducer.java +++ b/plc4j/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XProducer.java @@ -31,6 +31,7 @@ import org.apache.plc4x.java.api.messages.PlcWriteResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Iterator; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; @@ -56,16 +57,16 @@ public class Plc4XProducer extends DefaultAsyncProducer { Object body = in.getBody(); PlcWriteRequest.Builder builder = plcConnection.writeRequestBuilder(); if (body instanceof Map) { //Check if we have a Map - Map<String, Map.Entry<String, Object>> tags = (Map<String, Map.Entry<String, Object>>) body; - for (Map.Entry<String, Map.Entry<String, Object>> entry : tags.entrySet()) { - //Tags are stored like this --> Map<Tagname,Entry<Query,Value>> for writing + Map<String, Map<String, Object>> tags = (Map<String, Map<String, Object>>) body; + for (Map.Entry<String, Map<String, Object>> entry : tags.entrySet()) { + //Tags are stored like this --> Map<Tagname,Map<Query,Value>> for writing String name = entry.getKey(); - String query = entry.getValue().getKey(); - Object value = entry.getValue().getValue(); + String query = entry.getValue().keySet().iterator().next(); + Object value = entry.getValue().get(query); builder.addItem(name,query,value); } } else { - throw new PlcInvalidFieldException("Parameter 'tags' has to be a List of TagData"); + throw new PlcInvalidFieldException("The body must contain a Map<String,Map<String,Object>"); } CompletableFuture<? extends PlcWriteResponse> completableFuture = builder.build().execute();