Package er.taggable.model

Examples of er.taggable.model.ERTag


   * @return the corresponding ERTag (or null if not found)
   */
  @SuppressWarnings( { "cast", "unchecked" })
  public ERTag fetchTagNamed(EOEditingContext editingContext, String tagName, boolean createIfMissing) {
    NSArray<ERTag> tags = (NSArray<ERTag>) ERXEOControlUtilities.objectsWithQualifier(editingContext, _tagEntity.name(), ERTag.NAME.is(tagName), null, true, true, true, true);
    ERTag tag;
    if (tags.count() == 0) {
      if (createIfMissing) {
        // Create it in another transaction so we can catch the dupe exception.  Note that
        // this means that tags will ALWAYS be created even if the parent transaction
        // rolls back.  It's mostly for your own good :)
        EOEditingContext newEditingContext = ERXEC.newEditingContext();
        try {
          ERTag newTag = createTagNamed(newEditingContext, tagName);
          newEditingContext.saveChanges();
          tag = newTag.localInstanceIn(editingContext);
        }
        catch (EOGeneralAdaptorException e) {
          // We'll assume this was because of a duplicate key exception and just retry the original
          // fetch WITHOUT createIfMissing.  If that returns a null, then we know it was some other
          // crazy exception and just throw it.
View Full Code Here


   * @param editingContext the editing context to create within
   * @param tagName the new tag name
   * @return the created tag
   */
  public ERTag createTagNamed(EOEditingContext editingContext, String tagName) {
    ERTag tag = (ERTag) EOUtilities.createAndInsertInstance(editingContext, _tagEntity.name());
    tag.setName(tagName);
    return tag;
  }
View Full Code Here

    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);
      }
    }
  }
View Full Code Here

TOP

Related Classes of er.taggable.model.ERTag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.