diff --git a/ccm-cms-types-contact/application.xml b/ccm-cms-types-contact/application.xml index 43ea7f362..084003b08 100755 --- a/ccm-cms-types-contact/application.xml +++ b/ccm-cms-types-contact/application.xml @@ -2,7 +2,7 @@ diff --git a/ccm-cms-types-contact/pdl/com/arsdigita/content-types/Contact.pdl b/ccm-cms-types-contact/pdl/com/arsdigita/content-types/Contact.pdl index c1360f3b7..4afce4c04 100755 --- a/ccm-cms-types-contact/pdl/com/arsdigita/content-types/Contact.pdl +++ b/ccm-cms-types-contact/pdl/com/arsdigita/content-types/Contact.pdl @@ -20,6 +20,7 @@ model com.arsdigita.cms.contenttypes; import com.arsdigita.cms.ContentPage; +import com.arsdigita.cms.ContentItem; // object type to hold Contact content type object type Contact extends ContentPage { @@ -43,3 +44,46 @@ object type Contact extends ContentPage { reference key ( ct_contacts.contact_id ); } + +association { + + Contact[0..1] associatedContactForItem = + join cms_items.item_id to contact_content_item_map.item_id, + join contact_content_item_map.contact_id to ct_contacts.contact_id; + ContentItem[0..n] associatedContentItemsForContact = + join ct_contacts.contact_id to contact_content_item_map.contact_id, + join contact_content_item_map.item_id to cms_items.item_id; + + } + +// the above association works fine for adding but for some strange reason when +// you try to remove an item from the association it also tries to delete it +// so instead you have to use a data operation + +data operation removeContactFromContentItemAssociation { + do { + delete from contact_content_item_map where item_id = :itemID + } +} + +data operation removeContactFromAllAssociations { + do { + delete from contact_content_item_map where contact_id = :contactID + } +} + +query getContactForItem { + BigDecimal contactID; + BigDecimal itemID; + do { + select contact_id, item_id + from + contact_content_item_map + where + item_id = :itemID + } map { + contactID = contact_id; + itemID = item_id; + } +} + diff --git a/ccm-cms-types-contact/sql/ccm-cms-types-contact/default/upgrade/6.5.0-6.5.1/contact_content_item_map_table.sql b/ccm-cms-types-contact/sql/ccm-cms-types-contact/default/upgrade/6.5.0-6.5.1/contact_content_item_map_table.sql new file mode 100644 index 000000000..2a50893a4 --- /dev/null +++ b/ccm-cms-types-contact/sql/ccm-cms-types-contact/default/upgrade/6.5.0-6.5.1/contact_content_item_map_table.sql @@ -0,0 +1,16 @@ +create table contact_content_item_map ( + item_id INTEGER not null + constraint cont_con_ite_map_ite_i_p_scqe9 + primary key, + -- referential constraint for item_id deferred due to circular dependencies + contact_id INTEGER not null + -- referential constraint for contact_id deferred due to circular dependencies +); + + +alter table contact_content_item_map add + constraint cont_con_ite_map_con_i_f_lanid foreign key (contact_id) + references ct_contacts(contact_id); +alter table contact_content_item_map add + constraint cont_con_ite_map_ite_i_f_fr0po foreign key (item_id) + references cms_items(item_id); diff --git a/ccm-cms-types-contact/sql/ccm-cms-types-contact/upgrade/oracle-se-6.5.0-6.5.1.sql b/ccm-cms-types-contact/sql/ccm-cms-types-contact/upgrade/oracle-se-6.5.0-6.5.1.sql new file mode 100644 index 000000000..7e67195c5 --- /dev/null +++ b/ccm-cms-types-contact/sql/ccm-cms-types-contact/upgrade/oracle-se-6.5.0-6.5.1.sql @@ -0,0 +1,19 @@ +-- +-- Copyright (C) 2007 Magpie. 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 +-- + +@@ ../default/upgrade/6.5.0-6.5.1/contact_content_item_map_table.sql \ No newline at end of file diff --git a/ccm-cms-types-contact/sql/ccm-cms-types-contact/upgrade/postgres-6.5.0-6.5.1.sql b/ccm-cms-types-contact/sql/ccm-cms-types-contact/upgrade/postgres-6.5.0-6.5.1.sql new file mode 100644 index 000000000..0081706fd --- /dev/null +++ b/ccm-cms-types-contact/sql/ccm-cms-types-contact/upgrade/postgres-6.5.0-6.5.1.sql @@ -0,0 +1,21 @@ +-- +-- Copyright (C) 2007 Magpie. All Rights Reserved. +-- +-- The contents of this file are subject to the CCM 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.redhat.com/licenses/ccmpl.html. +-- +-- 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. +-- + +\echo Red Hat Enterprise CMS 6.5.0 -> 6.5.1 Upgrade Script (PostgreSQL) + +begin; + +\i ../default/upgrade/6.5.0-6.5.1/contact_content_item_map_table.sql + +commit; diff --git a/ccm-cms-types-contact/src/ccm-cms-types-contact.upgrade b/ccm-cms-types-contact/src/ccm-cms-types-contact.upgrade new file mode 100644 index 000000000..6bb705a2b --- /dev/null +++ b/ccm-cms-types-contact/src/ccm-cms-types-contact.upgrade @@ -0,0 +1,5 @@ + + +