minimum list management implemented
This commit is contained in:
@@ -63,9 +63,22 @@ public interface CacheService {
|
||||
*/
|
||||
List<CacheList> getAllCacheLists();
|
||||
|
||||
/**
|
||||
* Test if a cache list with the given name already exists
|
||||
* @param name of the cache list
|
||||
* @return true if a list with the given name exists
|
||||
*/
|
||||
boolean doesCacheListNameExist(String name);
|
||||
|
||||
/**
|
||||
* Stores a cache list
|
||||
* @param list list of caches
|
||||
*/
|
||||
void storeCacheList(CacheList list);
|
||||
|
||||
/**
|
||||
* Deletes a cache list
|
||||
* @param cacheList deletes the given cache list
|
||||
*/
|
||||
void deleteCacheList(CacheList cacheList);
|
||||
}
|
||||
|
||||
@@ -135,6 +135,33 @@ public class CacheServiceImpl implements CacheService {
|
||||
return lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesCacheListNameExist(String name) {
|
||||
boolean doesExist = false;
|
||||
try {
|
||||
EntityManager em = dbService.getEntityManager();
|
||||
String query = "select count(l) from CacheList l where l.name = :name";
|
||||
Long result = (Long)em.createQuery(query).setParameter("name", name).getSingleResult();
|
||||
doesExist = result > 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return doesExist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCacheList(CacheList cacheList) {
|
||||
EntityManager em = dbService.getEntityManager();
|
||||
try {
|
||||
em.getTransaction().begin();
|
||||
em.remove(cacheList);
|
||||
em.getTransaction().commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
em.getTransaction().rollback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user