// // 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: Resource.pdl 287 2005-02-22 00:29:02Z sskracic $ // $DateTime: 2004/08/17 23:15:09 $ model com.arsdigita.cms; object type ResourceType { String[1..1] id = cms_resource_types.type VARCHAR(200); String[1..1] baseClass = cms_resource_types.base_class VARCHAR(1000); String[1..1] label = cms_resource_types.label VARCHAR(1000); String[0..1] description = cms_resource_types.description VARCHAR(4000); object key (id); } object type Resource { BigDecimal[1..1] id = cms_resources.resource_id INTEGER; String[1..1] className = cms_resources.\class VARCHAR(1000); composite ResourceType[1..1] type = join cms_resources.type to cms_resource_types.type; object key (id); } object type ResourceMapping { BigDecimal[1..1] sectionId = cms_resource_map.section_id INTEGER; String[1..1] url = cms_resource_map.url VARCHAR(1000); BigDecimal[1..1] resourceId = cms_resource_map.resource_id INTEGER; object key (sectionId, url); retrieve { do { select section_id, url, resource_id from cms_resource_map where section_id = :sectionId and url = :url } map { sectionId = cms_resource_map.section_id; url = cms_resource_map.url; resourceId = cms_resource_map.resource_id; } } insert { do { insert into cms_resource_map ( section_id, url, resource_id ) values ( :sectionId, :url, :resourceId ) } } delete { do { delete from cms_resource_map where section_id = :sectionId and url = :url } } } query getResourceTypes { String id; String baseClass; String label; String description; do { select type, base_class, label, description from cms_resource_types } map { id = cms_resource_types.type; baseClass = cms_resource_types.base_class; label = cms_resource_types.label; description = cms_resource_types.description; } } // This query is used for efficiency reasons. // Common filters: // ( sectionId = :sectionId and url = :url ) query getResourceMappings { BigDecimal resourceId; String type; String className; BigDecimal sectionId; String url; do { select r.resource_id, r.type, r.class, m.section_id, m.url from cms_resources r, cms_resource_map m where r.resource_id = m.resource_id } map { resourceId = r.resource_id; type = r.type; className = r.\class; sectionId = m.section_id; url = m.url; } }