Change the batchoperation package to use the same ID for UpdateOperation
This task is a part of ONOS-1692.
Change-Id: Id7bf459b2910693d0a4be8709f0e8929b93571b4
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
index 93e9912..b4755e9 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
@@ -39,7 +39,7 @@
/**
* Adds an add-operation.
*
- * @param target IBatchOperationTarget to be added.
+ * @param target IBatchOperationTarget object to be added.
* @return true if succeeded, false otherwise.
*/
public boolean addAddOperation(T target) {
@@ -57,13 +57,14 @@
}
/**
- * Adds a update-operation.
+ * Adds an update-operation.
+ * <p>
+ * The existing entry having the same ID with the new target is overwritten.
*
- * @param oldTargetId ID of the existing target to be overwritten.
- * @param newTarget The new target to be added.
+ * @param target The new target to be used for the update.
* @return true if succeeded, false otherwise.
*/
- public boolean addUpdateOperation(BatchOperationTargetId oldTargetId, T newTarget) {
- return ops.add(new UpdateOperation(oldTargetId, newTarget));
+ public boolean addUpdateOperation(T target) {
+ return ops.add(new UpdateOperation(target));
}
}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java
index aaf649a..a2f368e 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java
@@ -4,18 +4,15 @@
* An update-operation entry of a batch operation.
*/
public class UpdateOperation implements BatchOperationEntry {
- private final BatchOperationTargetId oldTargetId;
- private final IBatchOperationTarget newTarget;
+ private final IBatchOperationTarget target;
/**
- * Creates a update-operation with specified targets.
+ * Creates an update-operation with specified targets.
*
- * @param oldTargetId The ID to be overwritten.
- * @param newTarget The new target to be added.
+ * @param target The new target to be used for the update.
*/
- public UpdateOperation(BatchOperationTargetId oldTargetId, IBatchOperationTarget newTarget) {
- this.oldTargetId = oldTargetId;
- this.newTarget = newTarget;
+ public UpdateOperation(IBatchOperationTarget target) {
+ this.target = target;
}
@Override
@@ -24,21 +21,12 @@
}
/**
- * Gets the old target ID to be overwritten.
+ * Gets the new target object to be used for the update.
*
- * @return The old target ID to be overwritten
+ * @return The new target object to be used for the update.
*/
- public BatchOperationTargetId getOldTargetId() {
- return oldTargetId;
- }
-
- /**
- * Gets the new target object to be added.
- *
- * @return The new target object to be added.
- */
- public IBatchOperationTarget getNewTarget() {
- return newTarget;
+ public IBatchOperationTarget getTarget() {
+ return target;
}
}
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
index 0c5be10..1f5f446 100644
--- a/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
@@ -42,7 +42,7 @@
@Override
public boolean updateFlow(IFlow flow) {
BatchOperation<IFlow> ops = new BatchOperation<IFlow>();
- ops.addUpdateOperation(flow.getId(), flow);
+ ops.addUpdateOperation(flow);
return executeBatch(ops);
}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
index a734026..c1fbd8e 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
@@ -34,7 +34,7 @@
@Override
public boolean updateMatchAction(MatchAction matchAction) {
BatchOperation<MatchAction> phase = new BatchOperation<MatchAction>();
- phase.addUpdateOperation(matchAction.getId(), matchAction);
+ phase.addUpdateOperation(matchAction);
MatchActionPlan plan = new MatchActionPlan();
plan.addPhase(phase);
return executePlan(plan);