m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java
index e8721b3..4694219 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java
@@ -12,6 +12,7 @@ import pl.edu.mimuw.cloudatlas.agent.messages.UpdateAttributesMessage;
import pl.edu.mimuw.cloudatlas.agent.messages.UpdateQueriesMessage;
import pl.edu.mimuw.cloudatlas.model.Attribute;
import pl.edu.mimuw.cloudatlas.model.AttributesMap;
+import pl.edu.mimuw.cloudatlas.model.AttributesUtil;
import pl.edu.mimuw.cloudatlas.model.PathName;
import pl.edu.mimuw.cloudatlas.model.Type;
import pl.edu.mimuw.cloudatlas.model.TypePrimitive;
@@ -67,7 +68,7 @@ public class Stanik extends Module {
ZMI zone = hierarchy.findDescendant(message.getPathName());
AttributesMap attributes = zone.getAttributes();
if (valueLower(attributes.get("timestamp"), message.getAttributes().get("timestamp"))) {
- transferAttributes(message.getAttributes(), attributes);
+ AttributesUtil.transferAttributes(message.getAttributes(), attributes);
} else {
System.out.println("DEBUG: not applying update with older attributes");
}
@@ -127,21 +128,6 @@ public class Stanik extends Module {
return value != null && !value.isNull() && value.getType().isCompatible(type);
}
- private void transferAttributes(AttributesMap fromAttributes, AttributesMap toAttributes) {
- Iterator<Entry<Attribute, Value>> iterator = toAttributes.iterator();
- while (iterator.hasNext()) {
- Entry<Attribute, Value> entry = iterator.next();
- Attribute attribute = entry.getKey();
- Value newValue = fromAttributes.getOrNull(attribute);
- if (newValue == null) {
- iterator.remove();
- }
- }
- for (Entry<Attribute, Value> entry : fromAttributes) {
- toAttributes.addOrChange(entry.getKey(), entry.getValue());
- }
- }
-
private void addMissingZones(PathName path) {
try {
if (!hierarchy.descendantExists(path)) {