libreccm-legacy/ccm-docrepo/pdl/com/arsdigita/docrepo/query-getRepositoriesView.p...

48 lines
2.0 KiB
Plaintext

//
// Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Id: docrepo/query-getRepositoriesView.pg.pdl pboy $
model com.arsdigita.docrepo;
query getRepositoriesView {
BigDecimal repositoryID;
BigDecimal isMounted;
BigDecimal numFiles;
do {
select distinct
dr_repositories.repository_id,
coalesce(dm.repository_id, null, 0, 1) as mounted,
dr_repository_num_files(dr_repositories.root_id) as num_files
from dr_repositories
left join (select repository_id from docs_mounted
where party_id = :userID) dm
on (dr_repositories.repository_id = dm.repository_id),
users,
group_member_map
where users.user_id = group_member_map.member_id
and dr_repositories.owner_id = users.user_id
and group_member_map.group_id in (select
group_id
from group_member_map
where member_id = :userID)
} map {
repositoryID = dr_repositories.repository_id;
isMounted = mounted;
numFiles = num_files;
}
}