Include impacted changes for APPC-346,APPC-348
[appc.git] / appc-dispatcher / appc-dispatcher-common / transaction-recorder / src / main / java / org / onap / appc / transactionrecorder / TransactionRecorder.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.transactionrecorder;
26
27
28 import org.onap.appc.domainmodel.lcm.RequestStatus;
29 import org.onap.appc.exceptions.APPCException;
30 import org.onap.appc.domainmodel.lcm.TransactionRecord;
31 import org.onap.appc.transactionrecorder.objects.TransactionConstants;
32
33 import java.util.List;
34 import java.util.Map;
35
36 /**
37  * Interface to persist and query LCM requests
38  */
39 public interface TransactionRecorder {
40     /**
41      * Stores transaction record to appc database by calling APPC Dao layer.
42      * @param record Transaction record data.
43      */
44     void store(TransactionRecord record) throws APPCException;
45
46     /**
47      * This method is called when a particular row in transactions needs to be updated
48      * @param key This is TransactionId which uniquely identifies the record.
49      * @param updateColumns Map containing names of updated columns and their values.
50      * @throws APPCException
51      */
52     void update(String key, Map<TransactionConstants.TRANSACTION_ATTRIBUTES, String> updateColumns) throws APPCException;
53
54     /**
55      * Marks all records in Transactions table in non-terminal state as ABORTED. This method is to be called during
56      * APPC startup.
57      *
58      * @param appcInstanceId
59      */
60     void markTransactionsAborted(String appcInstanceId);
61
62     /**
63      * Fetch list of Transactions which are in non-terminal state i.e. ACCEPTED or RECEIVED for particular TargetId.
64      * @param record Transactions object from which TargetId and StartTime is extracted to fetch list of in progress
65      *               requests which APPC received before the current request.
66      * @return List of Transactions in non terminal state.
67      * @throws APPCException
68      */
69     List<TransactionRecord> getInProgressRequests(TransactionRecord record) throws APPCException;
70
71     /**
72      * Checks whether the incoming request is duplicate.
73      * @param record Transaction object from which RequestId, SubRequestId, OriginatorId is extracted to check duplicate request.
74      * @return
75      * @throws APPCException
76      */
77     Boolean isTransactionDuplicate(TransactionRecord record) throws APPCException;
78
79     /**
80      * Retrieves {@link RequestStatus} from transaction table based on the passed parameters.
81      * @param requestId: RequestId of the request to search (Required)
82      * @param subrequestId: Sub-requestId (Optional)
83      * @param originatorId: Originator Id who sent the request(Optional)
84      * @param vnfId: VNFId to search (Required)
85      * @return list of RequestStatus'es
86      */
87     List<RequestStatus> getRecords(String requestId, String subrequestId, String originatorId, String vnfId)
88             throws APPCException;
89
90     /**
91      * Count of all requests which are currently in non-terminal state.
92      * @return Count of all request in state RECEIVED and ACCEPTED.
93      */
94     Integer getInProgressRequestsCount() throws APPCException;
95
96     /**
97      *
98      * @param appcInstanceId
99      */
100     void setAppcInstanceId(String appcInstanceId);
101 }