Exemplo n.º 1
0
  public int getNumDocuments(String folderId) {
    DmFolder folder = null;
    if (folderId != null) {
      folder = new DmFolder();
      folder.setId(folderId);
    }

    if (folder != null) {
      Disjunction disjunction = Restrictions.disjunction();
      disjunction.add(Restrictions.isNull("docApproval.id"));
      disjunction.add(
          Restrictions.ne("docApproval.status", ApplicationConstants.APPROVAL_STATUS_REJECTED));

      Criteria crit = getSession().createCriteria(DmDocumentFolder.class);
      crit.createAlias("document", "docInfo");
      crit.createAlias("docInfo.approval", "docApproval", CriteriaSpecification.LEFT_JOIN);
      crit.add(Restrictions.eq("folder", folder));
      //            crit.add(Restrictions.eq("docInfo.approved", true));
      crit.add(disjunction);

      return crit.list().size();
    }

    return 0;
  }
Exemplo n.º 2
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();
  }
Exemplo n.º 3
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;
  }