ERTaggableEntity< T extends ERXGenericRecord > Class Reference

Collaboration diagram for ERTaggableEntity< T extends ERXGenericRecord >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

int countUniqueTaggedWith (EOEditingContext editingContext, ERTag.Inclusion inclusion, Object tags)
ERTag createTagNamed (EOEditingContext editingContext, String tagName)
boolean equals (Object obj)
NSArray< StringfetchAllTags (EOEditingContext editingContext)
NSArray< StringfetchRelatedTags (EOEditingContext editingContext, Object tags)
NSArray< T > fetchTaggedWith (EOEditingContext editingContext, ERTag.Inclusion inclusion, int limit, Object tags, EOQualifier additionalQualifier)
NSArray< T > fetchTaggedWith (EOEditingContext editingContext, ERTag.Inclusion inclusion, int limit, Object tags)
NSArray< T > fetchTaggedWith (EOEditingContext editingContext, ERTag.Inclusion inclusion, Object tags)
NSArray< T > fetchTaggedWith (EOEditingContext editingContext, Object tags)
ERTag fetchTagNamed (EOEditingContext editingContext, String tagName, boolean createIfMissing)
NSArray< StringfetchTagsLike (EOEditingContext editingContext, String startsWith)
int hashCode ()
ERTagNormalizer normalizer ()
void removeTags (EOEditingContext editingContext, Object tags)
void replaceTags (EOEditingContext editingContext, ERTag.Inclusion inclusion, Object oldTags, Object newTags)
void setNormalizer (ERTagNormalizer normalizer)
NSArray< StringsplitTagNames (Object tags)
NSDictionary< String, Integer > tagCount (EOEditingContext editingContext, NSSelector selector, int count, int limit, EOQualifier additionalQualifier)
NSDictionary< String, Integer > tagCount (EOEditingContext editingContext, NSSelector selector, int count, int limit)
NSDictionary< String, Integer > tagCount (EOEditingContext editingContext, int limit, EOQualifier additionalQualifier)
NSDictionary< String, Integer > tagCount (EOEditingContext editingContext, int limit)
NSDictionary< String, Integer > tagCount (EOEditingContext editingContext, EOQualifier additionalQualifier)
NSDictionary< String, Integer > tagCount (EOEditingContext editingContext)
ERTaggable< T > taggable (T eo)
EORelationship tagsRelationship ()
String tagsRelationshipName ()

Static Public Member Functions

static NSDictionary< EOEntity,
NSArray<?extends
ERXGenericRecord > > 
fetchAllTaggedWith (EOEditingContext editingContext, ERTag.Inclusion inclusion, int limit, Object tags)
static NSDictionary< EOEntity,
NSArray<?extends
ERXGenericRecord > > 
fetchAllTaggedWith (EOEditingContext editingContext, ERTag.Inclusion inclusion, Object tags)
static NSDictionary< EOEntity,
NSArray<?extends
ERXGenericRecord > > 
fetchAllTaggedWith (EOEditingContext editingContext, Object tags)
static boolean isTaggable (EOEntity entity)
static boolean isWhitespaceSeparator (String separator)
static EOEntity registerTaggable (EOEntity entity, String tagsRelationshipName, EOEntity tagEntity, Class<?extends ERTaggableEntity<?>> taggableEntity)
static EOEntity registerTaggable (EOEntity entity, String tagsRelationshipName)
static EOEntity registerTaggable (EOEntity entity)
static EOEntity registerTaggable (String entityName)
static EOEntity registerTaggable (String entityName, Class<?extends ERTaggableEntity<?>> taggableEntity)
static void setTaggableEntityForEntityNamed (Class<?extends ERTaggableEntity<?>> taggableEntity, String entityName)
static NSArray< EOEntity > taggableEntities ()
static
< TextendsERXGenericRecord >
ERTaggableEntity< T > 
taggableEntity (T eo)
static
< TextendsERXGenericRecord >
ERTaggableEntity< T > 
taggableEntity (String entityName)
static
< TextendsERXGenericRecord >
ERTaggableEntity< T > 
taggableEntity (EOEntity entity)
static EORelationship tagsRelationshipForEntity (EOEntity entity, EOEntity tagEntity)

Static Public Attributes

static final String DEFAULT_TAGS_RELATIONSHIP_NAME = "tags"
static final String ERTAGGABLE_KEY = "_ERTaggable"
static final String ERTAGGABLE_TAG_ENTITY_KEY = "_ERTaggableTagEntity"
static final String ERTAGGABLE_TAG_RELATIONSHIP_KEY = "_ERTaggableTagRelationship"

Protected Member Functions

EOQualifier additionalTagCountQualifier ()
 ERTaggableEntity (EOEntity entity)

Package Functions

public< U > NSDictionary
< String, U > 
cloud (NSDictionary< String, Integer > tagHash, NSArray< U > categoryList)
public< U > NSDictionary
< String, U > 
cloud (EOEditingContext editingContext, NSArray< U > categoryList)

Private Member Functions

void addNormalizedTags (NSMutableSet< String > set, Object[] tags)

Private Attributes

final EOEntity _entity
ERTagNormalizer _normalizer = new ERDefaultTagNormalizer()
final String _separator = ERTaggableEntity.DEFAULT_SEPARATOR
final EOEntity _tagEntity
final EORelationship _tagsRelationship

Static Private Attributes

static final
NSMutableDictionary< String,
Class<?extends
ERTaggableEntity<?> > > 
_taggableEntities = new NSMutableDictionary<String, Class<? extends ERTaggableEntity<?>>>()
static final String DEFAULT_SEPARATOR = "[\\s,]+"


Detailed Description

ERTaggableEntity provides entity-level tag management and fetching methods.

Typically you would provide a cover method from your entity class to an instance of an ERTaggableEntity:

public class Person extends _Person { ... public static ERTaggableEntity<Person> taggableEntity() { return ERTaggableEntity.taggableEntity(Person.ENTITY_NAME); } }

Author:
mschrag
Parameters:
<T> the java class of the entity that this ERTaggableEntity is associated with

Constructor & Destructor Documentation

ERTaggableEntity ( EOEntity  entity  )  [protected]

Constructs an ERTaggableEntity.

Parameters:
entity the entity to tag


Member Function Documentation

EOQualifier additionalTagCountQualifier (  )  [protected]

void addNormalizedTags ( NSMutableSet< String set,
Object[]  tags 
) [private]

Normalizes tags from tags array and adds them to set

Parameters:
set set that normalized tags should be added to
tags array of unclean tags

public<U> NSDictionary<String, U> cloud ( NSDictionary< String, Integer >  tagHash,
NSArray< U >  categoryList 
) [package]

Takes the result of a tagCount call and an array of categories and distributes the entries in the tagCount hash evenly across the categories based on the count value for each tag.

Typically, this is used to display a 'tag cloud' in your UI.

Parameters:
tagHash the tag dictionary returned from a tagCount call
categoryList An array containing the categories to split the tags
Returns:
a dictionary mapping each tag name to its corresponding category

public<U> NSDictionary<String, U> cloud ( EOEditingContext  editingContext,
NSArray< U >  categoryList 
) [package]

Takes the result of a tagCount call and an array of categories and distributes the entries in the tagCount hash evenly across the categories based on the count value for each tag.

Typically, this is used to display a 'tag cloud' in your UI.

Parameters:
categoryList An array containing the categories to split the tags
Returns:
a dictionary mapping each tag name to its corresponding category

int countUniqueTaggedWith ( EOEditingContext  editingContext,
ERTag.Inclusion  inclusion,
Object  tags 
)

This method returns a simple count of the number of distinct objects which match the tags provided.

Parameters:
editingContext the editing context to fetch into
tags the tags to search (String to tokenize, NSArray<String>, etc)
inclusion find matches for ANY tags or ALL tags provided
Returns:
the count of distinct objects for the given tags

ERTag createTagNamed ( EOEditingContext  editingContext,
String  tagName 
)

Creates a tag with the given name.

