- boolean checkForConflict(Node parentNode, Node currentNode, Transition currentTransition) {
- ArrayList<NameValuePair> setSet = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap().get(currentTransition);
- HashMap<String, String> valueMap = new HashMap<String, String>(); // HashMap from varName to value
- HashMap<String, Integer> writerMap = new HashMap<String, Integer>(); // HashMap from varName to appNum
-
-
- // Update the valueMap and writerMap + check for conflict between the elements of setSet
- for (int i = 0;i < setSet.size();i++) {
- NameValuePair nameValuePair = setSet.get(i);
- String varName = nameValuePair.getVarName();
- String value = nameValuePair.getValue();
- Integer appNum = nameValuePair.getAppNum();
-
- if (valueMap.containsKey(varName)) {
- // Check if we have a same writer
- if (!writerMap.get(varName).equals(appNum)) {
- // Check if we have a conflict or not
- if (!valueMap.get(varName).equals(value)) {
- errorMessage = createErrorMessage(nameValuePair, valueMap, writerMap);
- return true;
- } else { // We have two writers writing the same value
- writerMap.put(varName, 3); // 3 represents both apps
- }
- } else {
- // Check if we have more than one value with the same writer
- if (!valueMap.get(varName).equals(value)) {
- // We have one writer writing more than one value in a same event
- valueMap.put(varName, "twoValue");
- }
- }
- } else {
- valueMap.put(varName, value);
- writerMap.put(varName, appNum);
- }
- }
-
- // Check for conflict between outSet and this transition setSet
- for (NameValuePair i : parentNode.getOutSet()) {
- if (valueMap.containsKey(i.getVarName())) {
- String value = valueMap.get(i.getVarName());
- Integer writer = writerMap.get(i.getVarName());
- if ((value != null)&&(writer != null)) {
- if (!value.equals(i.getValue())&&!writer.equals(i.getAppNum())) {
- // We have different values and different writers
- errorMessage = createErrorMessage(i, valueMap, writerMap);
- return true;
- }
- }
- }
- }
-
- return false;
- }
+ boolean propagateEdge(Edge e) {
+ HashMap<IndexObject, HashSet<Update>> srcUpdates = e.getSrc().getLastUpdates();
+ HashMap<IndexObject, HashSet<Update>> dstUpdates = e.getDst().getLastUpdates();
+ ArrayList<Update> edgeUpdates = e.getUpdates();
+ HashMap<IndexObject, Update> lastupdate = new HashMap<IndexObject, Update>();
+ boolean changed = false;
+
+ //Go through each update on the current transition
+ for(int i=0; i<edgeUpdates.size(); i++) {
+ Update u = edgeUpdates.get(i);
+ IndexObject io = u.getIndex();
+ HashSet<Update> confupdates = null;
+
+ //See if we have already updated this device attribute
+ if (lastupdate.containsKey(io)) {
+ confupdates = new HashSet<Update>();
+ confupdates.add(lastupdate.get(io));
+ } else if (srcUpdates.containsKey(io)){
+ confupdates = srcUpdates.get(io);
+ }