Merge "Add JUnit testing for FWaasHandler class."
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / ovsdb / transact / TransactCommandAggregator.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.ovsdb.southbound.ovsdb.transact;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
15 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18
19 public class TransactCommandAggregator implements TransactCommand {
20
21     private List<TransactCommand> commands = new ArrayList<TransactCommand>();
22     private AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes;
23     private DataBroker db;
24
25     public TransactCommandAggregator(DataBroker db,AsyncDataChangeEvent<InstanceIdentifier<?>,
26             DataObject> changes) {
27         this.db = db;
28         this.changes = changes;
29         commands.add(new BridgeCreateCommand(changes));
30         commands.add(new BridgeRemovedCommand(db,changes));
31         commands.add(new TerminationPointCreateCommand(changes));
32     }
33
34     @Override
35     public void execute(TransactionBuilder transaction) {
36         for (TransactCommand command:commands) {
37             command.execute(transaction);
38         }
39     }
40 }