Parameters:
editingContext the editing context to create within
tagName the new tag name
Returns:
the created tag

boolean equals ( Object  obj  ) 

static NSDictionary<EOEntity, NSArray<? extends ERXGenericRecord> > fetchAllTaggedWith ( EOEditingContext  editingContext,
ERTag.Inclusion  inclusion,
int  limit,
Object  tags 
) [static]

Fetches all the EOs of all taggable entities that are associated with the given tags.

Parameters:
editingContext the editing context to fetch into
tags the tags to search (String to tokenize, NSArray<String>, etc)
inclusion find matches for ANY tags or ALL tags provided
limit the limit of the number of objects to return (or -1 for unlimited)
Returns:
a dictionary mapping entities to an array of matching EO's

static NSDictionary<EOEntity, NSArray<? extends ERXGenericRecord> > fetchAllTaggedWith ( EOEditingContext  editingContext,
ERTag.Inclusion  inclusion,
Object  tags 
) [static]

Fetches all the EOs of all taggable entities that are associated with the given tags (unlimited).

Parameters:
editingContext the editing context to fetch into
tags the tags to search (String to tokenize, NSArray<String>, etc)
inclusion find matches for ANY tags or ALL tags provided
Returns:
a dictionary mapping entities to an array of matching EO's

static NSDictionary<EOEntity, NSArray<? extends ERXGenericRecord> > fetchAllTaggedWith ( EOEditingContext  editingContext,
Object  tags 
) [static]

Fetches all the EOs of all taggable entities that are associated with all of the given tags (unlimited).

Parameters:
editingContext the editing context to fetch into
tags the tags to search (String to tokenize, NSArray<String>, etc)
Returns:
a dictionary mapping entities to an array of matching EO's

NSArray<String> fetchAllTags ( EOEditingContext  editingContext  ) 

Returns an array of all of the available tags in the system.

Parameters:
editingContext the editing context to fetch into
Returns:
an array of matching tags

NSArray<String> fetchRelatedTags ( EOEditingContext  editingContext,
Object  tags 
)

Finds other tags that are related to the tags passed through the tags parameter, by finding common records that share similar sets of tags. Useful for constructing 'Related tags' lists.

Parameters:
tags the tags to search (String to tokenize, NSArray<String>, etc)

NSArray<T> fetchTaggedWith ( EOEditingContext  editingContext,
ERTag.Inclusion  inclusion,
int  limit,
Object  tags,
EOQualifier  additionalQualifier 
)

Fetches the list of objects of this entity type that are tagged with the given tags.

Parameters:
editingContext the editing context to fetch into
tags the tags to search (String to tokenize, NSArray<String>, etc)
inclusion find matches for ANY tags or ALL tags provided
limit limit the number of results to be returned (-1 for unlimited)
additionalQualifier an additional qualifier to chain in
Returns:
the array of matching eos

NSArray<T> fetchTaggedWith ( EOEditingContext  editingContext,
ERTag.Inclusion  inclusion,
int  limit,
Object  tags 
)

Fetches the list of objects of this entity type that are tagged with the given tags.

Parameters:
editingContext the editing context to fetch into
tags the tags to search (String to tokenize, NSArray<String>, etc)
inclusion find matches for ANY tags or ALL tags provided
limit limit the number of results to be returned (-1 for unlimited)
Returns:
the array of matching eos

NSArray<T> fetchTaggedWith ( EOEditingContext  editingContext,
ERTag.Inclusion  inclusion,
Object  tags 
)

Fetches the list of objects of this entity type that are tagged with the given tags with unlimited results.

Parameters:
editingContext the editing context to fetch into
tags the tags to search (String to tokenize, NSArray<String>, etc)
inclusion find matches for ANY tags or ALL tags provided
Returns:
the array of matching eos

NSArray<T> fetchTaggedWith ( EOEditingContext  editingContext,
Object  tags 
)

Fetches the list of objects of this entity type that are tagged with all of the given tags with unlimited results.

Parameters:
editingContext the editing context to fetch into
tags the tags to search (String to tokenize, NSArray<String>, etc)
Returns:
the array of matching eos

