Package org.damour.base.client.objects

Examples of org.damour.base.client.objects.Tag


import org.junit.Test;

public class TagTest {

  public Tag createTag(String name, String desc, Tag parent) {
    Tag tag = new Tag();
    tag.setName(name);
    tag.setDescription(desc);
    tag.setParentTag(parent);
    return tag;
  }
View Full Code Here


  @Test
  public void createTagTest() {
    Session session = HibernateUtil.getInstance().getSession();
    Transaction tx = session.beginTransaction();

    Tag cat = createTag("catName1", "desc1", null);
    Tag cat2 = createTag("catName2", "desc2", cat);

    session.save(cat);
    session.save(cat2);

    tx.commit();
View Full Code Here

  @Test
  public void deleteTag() {
    Session session = HibernateUtil.getInstance().getSession();
    Transaction tx = session.beginTransaction();

    Tag tag = createTag("to-be-deleted-parent", "desc1", null);
    Tag tag2 = createTag("to-be-deleted-child", "desc2", tag);

    TagMembership tagMem = new TagMembership();
    tagMem.setTag(tag);
    PermissibleObject obj = new PermissibleObject();
    obj.setName("tags for this should not exist");
View Full Code Here

    if (StringUtils.isEmpty(tagName)) {
      throw new SimpleMessageException("Tag name not provided.");
    }

    Tag hibParentTag = null;
    if (parentTag != null) {
      hibParentTag = ((Tag) session.get().load(Tag.class, parentTag.getId()));
    }

    Transaction tx = session.get().beginTransaction();
    try {
      Tag tag = new Tag();
      tag.setName(tagName);
      tag.setDescription(tagDescription);
      tag.setParentTag(hibParentTag);
      session.get().save(tag);
      tx.commit();
    } catch (Throwable t) {
      Logger.log(t);
      try {
View Full Code Here

    if (tag == null) {
      throw new SimpleMessageException("Tag not provided.");
    }

    Tag hibTag = ((Tag) session.get().load(Tag.class, tag.getId()));
    if (hibTag == null) {
      throw new SimpleMessageException("Tag not found: " + tag);
    }

    Transaction tx = session.get().beginTransaction();
View Full Code Here

      throw new SimpleMessageException("User is not authenticated.");
    }

    // assumption is that the membership does not exist but the category / permissible object do
    // they must be loaded
    Tag hibTag = ((Tag) session.get().load(Tag.class, tagMembership.getTag().getId()));
    if (hibTag == null) {
      throw new SimpleMessageException("Tag not found: " + tagMembership.getTag().getId());
    }

    PermissibleObject hibPermissibleObject = ((PermissibleObject) session.get().load(PermissibleObject.class, tagMembership.getPermissibleObject().getId()));
View Full Code Here

    if (permissibleObject == null) {
      throw new SimpleMessageException("PermissibleObject not provided.");
    }

    Tag hibTag = ((Tag) session.get().load(Tag.class, tag.getId()));
    if (hibTag == null) {
      throw new SimpleMessageException("Category not found: " + tag);
    }

    PermissibleObject hibPermissibleObject = ((PermissibleObject) session.get().load(PermissibleObject.class, permissibleObject.getId()));
View Full Code Here

TOP

Related Classes of org.damour.base.client.objects.Tag

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.