Package nl.knaw.dans.layerstore
Class LayerDatabaseImpl
java.lang.Object
nl.knaw.dans.layerstore.LayerDatabaseImpl
- All Implemented Interfaces:
LayerDatabase
-
Constructor Summary
ConstructorsConstructorDescriptionLayerDatabaseImpl(nl.knaw.dans.lib.util.PersistenceProvider<ItemRecord> persistenceProvider) -
Method Summary
Modifier and TypeMethodDescriptionaddDirectory(long layerId, String path) Adds a directory to the database.voiddeleteRecordsById(long... id) Deletes the records with the given ids.booleanexistsPathLike(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.getRecordsByLayerId(long layerId) Gets all records for the given layer id.getRecordsByPath(String path) Returns the records for the given path in any layer.listDirectory(String directoryPath) Lists the items indirectoryPath.Lists all layer IDs that are currently in the database.listRecursive(String directoryPath) Lists the items indirectoryPathrecursively.voidsaveRecords(ItemRecord... records) Save records to the database.
-
Constructor Details
-
LayerDatabaseImpl
-
-
Method Details
-
saveRecords
Description copied from interface:LayerDatabaseSave records to the database. The records may be new or existing. If a record already exists, it is updated.- Specified by:
saveRecordsin interfaceLayerDatabase- Parameters:
records- the records to save
-
deleteRecordsById
public void deleteRecordsById(long... id) Description copied from interface:LayerDatabaseDeletes the records with the given ids.- Specified by:
deleteRecordsByIdin interfaceLayerDatabase- Parameters:
id- the ids of the records to delete
-
listDirectory
Description copied from interface:LayerDatabaseLists 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:
listDirectoryin interfaceLayerDatabase- Parameters:
directoryPath- the directory path relative to the storage root- Returns:
- the items in the directory
- Throws:
IOException
-
listRecursive
Description copied from interface:LayerDatabaseLists the items indirectoryPathrecursively. It takes into account the complete stack of layers.- Specified by:
listRecursivein 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:LayerDatabaseAdds a directory to the database. Ancestor directories are added automatically if they do not exist in the same layer yet.- Specified by:
addDirectoryin interfaceLayerDatabasepath- 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:LayerDatabaseFinds all the layers that contain the given path.- Specified by:
findLayersContainingin 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:LayerDatabaseReturns the records for the given path in any layer. The records are ordered by layer id, with the newest layer first.- Specified by:
getRecordsByPathin interfaceLayerDatabase- Parameters:
path- path relative to the root of the storage- Returns:
- the records for the given path
-
getAllRecords
Description copied from interface:LayerDatabaseRetrieves a stream of all the records in the database.- Specified by:
getAllRecordsin interfaceLayerDatabase- Returns:
- a list of all the records in the database
-
existsPathLike
Description copied from interface:LayerDatabaseReturns whether the path pattern matches any path in the database.- Specified by:
existsPathLikein interfaceLayerDatabase- Parameters:
pathPattern- a path pattern that may contain wildcards- Returns:
- true if the pattern matches any path in the database, false otherwise
-
listLayerIds
Description copied from interface:LayerDatabaseLists all layer IDs that are currently in the database.- Specified by:
listLayerIdsin interfaceLayerDatabase- Returns:
- a list of layer IDs
-
getRecordsByLayerId
Description copied from interface:LayerDatabaseGets all records for the given layer id.- Specified by:
getRecordsByLayerIdin interfaceLayerDatabase- Parameters:
layerId- the layer id to get records for- Returns:
- a list of records for the given layer id
-