ERTag fetchTagNamed ( EOEditingContext  editingContext,
String  tagName,
boolean  createIfMissing 
)

Fetches the tag with the given name. If that tag doesn't exist and createIfMissing is true, a tag with that name will be created (otherwise null will be returned). Tags are created in a separate transaction to prevent race conditions with duplicate tag names from rolling back your primary editing context, which means that even if you rollback your editingContext, any tags created during its lifetime will remain.

Parameters:
editingContext the editing context to fetch into
tagName the name of the tag to lookup
createIfMissing if true, missing tags will be created
Returns:
the corresponding ERTag (or null if not found)

NSArray<String> fetchTagsLike ( EOEditingContext  editingContext,
String  startsWith 
)

Returns an array of all of the available tags in the system that start with the given string.

Parameters:
startsWith the prefix to lookup
editingContext the editing context to fetch into
Returns:
an array of matching tags

int hashCode (  ) 

static boolean isTaggable ( EOEntity  entity  )  [static]

Returns whether or not the given entity has been registered as taggable.

Parameters:
entity the entity to check
Returns:
true if the entity is taggable, false if not

static boolean isWhitespaceSeparator ( String  separator  )  [static]

Returns whether or not the given separator contains whitespace (and should be escaped).

Returns:
true if the given separator contains whitespace

ERTagNormalizer normalizer (  ) 

Returns the tag normalizer for this entity.

Returns:
the tag normalizer for this entity

static EOEntity registerTaggable ( EOEntity  entity,
String  tagsRelationshipName,
EOEntity  tagEntity,
Class<?extends ERTaggableEntity<?>>  taggableEntity 
) [static]

Registers the given entity as taggable. An entity must be registered as taggable prior to attempting any tagging operations on it. The application constructor is an obvious place to register an entity as taggable. If the entity does not contain a flattened to-many tags relationship, a join entity and a flattened tags relationship will be automatically generated.

Parameters:
entity the entity to register
tagsRelationshipName the name of the flattened to-many tags relationship
tagEntity the ERTag entity that contains the tags for this entity
taggableEntity the taggable entity to associate with this taggable
Returns:
the join entity (you can probably ignore this)

static EOEntity registerTaggable ( EOEntity  entity,
String  tagsRelationshipName 
) [static]

Registers the given entity as taggable. An entity must be registered as taggable prior to attempting any tagging operations on it. The application constructor is an obvious place to register an entity as taggable. If the entity does not contain a flattened to-many tags relationship, a join entity and a flattened tags relationship will be automatically generated.

Parameters:
entity the entity to register
tagsRelationshipName the name of the flattened to-many tags relationship
Returns:
the join entity (you can probably ignore this)

static EOEntity registerTaggable ( EOEntity  entity  )  [static]

Registers the given entity as taggable. An entity must be registered as taggable prior to attempting any tagging operations on it. The application constructor is an obvious place to register an entity as taggable. If the entity does not contain a flattened to-many tags relationship, a join entity (between your entity and "ERTag") and a flattened tags relationship (named "tags") will be automatically generated.

Parameters:
entity the entity to register
Returns:
the join entity (you can probably ignore this)

static EOEntity registerTaggable ( String  entityName  )  [static]

Registers the given entity name in the default model group as taggable. An entity must be registered as taggable prior to attempting any tagging operations on it. The application constructor is an obvious place to register an entity as taggable. If the entity does not contain a flattened to-many tags relationship, a join entity (between your entity and "ERTag") and a flattened tags relationship (named "tags") will be automatically generated.

Parameters:
entityName the name of the entity to lookup
Returns:
the join entity (you can probably ignore this)

static EOEntity registerTaggable ( String  entityName,
Class<?extends ERTaggableEntity<?>>  taggableEntity 
) [static]

Registers the given entity name in the default model group as taggable. An entity must be registered as taggable prior to attempting any tagging operations on it. The application constructor is an obvious place to register an entity as taggable. If the entity does not contain a flattened to-many tags relationship, a join entity (between your entity and "ERTag") and a flattened tags relationship (named "tags") will be automatically generated.

