cancel
Showing results for 
Search instead for 
Did you mean: 

Document counts from Spaces

schmidtster
Champ in-the-making
Champ in-the-making
Has anybody  run mysql database queries in alfresco backend to find the number of documents under a particluar Space/folder? or found other ways to get document counts in Alfresco? Thanks for your help Steve
1 REPLY 1

zomurn
Champ in-the-making
Champ in-the-making
Below, the code I use for this :

/**
    * number of documents having parent's folder as pSrcNodeRef and of type pType<br>
    *
    * @param pType
    *            Type de document à retourner
    * @param pSrcNodeRef
    *            Dossier source où sont les documents
    * @return number of doc. in pSrcFolder of type pType
    */
   public Integer getDocumentListCount(QName pType, NodeRef pSrcNodeRef) {

      MscValidateUtil.validateNotNull( pType );
      MscValidateUtil.validateNotNull( pSrcNodeRef );
      MscValidateUtil.validate( Arrays.asList( pSrcNodeRef ),
            ContentModel.TYPE_FOLDER, nodeService );

      String lSrcFolderName = (String) nodeService.getProperty( pSrcNodeRef,
            ContentModel.PROP_NAME );

      ResultSet lResultSet = searchService.query(
            MscStoreEnum.WORKSPACE_SPACES_STORE.getStoreRef(),
            SearchService.LANGUAGE_LUCENE, "+PATH:\"/app:company_home/cm:"
                  + lSrcFolderName + "/*\"" + " +TYPE:\"" + pType + "\"" );
      lResultSet.getResultSetMetaData().getSearchParameters().setLimitBy(
            LimitBy.UNLIMITED );

      return lResultSet.length();
   }

You need to use lucene query for this