37d1a6695b556eb1c00ed762103918f7a731ef9e
[dcaegen2/services.git] /
1 /*\r
2 * ============LICENSE_START=======================================================\r
3 * ONAP : DataLake\r
4 * ================================================================================\r
5 * Copyright 2019 China Mobile\r
6 *=================================================================================\r
7 * Licensed under the Apache License, Version 2.0 (the "License");\r
8 * you may not use this file except in compliance with the License.\r
9 * You may obtain a copy of the License at\r
10 *\r
11 *     http://www.apache.org/licenses/LICENSE-2.0\r
12 *\r
13 * Unless required by applicable law or agreed to in writing, software\r
14 * distributed under the License is distributed on an "AS IS" BASIS,\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 * See the License for the specific language governing permissions and\r
17 * limitations under the License.\r
18 * ============LICENSE_END=========================================================\r
19 */\r
20 package org.onap.datalake.feeder.repository;\r
21 \r
22 import org.onap.datalake.feeder.domain.Topic;\r
23 import org.springframework.data.couchbase.core.query.N1qlPrimaryIndexed;\r
24 import org.springframework.data.couchbase.core.query.Query;\r
25 import org.springframework.data.couchbase.core.query.ViewIndexed;\r
26 import org.springframework.data.couchbase.repository.CouchbasePagingAndSortingRepository;\r
27 import org.springframework.data.domain.Page;\r
28 import org.springframework.data.domain.Pageable;\r
29  \r
30 \r
31 import java.util.List;\r
32 \r
33 /**\r
34  * \r
35  * Topic Repository interface, implementation is taken care by Spring framework.\r
36  * Customization is done through TopicRepositoryCustom and its implementation TopicRepositoryImpl. \r
37  * \r
38  * @author Guobiao Mo\r
39  *\r
40  */\r
41 @ViewIndexed(designDoc = "topic", viewName = "all")\r
42 public interface TopicRepository extends CouchbasePagingAndSortingRepository<Topic, String>, TopicRepositoryCustom {\r
43 /*\r
44         Topic findFirstById(String topic);\r
45 \r
46         Topic findByIdAndState(String topic, boolean state);\r
47 \r
48     //Supports native JSON query string\r
49     @Query("{topic:'?0'}")\r
50     Topic findTopicById(String topic);\r
51 \r
52     @Query("{topic: { $regex: ?0 } })")\r
53     List<Topic> findTopicByRegExId(String topic);\r
54 \r
55 \r
56     //Page<Topic> findByCompanyIdAndNameLikeOrderByName(String companyId, String name, Pageable pageable);\r
57 \r
58     @Query("#{#n1ql.selectEntity} where #{#n1ql.filter} and companyId = $1 and $2 within #{#n1ql.bucket}")\r
59     Topic findByCompanyAndAreaId(String companyId, String areaId);\r
60 \r
61     @Query("#{#n1ql.selectEntity} where #{#n1ql.filter} AND ANY phone IN phoneNumbers SATISFIES phone = $1 END")\r
62     List<Topic> findByPhoneNumber(String telephoneNumber);\r
63 \r
64     @Query("SELECT COUNT(*) AS count FROM #{#n1ql.bucket} WHERE #{#n1ql.filter} and companyId = $1")\r
65     Long countBuildings(String companyId);\r
66     */\r
67 }\r