Klasse SelectionRule
A selection rule can be described in text form according to the following grammar (words in single quotes denote language key words, angled brackets denote optional elements, an ellipsis denotes zero or more repetitions of the element preceding it, a vertical bar denotes choice between two or more elements, all other punctuation characters are to be taken literally):
rule ::= simple_rule [ ; rule ] simple_rule ::= 'FOR' source_product_type 'SELECT' policy [ 'OPTIONAL' | 'MANDATORY' | 'MINCOVER' ( digit ... ) ] policy ::= simple_policy [ 'OR' policy ] simple_policy ::= policy_name [ ( delta_time , delta_time ) ] policy_name ::= 'ValCover' | 'LatestValCover' | 'ValIntersect' | 'latestValIntersect' | 'LatestValidityClosest' | 'BestCenteredCover' | 'LatestValCoverClosest' | 'LargestOverlap' | 'LargestOverlap85' | 'LatestValidity' | 'LatestValCoverNewestValidity' | 'ClosestStartValidity' | 'ClosestStopValidity' | 'LatestStartValidity' | 'LatestStopValidity' | 'ValIntersectWithoutDuplicates' | 'LastCreated' source_product_type ::= product_type[/parameter_key:parameter_value[,parameter_key:parameter_value] ...] delta_time ::= digit ... [ 'd' | 'h' | 'm' | 's' | 'ms' ] digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9Key words are not case sensitive, this includes the names of selection policies. Punctuation characters need not (but may) be enclosed by white space.
If for a simple rule neither OPTIONAL nor MINCOVER or MANDATORY is specified, MANDATORY is the default. If for a delta time, neither 'd' (days), 'h' (hours), 'm' (minutes), 's' (seconds) or 'ms' (microseconds) is specified, 'd' (days) is the default.
A simple rule marked as OPTIONAL is fulfilled even if no items satisfy the rule. For a simple rule marked MANDATORY at least one item must fulfil the rule criteria. If the rule is marked as MINCOVER(n), the set of items fulfilling the rule criteria must as a whole cover at least n % of the validity interval given as selection parameters. MINCOVER implies MANDATORY (even MINCOVER(0), in which case it is acceptable, if all items are outside of the validity interval).
The 'OR' operator is a short-circuited operator, i. e. if during the selection of items the first simple policy yields a non-empty result set, this result set is returned, and only if the result set is empty, the policy following the 'OR' is evaluated.
Multiple occurrences of 'LatestValidityClosest' for the same item type (product type) in one set of selection rules are only allowed, if all occurrences have the same delta times. (This policy actually refers to a point in time and not to a time interval, therefore a merge can only be done between policies referring to the same point in time.)
A 'source_product_type' consists of prosEO product (class) type and optionally parameter values to filter items within the collection. Parameter keys and values are separated from the product type by a slash ('/'), and are separated from each other by commas. Parameter key and value for each entry are separated by colons (':'). There must not be any white space between any of the elements of the product type. Note that for the purpose of the selection, source product types with the same product type name, but different parameters are considered different source product types. The parameter keys and values are only evaluated for the generation of JPQL and SQL queries.
The following are examples for legal rules:
- FOR AUX_CH4 SELECT ValIntersect(0, 0)
- FOR AUX_CH4 SELECT ValIntersect(0, 0) OR LatestValidity
- FOR AUX_CH4 SELECT ValIntersect(0, 0) OR LatestValidity OPTIONAL; for AUX_ECMWF-FC48 select latestvalintersect ( 12 h , 24 h )
The following rule examples are not valid:
- SELECT ValIntersect(0, 0) (the auxiliary product type must be specified)
- FOR AUX_CH4 SELECT ValIntersect(-1, 0) (no negative values)
- FOR AUX_CH4 SELECT ValIntersect(1h, 1h) (the time unit must be separated from the numerical value by white space)
- FOR AUX_CH4 SELECT ValIntersect(0, 0); (the semicolon is a rule separator, not a rule terminator)
- Autor:
- Dr. Thomas Bassler
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final Pattern
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
addSimpleRules
(Collection<SimpleSelectionRule> newSimpleRules) Adds a collection of simple selection rules to this rulevoid
Removes all simple selection rules from this ruleGets all simple selection rules contained in the selection rulehasPolicyFor
(String itemType) Tests whether this rule has a selection policy for the given item type (aux product type)merge
(SelectionRule anotherRule) Merge this selection rule with another selection rule, thereby extending the validity periods per product type for each policy in such a way that the validity periods of this rule and of the other rule are covered.static SelectionRule
parseSelectionRule
(ProductClass targetProductClass, String selectionRuleString) Parse the given string as a selection rule (seethe grammar definition in the class comment
).selectItems
(String productType, Collection<SelectionItem> items, Instant startTime, Instant stopTime) Select all items in the given collection of items that fulfil the selection rule with respect to a given time interval.selectProducts
(String productType, Collection<Product> products, Instant startTime, Instant stopTime) Select all products in the given collection of products that fulfil the selection rule with respect to a given time interval.selectUniqueItem
(String productType, Collection<SelectionItem> items, Instant startTime, Instant stopTime) Select the one item in the given collection of items that fulfils the selection rule with respect to a given time interval.selectUniqueProduct
(String productType, Collection<Product> products, Instant startTime, Instant stopTime) Select the one product in the given collection of products that fulfils the selection rule with respect to a given time interval.void
setSimpleRules
(Collection<SimpleSelectionRule> simpleRules) Sets the collection of simple selection rules for this ruletoString()
-
Felddetails
-
RULE_SEPARATOR
- Siehe auch:
-
RULE_FOR
- Siehe auch:
-
RULE_SELECT
- Siehe auch:
-
RULE_OPTIONAL
- Siehe auch:
-
RULE_MANDATORY
- Siehe auch:
-
RULE_MINCOVER
- Siehe auch:
-
RULE_MINCOVER_PATTERN
-
RULE_POLICY_OR
- Siehe auch:
-
RULE_PAREN_OPEN
- Siehe auch:
-
RULE_PAREN_CLOSE
- Siehe auch:
-
RULE_COMMA
- Siehe auch:
-
RULE_POLICY_VALCOV
- Siehe auch:
-
RULE_POLICY_LATVALCOV
- Siehe auch:
-
RULE_POLICY_VALINT
- Siehe auch:
-
RULE_POLICY_LATVALINT
- Siehe auch:
-
RULE_POLICY_LATVALCLO
- Siehe auch:
-
RULE_POLICY_BESTCENT
- Siehe auch:
-
RULE_POLICY_LATCOVCLO
- Siehe auch:
-
RULE_POLICY_OVERLAP
- Siehe auch:
-
RULE_POLICY_OVERLAP85
- Siehe auch:
-
RULE_POLICY_LATVALCOVNEW
- Siehe auch:
-
RULE_POLICY_LATVAL
- Siehe auch:
-
RULE_POLICY_CLOSTA
- Siehe auch:
-
RULE_POLICY_CLOSTO
- Siehe auch:
-
RULE_POLICY_LATSTA
- Siehe auch:
-
RULE_POLICY_LATSTO
- Siehe auch:
-
RULE_POLICY_VALINTNOD
- Siehe auch:
-
RULE_POLICY_LASCRE
- Siehe auch:
-
RULE_DELTA_DAYS
- Siehe auch:
-
RULE_DELTA_HOURS
- Siehe auch:
-
RULE_DELTA_MINS
- Siehe auch:
-
RULE_DELTA_SECS
- Siehe auch:
-
RULE_DELTA_MILLIS
- Siehe auch:
-
-
Konstruktordetails
-
SelectionRule
public SelectionRule()
-
-
Methodendetails
-
getSimpleRules
Gets all simple selection rules contained in the selection rule- Gibt zurück:
- a list of simple selection rules
-
clearSimpleRules
public void clearSimpleRules()Removes all simple selection rules from this rule -
addSimpleRules
Adds a collection of simple selection rules to this rule- Parameter:
newSimpleRules
- the collection of simple selection rules to add
-
setSimpleRules
Sets the collection of simple selection rules for this rule- Parameter:
simpleRules
- the collection of simple selection rules to set
-
parseSelectionRule
public static SelectionRule parseSelectionRule(ProductClass targetProductClass, String selectionRuleString) throws ParseException, IllegalArgumentException Parse the given string as a selection rule (seethe grammar definition in the class comment
). Returns a new instance of SelectionRule.- Parameter:
targetProductClass
- the product class, which requires this rule for processingselectionRuleString
- the string containing the selection rule- Gibt zurück:
- a new SelectionRule object
- Löst aus:
ParseException
- if the string does not conform to the grammar given in the class commentIllegalArgumentException
- if selectionRuleString is null
-
hasPolicyFor
Tests whether this rule has a selection policy for the given item type (aux product type)- Parameter:
itemType
- the item type to test for- Gibt zurück:
- true, if a policy for the item type exists, false otherwise
-
merge
Merge this selection rule with another selection rule, thereby extending the validity periods per product type for each policy in such a way that the validity periods of this rule and of the other rule are covered. This method returns a new SelectionRule object, the current object remains unchanged.For selection rules containing the policy 'LatestValidityClosest' a merge is possible, if and only if all occurrences of this policy for one product type in both rules have the same delta times (this policy actually refers to a point in time and not to a time interval, therefore a merge can only be done between policies referring to the same point in time).
- Parameter:
anotherRule
- the selection rule to merge this rule with- Gibt zurück:
- a new SelectionRule object reflecting the merged validity periods for each policy of both rules
- Löst aus:
IllegalArgumentException
- if a merge between rules with 'LatestValidityClosest' policies with differing delta times for the same product type is attempted
-
selectUniqueItem
public Object selectUniqueItem(String productType, Collection<SelectionItem> items, Instant startTime, Instant stopTime) throws NoSuchElementException, IllegalArgumentException Select the one item in the given collection of items that fulfils the selection rule with respect to a given time interval. All items in the collection must be of the same item product type. If the rule does not contain policies for the item type given in the collection, the result is the same as if all items had qualified (i. e. if the collection contains only one item, its object is returned, if it contains more than one item, NoSuchElementException is thrown).- Parameter:
productType
- the product type of the itemsitems
- the collection of items to be searchedstartTime
- the start time of the time interval to check againststopTime
- the end time of the time interval to check against- Gibt zurück:
- the single item object fulfilling the selection rule, if exactly one such item exists, or null, if no qualifying item exists and the selection rule is marked as 'OPTIONAL'
- Löst aus:
NoSuchElementException
- if there is more than one item fulfilling the selection rule, or if there is no such item and the selection rule is marked as 'MANDATORY'IllegalArgumentException
- if any of the parameters is null or if not all of the items are of the given type
-
selectUniqueProduct
public Product selectUniqueProduct(String productType, Collection<Product> products, Instant startTime, Instant stopTime) throws NoSuchElementException, IllegalArgumentException Select the one product in the given collection of products that fulfils the selection rule with respect to a given time interval. All products in the collection must be of the same product type. If the rule does not contain policies for the product type given in the collection, the result is the same as if all items had qualified (i. e. if the collection contains only one item, its object is returned, if it contains more than one item, NoSuchElementException is thrown).- Parameter:
productType
- the product type of the itemsproducts
- the collection of products to be searchedstartTime
- the start time of the time interval to check againststopTime
- the end time of the time interval to check against- Gibt zurück:
- the single item object fulfilling the selection rule, if exactly one such item exists, or null, if no qualifying item exists and the selection rule is marked as 'OPTIONAL'
- Löst aus:
NoSuchElementException
- if there is more than one item fulfilling the selection rule, or if there is no such item and the selection rule is marked as 'MANDATORY'IllegalArgumentException
- if any of the parameters is null or if not all of the items are of the given type
-
selectItems
public List<Object> selectItems(String productType, Collection<SelectionItem> items, Instant startTime, Instant stopTime) throws NoSuchElementException, IllegalArgumentException Select all items in the given collection of items that fulfil the selection rule with respect to a given time interval. All items in the collection must be of the same item product type. If the rule does not contain policies for the item type given in the collection, an empty list returned.- Parameter:
productType
- the type of the items to be searcheditems
- the collection of items to be searched (may be empty, but not null)startTime
- the start time of the time interval to check againststopTime
- the end time of the time interval to check against- Gibt zurück:
- a (possibly empty) list of all item objects fulfilling the selection rule, or null, if no such qualifying item exists and the selection rule is marked as 'OPTIONAL'
- Löst aus:
NoSuchElementException
- if no item fulfils the selection rule, and the selection rule is marked as 'MANDATORY'IllegalArgumentException
- if any of the parameters is null or if not all of the items are of the given item type
-
selectProducts
public List<Product> selectProducts(String productType, Collection<Product> products, Instant startTime, Instant stopTime) throws NoSuchElementException, IllegalArgumentException Select all products in the given collection of products that fulfil the selection rule with respect to a given time interval. All products in the collection must be of the same product type. If the rule does not contain policies for the product type given in the collection, an empty list returned.- Parameter:
productType
- the type of the items to be searchedproducts
- the collection of products to be searched (may be empty, but not null)startTime
- the start time of the time interval to check againststopTime
- the end time of the time interval to check against- Gibt zurück:
- a (possibly empty) list of all item objects fulfilling the selection rule, or null, if no such qualifying item exists and the selection rule is marked as 'OPTIONAL'
- Löst aus:
NoSuchElementException
- if no item fulfils the selection rule, and the selection rule is marked as 'MANDATORY'IllegalArgumentException
- if any of the parameters is null or if not all of the items are of the given item type
-
toString
-