import com.google.common.util.concurrent.SettableFuture;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTableInput> implements SalTableService {
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalTableServiceImpl.class);
private final TxFacade txFacade;
- private final NodeId nodeId;
+ private final ConvertorExecutor convertorExecutor;
+ private final VersionConvertorData data;
- public SalTableServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
- final NodeId nodeId) {
+ public SalTableServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
super(requestContextStack, deviceContext);
this.txFacade = deviceContext;
- this.nodeId = nodeId;
+ this.convertorExecutor = convertorExecutor;
+ data = new VersionConvertorData(getVersion());
}
@Override
txFacade.submitTransaction();
}
- protected static List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
+ protected List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
final List<MultipartReply> multipartReplies) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll = new ArrayList<>();
for (final MultipartReply multipartReply : multipartReplies) {
final MultipartReplyTableFeaturesCase tableFeaturesCase = ((MultipartReplyTableFeaturesCase) multipartReplyBody);
final MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase
.getMultipartReplyTableFeatures();
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesPartial = TableFeaturesReplyConvertor
- .toTableFeaturesReply(salTableFeatures);
- salTableFeaturesAll.addAll(salTableFeaturesPartial);
+
+ final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures>> salTableFeaturesPartial =
+ convertorExecutor.convert(salTableFeatures, data);
+
+ if (salTableFeaturesPartial.isPresent()) {
+ salTableFeaturesAll.addAll(salTableFeaturesPartial.get());
+ }
+
LOG.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
}
}
protected OfHeader buildRequest(final Xid xid, final UpdateTableInput input) {
final MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
final MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
- final List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input
- .getUpdatedTable());
- requestBuilder.setTableFeatures(ofTableFeatureList);
+
+ final Optional<List<TableFeatures>> ofTableFeatureList = convertorExecutor.convert(input.getUpdatedTable(), data);
+ requestBuilder.setTableFeatures(ofTableFeatureList.orElse(Collections.emptyList()));
caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
// Set request body to main multipart request