Package de.dlr.proseo.archivemgr.rest
Class ProductArchiveManager
java.lang.Object
de.dlr.proseo.archivemgr.rest.ProductArchiveManager
Service methods required to create, modify and delete product archives in the
prosEO database, and to query the database about such archives
- Author:
- Denys Chaykovskiy
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) ProductArchiveManagerConfigurationThe product archive manager configuration -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanarchiveExistsByCode(String code) Checks if archive exists, filtered by codebooleanChecks if archive exists, filtered by idcountArchives(Long id, String code, String name, String archiveType) Count the product archives matching the specified name and archive typecreateArchive(RestProductArchive restArchive) Creation of the product archivejakarta.persistence.QueryCreate database query to count or get objectsvoidDelete a product archive by IDgetArchiveByCode(String code) Gets a product archive, searched by codegetArchiveById(Long id) Find the product archive with the given IDgetArchives(Long id, String code, String name, String archiveType, Integer recordFrom, Integer recordTo) Get product archives by name and archive typegetArchivesByCode(String code) List of all product archives archives filtered by codemodifyArchive(Long id, RestProductArchive restArchive) Update the product archive with the given ID with the attribute values of the given Json object.
-
Field Details
-
config
The product archive manager configuration
-
-
Constructor Details
-
ProductArchiveManager
public ProductArchiveManager()
-
-
Method Details
-
createArchive
public RestProductArchive createArchive(RestProductArchive restArchive) throws IllegalArgumentException Creation of the product archive- Parameters:
restArchive- Rest Product Archive- Returns:
- created Rest Product Archive
- Throws:
IllegalArgumentException- if mandatory parameters missed or wrong
-
archiveExistsByCode
Checks if archive exists, filtered by code- Parameters:
code- code of the archive- Returns:
- true if exists
-
archiveExistsById
Checks if archive exists, filtered by id- Parameters:
id- id of the archive- Returns:
- true if exists
-
getArchiveByCode
Gets a product archive, searched by code- Parameters:
code- the code of the product archive- Returns:
- product archive
- Throws:
IllegalArgumentException- if no product archive matching the given code could be found
-
getArchivesByCode
List of all product archives archives filtered by code- Parameters:
code- the code of the product archive- Returns:
- a list of product archives, if code == null, returns all archives
- Throws:
jakarta.persistence.NoResultException- if no product archives matching the given search criteria could be found
-
getArchiveById
public RestProductArchive getArchiveById(Long id) throws IllegalArgumentException, jakarta.persistence.NoResultException Find the product archive with the given ID- Parameters:
id- the ID to look for- Returns:
- a Json object corresponding to the product archive found
- Throws:
IllegalArgumentException- if no product archive ID was givenjakarta.persistence.NoResultException- if no product archive with the given ID exists
-
createArchivesQuery
public jakarta.persistence.Query createArchivesQuery(Long id, String code, String name, String archiveType, Boolean count) Create database query to count or get objects- Parameters:
code- the archive codename- the archive namearchiveType- the archive typecount- if true create query for count of objects- Returns:
- a database query
-
getArchives
public List<RestProductArchive> getArchives(Long id, String code, String name, String archiveType, Integer recordFrom, Integer recordTo) throws jakarta.persistence.NoResultException Get product archives by name and archive type- Parameters:
code- the archive codename- the archive namearchiveType- the archive typerecordFrom- first record of filtered and ordered result to returnrecordTo- last record of filtered and ordered result to return- Returns:
- a list of Json objects representing product archives satisfying the search criteria
- Throws:
jakarta.persistence.NoResultException- if no product archives matching the given search criteria could be found
-
countArchives
Count the product archives matching the specified name and archive type- Parameters:
name- the product archive namearchiveType- the product archive type- Returns:
- the number of product archives found as string
-
modifyArchive
Update the product archive with the given ID with the attribute values of the given Json object. Unchanged values must be provided, too, or they will be changed to null.- Parameters:
id- the ID of the product archive to updaterestArchive- a Json object containing the modified (and unmodified) attributes- Returns:
- a Json object corresponding to the product archive after modification (with ID and version for all contained objects)
- Throws:
jakarta.persistence.EntityNotFoundException- if no product with the given ID existsIllegalArgumentException- if any of the input data was invalidConcurrentModificationException- if the facility has been modified since retrieval by the client
-
deleteArchiveById
public void deleteArchiveById(Long id) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, RuntimeException Delete a product archive by ID- Parameters:
id- the ID of the product archive to delete- Throws:
jakarta.persistence.EntityNotFoundException- if the product archive to delete does not exist in the databaseIllegalArgumentException- if the product archive to delete still has stored productsRuntimeException- if the deletion was not performed as expected
-