65 lines
2.0 KiB
Plaintext
Executable File
65 lines
2.0 KiB
Plaintext
Executable File
//
|
|
// Copyright (C) 2001 ArsDigita Corporation. All Rights Reserved.
|
|
//
|
|
// The contents of this file are subject to the ArsDigita Public
|
|
// License (the "License"); you may not use this file except in
|
|
// compliance with the License. You may obtain a copy of
|
|
// the License at http://www.arsdigita.com/ADPL.txt
|
|
//
|
|
// Software distributed under the License is distributed on an "AS
|
|
// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
// implied. See the License for the specific language governing
|
|
// rights and limitations under the License.
|
|
//
|
|
|
|
model com.arsdigita.docs;
|
|
|
|
import com.arsdigita.kernel.*;
|
|
import com.arsdigita.web.Application;
|
|
|
|
object type Repository extends Application {
|
|
|
|
BigDecimal rootID = docs_repositories.root_id INTEGER;
|
|
BigDecimal ownerID = docs_repositories.owner_id INTEGER;
|
|
|
|
|
|
reference key (docs_repositories.repository_id);
|
|
}
|
|
|
|
data operation addUserRepositoriesMapping {
|
|
do {
|
|
insert into docs_mounted
|
|
(party_id, repository_id)
|
|
select :userID, repository_id from docs_repositories
|
|
where repository_id in :repositoryIDs
|
|
and not exists (select 1 from docs_mounted
|
|
where docs_mounted.repository_id = docs_repositories.repository_id
|
|
and docs_mounted.party_id = :userID)
|
|
}
|
|
}
|
|
|
|
data operation removeUserRepositoriesMapping {
|
|
do {
|
|
delete from docs_mounted
|
|
where party_id = :userID
|
|
and repository_id in :repositoryIDs
|
|
}
|
|
}
|
|
|
|
|
|
query getRepositoryRoots {
|
|
BigDecimal id;
|
|
do {
|
|
select
|
|
d.resource_id,
|
|
from docs_resources d
|
|
where resource_id in (select docs_repositories.root_id
|
|
from docs_repositories, docs_mounted
|
|
where docs_mounted.repository_id = docs_repositories.repository_id
|
|
and docs_mounted.party_id = :userID)
|
|
} map {
|
|
id = d.resource_id;
|
|
}
|
|
}
|
|
|