Merge "Removed duplicate sal-binding-config dependency."
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / translator / FlowRemovedTranslator.java
index d11c8b6ad2ddb41c56affd31b7978357bc707911..c5683d2ebc171a071b446bbae668efa65be1a9e5 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
@@ -23,19 +23,29 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved> {
 
     @Override
-    public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceContext deviceContext, Object connectionDistinguisher) {
+    public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceInfo deviceInfo, Object connectionDistinguisher) {
         FlowRemovedBuilder flowRemovedBld = new FlowRemovedBuilder()
-                .setMatch(translateMatch(input, deviceContext).build())
+                .setMatch(translateMatch(input, deviceInfo).build())
                 .setCookie(new FlowCookie(input.getCookie()))
-                .setNode(new NodeRef(deviceContext.getDeviceState().getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier()))
                 .setPriority(input.getPriority())
-                .setTableId(input.getTableId().getValue().shortValue());
+                .setTableId(translateTableId(input));
 
         return flowRemovedBld.build();
     }
 
-    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceContext deviceContext) {
+    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
         return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(),
-                deviceContext.getDeviceState().getFeatures().getDatapathId(), OpenflowVersion.OF13);
+                deviceInfo.getDatapathId(), OpenflowVersion.OF13);
+    }
+
+    /**
+     * Translate the table ID in the FLOW_REMOVED message to SAL table ID.
+     *
+     * @param flowRemoved  FLOW_REMOVED message.
+     * @return  SAL table ID.
+     */
+    protected Short translateTableId(FlowRemoved flowRemoved) {
+        return flowRemoved.getTableId().getValue().shortValue();
     }
 }