m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-12-31 14:44:11 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-12-31 14:44:49 +0100
commitcc3c39501d22a7901e3f6d164d040a08c7d897a7 (patch)
treef0259568e07a4603b1b2d0a3698a1d1381465216 /src/main/java
parentc515a2e3d673c565a7b5c406cd3ab4a7b33e8f4e (diff)
Implement new query installation
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java27
1 files changed, 11 insertions, 16 deletions
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<Attribute, Entry<ValueQuery, ValueTime>> 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 {