Package com.dotmarketing.beans

Examples of com.dotmarketing.beans.Tree


            // parents if
            // not live.
            for (Tree tree : parentTrees) {
              // to keep relation types from parent only if it
              // exists
              Tree newTree = TreeFactory.getTree(tree.getParent(), file.getInode());
              if (!InodeUtils.isSet(newTree.getChild())) {
                newTree.setParent(tree.getParent());
                newTree.setChild(file.getInode());
                newTree.setRelationType(tree.getRelationType());
                newTree.setTreeOrder(0);
                TreeFactory.saveTree(newTree);
              }
            }
            APILocator.getVersionableAPI().setWorking(file);
            if(publish && perAPI.doesUserHavePermission(file, PermissionAPI.PERMISSION_PUBLISH, user))
View Full Code Here


import com.dotmarketing.util.InodeUtils;

public class RelationshipAPIImpl implements RelationshipAPI {

  public void addRelationship(String parent,String child, String relationType)throws DotDataException {   
    Tree tree = TreeFactory.getTree(parent, child,relationType);
    if (!InodeUtils.isSet(tree.getParent()) || !InodeUtils.isSet(tree.getChild())) {
      tree.setParent(parent);
      tree.setChild(child);
      tree.setRelationType(relationType);
      TreeFactory.saveTree(tree);
    } else {
      tree.setRelationType(relationType);
      TreeFactory.saveTree(tree);
    }
  }
View Full Code Here

  public static Tree getTree(String x) {
    try {
      return (Tree) new HibernateUtil(Tree.class).load(Long.parseLong(x));
    } catch (Exception e) {
      Tree tree = null ;
      try {
        tree =  (Tree) new HibernateUtil(Tree.class).load(x);
      } catch (DotHibernateException e1) {
        Logger.error(TreeFactory.class, "getTree failed:" + e, e);
      }
View Full Code Here

  public static Tree getTree(Tree object) {
    try {
      return (Tree) new HibernateUtil(Tree.class).load(Tree.class, object);
    } catch (Exception e) {
      return new Tree();
    }
  }
View Full Code Here

      return (Tree) dh.load();
    } catch (Exception e) {
      Logger.warn(TreeFactory.class, "getTree failed:" + e, e);
    }

    return new Tree();
  }
View Full Code Here

      return (Tree) dh.load();
    } catch (Exception e) {
      Logger.warn(TreeFactory.class, "getTree failed:" + e, e);
    }

    return new Tree();
  }
View Full Code Here

      return (Tree) dh.load();
    } catch (Exception e) {
      Logger.warn(TreeFactory.class, "getTree failed:" + e, e);
    }

    return new Tree();
  }
View Full Code Here

    List<Tree> newTrees = new ArrayList<Tree>();

    // Removing actual trees and creating the new ones
    Iterator<Tree> it = getTreesByParent(i1).iterator();
    while (it.hasNext()) {
      Tree tree = (Tree) it.next();
      newTrees.add(new Tree(i2.getInode(), tree.getChild(), tree.getRelationType(), tree.getTreeOrder()));
      deleteTree(tree);
    }

    it = getTreesByChild(i1).iterator();
    while (it.hasNext()) {
      Tree tree = (Tree) it.next();
      newTrees.add(new Tree(tree.getParent(), i2.getInode(), tree.getRelationType(), tree.getTreeOrder()));
      deleteTree(tree);
    }

    it = getTreesByParent(i2).iterator();
    while (it.hasNext()) {
      Tree tree = (Tree) it.next();
      newTrees.add(new Tree(i1.getInode(), tree.getChild(), tree.getRelationType(), tree.getTreeOrder()));
      deleteTree(tree);
    }

    it = getTreesByChild(i2).iterator();
    while (it.hasNext()) {
      Tree tree = (Tree) it.next();
      newTrees.add(new Tree(tree.getParent(), i1.getInode(), tree.getRelationType(), tree.getTreeOrder()));
      deleteTree(tree);
    }

    // Saving new trees
    it = newTrees.iterator();
    while (it.hasNext()) {
      Tree tree = (Tree) it.next();
      saveTree(tree);
    }
    try {
      HibernateUtil.flush();
      HibernateUtil.getSession().refresh(i1);
View Full Code Here

  @Override
  protected void addChild(Categorizable parent, Category child, String relationType) throws DotDataException {
    if(!UtilMethods.isSet(relationType))
      relationType = "child";
    List<Category> childCategories = getChildren(parent);
    Tree tree = TreeFactory.getTree(parent.getCategoryId(), child.getInode());
    if(tree == null || !InodeUtils.isSet(tree.getChild())) {
      tree.setChild(child.getInode());
      tree.setParent(parent.getCategoryId());
      tree.setRelationType(relationType);
      TreeFactory.saveTree(tree);
    }
    try {
      catCache.removeChild(parent, child);
    } catch (DotCacheException e) {
View Full Code Here

  @Override
  protected void addParent(Categorizable child, Category parent)
  throws DotDataException {
    List<Category> parentCats = getParents(child);
    Tree tree = TreeFactory.getTree(parent.getInode(), child.getCategoryId());
    if(tree == null || !InodeUtils.isSet(tree.getChild())) {
      tree.setChild(child.getCategoryId());
      tree.setParent(parent.getInode());
      tree.setRelationType("child");
      TreeFactory.saveTree(tree);
    }
    try {
      catCache.removeParent(child, parent);
    } catch (DotCacheException e) {
View Full Code Here

TOP

Related Classes of com.dotmarketing.beans.Tree

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.