public abstract class AbstractRepository<T extends Identifiable> extends Object implements Repository<T>
| Modifier and Type | Field and Description |
|---|---|
protected Loader<T> |
loader |
protected Path |
path |
protected JsonFileBasedPersister<T> |
persister |
protected BeanValidator |
validator |
| Constructor and Description |
|---|
AbstractRepository(Path path,
JsonFileBasedPersister<T> persister,
Loader<T> loader,
BeanValidator validator,
Watcher watcher) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsObject(String id)
Find if an object is used in pages
|
void |
createComponentDirectory(T component) |
void |
delete(String id)
Deletes component by its id
|
boolean |
exists(String id)
Return true if a component with provided id already exists in repository.
|
List<T> |
findByObjectId(String id)
Finds all pages which contains an object
|
Map<String,List<T>> |
findByObjectIds(List<String> ids)
Return a Map of object ids, with for each one all pages which contains this object
|
T |
get(String id)
Gets component by its id
|
List<T> |
getAll()
Get all the component in a directory
|
T |
getByUUID(String uuid)
Gets component by its uuid
Return null if the component does not Implement
HasUUID |
abstract String |
getComponentName()
Return the component name
|
String |
getNextAvailableId(String name) |
JsonFileBasedPersister<T> |
getPersister() |
T |
markAsFavorite(String id) |
Path |
resolvePath(String id)
Find the path file of a component linked with an id
|
Path |
resolvePathFolder(String id)
Path where the component files are saved
|
T |
save(T component)
Save a component but without updating last update date
|
void |
saveAll(List<T> toBeSaved)
Save a list of component
|
T |
unmarkAsFavorite(String id) |
T |
updateLastUpdateAndSave(T component)
Save a component
|
void |
walk(FileVisitor<? super Path> visitor) |
void |
watch(PathListener pathListener) |
protected JsonFileBasedPersister<T extends Identifiable> persister
protected Path path
protected BeanValidator validator
protected Loader<T extends Identifiable> loader
public AbstractRepository(Path path, JsonFileBasedPersister<T> persister, Loader<T> loader, BeanValidator validator, Watcher watcher)
public abstract String getComponentName()
RepositorygetComponentName in interface Repository<T extends Identifiable>public T get(String id) throws NotFoundException, RepositoryException
Repositoryget in interface Repository<T extends Identifiable>NotFoundExceptionRepositoryExceptionpublic T getByUUID(String uuid) throws RepositoryException
RepositoryHasUUIDgetByUUID in interface Repository<T extends Identifiable>RepositoryExceptionpublic List<T> getAll() throws RepositoryException
RepositorygetAll in interface Repository<T extends Identifiable>RepositoryExceptionpublic boolean containsObject(String id) throws RepositoryException
RepositorycontainsObject in interface Repository<T extends Identifiable>RepositoryExceptionpublic T updateLastUpdateAndSave(T component) throws RepositoryException
RepositoryupdateLastUpdateAndSave in interface Repository<T extends Identifiable>RepositoryExceptionpublic T save(T component) throws RepositoryException
Repositorysave in interface Repository<T extends Identifiable>RepositoryExceptionpublic void saveAll(List<T> toBeSaved) throws RepositoryException
RepositorysaveAll in interface Repository<T extends Identifiable>RepositoryExceptionpublic List<T> findByObjectId(String id) throws RepositoryException
RepositoryfindByObjectId in interface Repository<T extends Identifiable>RepositoryExceptionpublic Map<String,List<T>> findByObjectIds(List<String> ids) throws RepositoryException
RepositoryfindByObjectIds in interface Repository<T extends Identifiable>RepositoryExceptionpublic Path resolvePath(String id)
RepositoryresolvePath in interface Repository<T extends Identifiable>public void delete(String id) throws NotFoundException, RepositoryException
Repositorydelete in interface Repository<T extends Identifiable>NotFoundExceptionRepositoryExceptionpublic Path resolvePathFolder(String id)
RepositoryresolvePathFolder in interface Repository<T extends Identifiable>public void createComponentDirectory(T component)
public boolean exists(String id)
Repositoryexists in interface Repository<T extends Identifiable>public void walk(FileVisitor<? super Path> visitor) throws IOException
walk in interface Repository<T extends Identifiable>IOExceptionpublic void watch(PathListener pathListener) throws IOException
watch in interface Repository<T extends Identifiable>IOExceptionpublic T markAsFavorite(String id)
markAsFavorite in interface Repository<T extends Identifiable>public T unmarkAsFavorite(String id)
unmarkAsFavorite in interface Repository<T extends Identifiable>public String getNextAvailableId(String name) throws RepositoryException
getNextAvailableId in interface Repository<T extends Identifiable>RepositoryExceptionpublic JsonFileBasedPersister<T> getPersister()
Copyright © 2020. All rights reserved.