Class Profile
- java.lang.Object
-
- org.apache.unomi.api.Item
-
- org.apache.unomi.api.Profile
-
- All Implemented Interfaces:
Serializable
,SystemPropertiesItem
- Direct Known Subclasses:
Persona
,ProfileToImport
public class Profile extends Item implements SystemPropertiesItem
A user profile gathering all known information about a given user as well as segments it is part of and scores.Contrary to other unomi
Item
s, profiles are not part of a scope since we want to be able to track the associated user across applications. For this reason, data collected for a given profile in a specific scope is still available to any scoped item that accesses the profile information.It is interesting to note that there is not necessarily a one to one mapping between users and profiles as users can be captured across applications and different observation contexts. As identifying information might not be available in all contexts in which data is collected, resolving profiles to a single physical user can become complex because physical users are not observed directly. Rather, their portrait is progressively patched together and made clearer as unomi captures more and more traces of their actions. Unomi will merge related profiles as soon as collected data permits positive association between distinct profiles, usually as a result of the user performing some identifying action in a context where the user hadn’t already been positively identified.
- See Also:
Segment
, Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Map<String,Consent>
getConsents()
Returns all the consents, including the revokes ones.String
getMergedWith()
Deprecated.since 2.0.0 merge mechanism is now based on profile aliases, and this property is not used anymoreObject
getNestedProperty(String name)
Retrieves the value of the nested property identified by the specified name.Map<String,Object>
getProperties()
Retrieves a Map of all property name - value pairs for this profile.Object
getProperty(String name)
Retrieves the property identified by the specified name.String
getScope()
Retrieves the Item's scope.Map<String,Integer>
getScores()
Retrieves the scores associated to this profile.Set<String>
getSegments()
Retrieves the identifiers of the segments this profile is a member of.Map<String,Object>
getSystemProperties()
Retrieves a Map of system property name - value pairs for this profile.boolean
isAnonymousProfile()
Returns true if this profile is an anonymous profile.boolean
setConsent(Consent consent)
Set a consent into the profile.void
setMergedWith(String mergedWith)
Deprecated.since 2.0.0 merge mechanism is now based on profile aliases, and this property is not used anymorevoid
setProperties(Map<String,Object> properties)
Sets the property name - value pairs for this profile.void
setProperty(String name, Object value)
Sets the property identified by the specified name to the specified value.void
setScores(Map<String,Integer> scores)
TODO: should be removed from the APIvoid
setSegments(Set<String> segments)
Sets the identifiers of the segments this profile is a member of.void
setSystemProperties(Map<String,Object> systemProperties)
Specifies the system property name - value pairs for this profile.Object
setSystemProperty(String key, Object value)
Sets a system property, overwriting an existing one if it existed.String
toString()
-
Methods inherited from class org.apache.unomi.api.Item
equals, getItemId, getItemType, getItemType, getSystemMetadata, getVersion, hashCode, setItemId, setItemType, setScope, setSystemMetadata, setVersion
-
-
-
-
Field Detail
-
ITEM_TYPE
public static final String ITEM_TYPE
The Profile ITEM_TYPE
-
-
Constructor Detail
-
Profile
public Profile()
Instantiates a new Profile.
-
Profile
public Profile(String profileId)
Instantiates a new Profile with the specified identifier.- Parameters:
profileId
- the profile identifier
-
-
Method Detail
-
setProperty
public void setProperty(String name, Object value)
Sets the property identified by the specified name to the specified value. If a property with that name already exists, replaces its value, otherwise adds the new property with the specified name and value.- Parameters:
name
- the name of the property to setvalue
- the value of the property
-
getProperty
public Object getProperty(String name)
Retrieves the property identified by the specified name.- Parameters:
name
- the name of the property to retrieve- Returns:
- the value of the specified property or
null
if no such property exists
-
getNestedProperty
public Object getNestedProperty(String name)
Retrieves the value of the nested property identified by the specified name.- Parameters:
name
- the name of the property to be retrieved, splited in the nested properties with "."- Returns:
- the value of the property identified by the specified name
-
getProperties
public Map<String,Object> getProperties()
Retrieves a Map of all property name - value pairs for this profile.- Returns:
- a Map of all property name - value pairs for this profile
-
setProperties
public void setProperties(Map<String,Object> properties)
Sets the property name - value pairs for this profile.- Parameters:
properties
- a Map containing the property name - value pairs for this profile
-
getSystemProperties
public Map<String,Object> getSystemProperties()
Retrieves a Map of system property name - value pairs for this profile. System properties can be used by implementations to store non-user visible properties needed for internal purposes.- Specified by:
getSystemProperties
in interfaceSystemPropertiesItem
- Returns:
- a Map of system property name - value pairs for this profile
-
setSystemProperties
public void setSystemProperties(Map<String,Object> systemProperties)
Specifies the system property name - value pairs for this profile.- Parameters:
systemProperties
- a Map of system property name - value pairs for this profile
-
setSystemProperty
public Object setSystemProperty(String key, Object value)
Sets a system property, overwriting an existing one if it existed. This call will also created the system properties hash map if it didn't exist.- Parameters:
key
- the key for the system property hash mapvalue
- the value for the system property hash map- Returns:
- the previous value object if it existing.
-
getScope
public String getScope()
Retrieves the Item's scope. Note that Profiles are always in the shared system scope (Metadata.SYSTEM_SCOPE
).
-
getSegments
public Set<String> getSegments()
Retrieves the identifiers of the segments this profile is a member of.- Returns:
- the identifiers of the segments this profile is a member of
-
setSegments
public void setSegments(Set<String> segments)
Sets the identifiers of the segments this profile is a member of. TODO: should be removed from the API- Parameters:
segments
- the segments
-
getMergedWith
@Deprecated public String getMergedWith()
Deprecated.since 2.0.0 merge mechanism is now based on profile aliases, and this property is not used anymore
-
setMergedWith
@Deprecated public void setMergedWith(String mergedWith)
Deprecated.since 2.0.0 merge mechanism is now based on profile aliases, and this property is not used anymore
-
getScores
public Map<String,Integer> getScores()
Retrieves the scores associated to this profile.- Returns:
- the scores associated to this profile as a Map of
Scoring
identifier - score pairs
-
setScores
public void setScores(Map<String,Integer> scores)
TODO: should be removed from the API- Parameters:
scores
- new value for scores
-
getConsents
public Map<String,Consent> getConsents()
Returns all the consents, including the revokes ones.- Returns:
- a map that contains as a key the scope + "/" + consent type ID (or just the consent type ID if no scope was set on the consent), and the consent itself as a value
-
isAnonymousProfile
public boolean isAnonymousProfile()
Returns true if this profile is an anonymous profile.- Returns:
- true of the profile has been marked as an anonymous profile, false otherwise.
-
setConsent
public boolean setConsent(Consent consent)
Set a consent into the profile.- Parameters:
consent
- if the consent is REVOKED, it will try to remove a consent with the same type id if it exists for the profile.- Returns:
- true if the operation was successful (inserted exception in the case of a revoked consent, in which case it is successful if there was a consent to revoke).
-
-