/** * This method applies tags to the target object, by parsing the tags parameter * into Tag object instances and adding them to the tag collection of the object. * If the tag name already exists in the tags table, it just adds a relationship * to the existing tag record. If it doesn't exist, it then creates a new * Tag record for it. * * @param tags the tags to add (String to tokenize, NSArray<String>, etc) * @param clear if true, existing tags will be removed first */ public void addTags(boolean clear, Object tags) { // clear the collection if appropriate if (clear) { clearTags(); } NSArray<ERTag> erTags = tags(); EOEditingContext editingContext = _item.editingContext(); // append the tag names to the collection for (String tagName : _entity.splitTagNames(tags)) { // ensure that tag names don't get duplicated ERTag tag = _entity.fetchTagNamed(editingContext, tagName, true); if (!erTags.containsObject(tag)) { addTag(tag); } } }
protected NSArray indexableObjectsForObject(String type, EOEnterpriseObject object) { ERXGenericRecord eo = (ERXGenericRecord) object; EOEditingContext ec = eo.editingContext(); NSMutableSet<EOEnterpriseObject> result = new NSMutableSet(); String entityName = eo.entityName();
public NSArray<String> availableTags() { clearCacheIfNecessary(); if (_availableTags == null) { EOEditingContext editingContext = taggable().item().editingContext(); int minimum = minimum(); int limit = limit(); NSArray<String> availableTags; if (minimum == -1) { NSDictionary<String, Integer> tagCount = taggable().taggableEntity().tagCount(editingContext, limit, additionalQualifier()); availableTags = tagCount.allKeys(); } else { NSDictionary<String, Integer> tagCount = taggable().taggableEntity().tagCount(editingContext, ERXQ.GTEQ, minimum, limit, additionalQualifier()); availableTags = tagCount.allKeys(); } _availableTags = ERXArrayUtilities.sortedArrayUsingComparator(availableTags, NSComparator.AscendingStringComparator); } return _availableTags; }