Package nl.knaw.dans.layerstore
Class LayerDatabaseImpl
java.lang.Object
nl.knaw.dans.layerstore.LayerDatabaseImpl
- All Implemented Interfaces:
LayerDatabase
-
Constructor Summary
ConstructorDescriptionLayerDatabaseImpl
(nl.knaw.dans.lib.util.PersistenceProvider<ItemRecord> persistenceProvider) -
Method Summary
Modifier and TypeMethodDescriptionaddDirectory
(long layerId, String path) Adds a directory to the database.void
deleteRecordsById
(long... id) Deletes the records with the given ids.boolean
existsPathLike
(String pathPattern) Returns whether the path pattern matches any path in the database.findLayersContaining
(String path) Finds all the layers that contain the given path.Retrieves a stream of all the records in the database.getRecordsByPath
(String path) Returns the records for the given path in any layer.listDirectory
(String directoryPath) Lists the items indirectoryPath
.listRecursive
(String directoryPath) Lists the items indirectoryPath
recursively.void
saveRecords
(ItemRecord... records) Save records to the database.
-
Constructor Details
-
LayerDatabaseImpl
-
-
Method Details
-
saveRecords
Description copied from interface:LayerDatabase
Save records to the database. The records may be new or existing. If a record already exists, it is updated.- Specified by:
saveRecords
in interfaceLayerDatabase
- Parameters:
records
- the records to save
-
deleteRecordsById
public void deleteRecordsById(long... id) Description copied from interface:LayerDatabase
Deletes the records with the given ids.- Specified by:
deleteRecordsById
in interfaceLayerDatabase
- Parameters:
id
- the ids of the records to delete
-
listDirectory
Description copied from interface:LayerDatabase
Lists the items indirectoryPath
. It takes into account the complete stack of layers. If the directory does not exist in any of the layers, an IllegalArgumentException is thrown.- Specified by:
listDirectory
in interfaceLayerDatabase
- Parameters:
directoryPath
- the directory path relative to the storage root- Returns:
- the items in the directory
- Throws:
IOException
-
listRecursive
Description copied from interface:LayerDatabase
Lists the items indirectoryPath
recursively. It takes into account the complete stack of layers.- Specified by:
listRecursive
in interfaceLayerDatabase
- Parameters:
directoryPath
- the directory path relative to the storage root- Returns:
- the items in the directory and its subdirectories
- Throws:
IOException
-
addDirectory
Description copied from interface:LayerDatabase
Adds a directory to the database. Ancestor directories are added automatically, if they do not exist in the same layer yet.- Specified by:
addDirectory
in interfaceLayerDatabase
path
- the path of the directory relative to the storage root- Returns:
- the records that were added to the database for directories that did not exist yet
-
findLayersContaining
Description copied from interface:LayerDatabase
Finds all the layers that contain the given path.- Specified by:
findLayersContaining
in interfaceLayerDatabase
- Parameters:
path
- path relative to the root of the storage- Returns:
- the ids of the layers that contain the path
-
getRecordsByPath
Description copied from interface:LayerDatabase
Returns the records for the given path in any layer. The records are ordered by layer id, with the newest layer first.- Specified by:
getRecordsByPath
in interfaceLayerDatabase
- Parameters:
path
- path relative to the root of the storage- Returns:
- the records for the given path
-
getAllRecords
Description copied from interface:LayerDatabase
Retrieves a stream of all the records in the database.- Specified by:
getAllRecords
in interfaceLayerDatabase
- Returns:
- a list of all the records in the database
-
existsPathLike
Description copied from interface:LayerDatabase
Returns whether the path pattern matches any path in the database.- Specified by:
existsPathLike
in interfaceLayerDatabase
- Parameters:
pathPattern
- a path pattern that may contain wildcards- Returns:
- true if the pattern matches any path in the database, false otherwise
-