...
By default all entities share the same corpus of tag names. For any entity, you can register a custom ERTag subclass that stores in a separate table instead. This is generally only an issue if you need to provide tag completion and you want to restrict the set of completion offerings. Note that hooking to a custom ERTag table also requires that you use the optional constructor on the migration superclass to specify the name of that entity.
By default, tags are normalized by trimming and lowercasing them. You can override the tag normalizer that is used by setting it on your ERTaggableEntity. An example implementation is
Code Block |
---|
public class TagNormalizer implements ERTagNormalizer {
public String normalize(String tag) {
String normalizedTag = tag;
if (normalizedTag != null) {
normalizedTag = normalizedTag.trim();
}
return normalizedTag;
}
}
|
You can then register that normalizer wherever you have an instance method such as
Code Block |
---|
taggableMike = mike.taggable();
TagNormalizer myNormalizer = new TagNormalizer();
taggableMike.taggableEntity().setNormalizer(myNormalizer);
|
You MUST register your taggable entities prior to attempting any tagging operations. The framework will throw an exception scolding you if you do not.
By default, your EOModels are modified on-the-fly to inject tagging support into them. If you don't like magic, you can instead manually create the join entity between your entity and the ERTag entity. You MUST also create a flattened to-many relationship from your entity to the ERTag table through your join entity. If you name that relationship anything other than "tags" (or you use a custom ERTag entity), you must specify the relationship name when you register the entity.
Tags are unique and shared. To ensure this, ERTag commits new tag names in a separate transaction. This can lead to a potentially undesirable (yet mostly harmless) side effect where new tag names may be committed even though you roll back your editing context. Only tag names have this behavior, not tag relationships on your entities.
...