Commit 8beacd0c authored by Kristel Meikas's avatar Kristel Meikas
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Kristel Meikas

See merge request teis/files-service!92
parents 14845e18 0c1034dd
# Changelog
## [2.4.0] - 2022-09-12
* TEIS-2699: added method getCurrentByObjectIdAndFileIdAndObjectType
## [2.3.0] - 2022-08-26
* TEIS-2706: added method getCurrentByFileIdAndObjectType
......
theGroup=ee.sm.ti.teis
theVersion=2.3.0
theVersion=2.4.0
commonsVersion=2.7.0
commonApiGatewayVersion=2.6.0
pluginVersion=2.3.0
......
......@@ -100,6 +100,16 @@ public class FileReferenceBusinessService {
return dataService.getCurrentByFileId(fileId);
}
public FileReferenceDto getCurrentByObjectIdAndFileIdAndObjectType(UUID objectId, UUID fileId, String objectType,
RequestMetaDTO requestMetaDTO) {
Optional<FileReferenceEntity> fileReference = this.dataService.getCurrentByFileIdAndObjectIdAndObjectType(fileId, objectId, objectType);
if (fileReference.isEmpty()) {
throw new TeisResourceNotFoundException("Current file reference not found with ID and object type", List.of(fileId, objectType));
} else {
return composeService.toDto(fileReference.get(), requestMetaDTO);
}
}
public FileReferenceDto getCurrentByIdAndObjectType(UUID id, ObjectType objectType, RequestMetaDTO requestMetaDTO) {
Optional<FileReferenceEntity> fileReference = dataService.getCurrentByIdAndObjectType(id, objectType.getId());
if (fileReference.isEmpty()) {
......
......@@ -60,6 +60,11 @@ public class FileReferenceDataService {
return repository.findByFileIdAndObjectId(fileId, objectId);
}
public Optional<FileReferenceEntity> getCurrentByFileIdAndObjectIdAndObjectType(UUID fileId, UUID objectId,
String objectType) {
return repository.findByFileIdAndObjectIdAndObjectTypeAndObjectStatus(fileId, objectId, objectType, CURRENT);
}
public Optional<FileReferenceEntity> getByIdAndObjectType(UUID id, String objectType) {
return repository.findByIdAndObjectType(id, objectType);
}
......
......@@ -59,6 +59,9 @@ public interface FileReferenceRepository extends JpaRepository<FileReferenceEnti
Optional<FileReferenceEntity> findByFileIdAndObjectId(UUID fileId, UUID objectId);
Optional<FileReferenceEntity> findByFileIdAndObjectIdAndObjectTypeAndObjectStatus(UUID fileId, UUID objectId,
String objectType, ObjectStatus objectStatus);
Optional<FileReferenceEntity> findByIdAndObjectType(UUID id, String objectType);
default Optional<FileReferenceEntity> findCurrentByIdAndObjectType(UUID id, String objectType) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment