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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.model.basicmodel.dao;
23 import java.util.Collection;
24 import java.util.List;
26 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
27 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
28 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
29 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
32 * The Interface ApexDao describes the DAO interface for reading and writing Apex {@link AxConcept} concepts to and from
33 * databases using JDBC.
35 * @author Sergey Sachkov
36 * @author liam.fallon@ericsson.com
38 public interface ApexDao {
41 * Initialize the Apex DAO with the given parameters.
43 * @param daoParameters parameters to use to access the database
44 * @throws ApexException on initialization errors
46 void init(DaoParameters daoParameters) throws ApexException;
54 * Creates an Apex concept on the database.
56 * @param <T> the type of the object to create, a subclass of {@link AxConcept}
57 * @param obj the object to create
59 <T extends AxConcept> void create(T obj);
62 * Delete an Apex concept on the database.
64 * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
65 * @param obj the object to delete
67 <T extends AxConcept> void delete(T obj);
70 * Delete an Apex concept on the database.
72 * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
73 * @param someClass the class of the object to delete, a subclass of {@link AxConcept}
74 * @param key the key of the object to delete
76 <T extends AxConcept> void delete(Class<T> someClass, AxArtifactKey key);
79 * Delete an Apex concept on the database.
81 * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
82 * @param someClass the class of the object to delete, a subclass of {@link AxConcept}
83 * @param key the key of the object to delete
85 <T extends AxConcept> void delete(Class<T> someClass, AxReferenceKey key);
88 * Create a collection of objects in the database.
90 * @param <T> the type of the object to create, a subclass of {@link AxConcept}
91 * @param objs the objects to create
93 <T extends AxConcept> void createCollection(Collection<T> objs);
96 * Delete a collection of objects in the database.
98 * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
99 * @param objs the objects to delete
101 <T extends AxConcept> void deleteCollection(Collection<T> objs);
104 * Delete a collection of objects in the database referred to by artifact key.
106 * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
107 * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
108 * @param keys the keys of the objects to delete
109 * @return the number of objects deleted
111 <T extends AxConcept> int deleteByArtifactKey(Class<T> someClass, Collection<AxArtifactKey> keys);
114 * Delete a collection of objects in the database referred to by reference key.
116 * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
117 * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
118 * @param keys the keys of the objects to delete
119 * @return the number of objects deleted
121 <T extends AxConcept> int deleteByReferenceKey(Class<T> someClass, Collection<AxReferenceKey> keys);
124 * Delete all objects of a given class in the database.
126 * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
127 * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
129 <T extends AxConcept> void deleteAll(Class<T> someClass);
132 * Get an object from the database, referred to by artifact key.
134 * @param <T> the type of the object to get, a subclass of {@link AxConcept}
135 * @param someClass the class of the object to get, a subclass of {@link AxConcept}
136 * @param key the key of the object to get
137 * @return the object that was retrieved from the database
139 <T extends AxConcept> T get(Class<T> someClass, AxArtifactKey key);
142 * Get an object from the database, referred to by reference key.
144 * @param <T> the type of the object to get, a subclass of {@link AxConcept}
145 * @param someClass the class of the object to get, a subclass of {@link AxConcept}
146 * @param key the key of the object to get
147 * @return the object that was retrieved from the database or null if the object was not retrieved
149 <T extends AxConcept> T get(Class<T> someClass, AxReferenceKey key);
152 * Get all the objects in the database of a given type.
154 * @param <T> the type of the objects to get, a subclass of {@link AxConcept}
155 * @param someClass the class of the objects to get, a subclass of {@link AxConcept}
156 * @return the objects or null if no objects were retrieved
158 <T extends AxConcept> List<T> getAll(Class<T> someClass);
161 * Get all the objects in the database of the given type with the given parent artifact key.
163 * @param <T> the type of the objects to get, a subclass of {@link AxConcept}
164 * @param someClass the class of the objects to get, a subclass of {@link AxConcept}
165 * @param parentKey the parent key of the concepts to get
168 <T extends AxConcept> List<T> getAll(Class<T> someClass, AxArtifactKey parentKey);
171 * Get a concept from the database with the given artifact key.
173 * @param <T> the type of the object to get, a subclass of {@link AxConcept}
174 * @param someClass the class of the object to get, a subclass of {@link AxConcept}
175 * @param artifactId the artifact key of the concept to get
176 * @return the concept that matches the key or null if the concept is not retrieved
178 <T extends AxConcept> T getArtifact(Class<T> someClass, AxArtifactKey artifactId);
181 * Get a concept from the database with the given reference key.
183 * @param <T> the type of the object to get, a subclass of {@link AxConcept}
184 * @param someClass the class of the object to get, a subclass of {@link AxConcept}
185 * @param artifactId the artifact key of the concept to get
186 * @return the concept that matches the key or null if the concept is not retrieved
188 <T extends AxConcept> T getArtifact(Class<T> someClass, AxReferenceKey artifactId);
191 * Get the number of instances of a concept that exist in the database.
193 * @param <T> the type of the object to get, a subclass of {@link AxConcept}
194 * @param someClass the class of the object to get, a subclass of {@link AxConcept}
195 * @return the number of instances of the concept in the database
197 <T extends AxConcept> long size(Class<T> someClass);
200 * Update a concept in the database.
202 * @param <T> the type of the object to get, a subclass of {@link AxConcept}
203 * @param obj the object to update
204 * @return the updated object
206 <T extends AxConcept> T update(T obj);