Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / data / repository / ServiceRepository.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.onap.so.db.catalog.data.repository;
22
23 import org.onap.so.db.catalog.beans.Service;
24 import org.springframework.data.jpa.repository.JpaRepository;
25 import org.springframework.data.jpa.repository.Query;
26 import org.springframework.data.rest.core.annotation.RepositoryRestResource;
27 import java.util.List;
28
29 @RepositoryRestResource(collectionResourceRel = "service", path = "service")
30 public interface ServiceRepository extends JpaRepository<Service, String> {
31     List<Service> findByModelName(String modelName);
32
33     Service findOneByModelName(String modelName);
34
35     /**
36      * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the
37      * sorting
38      * 
39      * @param modelName
40      * @return
41      */
42     @Query(value = "SELECT * FROM service WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;",
43             nativeQuery = true)
44     Service findFirstByModelNameOrderByModelVersionDesc(String modelName);
45
46     /**
47      * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the
48      * sorting
49      * 
50      * @param modelName
51      * @return
52      */
53     @Query(value = "SELECT * FROM service WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;",
54             nativeQuery = true)
55     Service findByModelNameOrderByModelVersionDesc(String modelName);
56
57     Service findOneByModelNameAndModelVersion(String modelName, String modelVersion);
58
59     Service findByModelNameAndModelVersion(String modelName, String modelVersion);
60
61     Service findByServiceType(String serviceType);
62
63     /**
64      * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the
65      * sorting
66      * 
67      * @param modelUUID
68      * @return
69      */
70     @Query(value = "SELECT * FROM service WHERE MODEL_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;",
71             nativeQuery = true)
72     Service findFirstOneByModelUUIDOrderByModelVersionDesc(String modelUUID);
73
74     /**
75      * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the
76      * sorting
77      * 
78      * @param modelUUID
79      * @return
80      */
81     @Query(value = "SELECT * FROM service WHERE MODEL_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;",
82             nativeQuery = true)
83     Service findOneByModelUUIDOrderByModelVersionDesc(String modelUUID);
84
85     Service findFirstByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID);
86
87     /**
88      * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the
89      * sorting
90      * 
91      * @param modelInvariantUUID
92      * @return
93      */
94     @Query(value = "SELECT * FROM service WHERE MODEL_INVARIANT_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;",
95             nativeQuery = true)
96     Service findFirstByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID);
97
98     List<Service> findByModelUUID(String modelUUID);
99
100     Service findOneByModelUUID(String modelUUID);
101
102     /**
103      * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the
104      * sorting
105      * 
106      * @param modelInvariantUUID
107      * @return
108      */
109     @Query(value = "SELECT * FROM service WHERE MODEL_INVARIANT_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC;",
110             nativeQuery = true)
111     List<Service> findByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID);
112 }