コード例 #1
0
  public List<DmFolder> getChildList(String parentId) {
    DmFolder folderParent = null;
    if (parentId != null) {
      folderParent = new DmFolder();
      folderParent.setId(parentId);
    }

    List<DmFolder> folderList = null;
    if (folderParent != null) {
      Criteria crit = getSession().createCriteria(DmFolder.class);
      //        if (folderParent != null) {
      crit.add(Restrictions.eq("parent", folderParent));
      //        }
      //        else {
      //            crit.add(Restrictions.isNull("parent"));
      //        }
      crit.addOrder(Order.asc("name"));
      folderList = crit.list();

      // start - get children for each child (trigger lazy fetch)
      for (DmFolder folderTmp : folderList) {
        if (folderTmp.getChildList() != null) {
          folderTmp.getChildList().size();
        }
      }
      // end - get children for each child (trigger lazy fetch)
    }

    return folderList;
  }
コード例 #2
0
  public List<DmFolder> getFirstLevelList(String accountId) {
    DmAccount accountOwner = null;
    if (accountId != null) {
      accountOwner = new DmAccount();
      accountOwner.setId(accountId);
    }

    List<DmFolder> folderList = null;
    if (accountOwner != null) {
      Criteria crit = getSession().createCriteria(DmFolder.class);
      crit.add(Restrictions.eq("owner", accountOwner));
      crit.add(Restrictions.isNull("parent"));
      crit.addOrder(Order.asc("name"));
      folderList = crit.list();

      // start - get children for each child (trigger lazy fetch)
      for (DmFolder folderTmp : folderList) {
        if (folderTmp.getChildList() != null) {
          folderTmp.getChildList().size();
        }
      }
      // end - get children for each child (trigger lazy fetch)
    }

    return folderList;
  }
コード例 #3
0
  public List<DmFolder> getFirstLevelList() {
    List<DmFolder> folderList = null;
    Criteria crit = getSession().createCriteria(DmFolder.class);
    crit.add(Restrictions.isNull("parent"));
    crit.addOrder(Order.asc("name"));
    folderList = crit.list();

    // start - get children for each child (trigger lazy fetch)
    for (DmFolder folderTmp : folderList) {
      if (folderTmp.getChildList() != null) {
        folderTmp.getChildList().size();
      }
    }
    // end - get children for each child (trigger lazy fetch)

    return folderList;
  }
コード例 #4
0
  public List<DmFolder> getSharedChildList(String accountSharedId, String folderIdParent) {
    DmAccount permittedAccount = null;
    if (accountSharedId != null) {
      permittedAccount = new DmAccount();
      permittedAccount.setId(accountSharedId);
    }

    DmFolder parentFolder = null;
    if (folderIdParent != null) {
      parentFolder = findById(folderIdParent);
      //            parentFolder = new DmFolder();
      //            parentFolder.setId(folderIdParent);
    }

    List<DmFolder> folderList = null;

    if (parentFolder != null) {
      Criteria crit = getSession().createCriteria(DmFolderPermission.class);
      crit.setProjection(Projections.property("folder"));
      crit.add(Restrictions.eq("account", permittedAccount));
      crit.add(Restrictions.ne("account", parentFolder.getOwner()));
      //        crit.add(Restrictions.ge("permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_WRITER));

      crit.createAlias("folder", "folderInfo");
      crit.add(Restrictions.eq("folderInfo.parent", parentFolder));

      crit.addOrder(Order.asc("folderInfo.name"));

      folderList = crit.list();

      // start - get children for each child (trigger lazy fetch)
      for (DmFolder folderTmp : folderList) {
        if (folderTmp.getChildList() != null) {
          folderTmp.getChildList().size();
        }
      }
      // end - get children for each child (trigger lazy fetch)
    }

    return folderList;
  }
コード例 #5
0
  public List<DmFolder> getSharedFirstLevelList(String accountSharedId, String accountOwnerId) {
    DmAccount permittedAccount = null;
    if (accountSharedId != null) {
      permittedAccount = new DmAccount();
      permittedAccount.setId(accountSharedId);
    }

    DmAccount ownerAccount = null;
    if (accountOwnerId != null) {
      ownerAccount = new DmAccount();
      ownerAccount.setId(accountOwnerId);
    }

    List<DmFolder> folderList = null;
    if (permittedAccount != null) {
      Criteria crit = getSession().createCriteria(DmFolderPermission.class);
      crit.setProjection(Projections.property("folder"));

      Conjunction conjunction = Restrictions.conjunction();
      //            conjunction.add(Restrictions.ge("permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));
      conjunction.add(Restrictions.eq("account", permittedAccount));
      conjunction.add(Restrictions.ne("account", ownerAccount));
      crit.add(conjunction);

      crit.createAlias("folder", "folderShared", CriteriaSpecification.LEFT_JOIN);
      crit.add(Restrictions.eq("folderShared.owner", ownerAccount));

      crit.createAlias("folderShared.parent", "parentFolder", CriteriaSpecification.LEFT_JOIN);
      //            crit.createAlias("parentFolder.permissionList", "parentPermission");
      crit.createAlias(
          "parentFolder.permissionList", "parentPermission", CriteriaSpecification.LEFT_JOIN);

      //            DetachedCriteria subquery = DetachedCriteria.forClass(DmFolder.class,
      // "last_pos");
      DetachedCriteria subquery = DetachedCriteria.forClass(DmFolderPermission.class);
      subquery.setProjection(Projections.property("folder"));
      subquery.add(conjunction);

      Disjunction disjunction = Restrictions.disjunction();
      disjunction.add(Restrictions.isNull("folderShared.parent"));
      //            disjunction.add(Restrictions.isNull("parentFolder.permissionList"));
      //            disjunction.add(Restrictions.isNull("parentPermission.id"));
      //            disjunction.add(conjunction2);
      disjunction.add(Subqueries.propertyNotIn("folderShared.parent", subquery));

      //            crit.add(Subqueries.propertyNotIn("folderShared.parent", subquery));

      //            Conjunction conjunction2 = Restrictions.conjunction();
      //            conjunction2.add(Restrictions.eq("parentPermission.permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));
      //            conjunction2.add(Restrictions.eq("parentPermission.account", permittedAccount));
      //
      //            Conjunction conjunction3 = Restrictions.conjunction();
      //            conjunction3.add(Restrictions.eq("parentPermission.permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));
      //            conjunction3.add(Restrictions.eq("parentPermission.account", permittedAccount));

      //            disjunction.add(conjunction3);
      //            disjunction.add(Restrictions.ne("parentPermission.account", permittedAccount));
      //            disjunction.add(Restrictions.eq("parentPermission.permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));

      //            disjunction.add(Restrictions.isNull("parentFolder.permissionList"));

      //            disjunction.add(Restrictions.eq("parentPermission.permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));
      //            disjunction.add(Restrictions.ne("parentPermission.account", permittedAccount));

      crit.add(disjunction);

      folderList = crit.list();

      // start - get children for each child (trigger lazy fetch)
      for (DmFolder folderTmp : folderList) {
        if (folderTmp.getChildList() != null) {
          folderTmp.getChildList().size();
        }
      }
      // end - get children for each child (trigger lazy fetch)
    }

    return folderList;
  }