コード例 #1
0
  public DmFolder getByName(String folderName, String accountId, String folderIdParent) {
    DmFolder folderParent = null;
    if ((folderIdParent != null) && (!folderIdParent.isEmpty())) {
      folderParent = new DmFolder();
      folderParent.setId(folderIdParent);
    }

    DmAccount accountOwner = null;
    if (folderParent == null) {
      if ((accountId != null) && (!accountId.isEmpty())) {
        accountOwner = new DmAccount();
        accountOwner.setId(accountId);
      }
    }

    Criteria crit = getSession().createCriteria(DmFolder.class);
    crit.add(Restrictions.eq("name", folderName).ignoreCase());
    if (accountOwner != null) {
      crit.add(Restrictions.eq("owner", accountOwner));
    }
    if (folderParent != null) {
      crit.add(Restrictions.eq("parent", folderParent));
    } else {
      crit.add(Restrictions.isNull("parent"));
    }
    return (DmFolder) crit.uniqueResult();
  }
コード例 #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<DmAccount> getListOwnerByPermittedAccount(
      String accountId, Integer permissionLevelStart) {
    DmAccount permittedAccount = null;
    if (accountId != null) {
      permittedAccount = new DmAccount();
      permittedAccount.setId(accountId);
    }

    List<DmAccount> ownerList = null;
    if (permittedAccount != null) {
      Criteria crit = getSession().createCriteria(DmFolder.class);
      crit.setProjection(Projections.distinct(Projections.property("owner")));
      crit.add(Restrictions.ne("owner", permittedAccount));
      //            crit.setProjection(Projections.property("owner"));

      //            crit.add(Restrictions.eq("owner", accountOwner));
      //            crit.add(Restrictions.isNull("parent"));
      //            crit.addOrder(Order.asc("name"));
      //            if (permissionLevelStart != null) {
      //                crit.createCriteria("permissionList").add(Restrictions.ge("permissionType",
      // permissionLevelStart));
      //            }
      //            Criterion permissionCrit = null;

      Conjunction conjunction = Restrictions.conjunction();
      if (permissionLevelStart != null) {
        conjunction.add(Restrictions.ge("permissionType", permissionLevelStart));
      }
      conjunction.add(Restrictions.eq("account", permittedAccount));

      crit.createCriteria("permissionList").add(conjunction);

      ownerList = crit.list();

      //            if (ownerList != null) {
      //                for (DmAccount owner : ownerList) {
      //                    System.out.println("name = " + owner.getName());
      //                }
      //            }
      // 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 ownerList;
    //        return null;
  }
コード例 #4
0
  public DmFolder getParent(String folderId, String accountId) {
    DmAccount account = null;
    if (accountId != null) {
      //            folder = findById(folderId);
      account = new DmAccount();
      account.setId(accountId);
    }

    Criteria crit = getSession().createCriteria(DmFolder.class, "folder");
    crit.add(Restrictions.eq("folder.id", (folderId != null) ? folderId : ""));
    crit.setProjection(Projections.property("folder.parent"));
    crit.createAlias("parent", "folderParent");
    crit.createAlias("folderParent.permissionList", "permissions");
    crit.add(Restrictions.eq("permissions.account", account));

    return (DmFolder) crit.uniqueResult();
  }
コード例 #5
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;
  }
コード例 #6
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;
  }