Package de.dlr.proseo.prodclmgr.rest
Class ProductClassManager
java.lang.Object
de.dlr.proseo.prodclmgr.rest.ProductClassManager
@Component
@Transactional(isolation=REPEATABLE_READ)
public class ProductClassManager
extends Object
Service methods required to manage product classes and their selection rules
- Author:
- Dr. Thomas Bassler
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) ProductClassConfigurationThe product class configuration -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddProcessorToRule(String configuredProcessor, Long ruleid, Long id) Add the configured processor to the selection rule (if it is not already part of the selection rule)countProductClasses(String mission, String[] productType, String[] processorClass, String level, String visibility) Count product classes, optionally filtered by mission and/or product typecreateRestProductClass(RestProductClass productClass) Create a new product classcreateSelectionRuleString(Long id, @Valid List<SelectionRuleString> selectionRuleStrings) Create a selection rule using Rule LanguagevoidDelete a product class by ID (with all its selection rules)voiddeleteSelectionrule(Long ruleid, Long id) Delete a selection rulegetProductClassNames(String mission, String productType) Get the product class names, optionally filtered by mission and/or product typegetRestProductClass(String mission, String[] productType, String[] processorClass, String level, String visibility, String[] orderBy, Integer recordFrom, Integer recordTo) Get product classes, optionally filtered by mission and/or product typeGet a product class by IDgetSelectionRuleString(Long ruleid, Long id) Get a selection rule by IDgetSelectionRuleStrings(Long id, String sourceClass) Get the simple selection rules as formatted string, optionally selected by source classmodifyRestProductClass(Long id, RestProductClass productClass) Update a product class by ID (does not update its selection rules)modifySelectionRuleString(Long ruleid, Long id, SelectionRuleString selectionRuleString) Update a selection rule using Rule LanguageremoveProcessorFromRule(String configuredProcessor, Long ruleid, Long id) Remove the configured processor from the selection rule (the selection rule will be disconnected from the configured processor)
-
Field Details
-
config
The product class configuration
-
-
Constructor Details
-
ProductClassManager
public ProductClassManager()
-
-
Method Details
-
getRestProductClass
public List<RestProductClass> getRestProductClass(String mission, String[] productType, String[] processorClass, String level, String visibility, String[] orderBy, Integer recordFrom, Integer recordTo) throws jakarta.persistence.NoResultException, SecurityException, org.springframework.web.client.HttpClientErrorException.TooManyRequests Get product classes, optionally filtered by mission and/or product type- Parameters:
mission- the mission codeproductType- a list of product types as agreed in the mission specification documents (e. g. L2_CLOUD___)processorClass- a list of processor types capable of producing products from the retrieved product classeslevel- the required level of processing for the retrieved product classesvisibility- the visibility of products from the retrieved product classes to external usersorderBy- an array of strings containing a column name and an optional sort direction (ASC/DESC), separated by white spacerecordFrom- the first result to returnrecordTo- the last result to return- Returns:
- a list of product classes conforming to the search criteria
- Throws:
jakarta.persistence.NoResultException- if no product classes matching the given search criteria could be foundSecurityException- if a cross-mission data access was attemptedorg.springframework.web.client.HttpClientErrorException.TooManyRequests- if the result list would exceed a configured maximum
-
countProductClasses
public String countProductClasses(String mission, String[] productType, String[] processorClass, String level, String visibility) throws jakarta.persistence.NoResultException, SecurityException Count product classes, optionally filtered by mission and/or product type- Parameters:
mission- the mission codeproductType- a list of product types as agreed in the mission specification documents (e. g. L2_CLOUD___)processorClass- a list of processor types capable of producing products from the retrieved product classeslevel- the required level of processing for the retrieved product classesvisibility- the visibility of products from the retrieved product classes to external users- Returns:
- a list of product classes conforming to the search criteria
- Throws:
jakarta.persistence.NoResultException- if no product classes matching the given search criteria could be foundSecurityException- if a cross-mission data access was attempted
-
getProductClassNames
public List<String> getProductClassNames(String mission, String productType) throws jakarta.persistence.NoResultException, SecurityException Get the product class names, optionally filtered by mission and/or product type- Parameters:
mission- the mission codeproductType- a list of product types as agreed in the mission specification documents (e. g. L2_CLOUD___)- Returns:
- a list of product classes conforming to the search criteria
- Throws:
jakarta.persistence.NoResultException- if no product classes matching the given search criteria could be foundSecurityException- if a cross-mission data access was attempted
-
createRestProductClass
public RestProductClass createRestProductClass(RestProductClass productClass) throws IllegalArgumentException, javax.ws.rs.ServerErrorException, SecurityException Create a new product class- Parameters:
productClass- a Json object describing the new product class- Returns:
- a Json object describing the product class created (including ID and version) and HTTP status CREATED
- Throws:
IllegalArgumentException- if any of the input data was invalidjavax.ws.rs.ServerErrorException- if saving the product class to the database failsSecurityException- if a cross-mission data access was attempted
-
getRestProductClassById
public RestProductClass getRestProductClassById(Long id) throws IllegalArgumentException, jakarta.persistence.NoResultException, SecurityException Get a product class by ID- Parameters:
id- the database ID of the product class- Returns:
- a Json object describing the product class and HTTP status OK
- Throws:
IllegalArgumentException- if no product class ID was givenjakarta.persistence.NoResultException- if no product class with the given ID existsSecurityException- if a cross-mission data access was attempted
-
modifyRestProductClass
public RestProductClass modifyRestProductClass(Long id, RestProductClass productClass) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, SecurityException, ConcurrentModificationException Update a product class by ID (does not update its selection rules)- Parameters:
id- the database ID of the product class to updateproductClass- a Json object describing the product class to modify- Returns:
- a Json object describing the product class modified (including incremented version)
- Throws:
jakarta.persistence.EntityNotFoundException- if no product class with the given ID existsIllegalArgumentException- if any of the input data was invalidSecurityException- if a cross-mission data access was attemptedConcurrentModificationException- if the product class has been modified since retrieval by the client
-
deleteProductclassById
public void deleteProductclassById(Long id) throws jakarta.persistence.EntityNotFoundException, RuntimeException, IllegalArgumentException, SecurityException Delete a product class by ID (with all its selection rules)- Parameters:
id- the database ID of the product class to delete- Throws:
jakarta.persistence.EntityNotFoundException- if the processor to delete does not exist in the databaseRuntimeException- if the deletion was not performed as expectedIllegalArgumentException- if the product class ID was not given, or if dependent objects existSecurityException- if a cross-mission data access was attempted
-
getSelectionRuleStrings
public List<SelectionRuleString> getSelectionRuleStrings(Long id, String sourceClass) throws jakarta.persistence.NoResultException, SecurityException Get the simple selection rules as formatted string, optionally selected by source class- Parameters:
id- the database ID of the product class to get the selection rule fromsourceClass- the prosEO product type of the source class, from which the product class can be generated (may be null)- Returns:
- a list of strings describing the selection rules for all configured processors
- Throws:
jakarta.persistence.NoResultException- if no simple selection rules matching the given search criteria could be foundSecurityException- if a cross-mission data access was attempted
-
createSelectionRuleString
public RestProductClass createSelectionRuleString(Long id, @Valid @Valid List<SelectionRuleString> selectionRuleStrings) throws IllegalArgumentException, SecurityException Create a selection rule using Rule Language- Parameters:
id- the database ID of the product classselectionRuleStrings- a Json representation of a selection rule in Rule Language- Returns:
- a Json object representing the simple selection rule created and HTTP status CREATED
- Throws:
IllegalArgumentException- if any of the input data was invalidSecurityException- if a cross-mission data access was attempted
-
getSelectionRuleString
public SelectionRuleString getSelectionRuleString(Long ruleid, Long id) throws jakarta.persistence.NoResultException, SecurityException Get a selection rule by ID- Parameters:
ruleid- the database ID of the simple selection rule to readid- the database ID of the product class- Returns:
- a Json object representing the simple selection rule in Rule Language
- Throws:
jakarta.persistence.NoResultException- if no selection rule or product class with the given ID existSecurityException- if a cross-mission data access was attempted
-
modifySelectionRuleString
public SelectionRuleString modifySelectionRuleString(Long ruleid, Long id, SelectionRuleString selectionRuleString) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, SecurityException, ConcurrentModificationException Update a selection rule using Rule Language- Parameters:
ruleid- the database ID of the simple selection rule to updateid- the database ID of the product classselectionRuleString- a Json object representing the simple selection rule in Rule Language- Returns:
- a Json object representing the modified simple selection rule in Rule Language
- Throws:
jakarta.persistence.EntityNotFoundException- if no selection rule or product class with the given ID existIllegalArgumentException- if any of the input data was invalidSecurityException- if a cross-mission data access was attemptedConcurrentModificationException- if the selection rule has been modified since retrieval by the client
-
deleteSelectionrule
public void deleteSelectionrule(Long ruleid, Long id) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, SecurityException Delete a selection rule- Parameters:
ruleid- the database ID of the simple selection rule to deleteid- the database ID of the product class- Throws:
jakarta.persistence.EntityNotFoundException- if the selection rule to delete or the product class do not exist in the databaseIllegalArgumentException- if the ID of the product class or the selection rule was not given, or the rule cannot be deleted due to existing product queriesSecurityException- if a cross-mission data access was attempted
-
addProcessorToRule
public SelectionRuleString addProcessorToRule(String configuredProcessor, Long ruleid, Long id) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, SecurityException Add the configured processor to the selection rule (if it is not already part of the selection rule)- Parameters:
configuredProcessor- the name of the configured processor to add to the selection ruleruleid- the database ID of the simple selection ruleid- the database ID of the product class- Returns:
- the modified selection rule in Rule Language
- Throws:
jakarta.persistence.EntityNotFoundException- if no configured processor with the given name or no selection rule or product class with the given ID existIllegalArgumentException- if the product class ID, the selection rule ID or the name of the configured processor were not givenSecurityException- if a cross-mission data access was attempted
-
removeProcessorFromRule
public SelectionRuleString removeProcessorFromRule(String configuredProcessor, Long ruleid, Long id) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, SecurityException Remove the configured processor from the selection rule (the selection rule will be disconnected from the configured processor)- Parameters:
configuredProcessor- the name of the configured processor to remove from the selection ruleruleid- the database ID of the simple selection ruleid- the database ID of the product class- Returns:
- the Json representation of the modified selection rule
- Throws:
jakarta.persistence.EntityNotFoundException- if no configured processor with the given name or no selection rule or product class with the given ID existIllegalArgumentException- if the product class ID, the selection rule ID or the name of the configured processor were not givenSecurityException- if a cross-mission data access was attempted
-