Update MRI projects for Aluminium
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / batch / FlatBatchFlowAdapters.java
index 9df13053dab82773be9a49f14226ca49620548a0..ef734d242f4df4ccb4062c4b41acb9167a2cae07 100644 (file)
@@ -11,14 +11,10 @@ package org.opendaylight.openflowplugin.impl.services.batch;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.Future;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow;
@@ -130,18 +126,14 @@ public final class FlatBatchFlowAdapters {
     @VisibleForTesting
     static <T extends BatchFlowOutputListGrouping> Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>
         convertBatchFlowResult(final int stepOffset) {
-        return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
-                List<BatchFailure> batchFailures = wrapBatchFlowFailuresForFlat(input, stepOffset);
-                ProcessFlatBatchOutputBuilder outputBuilder =
-                        new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
-                return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful())
-                                       .withRpcErrors(input.getErrors())
-                                       .withResult(outputBuilder.build())
-                                       .build();
-            }
+        return input -> {
+            List<BatchFailure> batchFailures = wrapBatchFlowFailuresForFlat(input, stepOffset);
+            ProcessFlatBatchOutputBuilder outputBuilder =
+                    new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
+            return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful())
+                                   .withRpcErrors(input.getErrors())
+                                   .withResult(outputBuilder.build())
+                                   .build();
         };
     }
 
@@ -149,9 +141,9 @@ public final class FlatBatchFlowAdapters {
             final RpcResult<T> input, final int stepOffset) {
         final List<BatchFailure> batchFailures = new ArrayList<>();
         if (input.getResult().getBatchFailedFlowsOutput() != null) {
-            for (BatchFailedFlowsOutput stepOutput : input.getResult().getBatchFailedFlowsOutput()) {
+            for (BatchFailedFlowsOutput stepOutput : input.getResult().nonnullBatchFailedFlowsOutput().values()) {
                 final BatchFailure batchFailure = new BatchFailureBuilder()
-                        .setBatchOrder(stepOffset + stepOutput.getBatchOrder())
+                        .setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava())
                         .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder()
                                 .setFlowId(stepOutput.getFlowId())
                                 .build())
@@ -171,10 +163,9 @@ public final class FlatBatchFlowAdapters {
      * @return ListenableFuture with converted result {@link ProcessFlatBatchOutput}
      */
     public static <T extends BatchFlowOutputListGrouping> ListenableFuture<RpcResult<ProcessFlatBatchOutput>>
-        convertFlowBatchFutureForChain(final Future<RpcResult<T>> resultUpdateFlowFuture,
+        convertFlowBatchFutureForChain(final ListenableFuture<RpcResult<T>> resultUpdateFlowFuture,
                                    final int currentOffset) {
-        return Futures.transform(JdkFutureAdapters.listenInPoolThread(resultUpdateFlowFuture),
-                FlatBatchFlowAdapters.<T>convertBatchFlowResult(currentOffset),
+        return Futures.transform(resultUpdateFlowFuture, FlatBatchFlowAdapters.convertBatchFlowResult(currentOffset),
                 MoreExecutors.directExecutor());
     }
 }