Package org.apache.unomi.api.services
Interface SegmentService
- All Known Implementing Classes:
SegmentServiceImpl
public interface SegmentService
-
Method Summary
Modifier and TypeMethodDescriptionvoid
createScoringDefinition
(String scope, String scoringId, String name, String description) Creates a scoring with the specified scope, identifier, name and description.getGeneratedPropertyKey
(Condition condition, Condition parentCondition) Get generated property key for past event conditiongetMatchingIndividuals
(String segmentID, int offset, int size, String sortBy) Retrieves a list of profiles matching the conditions defined by the segment identified by the specified identifier, ordered according to the specifiedsortBy
String and and paged: onlysize
of them are retrieved, starting with theoffset
-th one.long
getMatchingIndividualsCount
(String segmentID) Retrieves the number of profiles matching the conditions defined by the segment identified by the specified identifier.getScoringDefinition
(String scoringId) Retrieves the scoring identified by the specified identifier.getScoringDependentMetadata
(String scoringId) Retrieves the list of Segment and Scoring metadata depending on the specified scoring.getScoringMetadatas
(int offset, int size, String sortBy) Retrieves the set of all scoring metadata.getScoringMetadatas
(Query query) Retrieves the set of scoring metadata for scorings matching the specified query.getSegmentDefinition
(String segmentId) Retrieves the segment identified by the specified identifier.getSegmentDependentMetadata
(String segmentId) Retrieves the list of Segment and Scoring metadata depending on the specified segment.getSegmentMetadatas
(int offset, int size, String sortBy) Retrieves segment metadatas, ordered according to the specifiedsortBy
String and and paged: onlysize
of them are retrieved, starting with theoffset
-th one.getSegmentMetadatas
(String scope, int offset, int size, String sortBy) Retrieves segment metadatas for segments in the specified scope, ordered according to the specifiedsortBy
String and and paged: onlysize
of them are retrieved, starting with theoffset
-th one.getSegmentMetadatas
(Query query) Retrieves the metadata for segments matching the specifiedQuery
.getSegmentMetadatasForProfile
(Profile profile) Retrieves the list of segment metadata for the segments the specified profile is a member of.getSegmentsAndScoresForProfile
(Profile profile) Retrieves the segments and scores for the specified profile.isProfileInSegment
(Profile profile, String segmentId) Determines whether the specified profile is part of the segment identified by the specified identifier.void
This will recalculate the past event conditions from existing rules It will also recalculate date relative Segments and Scorings (when they contains date expression conditions for example) This operation can be heavy and take time, it will: - browse existing rules to extract the past event condition, - query the matching events for those conditions, - update the corresponding profiles - reevaluate segments/scorings linked to this rules to engaged/disengaged profiles after the occurrences have been updated - reevaluate segments/scoring that contains date expressions So use it carefully or execute this method in a dedicated thread.removeScoringDefinition
(String scoringId, boolean validate) Removes the scoring definition identified by the specified identifier.removeSegmentDefinition
(String segmentId, boolean validate) Removes the segment definition identified by the specified identifier.void
setScoringDefinition
(Scoring scoring) Persists the specified scoring in the context server.void
setSegmentDefinition
(Segment segment) Persists the specified segment in the context server.
-
Method Details
-
getSegmentMetadatas
Retrieves segment metadatas, ordered according to the specifiedsortBy
String and and paged: onlysize
of them are retrieved, starting with theoffset
-th one.- Parameters:
offset
- zero or a positive integer specifying the position of the first element in the total ordered collection of matching elementssize
- a positive integer specifying how many matching elements should be retrieved or-1
if all of them should be retrievedsortBy
- an optional (null
if no sorting is required) String of comma (,
) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:
) and an order specifier:asc
ordesc
.- Returns:
- a
PartialList
of segment metadata
-
getSegmentMetadatas
Retrieves segment metadatas for segments in the specified scope, ordered according to the specifiedsortBy
String and and paged: onlysize
of them are retrieved, starting with theoffset
-th one. TODO: remove?- Parameters:
scope
- the scope for which we want to retrieve segment metadataoffset
- zero or a positive integer specifying the position of the first element in the total ordered collection of matching elementssize
- a positive integer specifying how many matching elements should be retrieved or-1
if all of them should be retrievedsortBy
- an optional (null
if no sorting is required) String of comma (,
) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:
) and an order specifier:asc
ordesc
.- Returns:
- a
PartialList
of segment metadata
-
getSegmentMetadatas
Retrieves the metadata for segments matching the specifiedQuery
.- Parameters:
query
- the query that the segments must match for their metadata to be retrieved- Returns:
- a
PartialList
of segment metadata
-
getSegmentDefinition
Retrieves the segment identified by the specified identifier.- Parameters:
segmentId
- the identifier of the segment to be retrieved- Returns:
- the segment identified by the specified identifier or
null
if no such segment exists
-
setSegmentDefinition
Persists the specified segment in the context server.- Parameters:
segment
- the segment to be persisted
-
removeSegmentDefinition
Removes the segment definition identified by the specified identifier. We can specify that we want the operation to be validated beforehand so that we can know if any other segment that might use the segment we're trying to delete as a condition might be impacted. Ifvalidate
is set tofalse
, no validation is performed. If set totrue
, we will first check if any segment or scoring depends on the segment we're trying to delete and if so we will not delete the segment but rather return the list of the metadata of the impacted items. If no dependents are found, then we properly delete the segment.- Parameters:
segmentId
- the identifier of the segment we want to deletevalidate
- whether or not to perform validation- Returns:
- a list of impacted segment metadata if any or an empty list if none were found or validation was skipped
-
getSegmentDependentMetadata
Retrieves the list of Segment and Scoring metadata depending on the specified segment. A segment or scoring is depending on a segment if it includes a profileSegmentCondition with a test on this segment.- Parameters:
segmentId
- the segment identifier- Returns:
- a list of Segment/Scoring Metadata depending on the specified segment
-
getMatchingIndividuals
Retrieves a list of profiles matching the conditions defined by the segment identified by the specified identifier, ordered according to the specifiedsortBy
String and and paged: onlysize
of them are retrieved, starting with theoffset
-th one.- Parameters:
segmentID
- the identifier of the segment for which we want to retrieve matching profilesoffset
- zero or a positive integer specifying the position of the first element in the total ordered collection of matching elementssize
- a positive integer specifying how many matching elements should be retrieved or-1
if all of them should be retrievedsortBy
- an optional (null
if no sorting is required) String of comma (,
) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:
) and an order specifier:asc
ordesc
.- Returns:
- a
PartialList
of profiles matching the specified segment
-
getMatchingIndividualsCount
Retrieves the number of profiles matching the conditions defined by the segment identified by the specified identifier.- Parameters:
segmentID
- the identifier of the segment for which we want to retrieve matching profiles- Returns:
- the number of profiles matching the conditions defined by the segment identified by the specified identifier
-
isProfileInSegment
Determines whether the specified profile is part of the segment identified by the specified identifier.- Parameters:
profile
- the profile we want to checksegmentId
- the identifier of the segment against which we want to check the profile- Returns:
true
if the specified profile is in the specified segment,false
otherwise
-
getSegmentsAndScoresForProfile
Retrieves the segments and scores for the specified profile.- Parameters:
profile
- the profile for which we want to retrieve segments and scores- Returns:
- a
SegmentsAndScores
instance encapsulating the segments and scores for the specified profile
-
getSegmentMetadatasForProfile
Retrieves the list of segment metadata for the segments the specified profile is a member of.- Parameters:
profile
- the profile for which we want to retrieve the segment metadata- Returns:
- the (possibly empty) list of segment metadata for the segments the specified profile is a member of
-
getScoringMetadatas
Retrieves the set of all scoring metadata.- Parameters:
offset
- the offsetsize
- the sizesortBy
- sort by- Returns:
- the set of all scoring metadata
-
getScoringMetadatas
Retrieves the set of scoring metadata for scorings matching the specified query.- Parameters:
query
- the query the scorings must match for their metadata to be retrieved- Returns:
- the set of scoring metadata for scorings matching the specified query
-
getScoringDefinition
Retrieves the scoring identified by the specified identifier.- Parameters:
scoringId
- the identifier of the scoring to be retrieved- Returns:
- the scoring identified by the specified identifier or
null
if no such scoring exists
-
setScoringDefinition
Persists the specified scoring in the context server.- Parameters:
scoring
- the scoring to be persisted
-
createScoringDefinition
Creates a scoring with the specified scope, identifier, name and description.- Parameters:
scope
- the scope for the new scoringscoringId
- the identifier for the new scoringname
- the name of the new scoringdescription
- the description of the new scoring- See Also:
-
removeScoringDefinition
Removes the scoring definition identified by the specified identifier. We can specify that we want the operation to be validated beforehand so that we can know if any other segment that might use the segment we're trying to delete as a condition might be impacted. Ifvalidate
is set tofalse
, no validation is performed. If set totrue
, we will first check if any segment or scoring depends on the scoring we're trying to delete and if so we will not delete the scoring but rather return the list of the metadata of the impacted items. If no dependents are found, then we properly delete the scoring.- Parameters:
scoringId
- the identifier of the scoring we want to deletevalidate
- whether or not to perform validation- Returns:
- a list of impacted items metadata if any or an empty list if none were found or validation was skipped
-
getScoringDependentMetadata
Retrieves the list of Segment and Scoring metadata depending on the specified scoring. A segment or scoring is depending on a segment if it includes a scoringCondition with a test on this scoring.- Parameters:
scoringId
- the segment identifier- Returns:
- a list of Segment/Scoring Metadata depending on the specified scoring
-
getGeneratedPropertyKey
Get generated property key for past event condition- Parameters:
condition
- The event conditionparentCondition
- The past event condition- Returns:
- a String representing the condition and parent condition uniquelly
-
recalculatePastEventConditions
void recalculatePastEventConditions()This will recalculate the past event conditions from existing rules It will also recalculate date relative Segments and Scorings (when they contains date expression conditions for example) This operation can be heavy and take time, it will: - browse existing rules to extract the past event condition, - query the matching events for those conditions, - update the corresponding profiles - reevaluate segments/scorings linked to this rules to engaged/disengaged profiles after the occurrences have been updated - reevaluate segments/scoring that contains date expressions So use it carefully or execute this method in a dedicated thread.
-