From 92fb740757beab182e58d9d95f4442ae43785b5c Mon Sep 17 00:00:00 2001 From: jensp Date: Sun, 5 Jun 2011 20:00:06 +0000 Subject: [PATCH] =?UTF-8?q?Zweiter=20Teil=20der=20Dateien=20f=C3=BCr=20ccm?= =?UTF-8?q?-sci-types-organizationwithpublications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@953 8810af33-2d31-482b-a856-94f89814c4df --- .../SciDepartmentWithPublications.pdl | 34 +++ .../SciOrganizationWithPublications.pdl | 34 +++ .../SciProjectWithPublications.pdl | 36 +++ .../SciDepartmentWithPublications.xml | 65 +++++ .../SciOrganizationWithPublications.xml | 64 +++++ .../SciProjectWithPublications.xml | 65 +++++ .../scidepartment-with-publications-item.jsp | 44 +++ ...sciorganization-with-publications-item.jsp | 44 +++ .../sciproject-with-publications-item.jsp | 44 +++ .../SciDepartmentWithPublications.xml | 13 + .../SciOrganizationWithPublications.xml | 13 + .../SciProjectWithPublications.xml | 19 ++ .../PublicationSciDepartmentCollection.java | 43 +++ .../PublicationSciOrganizationCollection.java | 43 +++ .../PublicationSciProjectCollection.java | 43 +++ .../SciDepartmentPublicationsCollection.java | 41 +++ ...DepartmentWithPublicationsInitializer.java | 71 +++++ .../SciDepartmentWithPublicationsLoader.java | 73 +++++ ...SciOrganizationPublicationsCollection.java | 44 +++ ...ganizationWithPublicationsInitializer.java | 71 +++++ ...SciOrganizationWithPublicationsLoader.java | 74 +++++ .../SciProjectPublicationsCollection.java | 40 +++ ...SciProjectWithPublicationsInitializer.java | 71 +++++ .../SciProjectWithPublicationsLoader.java | 74 +++++ .../ui/PublicationSciDepartmentAddForm.java | 92 ++++++ .../ui/PublicationSciDepartmentStep.java | 59 ++++ .../ui/PublicationSciDepartmentTable.java | 265 +++++++++++++++++ .../ui/PublicationSciOrganizationAddForm.java | 90 ++++++ .../ui/PublicationSciOrganizationStep.java | 59 ++++ .../ui/PublicationSciOrganizationTable.java | 268 +++++++++++++++++ .../ui/PublicationSciProjectAddForm.java | 90 ++++++ .../ui/PublicationSciProjectStep.java | 60 ++++ .../ui/PublicationSciProjectTable.java | 266 +++++++++++++++++ .../ui/SciDepartmentPublicationsAddForm.java | 82 ++++++ .../ui/SciDepartmentPublicationsStep.java | 59 ++++ .../ui/SciDepartmentPublicationsTable.java | 269 ++++++++++++++++++ .../SciOrganizationPublicationsAddForm.java | 82 ++++++ .../ui/SciOrganizationPublicationsStep.java | 58 ++++ .../ui/SciOrganizationPublicationsTable.java | 267 +++++++++++++++++ .../ui/SciProjectPublicationsAddForm.java | 82 ++++++ .../ui/SciProjectPublicationsStep.java | 57 ++++ .../ui/SciProjectPublicationsTable.java | 265 +++++++++++++++++ .../src/empty.pdl.mf | 0 43 files changed, 3633 insertions(+) create mode 100644 ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciDepartmentWithPublications.pdl create mode 100644 ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciOrganizationWithPublications.pdl create mode 100644 ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciProjectWithPublications.pdl create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/scidepartment-with-publications-item.jsp create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/sciorganization-with-publications-item.jsp create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/sciproject-with-publications-item.jsp create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml create mode 100644 ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciDepartmentCollection.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciOrganizationCollection.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciProjectCollection.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentPublicationsCollection.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentWithPublicationsInitializer.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentWithPublicationsLoader.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationPublicationsCollection.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationWithPublicationsInitializer.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationWithPublicationsLoader.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectPublicationsCollection.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectWithPublicationsInitializer.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectWithPublicationsLoader.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentAddForm.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentStep.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentTable.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationAddForm.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationStep.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationTable.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectAddForm.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectStep.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectTable.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsAddForm.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsStep.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsTable.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsAddForm.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsStep.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsTable.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsAddForm.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsStep.java create mode 100644 ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsTable.java create mode 100644 ccm-sci-types-organizationwithpublications/src/empty.pdl.mf diff --git a/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciDepartmentWithPublications.pdl b/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciDepartmentWithPublications.pdl new file mode 100644 index 000000000..241a0c22b --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciDepartmentWithPublications.pdl @@ -0,0 +1,34 @@ +model com.arsdigita.cms.contenttypes; + +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.cms.*; + +object type SciDepartmentWithPublications extends SciDepartment { + reference key ( ct_sciorga_departments_with_publications.department_id ); +} + +association { + SciDepartment[0..n] departments = join ct_publications.publication_id + to ct_department_publication_map.publication_id, + join ct_department_publication_map.department_id + to ct_sciorga_departments_with_publications.department_id; + + Publication[0..n] publications = join ct_sciorga_departments_with_publications.department_id + to ct_department_publication_map.department_id, + join ct_department_publication_map.publication_id + to ct_publications.publication_id; + + Integer[0..1] publicationOrder = ct_department_publication_map.publication_order INTEGER; +} + +query getIdsOfPublicationsOfSciDepartment { + BigDecimal publicationId; + + do { + select ct_department_publication_map.publication_id + from ct_department_publication_map + where ct_department_publication_map.department_id = :department + } map { + publicationId = ct_department_publication_map.publication_id; + } +} \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciOrganizationWithPublications.pdl b/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciOrganizationWithPublications.pdl new file mode 100644 index 000000000..72385f50b --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciOrganizationWithPublications.pdl @@ -0,0 +1,34 @@ +model com.arsdigita.cms.contenttypes; + +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.cms.*; + +object type SciOrganizationWithPublications extends SciOrganization { + reference key ( ct_sciorga_organizations_with_publications.organization_id ); +} + +association { + SciOrganization[0..n] organizations = join ct_publications.publication_id + to ct_organization_publication_map.publication_id, + join ct_organization_publication_map.organization_id + to ct_sciorga_organizations_with_publications.organization_id; + + Publication[0..n] publications = join ct_sciorga_organizations_with_publications.organization_id + to ct_organization_publication_map.organization_id, + join ct_organization_publication_map.publication_id + to ct_publications.publication_id; + + Integer[0..1] publicationOrder = ct_organization_publication_map.publication_order INTEGER; +} + +query getIdsOfPublicationsOfSciOrganization { + BigDecimal publicationId; + + do { + select ct_organization_publication_map.publication_id + from ct_organization_publication_map + where ct_organization_publication_map.organization_id = :organization + } map { + publicationId = ct_organization_publication_map.publication_id; + } +} \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciProjectWithPublications.pdl b/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciProjectWithPublications.pdl new file mode 100644 index 000000000..0f7230d8b --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/pdl/com/arsdigita/content-types/SciProjectWithPublications.pdl @@ -0,0 +1,36 @@ +model com.arsdigita.cms.contenttypes; + +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.cms.*; + +object type SciProjectWithPublications extends SciProject { + + reference key ( ct_sciorga_projects_with_publications.project_id ); +} + +association { + SciProject[0..n] projects = join ct_publications.publication_id + to ct_project_publication_map.publication_id, + join ct_project_publication_map.project_id + to ct_sciorga_projects_with_publications.project_id; + + Publication[0..n] publications = join ct_sciorga_projects_with_publications.project_id + to ct_project_publication_map.project_id, + join ct_project_publication_map.publication_id + to ct_publications.publication_id; + + Integer[0..1] publicationOrder = ct_project_publication_map.publication_order INTEGER; + +} + +query getIdsOfPublicationsOfSciProject { + BigDecimal publicationId; + + do { + select ct_project_publication_map.publication_id + from ct_project_publication_map + where ct_project_publication_map.project_id = :project + } map { + publicationId = ct_project_publication_map.publication_id; + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml new file mode 100644 index 000000000..7de75ac0b --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml new file mode 100644 index 000000000..2b1ab7894 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml new file mode 100644 index 000000000..52927fd9f --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/scidepartment-with-publications-item.jsp b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/scidepartment-with-publications-item.jsp new file mode 100644 index 000000000..8e3e4cb3c --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/scidepartment-with-publications-item.jsp @@ -0,0 +1,44 @@ + + + + + + NavigationModel model = new CMSNavigationModel(); + + + + + + + ((com.arsdigita.london.navigation.ui.category.Path)categoryPath) + .setModel(model); + + + + ((com.arsdigita.london.navigation.ui.category.Menu)categoryMenu) + .setModel(model); + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/sciorganization-with-publications-item.jsp b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/sciorganization-with-publications-item.jsp new file mode 100644 index 000000000..d673bea10 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/sciorganization-with-publications-item.jsp @@ -0,0 +1,44 @@ + + + + + + NavigationModel model = new CMSNavigationModel(); + + + + + + + ((com.arsdigita.london.navigation.ui.category.Path)categoryPath) + .setModel(model); + + + + ((com.arsdigita.london.navigation.ui.category.Menu)categoryMenu) + .setModel(model); + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/sciproject-with-publications-item.jsp b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/sciproject-with-publications-item.jsp new file mode 100644 index 000000000..739de1477 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/sciproject-with-publications-item.jsp @@ -0,0 +1,44 @@ + + + + + + NavigationModel model = new CMSNavigationModel(); + + + + + + + ((com.arsdigita.london.navigation.ui.category.Path)categoryPath) + .setModel(model); + + + + ((com.arsdigita.london.navigation.ui.category.Menu)categoryMenu) + .setModel(model); + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml b/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml new file mode 100644 index 000000000..35c899532 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml b/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml new file mode 100644 index 000000000..1bedd0dc2 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml b/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml new file mode 100644 index 000000000..02c350a3d --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciDepartmentCollection.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciDepartmentCollection.java new file mode 100644 index 000000000..84e187587 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciDepartmentCollection.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciDepartmentCollection extends DomainCollection { + + public PublicationSciDepartmentCollection( + final DataCollection dataCollection) { + super(dataCollection); + + addOrder("title"); + } + + public SciDepartmentWithPublications getDepartment() { + return (SciDepartmentWithPublications) DomainObjectFactory.newInstance(m_dataCollection. + getDataObject()); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciOrganizationCollection.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciOrganizationCollection.java new file mode 100644 index 000000000..6d25d9cbb --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciOrganizationCollection.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciOrganizationCollection extends DomainCollection { + + public PublicationSciOrganizationCollection( + final DataCollection dataCollection) { + super(dataCollection); + + addOrder("title"); + } + + public SciOrganizationWithPublications getOrganization() { + return (SciOrganizationWithPublications) DomainObjectFactory.newInstance(m_dataCollection. + getDataObject()); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciProjectCollection.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciProjectCollection.java new file mode 100644 index 000000000..ba69d14ca --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/PublicationSciProjectCollection.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciProjectCollection extends DomainCollection { + + public PublicationSciProjectCollection( + final DataCollection dataCollection) { + super(dataCollection); + + addOrder("title"); + } + + public SciProjectWithPublications getOrganization() { + return (SciProjectWithPublications) DomainObjectFactory.newInstance(m_dataCollection. + getDataObject()); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentPublicationsCollection.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentPublicationsCollection.java new file mode 100644 index 000000000..9eaeaae34 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentPublicationsCollection.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; + +/** + * + * @author Jens Pelzetter + */ +public class SciDepartmentPublicationsCollection extends DomainCollection { + + public SciDepartmentPublicationsCollection( + final DataCollection dataCollection) { + super(dataCollection); + } + + public Publication getPublication() { + return (Publication) DomainObjectFactory.newInstance(m_dataCollection. + getDataObject()); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentWithPublicationsInitializer.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentWithPublicationsInitializer.java new file mode 100644 index 000000000..cf775a603 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentWithPublicationsInitializer.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.contenttypes.ui.PublicationSciDepartmentStep; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.runtime.DomainInitEvent; + +/** + * + * @author Jens Pelzetter + */ +public class SciDepartmentWithPublicationsInitializer + extends ContentTypeInitializer { + + public SciDepartmentWithPublicationsInitializer() { + super("empty.pdl.mf", + SciOrganizationWithPublications.BASE_DATA_OBJECT_TYPE); + } + + @Override + public void init(final DomainInitEvent event) { + super.init(event); + + ContentType departmentType = + ContentType.findByAssociatedObjectType(SciDepartment.class. + getName()); + departmentType.setMode("internal"); + + AuthoringKitWizard.registerAssetStep(Publication.BASE_DATA_OBJECT_TYPE, + PublicationSciDepartmentStep.class, + new GlobalizedMessage( + "sciorganizationpublication.ui.publication.departments.title", + "com.arsdigita.cms.contenttypes.ui.SciOrganizationWithPublicationsResources"), + new GlobalizedMessage( + "sciorganizationpublication.ui.publication.departments.description", + "com.arsdigita.cms.contenttypes.ui.SciOrganizationWithPublicationsResources"), + 1); + } + + @Override + public String[] getStylesheets() { + return new String[]{ + "/static/content-types/com/arsdigita/cms/contenttypes/SciDepartment.xsl"}; + } + + @Override + public String getTraversalXML() { + return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml"; + + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentWithPublicationsLoader.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentWithPublicationsLoader.java new file mode 100644 index 000000000..aa7cd959d --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciDepartmentWithPublicationsLoader.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.lifecycle.LifecycleDefinition; +import com.arsdigita.util.parameter.Parameter; +import com.arsdigita.util.parameter.ResourceParameter; +import com.arsdigita.workflow.simple.WorkflowTemplate; +import java.io.InputStream; + +/** + * + * @author Jens Pelzetter + */ +public class SciDepartmentWithPublicationsLoader extends AbstractContentTypeLoader { + + private ResourceParameter m_template; + private static final String[] TYPES = { + "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciDepartmentWithPublications.xml" + }; + + public SciDepartmentWithPublicationsLoader() { + super(); + + m_template = + new ResourceParameter( + "com.arsdigita.cms.contenttypes.SciDepartmentWithPublicationsTemplate", + Parameter.REQUIRED, + "/WEB-INF/content-types/com/arsdigita/" + + "cms/contenttypes/scidepartment-with-publications-item.jsp"); + + register(m_template); + } + + public String[] getTypes() { + return TYPES; + } + + @Override + protected void prepareSection(final ContentSection section, + final ContentType type, + final LifecycleDefinition lifecycle, + final WorkflowTemplate workflow) { + super.prepareSection(section, type, lifecycle, workflow); + + setDefaultTemplate("SciDepartmentWithPublications Item", + "scidepartment-with-publications-item", + (InputStream) get(m_template), + section, + type, + lifecycle, + workflow); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationPublicationsCollection.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationPublicationsCollection.java new file mode 100644 index 000000000..8a3fc5512 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationPublicationsCollection.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; + +/** + * + * @author Jens Pelzetter + */ +public class SciOrganizationPublicationsCollection extends DomainCollection { + + public String ORDER = "departmentOrder"; + public String LINKORDER = "link.departmentOrder"; + + public SciOrganizationPublicationsCollection( + final DataCollection dataCollection) { + super(dataCollection); + } + + public Publication getPublication() { + return (Publication) DomainObjectFactory.newInstance(m_dataCollection. + getDataObject()); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationWithPublicationsInitializer.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationWithPublicationsInitializer.java new file mode 100644 index 000000000..9d1b0e1a4 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationWithPublicationsInitializer.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.contenttypes.ui.PublicationSciOrganizationStep; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.runtime.DomainInitEvent; + +/** + * + * @author Jens Pelzetter + */ +public class SciOrganizationWithPublicationsInitializer + extends ContentTypeInitializer { + + public SciOrganizationWithPublicationsInitializer() { + super("ccm-sci-types-organizationwithpublications.pdl.mf", + SciOrganizationWithPublications.BASE_DATA_OBJECT_TYPE); + } + + @Override + public void init(final DomainInitEvent event) { + super.init(event); + + ContentType orgaType = + ContentType.findByAssociatedObjectType(SciOrganization.class. + getName()); + orgaType.setMode("internal"); + + AuthoringKitWizard.registerAssetStep(Publication.BASE_DATA_OBJECT_TYPE, + PublicationSciOrganizationStep.class, + new GlobalizedMessage( + "sciorganizationpublication.ui.publication.organization.title", + "com.arsdigita.cms.contenttypes.ui.SciOrganizationWithPublicationsResources"), + new GlobalizedMessage( + "sciorganizationpublication.ui.publication.organization.description", + "com.arsdigita.cms.contenttypes.ui.SciOrganizationWithPublicationsResources"), + 1); + } + + @Override + public String[] getStylesheets() { + return new String[]{ + "/static/content-types/com/arsdigita/cms/contenttypes/SciOrganization.xsl"}; + } + + @Override + public String getTraversalXML() { + return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciOrganizationWithPublications.xml"; + + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationWithPublicationsLoader.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationWithPublicationsLoader.java new file mode 100644 index 000000000..39b12e111 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciOrganizationWithPublicationsLoader.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.lifecycle.LifecycleDefinition; +import com.arsdigita.util.parameter.Parameter; +import com.arsdigita.util.parameter.ResourceParameter; +import com.arsdigita.workflow.simple.WorkflowTemplate; +import java.io.InputStream; + +/** + * + * @author Jens Pelzetter + */ +public class SciOrganizationWithPublicationsLoader extends AbstractContentTypeLoader { + + private ResourceParameter m_template; + + public SciOrganizationWithPublicationsLoader() { + super(); + + m_template = new ResourceParameter( + "com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsTemplate", + Parameter.REQUIRED, + "/WEB-INF/content-types/com/arsdigita/" + + "cms/contenttypes/sciorganization-with-publications-item.jsp"); + + register(m_template); + } + private static final String[] TYPES = { + "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/" + + "SciOrganizationWithPublications.xml" + }; + + @Override + public String[] getTypes() { + return TYPES; + } + + @Override + protected void prepareSection(final ContentSection section, + final ContentType type, + final LifecycleDefinition lifecycle, + final WorkflowTemplate workflow) { + super.prepareSection(section, type, lifecycle, workflow); + + setDefaultTemplate("SciOrganizationWithPublications Item", + "sciorganization-with-publications-item", + (InputStream) get(m_template), + section, + type, + lifecycle, + workflow); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectPublicationsCollection.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectPublicationsCollection.java new file mode 100644 index 000000000..fbb592469 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectPublicationsCollection.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; + +/** + * + * @author Jens Pelzetter + */ +public class SciProjectPublicationsCollection extends DomainCollection { + + public SciProjectPublicationsCollection(final DataCollection dataCollection) { + super(dataCollection); + } + + public Publication getPublication() { + return (Publication) DomainObjectFactory.newInstance(m_dataCollection. + getDataObject()); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectWithPublicationsInitializer.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectWithPublicationsInitializer.java new file mode 100644 index 000000000..60b05b772 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectWithPublicationsInitializer.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.contenttypes.ui.PublicationSciProjectStep; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.runtime.DomainInitEvent; + +/** + * + * @author Jens Pelzetter + */ +public class SciProjectWithPublicationsInitializer + extends ContentTypeInitializer { + + public SciProjectWithPublicationsInitializer() { + super("empty.pdl.mf", + SciOrganizationWithPublications.BASE_DATA_OBJECT_TYPE); + } + + @Override + public void init(final DomainInitEvent event) { + super.init(event); + + ContentType projectType = + ContentType.findByAssociatedObjectType(SciProject.class. + getName()); + projectType.setMode("internal"); + + AuthoringKitWizard.registerAssetStep(Publication.BASE_DATA_OBJECT_TYPE, + PublicationSciProjectStep.class, + new GlobalizedMessage( + "sciorganizationpublication.ui.publication.projects.title", + "com.arsdigita.cms.contenttypes.ui.SciOrganizationWithPublicationsResources"), + new GlobalizedMessage( + "sciorganizationpublication.ui.publication.projects.description", + "com.arsdigita.cms.contenttypes.ui.SciOrganizationWithPublicationsResources"), + 1); + } + + @Override + public String[] getStylesheets() { + return new String[]{ + "/static/content-types/com/arsdigita/cms/contenttypes/SciProject.xsl"}; + } + + @Override + public String getTraversalXML() { + return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml"; + + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectWithPublicationsLoader.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectWithPublicationsLoader.java new file mode 100644 index 000000000..406d4bf6e --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/SciProjectWithPublicationsLoader.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.lifecycle.LifecycleDefinition; +import com.arsdigita.util.parameter.Parameter; +import com.arsdigita.util.parameter.ResourceParameter; +import com.arsdigita.workflow.simple.WorkflowTemplate; +import java.io.InputStream; + +/** + * + * @author Jens Pelzetter + */ +public class SciProjectWithPublicationsLoader extends AbstractContentTypeLoader { + + private ResourceParameter m_template; + private static final String[] TYPES = { + "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProjectWithPublications.xml" + }; + + public SciProjectWithPublicationsLoader() { + super(); + + m_template = + new ResourceParameter( + "com.arsdigita.cms.contenttypes.SciProjectWithPublicationsTemplate", + Parameter.REQUIRED, + "/WEB-INF/content-types/com/arsdigita/" + + "cms/contenttypes/sciproject-with-publications-item.jsp"); + + register(m_template); + } + + @Override + public String[] getTypes() { + return TYPES; + } + + @Override + protected void prepareSection(final ContentSection section, + final ContentType type, + final LifecycleDefinition lifecycle, + final WorkflowTemplate workflow) { + super.prepareSection(section, type, lifecycle, workflow); + + setDefaultTemplate("SciProjectWithPublications Item", + "sciproject-with-publications-item", + (InputStream) get(m_template), + section, + type, + lifecycle, + workflow); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentAddForm.java new file mode 100644 index 000000000..83ea4ee52 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentAddForm.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.persistence.DataObject; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciDepartmentAddForm + extends BasicItemForm + implements FormProcessListener, + FormInitListener { + + private ItemSearchWidget itemSearch; + private final String ITEM_SEARCH = "departments"; + + public PublicationSciDepartmentAddForm(ItemSelectionModel itemModel) { + super("PublicationSciDepartmentAddForm", itemModel); + } + + @Override + public void addWidgets() { + add(new Label((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganization.ui.selectDepartment").localize())); + itemSearch = new ItemSearchWidget(ITEM_SEARCH, + ContentType.findByAssociatedObjectType(SciDepartmentWithPublications.class. + getName())); + add(itemSearch); + } + + @Override + public void init(final FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + + setVisible(state, true); + } + + @Override + public void process(final FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + + Publication publication = (Publication) getItemSelectionModel(). + getSelectedObject(state); + + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { + SciDepartmentWithPublications department = + (SciDepartmentWithPublications) data. + get( + ITEM_SEARCH); + DataObject link = publication.add("departments", department); + link.set("publicationOrder", Integer.valueOf((int) department. + getPublications().size())); + + link.save(); + } + + init(fse); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentStep.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentStep.java new file mode 100644 index 000000000..01bf10f0b --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentStep.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciDepartmentStep extends SimpleEditStep { + + private String ADD_ORGANIZATION_SHEET_NAME = "addSciDepartment"; + + public PublicationSciDepartmentStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public PublicationSciDepartmentStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final String prefix) { + super(itemModel, parent, prefix); + + BasicItemForm addDepartmentSheet = + new PublicationSciDepartmentAddForm(itemModel); + add(ADD_ORGANIZATION_SHEET_NAME, + (String) SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.addDepartment").localize(), + new WorkflowLockedComponentAccess(addDepartmentSheet, itemModel), + addDepartmentSheet.getSaveCancelSection().getCancelButton()); + + PublicationSciDepartmentTable departmentTable = + new PublicationSciDepartmentTable( + itemModel); + setDisplayComponent(departmentTable); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentTable.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentTable.java new file mode 100644 index 000000000..9d3a68fe5 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentTable.java @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.ControlLink; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.event.TableActionEvent; +import com.arsdigita.bebop.event.TableActionListener; +import com.arsdigita.bebop.table.TableCellRenderer; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.PublicationSciDepartmentCollection; +import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications; +import com.arsdigita.cms.dispatcher.ItemResolver; +import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; +import com.arsdigita.persistence.DataCollection; +import com.arsdigita.util.Assert; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciDepartmentTable + extends Table + implements TableActionListener { + + private final String TABLE_COL_EDIT = "table_col_edit"; + private final String TABLE_COL_DEL = "table_col_del"; + private ItemSelectionModel itemModel; + + public PublicationSciDepartmentTable(final ItemSelectionModel itemModel) { + super(); + this.itemModel = itemModel; + + setEmptyView(new Label(SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganizationpublication.ui.departments.none"))); + + TableColumnModel columnModel = getColumnModel(); + columnModel.add(new TableColumn( + 0, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.department").localize(), + TABLE_COL_EDIT)); + columnModel.add(new TableColumn( + 1, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.department.remove"). + localize(), TABLE_COL_DEL)); + + setModelBuilder(new PublicationSciDepartmentTableModelBuilder( + itemModel)); + + columnModel.get(0).setCellRenderer(new EditCellRenderer()); + columnModel.get(1).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + } + + private class PublicationSciDepartmentTableModelBuilder + extends LockableImpl + implements TableModelBuilder { + + private ItemSelectionModel itemModel; + + public PublicationSciDepartmentTableModelBuilder( + final ItemSelectionModel itemModel) { + this.itemModel = itemModel; + } + + public TableModel makeModel(final Table table, final PageState state) { + table.getRowSelectionModel().clearSelection(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + return new PublicationSciDepartmentTableModel(table, + state, + publication); + } + } + + private class PublicationSciDepartmentTableModel implements TableModel { + + private Table table; + private PublicationSciDepartmentCollection departments; + private SciDepartmentWithPublications department; + + public PublicationSciDepartmentTableModel(final Table table, + final PageState state, + final Publication publication) { + this.table = table; + + departments = + new PublicationSciDepartmentCollection((DataCollection) publication. + get("departments")); + } + + public int getColumnCount() { + return table.getColumnModel().size(); + } + + public boolean nextRow() { + boolean ret; + + if ((departments != null) && departments.next()) { + department = departments.getDepartment(); + ret = true; + } else { + ret = false; + } + + return ret; + } + + public Object getElementAt(int columnIndex) { + switch (columnIndex) { + case 0: + return department.getTitle(); + case 1: + return SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.department.remove"). + localize(); + default: + return null; + } + } + + public Object getKeyAt(int columnIndex) { + return department.getID(); + } + } + + private class EditCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.EDIT_ITEM, + publication); + + if (canEdit) { + SciDepartmentWithPublications department; + try { + department = + new SciDepartmentWithPublications((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = + new Link(value.toString(), + resolver.generateItemURL(state, + department, + section, + department.getVersion())); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + private class DeleteCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.DELETE_ITEM, + publication); + + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + link.setConfirmation((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.department.confirm.remove"). + localize()); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + public void cellSelected(final TableActionEvent event) { + PageState state =event.getPageState(); + + SciDepartmentWithPublications department = new SciDepartmentWithPublications( + new BigDecimal(event.getRowKey().toString())); + + Publication publication = (Publication) itemModel.getSelectedObject(state); + + TableColumn column = getColumnModel().get(event.getColumn().intValue()); + + if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { + //Nothing to do + } else if(TABLE_COL_DEL.equals(column.getHeaderKey().toString())) { + Assert.exists(department, SciDepartmentWithPublications.class); + + publication.remove("departments", department); + } + } + + public void headSelected(final TableActionEvent event) { + //Nothing to do + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationAddForm.java new file mode 100644 index 000000000..d66d5e5f2 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationAddForm.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.persistence.DataObject; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciOrganizationAddForm + extends BasicItemForm + implements FormProcessListener, + FormInitListener { + + private ItemSearchWidget itemSearch; + private final String ITEM_SEARCH = "organizations"; + + public PublicationSciOrganizationAddForm(final ItemSelectionModel itemModel) { + super("PublicationSciOrganizationAddForm", itemModel); + } + + @Override + public void addWidgets() { + add(new Label((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganization.ui.selectOrganization").localize())); + itemSearch = new ItemSearchWidget(ITEM_SEARCH, + ContentType.findByAssociatedObjectType(SciOrganizationWithPublications.class. + getName())); + add(itemSearch); + } + + @Override + public void init(final FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + + setVisible(state, true); + } + + @Override + public void process(final FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + + Publication publication = (Publication) getItemSelectionModel(). + getSelectedObject(state); + + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { + SciOrganizationWithPublications organization = + (SciOrganizationWithPublications) data. + get( + ITEM_SEARCH); + DataObject link = publication.add("organizations", organization); + link.set("publicationOrder", Integer.valueOf((int)organization.getPublications().size())); + link.save(); + } + + init(fse); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationStep.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationStep.java new file mode 100644 index 000000000..7f356072b --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationStep.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciOrganizationStep extends SimpleEditStep { + + private String ADD_ORGANIZATION_SHEET_NAME = "addSciOrganization"; + + public PublicationSciOrganizationStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public PublicationSciOrganizationStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final String prefix) { + super(itemModel, parent, prefix); + + BasicItemForm addOrganizationSheet = + new PublicationSciOrganizationAddForm(itemModel); + add(ADD_ORGANIZATION_SHEET_NAME, + (String) SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.addOrganization").localize(), + new WorkflowLockedComponentAccess(addOrganizationSheet, itemModel), + addOrganizationSheet.getSaveCancelSection().getCancelButton()); + + PublicationSciOrganizationTable organizationTable = + new PublicationSciOrganizationTable( + itemModel); + setDisplayComponent(organizationTable); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationTable.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationTable.java new file mode 100644 index 000000000..f41e3ff14 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationTable.java @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.ControlLink; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.event.TableActionEvent; +import com.arsdigita.bebop.event.TableActionListener; +import com.arsdigita.bebop.table.TableCellRenderer; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.PublicationSciOrganizationCollection; +import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; +import com.arsdigita.cms.dispatcher.ItemResolver; +import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; +import com.arsdigita.persistence.DataCollection; +import com.arsdigita.util.Assert; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciOrganizationTable + extends Table + implements TableActionListener { + + private final String TABLE_COL_EDIT = "table_col_edit"; + private final String TABLE_COL_DEL = "table_col_del"; + private ItemSelectionModel itemModel; + + public PublicationSciOrganizationTable(final ItemSelectionModel itemModel) { + super(); + this.itemModel = itemModel; + + setEmptyView(new Label(SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganizationpublication.ui.organizations.none"))); + + TableColumnModel columnModel = getColumnModel(); + columnModel.add(new TableColumn( + 0, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.organization").localize(), + TABLE_COL_EDIT)); + columnModel.add(new TableColumn( + 1, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.organization.remove"). + localize(), TABLE_COL_DEL)); + + setModelBuilder(new PublicationSciOrganizationTableModelBuilder( + itemModel)); + + columnModel.get(0).setCellRenderer(new EditCellRenderer()); + columnModel.get(1).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + } + + private class PublicationSciOrganizationTableModelBuilder + extends LockableImpl + implements TableModelBuilder { + + private ItemSelectionModel itemModel; + + public PublicationSciOrganizationTableModelBuilder( + final ItemSelectionModel itemModel) { + this.itemModel = itemModel; + } + + public TableModel makeModel(final Table table, final PageState state) { + table.getRowSelectionModel().clearSelection(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + return new PublicationSciOrganizationTableModel(table, + state, + publication); + } + } + + private class PublicationSciOrganizationTableModel implements TableModel { + + private Table table; + private PublicationSciOrganizationCollection organizations; + private SciOrganizationWithPublications organization; + + public PublicationSciOrganizationTableModel(final Table table, + final PageState state, + final Publication publication) { + + this.table = table; + + organizations = + new PublicationSciOrganizationCollection((DataCollection) publication. + get("organizations")); + } + + public int getColumnCount() { + return table.getColumnModel().size(); + } + + public boolean nextRow() { + boolean ret; + + if ((organizations != null) && organizations.next()) { + organization = organizations.getOrganization(); + ret = true; + } else { + ret = false; + } + + return ret; + } + + public Object getElementAt(int columnIndex) { + switch (columnIndex) { + case 0: + return organization.getTitle(); + case 1: + return SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.organization.remove"). + localize(); + default: + return null; + } + } + + public Object getKeyAt(int columnIndex) { + return organization.getID(); + } + } + + private class EditCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.EDIT_ITEM, + publication); + + if (canEdit) { + SciOrganizationWithPublications organization; + try { + organization = + new SciOrganizationWithPublications((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = + new Link(value.toString(), + resolver.generateItemURL(state, + organization, + section, + organization.getVersion())); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + private class DeleteCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.DELETE_ITEM, + publication); + + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + link.setConfirmation((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.organization.confirm.remove"). + localize()); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + public void cellSelected(final TableActionEvent event) { + PageState state = event.getPageState(); + + SciOrganizationWithPublications organization = + new SciOrganizationWithPublications( + new BigDecimal(event.getRowKey().toString())); + + Publication publication = (Publication) itemModel.getSelectedObject( + state); + + TableColumn column = getColumnModel().get(event.getColumn().intValue()); + + if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { + //Nothing to do + } else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) { + Assert.exists(organization, SciOrganizationWithPublications.class); + + publication.remove("organizations", organization); + } + } + + public void headSelected(final TableActionEvent event) { + //Nothing to do + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectAddForm.java new file mode 100644 index 000000000..8d56ee065 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectAddForm.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciProjectWithPublications; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.persistence.DataObject; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciProjectAddForm + extends BasicItemForm + implements FormProcessListener, + FormInitListener { + + private ItemSearchWidget itemSearch; + private final String ITEM_SEARCH = "projects"; + + public PublicationSciProjectAddForm(final ItemSelectionModel itemModel) { + super("PublicationSciProjectAddForm", itemModel); + } + + @Override + public void addWidgets() { + add(new Label((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganization.ui.selectProject").localize())); + itemSearch = new ItemSearchWidget(ITEM_SEARCH, + ContentType.findByAssociatedObjectType(SciProjectWithPublications.class. + getName())); + add(itemSearch); + } + + @Override + public void init(final FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + + setVisible(state, true); + } + + @Override + public void process(final FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + + Publication publication = (Publication) getItemSelectionModel(). + getSelectedObject(state); + + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { + SciProjectWithPublications project = + (SciProjectWithPublications) data.get( + ITEM_SEARCH); + DataObject link = publication.add("projects", project); + link.set("publicationOrder", Integer.valueOf((int) project. + getPublications().size())); + link.save(); + } + + init(fse); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectStep.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectStep.java new file mode 100644 index 000000000..cf32dda77 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectStep.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciProjectStep extends SimpleEditStep { + + private String ADD_ORGANIZATION_SHEET_NAME = "addSciProject"; + + public PublicationSciProjectStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public PublicationSciProjectStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final String prefix) { + super(itemModel, parent, prefix); + + BasicItemForm addProjectSheet = + new PublicationSciProjectAddForm(itemModel); + add(ADD_ORGANIZATION_SHEET_NAME, + (String) SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.addOrganization").localize(), + new WorkflowLockedComponentAccess(addProjectSheet, itemModel), + addProjectSheet.getSaveCancelSection().getCancelButton()); + + PublicationSciProjectTable projectTable = + new PublicationSciProjectTable( + itemModel); + setDisplayComponent(projectTable); + } + +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectTable.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectTable.java new file mode 100644 index 000000000..bc21f119c --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectTable.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.ControlLink; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.event.TableActionEvent; +import com.arsdigita.bebop.event.TableActionListener; +import com.arsdigita.bebop.table.TableCellRenderer; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.PublicationSciProjectCollection; +import com.arsdigita.cms.contenttypes.SciProjectWithPublications; +import com.arsdigita.cms.dispatcher.ItemResolver; +import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; +import com.arsdigita.persistence.DataCollection; +import com.arsdigita.util.Assert; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; + +/** + * + * @author Jens Pelzetter + */ +public class PublicationSciProjectTable + extends Table + implements TableActionListener { + + private final String TABLE_COL_EDIT = "table_col_edit"; + private final String TABLE_COL_DEL = "table_col_del"; + private ItemSelectionModel itemModel; + + public PublicationSciProjectTable(final ItemSelectionModel itemModel) { + super(); + this.itemModel = itemModel; + + setEmptyView(new Label(SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganizationpublication.ui.projects.none"))); + + TableColumnModel columnModel = getColumnModel(); + columnModel.add(new TableColumn( + 0, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.projects").localize(), + TABLE_COL_EDIT)); + columnModel.add(new TableColumn( + 1, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.projects.remove"). + localize(), TABLE_COL_DEL)); + + setModelBuilder(new PublicationSciProjectTableModelBuilder( + itemModel)); + + columnModel.get(0).setCellRenderer(new EditCellRenderer()); + columnModel.get(1).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + } + + private class PublicationSciProjectTableModelBuilder + extends LockableImpl + implements TableModelBuilder { + + private ItemSelectionModel itemModel; + + public PublicationSciProjectTableModelBuilder( + final ItemSelectionModel itemModel) { + this.itemModel = itemModel; + } + + public TableModel makeModel(final Table table, final PageState state) { + table.getRowSelectionModel().clearSelection(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + return new PublicationSciProjectTableModel(table, + state, + publication); + } + } + + private class PublicationSciProjectTableModel implements TableModel { + + private Table table; + private PublicationSciProjectCollection projects; + private SciProjectWithPublications project; + + public PublicationSciProjectTableModel(final Table table, + final PageState state, + final Publication publication) { + + this.table = table; + + projects = + new PublicationSciProjectCollection((DataCollection) publication. + get("projects")); + } + + public int getColumnCount() { + return table.getColumnModel().size(); + } + + public boolean nextRow() { + boolean ret; + + if ((projects != null) && projects.next()) { + project = projects.getOrganization(); + ret = true; + } else { + ret = false; + } + + return ret; + } + + public Object getElementAt(int columnIndex) { + switch (columnIndex) { + case 0: + return project.getTitle(); + case 1: + return SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.project.remove"). + localize(); + default: + return null; + } + } + + public Object getKeyAt(int columnIndex) { + return project.getID(); + } + } + + private class EditCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.EDIT_ITEM, + publication); + + if (canEdit) { + SciProjectWithPublications project; + try { + project = + new SciProjectWithPublications((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = + new Link(value.toString(), + resolver.generateItemURL(state, + project, + section, + project.getVersion())); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + private class DeleteCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + Publication publication = (Publication) itemModel.getSelectedObject( + state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.DELETE_ITEM, + publication); + + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + link.setConfirmation((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.project.confirm.remove"). + localize()); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + public void cellSelected(final TableActionEvent event) { + PageState state =event.getPageState(); + + SciProjectWithPublications project = new SciProjectWithPublications( + new BigDecimal(event.getRowKey().toString())); + + Publication publication = (Publication) itemModel.getSelectedObject(state); + + TableColumn column = getColumnModel().get(event.getColumn().intValue()); + + if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { + //Nothing to do + } else if(TABLE_COL_DEL.equals(column.getHeaderKey().toString())) { + Assert.exists(project, SciProjectWithPublications.class); + + publication.remove("projects", project); + } + } + + public void headSelected(final TableActionEvent event) { + //Nothing to do + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsAddForm.java new file mode 100644 index 000000000..af2a92ab1 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsAddForm.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ui.authoring.BasicItemForm; + +/** + * + * @author Jens Pelzetter + */ +public class SciDepartmentPublicationsAddForm + extends BasicItemForm + implements FormProcessListener, + FormInitListener { + + private ItemSearchWidget itemSearch; + private final String ITEM_SEARCH = "publications"; + + public SciDepartmentPublicationsAddForm(final ItemSelectionModel itemModel) { + super("SciDepartmentPublicationsAddForm", itemModel); + } + + @Override + public void addWidgets() { + add(new Label((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganization.ui.selectPublication").localize())); + itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. + findByAssociatedObjectType(Publication.class.getName())); + add(itemSearch); + } + + @Override + public void init(final FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + + setVisible(state, true); + } + + @Override + public void process(final FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + SciDepartmentWithPublications organization = + (SciDepartmentWithPublications) getItemSelectionModel(). + getSelectedObject(state); + + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { + organization.addPublication((Publication) data.get(ITEM_SEARCH)); + } + + init(fse); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsStep.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsStep.java new file mode 100644 index 000000000..e1d5c19f8 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsStep.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; + +/** + * + * @author Jens Pelzetter + */ +public class SciDepartmentPublicationsStep extends SimpleEditStep { + + private String ADD_PUBLICATION_SHEET_NAME = "addPublication"; + + public SciDepartmentPublicationsStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public SciDepartmentPublicationsStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final String prefix) { + super(itemModel, parent, prefix); + + BasicItemForm addPublicationSheet = + new SciDepartmentPublicationsAddForm(itemModel); + add(ADD_PUBLICATION_SHEET_NAME, + (String) SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.addPublication").localize(), + new WorkflowLockedComponentAccess(addPublicationSheet, itemModel), + addPublicationSheet.getSaveCancelSection().getCancelButton()); + + SciDepartmentPublicationsTable publicationTable = + new SciDepartmentPublicationsTable( + itemModel); + setDisplayComponent(publicationTable); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsTable.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsTable.java new file mode 100644 index 000000000..5b98f7218 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsTable.java @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.ControlLink; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.event.TableActionEvent; +import com.arsdigita.bebop.event.TableActionListener; +import com.arsdigita.bebop.table.TableCellRenderer; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciDepartmentPublicationsCollection; +import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications; +import com.arsdigita.cms.dispatcher.ItemResolver; +import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; + +/** + * + * @author Jens Pelzetter + */ +public class SciDepartmentPublicationsTable + extends Table + implements TableActionListener { + + private final String TABLE_COL_EDIT = "table_col_edit"; + private final String TABLE_COL_DEL = "table_col_del"; + private ItemSelectionModel itemModel; + + public SciDepartmentPublicationsTable(final ItemSelectionModel itemModel) { + super(); + this.itemModel = itemModel; + + setEmptyView(new Label(SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganizationpublication.ui.publications.none"))); + + TableColumnModel columnModel = getColumnModel(); + columnModel.add(new TableColumn( + 0, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.publication").localize(), + TABLE_COL_EDIT)); + columnModel.add(new TableColumn( + 1, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.publication.remove"). + localize(), TABLE_COL_DEL)); + + setModelBuilder( + new SciDepartmentPublicationsTableModelBuilder(itemModel)); + + columnModel.get(0).setCellRenderer(new EditCellRenderer()); + columnModel.get(1).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + } + + private class SciDepartmentPublicationsTableModelBuilder + extends LockableImpl + implements TableModelBuilder { + + private ItemSelectionModel itemModel; + + public SciDepartmentPublicationsTableModelBuilder( + final ItemSelectionModel itemModel) { + this.itemModel = itemModel; + } + + public TableModel makeModel(final Table table, + final PageState state) { + table.getRowSelectionModel().clearSelection(state); + SciDepartmentWithPublications department = + (SciDepartmentWithPublications) itemModel. + getSelectedObject(state); + + return new SciDepartmentPublicationsTableModel(table, + state, + department); + } + } + + private class SciDepartmentPublicationsTableModel + implements TableModel { + + private Table table; + private SciDepartmentPublicationsCollection publications; + private Publication publication; + + public SciDepartmentPublicationsTableModel( + final Table table, + final PageState state, + final SciDepartmentWithPublications department) { + this.table = table; + publications = department.getPublications(); + } + + public int getColumnCount() { + return table.getColumnModel().size(); + } + + public boolean nextRow() { + boolean ret; + + if ((publications != null) && publications.next()) { + publication = publications.getPublication(); + ret = true; + } else { + ret = false; + } + + return ret; + } + + public Object getElementAt(int columnIndex) { + switch (columnIndex) { + case 0: + return publication.getTitle(); + case 1: + return SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.publiction.remove"). + localize(); + default: + return null; + } + } + + public Object getKeyAt(int columnIndex) { + return publication.getID(); + } + } + + private class EditCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + + SciDepartmentWithPublications department = + (SciDepartmentWithPublications) itemModel. + getSelectedObject(state); + + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.EDIT_ITEM, + department); + + if (canEdit) { + Publication publication; + try { + publication = new Publication((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = new Link(value.toString(), + resolver.generateItemURL(state, + publication, + section, + publication. + getVersion())); + + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + private class DeleteCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + SciDepartmentWithPublications organization = + (SciDepartmentWithPublications) itemModel. + getSelectedObject(state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.DELETE_ITEM, + organization); + + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + link.setConfirmation((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.publication.confirm.remove"). + localize()); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + public void cellSelected(final TableActionEvent event) { + PageState state = event.getPageState(); + + Publication publication = + new Publication(new BigDecimal(event.getRowKey().toString())); + + SciDepartmentWithPublications department = + (SciDepartmentWithPublications) itemModel. + getSelectedObject(state); + + TableColumn column = getColumnModel().get(event.getColumn().intValue()); + + if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { + //Nothing to do here + } else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) { + department.removePublication(publication); + } + } + + public void headSelected(final TableActionEvent event) { + //Nothing to do her + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsAddForm.java new file mode 100644 index 000000000..2024b075a --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsAddForm.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ui.authoring.BasicItemForm; + +/** + * + * @author Jens Pelzetter + */ +public class SciOrganizationPublicationsAddForm + extends BasicItemForm + implements FormProcessListener, + FormInitListener { + + private ItemSearchWidget itemSearch; + private final String ITEM_SEARCH = "publications"; + + public SciOrganizationPublicationsAddForm(final ItemSelectionModel itemModel) { + super("SciOrganizationPublicationsAddForm", itemModel); + } + + @Override + public void addWidgets() { + add(new Label((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganization.ui.selectPublication").localize())); + itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. + findByAssociatedObjectType(Publication.class.getName())); + add(itemSearch); + } + + @Override + public void init(final FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + + setVisible(state, true); + } + + @Override + public void process(final FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + SciOrganizationWithPublications organization = + (SciOrganizationWithPublications) getItemSelectionModel(). + getSelectedObject(state); + + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { + organization.addPublication((Publication) data.get(ITEM_SEARCH)); + } + + init(fse); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsStep.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsStep.java new file mode 100644 index 000000000..c55c11340 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsStep.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; + +/** + * + * @author Jens Pelzetter + */ +public class SciOrganizationPublicationsStep extends SimpleEditStep { + + private String ADD_PUBLICATION_SHEET_NAME = "addPublication"; + + public SciOrganizationPublicationsStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public SciOrganizationPublicationsStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final String prefix) { + super(itemModel, parent, prefix); + + BasicItemForm addPublicationSheet = new SciOrganizationPublicationsAddForm(itemModel); + add(ADD_PUBLICATION_SHEET_NAME, + (String) SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.addPublication").localize(), + new WorkflowLockedComponentAccess(addPublicationSheet, itemModel), + addPublicationSheet.getSaveCancelSection().getCancelButton()); + + SciOrganizationPublicationsTable publicationTable = new SciOrganizationPublicationsTable(itemModel); + setDisplayComponent(publicationTable); + + } + +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsTable.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsTable.java new file mode 100644 index 000000000..f3e1b6527 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsTable.java @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.ControlLink; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.event.TableActionEvent; +import com.arsdigita.bebop.event.TableActionListener; +import com.arsdigita.bebop.table.TableCellRenderer; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciOrganizationPublicationsCollection; +import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; +import com.arsdigita.cms.dispatcher.ItemResolver; +import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; + +/** + * + * @author Jens Pelzetter + */ +public class SciOrganizationPublicationsTable + extends Table + implements TableActionListener { + + private final String TABLE_COL_EDIT = "table_col_edit"; + private final String TABLE_COL_DEL = "table_col_del"; + private ItemSelectionModel itemModel; + + public SciOrganizationPublicationsTable(final ItemSelectionModel itemModel) { + super(); + this.itemModel = itemModel; + + setEmptyView(new Label(SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganizationpublication.ui.publications.none"))); + + TableColumnModel columnModel = getColumnModel(); + columnModel.add(new TableColumn( + 0, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.publication").localize(), + TABLE_COL_EDIT)); + columnModel.add(new TableColumn( + 1, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.publication.remove"). + localize(), TABLE_COL_DEL)); + + setModelBuilder(new SciOrganizationPublicationsTableModelBuilder( + itemModel)); + + columnModel.get(0).setCellRenderer(new EditCellRenderer()); + columnModel.get(1).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + } + + private class SciOrganizationPublicationsTableModelBuilder + extends LockableImpl + implements TableModelBuilder { + + private ItemSelectionModel itemModel; + + public SciOrganizationPublicationsTableModelBuilder( + final ItemSelectionModel itemModel) { + this.itemModel = itemModel; + } + + public TableModel makeModel(final Table table, final PageState state) { + table.getRowSelectionModel().clearSelection(state); + SciOrganizationWithPublications organization = + (SciOrganizationWithPublications) itemModel. + getSelectedObject(state); + + return new SciOrganizationPublicationsTableModel(table, + state, + organization); + } + } + + private class SciOrganizationPublicationsTableModel implements TableModel { + + private Table table; + private SciOrganizationPublicationsCollection publications; + private Publication publication; + + public SciOrganizationPublicationsTableModel( + final Table table, + final PageState state, + final SciOrganizationWithPublications organization) { + this.table = table; + publications = organization.getPublications(); + } + + public int getColumnCount() { + return table.getColumnModel().size(); + } + + public boolean nextRow() { + boolean ret; + + if ((publications != null) && publications.next()) { + publication = publications.getPublication(); + ret = true; + } else { + ret = false; + } + + return ret; + } + + public Object getElementAt(final int columnIndex) { + switch (columnIndex) { + case 0: + return publication.getTitle(); + case 1: + return SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.publiction.remove"). + localize(); + default: + return null; + } + } + + public Object getKeyAt(final int columnIndex) { + return publication.getID(); + } + } + + private class EditCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + SciOrganizationWithPublications organization = + (SciOrganizationWithPublications) itemModel. + getSelectedObject(state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.EDIT_ITEM, + organization); + + if (canEdit) { + Publication publication; + try { + publication = new Publication((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = new Link(value.toString(), + resolver.generateItemURL(state, + publication, + section, + publication. + getVersion())); + + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + private class DeleteCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + SciOrganizationWithPublications organization = + (SciOrganizationWithPublications) itemModel. + getSelectedObject(state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.DELETE_ITEM, + organization); + + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + link.setConfirmation((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.publication.confirm.remove"). + localize()); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + @Override + public void cellSelected(final TableActionEvent event) { + PageState state = event.getPageState(); + + Publication publication = + new Publication(new BigDecimal(event.getRowKey().toString())); + + SciOrganizationWithPublications organization = + (SciOrganizationWithPublications) itemModel. + getSelectedObject(state); + + TableColumn column = getColumnModel().get(event.getColumn().intValue()); + + if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { + //Nothing to do here + } else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) { + organization.removePublication(publication); + } + } + + @Override + public void headSelected(final TableActionEvent event) { + //Nothing to do. + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsAddForm.java new file mode 100644 index 000000000..76d3910c8 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsAddForm.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciProjectWithPublications; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ui.authoring.BasicItemForm; + +/** + * + * @author Jens Pelzetter + */ +public class SciProjectPublicationsAddForm + extends BasicItemForm + implements FormInitListener, + FormProcessListener { + + private ItemSearchWidget itemSearch; + private final String ITEM_SEARCH = "publications"; + + public SciProjectPublicationsAddForm(final ItemSelectionModel itemModel) { + super("SciProjectPublicationsAddForm", itemModel); + } + + @Override + public void addWidgets() { + add(new Label((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganization.ui.selectPublication").localize())); + itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. + findByAssociatedObjectType(Publication.class.getName())); + add(itemSearch); + } + + @Override + public void init(final FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + + setVisible(state, true); + } + + @Override + public void process(final FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + SciProjectWithPublications project = + (SciProjectWithPublications) getItemSelectionModel(). + getSelectedObject(state); + + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { + project.addPublication((Publication) data.get(ITEM_SEARCH)); + } + + init(fse); + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsStep.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsStep.java new file mode 100644 index 000000000..21214bf98 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsStep.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; + +/** + * + * @author Jens Pelzetter + */ +public class SciProjectPublicationsStep extends SimpleEditStep { + + private String ADD_PUBLICATION_SHEET_NAME = "addPublication"; + + public SciProjectPublicationsStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public SciProjectPublicationsStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final String prefix) { + super(itemModel, parent, prefix); + + BasicItemForm addPublicationSheet = new SciProjectPublicationsAddForm(itemModel); + add(ADD_PUBLICATION_SHEET_NAME, + (String) SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.project.addPublication").localize(), + new WorkflowLockedComponentAccess(addPublicationSheet, itemModel), + addPublicationSheet.getSaveCancelSection().getCancelButton()); + + SciProjectPublicationsTable publicationTable = new SciProjectPublicationsTable(itemModel); + setDisplayComponent(publicationTable); + + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsTable.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsTable.java new file mode 100644 index 000000000..adf9b3409 --- /dev/null +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsTable.java @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * 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 + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.ControlLink; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.event.TableActionEvent; +import com.arsdigita.bebop.event.TableActionListener; +import com.arsdigita.bebop.table.TableCellRenderer; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.SciProjectPublicationsCollection; +import com.arsdigita.cms.contenttypes.SciProjectWithPublications; +import com.arsdigita.cms.dispatcher.ItemResolver; +import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; + +/** + * + * @author Jens Pelzetter + */ +public class SciProjectPublicationsTable + extends Table + implements TableActionListener { + + private final String TABLE_COL_EDIT = "table_col_edit"; + private final String TABLE_COL_DEL = "table_col_del"; + private ItemSelectionModel itemModel; + + public SciProjectPublicationsTable(final ItemSelectionModel itemModel) { + super(); + this.itemModel = itemModel; + + setEmptyView(new Label(SciOrganizationWithPublicationsGlobalizationUtil. + globalize("sciorganizationpublication.ui.publications.none"))); + + TableColumnModel columnModel = getColumnModel(); + columnModel.add(new TableColumn( + 0, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.publication").localize(), + TABLE_COL_EDIT)); + columnModel.add(new TableColumn( + 1, + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganizationpublication.ui.publication.remove"). + localize(), TABLE_COL_DEL)); + + setModelBuilder(new SciProjectPublicationsTableModelBuilder( + itemModel)); + + columnModel.get(0).setCellRenderer(new EditCellRenderer()); + columnModel.get(1).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + } + + private class SciProjectPublicationsTableModelBuilder + extends LockableImpl + implements TableModelBuilder { + + private ItemSelectionModel itemModel; + + public SciProjectPublicationsTableModelBuilder( + final ItemSelectionModel itemModel) { + this.itemModel = itemModel; + } + + public TableModel makeModel(final Table table, final PageState state) { + table.getRowSelectionModel().clearSelection(state); + SciProjectWithPublications project = + (SciProjectWithPublications) itemModel. + getSelectedObject(state); + + return new SciProjectPublicationsTableModel(table, + state, + project); + } + } + + private class SciProjectPublicationsTableModel implements TableModel { + + private Table table; + private SciProjectPublicationsCollection publications; + private Publication publication; + + public SciProjectPublicationsTableModel( + final Table table, + final PageState state, + final SciProjectWithPublications project) { + this.table = table; + publications = project.getPublications(); + } + + public int getColumnCount() { + return table.getColumnModel().size(); + } + + public boolean nextRow() { + boolean ret; + + if ((publications != null) && publications.next()) { + publication = publications.getPublication(); + ret = true; + } else { + ret = false; + } + + return ret; + } + + public Object getElementAt(int columnIndex) { + switch (columnIndex) { + case 0: + return publication.getTitle(); + case 1: + return SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.publiction.remove"). + localize(); + default: + return null; + } + } + + public Object getKeyAt(int columnIndex) { + return publication.getID(); + } + } + + private class EditCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + SciProjectWithPublications project = + (SciProjectWithPublications) itemModel. + getSelectedObject(state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.EDIT_ITEM, + project); + + if (canEdit) { + Publication publication; + try { + publication = new Publication((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = new Link(value.toString(), + resolver.generateItemURL(state, + publication, + section, + publication. + getVersion())); + + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + private class DeleteCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int column) { + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + SciProjectWithPublications project = + (SciProjectWithPublications) itemModel. + getSelectedObject(state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.DELETE_ITEM, + project); + + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + link.setConfirmation((String) SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganizationpublication.ui.publication.confirm.remove"). + localize()); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + public void cellSelected(final TableActionEvent event) { + PageState state = event.getPageState(); + + Publication publication = + new Publication(new BigDecimal(event.getRowKey().toString())); + + SciProjectWithPublications project = + (SciProjectWithPublications) itemModel. + getSelectedObject(state); + + TableColumn column = getColumnModel().get(event.getColumn().intValue()); + + if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { + //Nothing to do here + } else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) { + project.removePublication(publication); + } + } + + public void headSelected(final TableActionEvent event) { + //Nothing to do. + } +} diff --git a/ccm-sci-types-organizationwithpublications/src/empty.pdl.mf b/ccm-sci-types-organizationwithpublications/src/empty.pdl.mf new file mode 100644 index 000000000..e69de29bb