[SDC-29] catalog 1707 rebase commit.
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / dao / cassandra / AuditAccessor.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.dao.cassandra;
22
23 import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent;
24 import org.openecomp.sdc.be.resources.data.auditing.DistributionNotificationEvent;
25 import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent;
26 import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
27
28 import com.datastax.driver.mapping.Result;
29 import com.datastax.driver.mapping.annotations.Accessor;
30 import com.datastax.driver.mapping.annotations.Param;
31 import com.datastax.driver.mapping.annotations.Query;
32
33 @Accessor
34 public interface AuditAccessor {
35
36         // ***** distributionstatusevent table
37         @Query("SELECT * FROM sdcaudit.distributionstatusevent WHERE DID = :did AND ACTION = 'DStatus' ALLOW FILTERING")
38         Result<DistributionStatusEvent> getListOfDistributionStatuses(@Param("did") String did);
39
40         // ***** resourceadminevent table
41         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DRequest' ALLOW FILTERING")
42         Result<ResourceAdminEvent> getServiceDistributionStatus(@Param("serviceInstanceId") String serviceInstanceId);
43
44         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId ")
45         Result<ResourceAdminEvent> getByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
46
47         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND PREV_VERSION = :prevVersion ALLOW FILTERING")
48         Result<ResourceAdminEvent> getAuditByServiceIdAndPrevVersion(@Param("serviceInstanceId") String serviceInstanceId,
49                         @Param("prevVersion") String prevVersion);
50
51         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE DID = :did AND ACTION = :action ALLOW FILTERING")
52         Result<ResourceAdminEvent> getDistributionRequest(@Param("did") String did, @Param("action") String action);
53
54         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND CURR_VERSION = :currVersion ALLOW FILTERING")
55         Result<ResourceAdminEvent> getAuditByServiceIdAndCurrVersion(@Param("serviceInstanceId") String serviceInstanceId,
56                         @Param("currVersion") String currVersion);
57
58         // ***** distributiondeployevent table
59         @Query("SELECT * FROM sdcaudit.distributiondeployevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DResult' ALLOW FILTERING")
60         Result<DistributionDeployEvent> getServiceDistributionDeploy(@Param("serviceInstanceId") String serviceInstanceId);
61
62         @Query("SELECT * FROM sdcaudit.distributiondeployevent WHERE DID = :did AND ACTION = :action AND STATUS = :status ALLOW FILTERING")
63         Result<DistributionDeployEvent> getDistributionDeployByStatus(@Param("did") String did,
64                         @Param("action") String action, @Param("status") String status);
65
66         // ***** distributionnotificationevent table
67         @Query("SELECT * FROM sdcaudit.distributionnotificationevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DNotify' ALLOW FILTERING")
68         Result<DistributionNotificationEvent> getServiceDistributionNotify(
69                         @Param("serviceInstanceId") String serviceInstanceId);
70
71         @Query("SELECT * FROM sdcaudit.distributionnotificationevent WHERE DID = :did AND ACTION = :action ALLOW FILTERING")
72         Result<DistributionNotificationEvent> getDistributionNotify(@Param("did") String did,
73                         @Param("action") String action);
74
75 }