Package org.apache.unomi.rest.endpoints
Class SegmentServiceEndPoint
- java.lang.Object
-
- org.apache.unomi.rest.endpoints.SegmentServiceEndPoint
-
-
Constructor Summary
Constructors Constructor Description SegmentServiceEndPoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PartialList<Metadata>
getListMetadatas(Query query)
Retrieves the metadata for segments matching the specifiedQuery
.PartialList<Profile>
getMatchingIndividuals(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.Segment
getSegmentDefinition(String segmentId)
Retrieves the segment identified by the specified identifier.DependentMetadata
getSegmentDependentMetadata(String segmentId)
Retrieves the list of Segment and Scoring metadata depending on the specified segment.List<Metadata>
getSegmentMetadatas(int offset, int size, String sortBy)
Retrieves the 50 first segment metadatas.Boolean
isProfileInSegment(Profile profile, String segmentId)
Determines whether the specified profile is part of the segment identified by the specified identifier.DependentMetadata
removeSegmentDefinition(String segmentId, boolean validate)
Removes the segment definition identified by the specified identifier.void
resetQueries()
Deprecated.As of version 1.1.0-incubating, not needed anymorevoid
setSegmentDefinition(Segment segment)
Persists the specified segment in the context server.void
setSegmentService(SegmentService segmentService)
-
-
-
Method Detail
-
setSegmentService
public void setSegmentService(SegmentService segmentService)
-
getMatchingIndividuals
@GET @Path("/{segmentID}/match") public PartialList<Profile> getMatchingIndividuals(@PathParam("segmentID") String segmentId, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("size") @DefaultValue("50") int size, @QueryParam("sort") 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.- 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
@GET @Path("/{segmentID}/count") public long getMatchingIndividualsCount(@PathParam("segmentID") String segmentId)
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
@GET @Path("/{segmentID}/match/{profile}") public Boolean isProfileInSegment(@PathParam("profile") Profile profile, @PathParam("segmentID") String segmentId)
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
-
getSegmentMetadatas
@GET @Path("/") public List<Metadata> getSegmentMetadatas(@QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("size") @DefaultValue("50") int size, @QueryParam("sort") String sortBy)
Retrieves the 50 first segment metadatas.- 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 List of the 50 first segment metadata
-
getSegmentDependentMetadata
@GET @Path("/{segmentID}/impacted") public DependentMetadata getSegmentDependentMetadata(@PathParam("segmentID") String segmentId)
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
-
setSegmentDefinition
@POST @Path("/") public void setSegmentDefinition(Segment segment)
Persists the specified segment in the context server.- Parameters:
segment
- the segment to be persisted
-
getListMetadatas
@POST @Path("/query") public PartialList<Metadata> getListMetadatas(Query query)
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
@GET @Path("/{segmentID}") public Segment getSegmentDefinition(@PathParam("segmentID") String segmentId)
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
-
removeSegmentDefinition
@DELETE @Path("/{segmentID}") public DependentMetadata removeSegmentDefinition(@PathParam("segmentID") String segmentId, @QueryParam("validate") boolean validate)
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
-
resetQueries
@Deprecated @GET @Path("/resetQueries") public void resetQueries()
Deprecated.As of version 1.1.0-incubating, not needed anymoreTODO: remove
-
-