libreccm-legacy/ccm-core/pdl/com/arsdigita/kernel/Party.pdl

101 lines
3.1 KiB
Plaintext
Executable File

//
// Copyright (C) 2001-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: Party.pdl 287 2005-02-22 00:29:02Z sskracic $
// $DateTime: 2004/08/16 18:10:38 $
model com.arsdigita.kernel;
object type Party extends ACSObject {
// this is logically an association to PartyEmail, but all we care
// about in PartyEmail is the string email address, so we just
// define that attribute directly here. This helps performance
// until MDSQL is further optimized.
String[0..1] primaryEmail = parties.primary_email VARCHAR(100);
String[0..1] uri = parties.uri VARCHAR(200);
reference key (parties.party_id);
}
// This object type is an internal implementation detail -- no one
// should work with it directly. It exists because parties have
// multiple email addresses, which are strings, but multi-value
// attributes aren't supported, so we need to define a seperate
// type and associate to it.
object type PartyEmail {
BigDecimal partyID = party_email_map.party_id INTEGER;
String[1..1] emailAddress = party_email_map.email_address VARCHAR(100);
object key (partyID, emailAddress);
insert {
do {
insert into party_email_map (party_id, email_address)
values (:partyID, :emailAddress)
}
}
retrieve {
do {
select party_id, email_address from party_email_map
where party_id = :partyID and email_address = :emailAddress
} map {
partyID = party_email_map.party_id;
emailAddress = party_email_map.email_address;
}
}
delete {
do {
delete from party_email_map
where party_id = :partyID and email_address = :emailAddress
}
}
}
association {
Party[1..1] party = join party_email_map.party_id to parties.party_id;
component PartyEmail[0..n] emailAddresses = join parties.party_id
to party_email_map.party_id;
retrieve emailAddresses {
do {
select party_id, email_address
from party_email_map
where party_id = :id
} map {
emailAddresses.partyID = party_email_map.party_id;
emailAddresses.emailAddress = party_email_map.email_address;
}
}
add emailAddresses {}
remove emailAddresses {}
clear emailAddresses {
do {
delete from party_email_map where party_id = :id
}
}
add party {}
remove party {}
clear party {}
}