299115d9941f6976097ac987ece6c5d4c1b41a2d
[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-2018 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  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.transactionrecorder;
25
26
27 import org.onap.appc.domainmodel.lcm.RequestStatus;
28 import org.onap.appc.exceptions.APPCException;
29 import org.onap.appc.domainmodel.lcm.TransactionRecord;
30 import org.onap.appc.transactionrecorder.objects.TransactionConstants;
31
32 import java.util.List;
33 import java.util.Map;
34
35 /**
36  * Interface to persist and query LCM requests
37  */
38 public interface TransactionRecorder {
39     /**
40      * Stores transaction record to appc database by calling APPC Dao layer.
41      * @param record Transaction record data.
42      */
43     void store(TransactionRecord record) throws APPCException;
44
45     /**
46      * This method is called when a particular row in transactions needs to be updated
47      * @param key This is TransactionId which uniquely identifies the record.
48      * @param updateColumns Map containing names of updated columns and their values.
49      * @throws APPCException
50      */
51     void update(String key, Map<TransactionConstants.TRANSACTION_ATTRIBUTES, String> updateColumns) throws APPCException;
52
53     /**
54      * Marks all records in Transactions table in non-terminal state as ABORTED. This method is to be called during
55      * APPC startup.
56      *
57      * @param appcInstanceId
58      */
59     void markTransactionsAborted(String appcInstanceId);
60
61     /**
62      * Fetch list of Transactions which are in non-terminal state i.e. ACCEPTED or RECEIVED for particular TargetId.
63      * @param record Transactions object from which TargetId and StartTime is extracted to fetch list of in progress
64      *               requests which APPC received before the current request.
65      * @return List of Transactions in non terminal state.
66      * @throws APPCException
67      */
68     List<TransactionRecord> getInProgressRequests(TransactionRecord record) throws APPCException;
69
70     /**
71      * Checks whether the incoming request is duplicate.
72      * @param record Transaction object from which RequestId, SubRequestId, OriginatorId is extracted to check duplicate request.
73      * @return
74      * @throws APPCException
75      */
76     Boolean isTransactionDuplicate(TransactionRecord record) throws APPCException;
77
78     /**
79      * Retrieves {@link RequestStatus} from transaction table based on the passed parameters.
80      * @param requestId: RequestId of the request to search (Required)
81      * @param subrequestId: Sub-requestId (Optional)
82      * @param originatorId: Originator Id who sent the request(Optional)
83      * @param vnfId: VNFId to search (Required)
84      * @return list of RequestStatus'es
85      */
86     List<RequestStatus> getRecords(String requestId, String subrequestId, String originatorId, String vnfId)
87             throws APPCException;
88
89     /**
90      * Count of all requests which are currently in non-terminal state.
91      * @return Count of all request in state RECEIVED and ACCEPTED.
92      */
93     Integer getInProgressRequestsCount() throws APPCException;
94
95     /**
96      *
97      * @param appcInstanceId
98      */
99     void setAppcInstanceId(String appcInstanceId);
100 }