Changes for checkstyle 8.32
[policy/apex-pdp.git] / model / basic-model / src / main / java / org / onap / policy / apex / model / basicmodel / dao / ApexDao.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.model.basicmodel.dao;
22
23 import java.util.Collection;
24 import java.util.List;
25 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
26 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
27 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
28 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
29
30 /**
31  * The Interface ApexDao describes the DAO interface for reading and writing Apex {@link AxConcept} concepts to and from
32  * databases using JDBC.
33  *
34  * @author Sergey Sachkov
35  * @author liam.fallon@ericsson.com
36  */
37 public interface ApexDao {
38
39     /**
40      * Initialize the Apex DAO with the given parameters.
41      *
42      * @param daoParameters parameters to use to access the database
43      * @throws ApexException on initialization errors
44      */
45     void init(DaoParameters daoParameters) throws ApexException;
46
47     /**
48      * Close the Apex DAO.
49      */
50     void close();
51
52     /**
53      * Creates an Apex concept on the database.
54      *
55      * @param <T> the type of the object to create, a subclass of {@link AxConcept}
56      * @param obj the object to create
57      */
58     <T extends AxConcept> void create(T obj);
59
60     /**
61      * Delete an Apex concept on the database.
62      *
63      * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
64      * @param obj the object to delete
65      */
66     <T extends AxConcept> void delete(T obj);
67
68     /**
69      * Delete an Apex concept on the database.
70      *
71      * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
72      * @param someClass the class of the object to delete, a subclass of {@link AxConcept}
73      * @param key the key of the object to delete
74      */
75     <T extends AxConcept> void delete(Class<T> someClass, AxArtifactKey key);
76
77     /**
78      * Delete an Apex concept on the database.
79      *
80      * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
81      * @param someClass the class of the object to delete, a subclass of {@link AxConcept}
82      * @param key the key of the object to delete
83      */
84     <T extends AxConcept> void delete(Class<T> someClass, AxReferenceKey key);
85
86     /**
87      * Create a collection of objects in the database.
88      *
89      * @param <T> the type of the object to create, a subclass of {@link AxConcept}
90      * @param objs the objects to create
91      */
92     <T extends AxConcept> void createCollection(Collection<T> objs);
93
94     /**
95      * Delete a collection of objects in the database.
96      *
97      * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
98      * @param objs the objects to delete
99      */
100     <T extends AxConcept> void deleteCollection(Collection<T> objs);
101
102     /**
103      * Delete a collection of objects in the database referred to by artifact key.
104      *
105      * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
106      * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
107      * @param keys the keys of the objects to delete
108      * @return the number of objects deleted
109      */
110     <T extends AxConcept> int deleteByArtifactKey(Class<T> someClass, Collection<AxArtifactKey> keys);
111
112     /**
113      * Delete a collection of objects in the database referred to by reference key.
114      *
115      * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
116      * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
117      * @param keys the keys of the objects to delete
118      * @return the number of objects deleted
119      */
120     <T extends AxConcept> int deleteByReferenceKey(Class<T> someClass, Collection<AxReferenceKey> keys);
121
122     /**
123      * Delete all objects of a given class in the database.
124      *
125      * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
126      * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
127      */
128     <T extends AxConcept> void deleteAll(Class<T> someClass);
129
130     /**
131      * Get an object from the database, referred to by artifact key.
132      *
133      * @param <T> the type of the object to get, a subclass of {@link AxConcept}
134      * @param someClass the class of the object to get, a subclass of {@link AxConcept}
135      * @param key the key of the object to get
136      * @return the object that was retrieved from the database
137      */
138     <T extends AxConcept> T get(Class<T> someClass, AxArtifactKey key);
139
140     /**
141      * Get an object from the database, referred to by reference key.
142      *
143      * @param <T> the type of the object to get, a subclass of {@link AxConcept}
144      * @param someClass the class of the object to get, a subclass of {@link AxConcept}
145      * @param key the key of the object to get
146      * @return the object that was retrieved from the database or null if the object was not retrieved
147      */
148     <T extends AxConcept> T get(Class<T> someClass, AxReferenceKey key);
149
150     /**
151      * Get all the objects in the database of a given type.
152      *
153      * @param <T> the type of the objects to get, a subclass of {@link AxConcept}
154      * @param someClass the class of the objects to get, a subclass of {@link AxConcept}
155      * @return the objects or null if no objects were retrieved
156      */
157     <T extends AxConcept> List<T> getAll(Class<T> someClass);
158
159     /**
160      * Get all the objects in the database of the given type with the given parent artifact key.
161      *
162      * @param <T> the type of the objects to get, a subclass of {@link AxConcept}
163      * @param someClass the class of the objects to get, a subclass of {@link AxConcept}
164      * @param parentKey the parent key of the concepts to get
165      * @return the all
166      */
167     <T extends AxConcept> List<T> getAll(Class<T> someClass, AxArtifactKey parentKey);
168
169     /**
170      * Get a concept from the database with the given artifact key.
171      *
172      * @param <T> the type of the object to get, a subclass of {@link AxConcept}
173      * @param someClass the class of the object to get, a subclass of {@link AxConcept}
174      * @param artifactId the artifact key of the concept to get
175      * @return the concept that matches the key or null if the concept is not retrieved
176      */
177     <T extends AxConcept> T getArtifact(Class<T> someClass, AxArtifactKey artifactId);
178
179     /**
180      * Get a concept from the database with the given reference key.
181      *
182      * @param <T> the type of the object to get, a subclass of {@link AxConcept}
183      * @param someClass the class of the object to get, a subclass of {@link AxConcept}
184      * @param artifactId the artifact key of the concept to get
185      * @return the concept that matches the key or null if the concept is not retrieved
186      */
187     <T extends AxConcept> T getArtifact(Class<T> someClass, AxReferenceKey artifactId);
188
189     /**
190      * Get the number of instances of a concept that exist in the database.
191      *
192      * @param <T> the type of the object to get, a subclass of {@link AxConcept}
193      * @param someClass the class of the object to get, a subclass of {@link AxConcept}
194      * @return the number of instances of the concept in the database
195      */
196     <T extends AxConcept> long size(Class<T> someClass);
197
198     /**
199      * Update a concept in the database.
200      *
201      * @param <T> the type of the object to get, a subclass of {@link AxConcept}
202      * @param obj the object to update
203      * @return the updated object
204      */
205     <T extends AxConcept> T update(T obj);
206 }