Package org.ehrbase.api.service
Interface FolderService
-
- All Superinterfaces:
BaseService
public interface FolderService extends BaseService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description UUIDcreate(UUID ehrId, com.nedap.archie.rm.directory.Folder content)Creates a new folder entry at the database from content.LocalDateTimedelete(UUID folderId)Marks a given folder as deleted and moves it into the history table.IntegergetLastVersionNumber(UUID folderId)Searches the last version number of a given folder entry from database.IntegergetVersionNumberForTimestamp(UUID folderId, LocalDateTime timestamp)Searches for the folder version that was the current version at the given timestamp.Optional<FolderDto>retrieve(UUID folderId, Integer version, String path)Returns a versioned folder object by target version number.Optional<FolderDto>retrieveByTimestamp(UUID folderId, Timestamp timestamp, String path)Returns a versioned folder object which has been or is current at the given timestamp.Optional<FolderDto>retrieveLatest(UUID ehrId, String path)StructuredStringserialize(com.nedap.archie.rm.directory.Folder folder, StructuredStringFormat format)Serializes folder content from request body into a structured string that can be used by database save mechanism to parse in into jsonb format that will be saved at the database.Optional<FolderDto>update(UUID folderId, com.nedap.archie.rm.directory.Folder update, UUID ehrId)Updates a target folder entry identified by the given folderId with new content.-
Methods inherited from interface org.ehrbase.api.service.BaseService
getServerConfig, getSystemUuid
-
-
-
-
Method Detail
-
create
UUID create(UUID ehrId, com.nedap.archie.rm.directory.Folder content)
Creates a new folder entry at the database from content. The provided content from request payload will be serialized before corresponding to the given source format. The folder will be linked to the EHR addressed by the request.- Parameters:
ehrId- - ID for the corresponding EHRcontent- -Folderto persist- Returns:
- UUID of the new created Folder from database
-
retrieve
Optional<FolderDto> retrieve(UUID folderId, Integer version, String path)
Returns a versioned folder object by target version number. If the version number is missing the latest version will be fetched from folder table. If the version is older than the last one from folder table the target folder will be fetched from folder_history.- Parameters:
folderId- - UUID of the folder to fetchversion- - Target version to fetchpath- - Path of sub folder to get- Returns:
- Data transfer object to return to client
-
retrieveByTimestamp
Optional<FolderDto> retrieveByTimestamp(UUID folderId, Timestamp timestamp, String path)
Returns a versioned folder object which has been or is current at the given timestamp. Therefore the folder table must be queried if there is an actual folder with that uuid that has been created before the given timestamp. Otherwise the folder_history table will be queried to find a folder created after that timestamp.- Parameters:
folderId- - UUID of the target foldertimestamp- - Given timestamp to look for an actual folder- Returns:
- - Created folder object
-
update
Optional<FolderDto> update(UUID folderId, com.nedap.archie.rm.directory.Folder update, UUID ehrId)
Updates a target folder entry identified by the given folderId with new content. The content string will be serialized from the given source format. TODO: Copy from CompositionService. Must be designed for folder- Parameters:
folderId- - Id of the target folderupdate- - Update content from request bodyehrId- - EHR id for contribution creation- Returns:
- Updated folder entry
-
delete
LocalDateTime delete(UUID folderId)
Marks a given folder as deleted and moves it into the history table. The folder will no longer be accessible without time or version information available.- Parameters:
folderId- - Id of the target folder- Returns:
- Timestamp of successful delete operation
-
serialize
StructuredString serialize(com.nedap.archie.rm.directory.Folder folder, StructuredStringFormat format)
Serializes folder content from request body into a structured string that can be used by database save mechanism to parse in into jsonb format that will be saved at the database.- Parameters:
folder- - Folder to serializeformat- - Source format of the folder- Returns:
- Structured string that can be parsed into jsonb
-
getLastVersionNumber
Integer getLastVersionNumber(UUID folderId)
Searches the last version number of a given folder entry from database. This will be executed against the folder table which contains the latest entry of a folder. The version will be extracted from there.- Parameters:
folderId- - Id of the folder to search for the latest version- Returns:
- Version number of the latest folder entry
- Throws:
ObjectNotFoundException- - Folder entry does not exist
-
getVersionNumberForTimestamp
Integer getVersionNumberForTimestamp(UUID folderId, LocalDateTime timestamp)
Searches for the folder version that was the current version at the given timestamp. If the entry from folder table has a later timestamp the folder history will be queried to find the version at the timestamp- Parameters:
folderId- - Id of the folder to search the versiontimestamp- - Timestamp to look for the version number- Returns:
- - Version number that was actual at the timestamp
- Throws:
ObjectNotFoundException- - Folder entry does not exist at the time
-
-