re base code
[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 com.datastax.driver.mapping.Result;
24 import com.datastax.driver.mapping.annotations.Accessor;
25 import com.datastax.driver.mapping.annotations.Param;
26 import com.datastax.driver.mapping.annotations.Query;
27 import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent;
28 import org.openecomp.sdc.be.resources.data.auditing.DistributionNotificationEvent;
29 import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent;
30 import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
31
32 @Accessor
33 public interface AuditAccessor {
34
35         // ***** distributionstatusevent table
36         @Query("SELECT * FROM sdcaudit.distributionstatusevent WHERE DID = :did AND ACTION = 'DStatus' ALLOW FILTERING")
37         Result<DistributionStatusEvent> getListOfDistributionStatuses(@Param("did") String did);
38
39         // ***** resourceadminevent table
40         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DRequest' ALLOW FILTERING")
41         Result<ResourceAdminEvent> getServiceDistributionStatus(@Param("serviceInstanceId") String serviceInstanceId);
42
43         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId ")
44         Result<ResourceAdminEvent> getByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
45
46         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND PREV_VERSION = :prevVersion ALLOW FILTERING")
47         Result<ResourceAdminEvent> getAuditByServiceIdAndPrevVersion(@Param("serviceInstanceId") String serviceInstanceId,
48                         @Param("prevVersion") String prevVersion);
49
50         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE DID = :did AND ACTION = :action ALLOW FILTERING")
51         Result<ResourceAdminEvent> getDistributionRequest(@Param("did") String did, @Param("action") String action);
52
53         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND CURR_VERSION = :currVersion ALLOW FILTERING")
54         Result<ResourceAdminEvent> getAuditByServiceIdAndCurrVersion(@Param("serviceInstanceId") String serviceInstanceId,
55                         @Param("currVersion") String currVersion);
56
57         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'ArchiveComponent' ALLOW FILTERING")
58         Result<ResourceAdminEvent> getArchiveAuditByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
59
60         @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'RestoreComponent' ALLOW FILTERING")
61         Result<ResourceAdminEvent> getRestoreAuditByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
62
63         // ***** distributiondeployevent table
64         @Query("SELECT * FROM sdcaudit.distributiondeployevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DResult' ALLOW FILTERING")
65         Result<DistributionDeployEvent> getServiceDistributionDeploy(@Param("serviceInstanceId") String serviceInstanceId);
66
67         @Query("SELECT * FROM sdcaudit.distributiondeployevent WHERE DID = :did AND ACTION = :action AND STATUS = :status ALLOW FILTERING")
68         Result<DistributionDeployEvent> getDistributionDeployByStatus(@Param("did") String did,
69                         @Param("action") String action, @Param("status") String status);
70
71         // ***** distributionnotificationevent table
72         @Query("SELECT * FROM sdcaudit.distributionnotificationevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DNotify' ALLOW FILTERING")
73         Result<DistributionNotificationEvent> getServiceDistributionNotify(
74                         @Param("serviceInstanceId") String serviceInstanceId);
75
76         @Query("SELECT * FROM sdcaudit.distributionnotificationevent WHERE DID = :did AND ACTION = :action ALLOW FILTERING")
77         Result<DistributionNotificationEvent> getDistributionNotify(@Param("did") String did,
78                         @Param("action") String action);
79
80 }