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;
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;
31 * The Interface ApexDao describes the DAO interface for reading and writing Apex {@link AxConcept} concepts to and from
32 * databases using JDBC.
34 * @author Sergey Sachkov
35 * @author liam.fallon@ericsson.com
37 public interface ApexDao {
40 * Initialize the Apex DAO with the given parameters.
42 * @param daoParameters parameters to use to access the database
43 * @throws ApexException on initialization errors
45 void init(DaoParameters daoParameters) throws ApexException;
53 * Creates an Apex concept on the database.
55 * @param <T> the type of the object to create, a subclass of {@link AxConcept}
56 * @param obj the object to create
58 <T extends AxConcept> void create(T obj);
61 * Delete an Apex concept on the database.
63 * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
64 * @param obj the object to delete
66 <T extends AxConcept> void delete(T obj);
69 * Delete an Apex concept on the database.
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
75 <T extends AxConcept> void delete(Class<T> someClass, AxArtifactKey key);
78 * Delete an Apex concept on the database.
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
84 <T extends AxConcept> void delete(Class<T> someClass, AxReferenceKey key);
87 * Create a collection of objects in the database.
89 * @param <T> the type of the object to create, a subclass of {@link AxConcept}
90 * @param objs the objects to create
92 <T extends AxConcept> void createCollection(Collection<T> objs);
95 * Delete a collection of objects in the database.
97 * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
98 * @param objs the objects to delete
100 <T extends AxConcept> void deleteCollection(Collection<T> objs);
103 * Delete a collection of objects in the database referred to by artifact key.
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
110 <T extends AxConcept> int deleteByArtifactKey(Class<T> someClass, Collection<AxArtifactKey> keys);
113 * Delete a collection of objects in the database referred to by reference key.
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
120 <T extends AxConcept> int deleteByReferenceKey(Class<T> someClass, Collection<AxReferenceKey> keys);
123 * Delete all objects of a given class in the database.
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}
128 <T extends AxConcept> void deleteAll(Class<T> someClass);
131 * Get an object from the database, referred to by artifact key.
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
138 <T extends AxConcept> T get(Class<T> someClass, AxArtifactKey key);
141 * Get an object from the database, referred to by reference key.
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
148 <T extends AxConcept> T get(Class<T> someClass, AxReferenceKey key);
151 * Get all the objects in the database of a given type.
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
157 <T extends AxConcept> List<T> getAll(Class<T> someClass);
160 * Get all the objects in the database of the given type with the given parent artifact key.
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
167 <T extends AxConcept> List<T> getAll(Class<T> someClass, AxArtifactKey parentKey);
170 * Get a concept from the database with the given artifact key.
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
177 <T extends AxConcept> T getArtifact(Class<T> someClass, AxArtifactKey artifactId);
180 * Get a concept from the database with the given reference key.
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
187 <T extends AxConcept> T getArtifact(Class<T> someClass, AxReferenceKey artifactId);
190 * Get the number of instances of a concept that exist in the database.
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
196 <T extends AxConcept> long size(Class<T> someClass);
199 * Update a concept in the database.
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
205 <T extends AxConcept> T update(T obj);