| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| IDaoPersistenceContext |
|
| 1.0;1 |
| 1 | package org.jtheque.core.managers.persistence.context; | |
| 2 | ||
| 3 | import org.jtheque.core.managers.persistence.QueryMapper; | |
| 4 | import org.jtheque.core.managers.persistence.able.Entity; | |
| 5 | import org.springframework.jdbc.core.simple.ParameterizedRowMapper; | |
| 6 | ||
| 7 | import java.util.Collection; | |
| 8 | ||
| 9 | /* | |
| 10 | * This file is part of JTheque. | |
| 11 | * | |
| 12 | * JTheque is free software: you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation, either version 3 of the License. | |
| 15 | * | |
| 16 | * JTheque is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
| 23 | */ | |
| 24 | ||
| 25 | /** | |
| 26 | * A dao persistence context specification. | |
| 27 | * | |
| 28 | * @author Baptiste Wicht | |
| 29 | */ | |
| 30 | public interface IDaoPersistenceContext { | |
| 31 | /** | |
| 32 | * Return all the entities of a certain class. | |
| 33 | * | |
| 34 | * @param <T> The entity class type. | |
| 35 | * @param table The entity table. | |
| 36 | * @param mapper The row mapper. | |
| 37 | * @return A List sorted by entity displayable text containing all the entity of the class. | |
| 38 | */ | |
| 39 | <T extends Entity> Collection<T> getSortedList(String table, ParameterizedRowMapper<T> mapper); | |
| 40 | ||
| 41 | /** | |
| 42 | * Return an entity of a specific ID. | |
| 43 | * | |
| 44 | * @param <T> The entity class type. | |
| 45 | * @param id The searched id. | |
| 46 | * @param table The entity table. | |
| 47 | * @param mapper The row mapper. | |
| 48 | * @return The entity. | |
| 49 | */ | |
| 50 | <T extends Entity> T getDataByID(String table, int id, ParameterizedRowMapper<T> mapper); | |
| 51 | ||
| 52 | /** | |
| 53 | * Delete an entity of a specific ID. | |
| 54 | * | |
| 55 | * @param id The searched id. | |
| 56 | * @param table The entity table. | |
| 57 | * @return true if the object is deleted else false. | |
| 58 | */ | |
| 59 | boolean delete(String table, int id); | |
| 60 | ||
| 61 | /** | |
| 62 | * Delete an Entity. | |
| 63 | * | |
| 64 | * @param d The entity to delete. | |
| 65 | * @param table The entity table. | |
| 66 | * @return true if the object is deleted else false. | |
| 67 | */ | |
| 68 | boolean delete(String table, Entity d); | |
| 69 | ||
| 70 | /** | |
| 71 | * Save or update an entity. | |
| 72 | * | |
| 73 | * @param entity The entity to save or update. | |
| 74 | * @param mapper The query mapper. | |
| 75 | * @return true if the object is saved else false. | |
| 76 | * @throws IllegalArgumentException if entity is null. | |
| 77 | */ | |
| 78 | boolean saveOrUpdate(Entity entity, QueryMapper mapper); | |
| 79 | ||
| 80 | /** | |
| 81 | * Delete all the entities of a certain class. | |
| 82 | * | |
| 83 | * @param table The entity table. | |
| 84 | */ | |
| 85 | void deleteAll(String table); | |
| 86 | } |