Parameters:
entityName the name of the entity to lookup
taggableEntity the taggable entity to associate with this taggable
Returns:
the join entity (you can probably ignore this)

void removeTags ( EOEditingContext  editingContext,
Object  tags 
)

Remove all of the tags from instances of this entity type.

Parameters:
editingContext the editing context to fetch into
tags the tags to remove (String to tokenize, NSArray<String>, etc)

void replaceTags ( EOEditingContext  editingContext,
ERTag.Inclusion  inclusion,
Object  oldTags,
Object  newTags 
)

Looks for items with oldTags and replaces them with all of newTags.

Parameters:
editingContext the editing context to remove with
oldTags the tags to find and remove (String to tokenize, NSArray<String>, etc)
newTags the tags to add
inclusion if ANY, finds any tags that match, removes them all, and adds newTags; if all, requires all tags to match before replacing

void setNormalizer ( ERTagNormalizer  normalizer  ) 

Sets the tag normalizer for this entity.

Parameters:
normalizer the tag normalizer for this entity

static void setTaggableEntityForEntityNamed ( Class<?extends ERTaggableEntity<?>>  taggableEntity,
String  entityName 
) [static]

Sets the taggable entity class for the given entity name. This allows you to override the taggable entity that will be used throughout the framework for any particular entity.

Parameters:
taggableEntity the taggable entity class
entityName the name of the entity to associate with

NSArray<String> splitTagNames ( Object  tags  ) 

Splits the given "tags" object (String, array of Strings, etc) into an array of normalized tag strings.

Parameters:
tags the object that contains the tags to split
Returns:
the list of split tag names

NSDictionary<String, Integer> tagCount ( EOEditingContext  editingContext,
NSSelector  selector,
int  count,
int  limit,
EOQualifier  additionalQualifier 
)

This method counts the number of times the tags have been applied to your objects and, by default, returns a dictionary in the form of { 'tag_name' => count, ... }. Providing a selector and count allows you to add a restriction on, for instance, the minimum number of occurrences required for a result to appear. As an example, you might have selector = EOQualifier.QualifierOperatorGreaterThan, count = 1 to only return tags with more than one occurrence.

Parameters:
editingContext the editing context to fetch into
selector a selector for the count restriction (see EOQualifier.QualifierOperators)
count the count restriction required for the result to be returned
limit the limit of the number of results to return (ordered by count DESC)
additionalQualifier an optional restrictingQualifier. This is combined with the qualifier returned by additionalTagCountQualifier()
Returns:
a dictionary of tags and their occurrence count

NSDictionary<String, Integer> tagCount ( EOEditingContext  editingContext,
NSSelector  selector,
int  count,
int  limit 
)

This method counts the number of times the tags have been applied to your objects and, by default, returns a dictionary in the form of { 'tag_name' => count, ... }. Providing a selector and count allows you to add a restriction on, for instance, the minimum number of occurrences required for a result to appear. As an example, you might have selector = EOQualifier.QualifierOperatorGreaterThan, count = 1 to only return tags with more than one occurrence.

Parameters:
editingContext the editing context to fetch into
selector a selector for the count restriction (see EOQualifier.QualifierOperators)
count the count restriction required for the result to be returned
limit the limit of the number of results to return (ordered by count DESC)
Returns:
a dictionary of tags and their occurrence count

NSDictionary<String, Integer> tagCount ( EOEditingContext  editingContext,
int  limit,
EOQualifier  additionalQualifier 
)

This method counts the number of times the tags have been applied to your objects and, by default, returns a dictionary in the form of { 'tag_name' => count, ... }. This does not include any restriction on the count required for results to be returned.

Parameters:
editingContext the editing context to fetch into
limit the limit of the number of results to return (ordered by count DESC)
additionalQualifier an optional restrictingQualifier
Returns:
a dictionary of tags and their occurrence count

NSDictionary<String, Integer> tagCount ( EOEditingContext  editingContext,
int  limit 
)

