b60d86e0663f7eed0bf201163ea85267c786d725
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / transactions / TransactionVarsWrapper.java
1 /*
2  * Copyright (c) 2016 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.restconf.nb.rfc8040.rests.transactions;
9
10 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
11 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
12 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
13 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
14 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
15
16 /**
17  * This class represent delegation wrapper for transaction variables.
18  *
19  */
20 public final class TransactionVarsWrapper {
21
22     private final InstanceIdentifierContext<?> instanceIdentifier;
23     private final DOMMountPoint mountPoint;
24     private LogicalDatastoreType configuration = null;
25     private final DOMTransactionChain transactionChain;
26     private final TransactionChainHandler transactionChainHandler;
27
28     /**
29      * Set base type of variables, which ones we need for transaction.
30      * {@link LogicalDatastoreType} is default set to null (to read all data
31      * from DS - config + state).
32      *
33      * @param instanceIdentifier
34      *             {@link InstanceIdentifierContext} of data for transaction
35      * @param mountPoint
36      *             mount point if is present
37      * @param transactionChainHandler
38      *             used to obtain the transaction chain for creating specific type of transaction
39      *             in specific operation
40      */
41     public TransactionVarsWrapper(final InstanceIdentifierContext<?> instanceIdentifier, final DOMMountPoint mountPoint,
42             final TransactionChainHandler transactionChainHandler) {
43         this.instanceIdentifier = instanceIdentifier;
44         this.mountPoint = mountPoint;
45         this.transactionChainHandler = transactionChainHandler;
46         transactionChain = transactionChainHandler.get();
47     }
48
49     /**
50      * Get instance identifier of data.
51      *
52      * @return {@link InstanceIdentifierContext}
53      */
54     public InstanceIdentifierContext<?> getInstanceIdentifier() {
55         return this.instanceIdentifier;
56     }
57
58     /**
59      * Get mount point.
60      *
61      * @return {@link DOMMountPoint}
62      */
63     public DOMMountPoint getMountPoint() {
64         return this.mountPoint;
65     }
66
67     /**
68      * Set {@link LogicalDatastoreType} of data for transaction.
69      *
70      * @param datastoreType
71      *             {@link LogicalDatastoreType}
72      */
73     public void setLogicalDatastoreType(final LogicalDatastoreType datastoreType) {
74         this.configuration = datastoreType;
75
76     }
77
78     /**
79      * Get type of data.
80      *
81      * @return {@link LogicalDatastoreType}
82      */
83     public LogicalDatastoreType getLogicalDatastoreType() {
84         return this.configuration;
85     }
86
87     /**
88      * Get transaction chain for creating specific transaction for specific
89      * operation.
90      *
91      * @return transaction chain
92      */
93     public DOMTransactionChain getTransactionChain() {
94         return this.transactionChain;
95     }
96
97     public TransactionChainHandler getTransactionChainHandler() {
98         return transactionChainHandler;
99     }
100 }