From cc3c39501d22a7901e3f6d164d040a08c7d897a7 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Tue, 31 Dec 2019 14:44:11 +0100 Subject: Implement new query installation --- .../cloudatlas/agent/NewApiImplementation.java | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src/main') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java index c0b313d..3bedd90 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java @@ -6,8 +6,11 @@ import java.rmi.RemoteException; import java.util.concurrent.CompletableFuture; import java.util.List; +import java.util.AbstractMap.SimpleImmutableEntry; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.regex.Pattern; import java.util.regex.Matcher; @@ -16,6 +19,7 @@ import java.util.regex.Matcher; import pl.edu.mimuw.cloudatlas.agent.messages.RequestStateMessage; import pl.edu.mimuw.cloudatlas.agent.messages.ResponseMessage; import pl.edu.mimuw.cloudatlas.agent.messages.StateMessage; +import pl.edu.mimuw.cloudatlas.agent.messages.UpdateQueriesMessage; import pl.edu.mimuw.cloudatlas.interpreter.Interpreter; import pl.edu.mimuw.cloudatlas.interpreter.InterpreterException; import pl.edu.mimuw.cloudatlas.interpreter.Main; @@ -25,9 +29,10 @@ import pl.edu.mimuw.cloudatlas.model.AttributesMap; import pl.edu.mimuw.cloudatlas.model.PathName; import pl.edu.mimuw.cloudatlas.model.ValueContact; import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueNull; import pl.edu.mimuw.cloudatlas.model.ValueQuery; import pl.edu.mimuw.cloudatlas.model.ValueSet; -import pl.edu.mimuw.cloudatlas.model.ValueNull; +import pl.edu.mimuw.cloudatlas.model.ValueTime; import pl.edu.mimuw.cloudatlas.model.Type; import pl.edu.mimuw.cloudatlas.model.TypePrimitive; import pl.edu.mimuw.cloudatlas.model.ZMI; @@ -90,7 +95,6 @@ public class NewApiImplementation implements Api { } public void installQuery(String name, String queryCode) throws RemoteException { - /* Pattern queryNamePattern = Pattern.compile("&[a-zA-Z][\\w_]*"); Matcher matcher = queryNamePattern.matcher(name); if (!matcher.matches()) { @@ -99,23 +103,14 @@ public class NewApiImplementation implements Api { try { ValueQuery query = new ValueQuery(queryCode); Attribute attributeName = new Attribute(name); - installQueryInHierarchy(root, attributeName, query); - executeAllQueries(root); + ValueTime timestamp = new ValueTime(System.currentTimeMillis()); + Map> queries = new HashMap(); + queries.put(attributeName, new SimpleImmutableEntry(query, timestamp)); + UpdateQueriesMessage message = new UpdateQueriesMessage("", 0, queries); + eventBus.addMessage(message); } catch (Exception e) { throw new RemoteException("Failed to install query", e); } - */ - } - - private void installQueryInHierarchy(ZMI zmi, Attribute queryName, ValueQuery query) { - /* - if (!zmi.getSons().isEmpty()) { - zmi.getAttributes().addOrChange(queryName, query); - for (ZMI son : zmi.getSons()) { - installQueryInHierarchy(son, queryName, query); - } - } - */ } public void uninstallQuery(String queryName) throws RemoteException { -- cgit v1.2.3