This method counts the number of times the tags have been applied to your objects and, by default, returns a dictionary in the form of { 'tag_name' => count, ... }. This does not include any restriction on the count required for results to be returned.

Parameters:
editingContext the editing context to fetch into
limit the limit of the number of results to return (ordered by count DESC)
Returns:
a dictionary of tags and their occurrence count

NSDictionary<String, Integer> tagCount ( EOEditingContext  editingContext,
EOQualifier  additionalQualifier 
)

This method counts the number of times the tags have been applied to your objects and, by default, returns a dictionary in the form of { 'tag_name' => count, ... }. This does not include any restriction on the count required for results to be returned nor does it limit the number of results returned.

Parameters:
editingContext the editing context to fetch into
additionalQualifier an optional restrictingQualifier
Returns:
a dictionary of tags and their occurrence count

NSDictionary<String, Integer> tagCount ( EOEditingContext  editingContext  ) 

This method counts the number of times the tags have been applied to your objects and, by default, returns a dictionary in the form of { 'tag_name' => count, ... }. This does not include any restriction on the count required for results to be returned nor does it limit the number of results returned.

Parameters:
editingContext the editing context to fetch into
Returns:
a dictionary of tags and their occurrence count

ERTaggable<T> taggable ( eo  ) 

Factory method for generating an ERTaggable wrapper for an EO.

Parameters:
eo the EO to wrap
Returns:
an ERTaggable wrapper

static NSArray<EOEntity> taggableEntities (  )  [static]

Returns an array of taggable entities.

Returns:
an array of taggable entities

static <TextendsERXGenericRecord> ERTaggableEntity<T> taggableEntity ( eo  )  [static]

Shortcut for getting an ERTaggableEntity for an EO.

Parameters:
<T> the type of the entity
eo the EO
Returns:
an ERTaggableEntity corresponding to the entity of the EO

static <TextendsERXGenericRecord> ERTaggableEntity<T> taggableEntity ( String  entityName  )  [static]

Constructs an ERTaggableEntity.

Parameters:
entityName the name of the entity to tag

static <TextendsERXGenericRecord> ERTaggableEntity<T> taggableEntity ( EOEntity  entity  )  [static]

Constructs an ERTaggableEntity.

Parameters:
entity the entity to tag

EORelationship tagsRelationship (  ) 

Returns the tags relationship for this entity.

Returns:
the tags relationship for this entity

static EORelationship tagsRelationshipForEntity ( EOEntity  entity,
EOEntity  tagEntity 
) [static]

Returns the flattened to-many relationship from the taggable entity to the given tag entity.

Parameters:
entity the taggable entity
tagEntity the tag entity
Returns:
the flattened to-many relationship between them (or null if there isn't one)

String tagsRelationshipName (  ) 

Returns the name of the tags relationship for this entity.

Returns:
the name of the tags relationship for this entity


Member Data Documentation

final EOEntity _entity [private]

final String _separator = ERTaggableEntity.DEFAULT_SEPARATOR [private]

final EOEntity _tagEntity [private]

final NSMutableDictionary<String, Class<? extends ERTaggableEntity<?> > > _taggableEntities = new NSMutableDictionary<String, Class<? extends ERTaggableEntity<?>>>() [static, private]

final EORelationship _tagsRelationship [private]

final String DEFAULT_SEPARATOR = "[\\s,]+" [static, private]

Default is white-space and/or comma(s). Multiple string of separators treated as one.

final String DEFAULT_TAGS_RELATIONSHIP_NAME = "tags" [static]

The default name of the flattened to-many relationship to the tag entity.

final String ERTAGGABLE_KEY = "_ERTaggable" [static]

The key stored in entity userInfo that flags an entity as taggable.

final String ERTAGGABLE_TAG_ENTITY_KEY = "_ERTaggableTagEntity" [static]

The key stored in entity userInfo that specifies the name of the tag entity.

final String ERTAGGABLE_TAG_RELATIONSHIP_KEY = "_ERTaggableTagRelationship" [static]

The key stored in entity userInfo that specifies the name of the tag relationship.


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:35 2012 for Project Wonder by  doxygen 1.5.8