PublicationList Contenttyp zur Erstellung von Publikationslisten.

git-svn-id: https://svn.libreccm.org/ccm/trunk@533 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2010-09-16 15:52:11 +00:00
parent afaff626c9
commit c3ae973099
26 changed files with 930 additions and 35 deletions

View File

@ -66,8 +66,8 @@ association {
to cms_contacts.contact_id;
// Link Attribute
BigDecimal[1..1] contact_order = cms_person_contact_map.contact_order INTEGER;
BigDecimal[0..1] contact_order = cms_person_contact_map.contact_order INTEGER;
// Can't use a join statement here because contacttype_id is not unique
String[1..1] contact_type = cms_person_contact_map.key VARCHAR(100);
String[0..1] contact_type = cms_person_contact_map.key VARCHAR(100);
}

View File

@ -34,7 +34,7 @@ object type GenericOrganizationalUnit extends ContentPage {
// Parent <-> child relation organizationalunits to build department structures etc.
association {
GenericOrganizationalUnit[0..1] orgaunit_parent = join cms_organizationalunits.organizationalunit_id
GenericOrganizationalUnit[0..n] orgaunit_parent = join cms_organizationalunits.organizationalunit_id
to cms_organizationalunits_organizationalunit_map.orgaunit_children_id,
join cms_organizationalunits_organizationalunit_map.orgaunit_parent_id
to cms_organizationalunits.organizationalunit_id;
@ -62,15 +62,15 @@ association {
to cms_contacts.contact_id;
// Some link attributes.
String contact_type = cms_organizationalunits_contact_map.contact_type VARCHAR(100);
Integer contact_order = cms_organizationalunits_contact_map.map_order INTEGER;
String[0..1] contact_type = cms_organizationalunits_contact_map.contact_type VARCHAR(100);
Integer[0..1] contact_order = cms_organizationalunits_contact_map.map_order INTEGER;
}
// Links a organization with persons.
association {
GenericOrganizationalUnit[0..1] organizationalunit = join cms_persons.person_id
GenericOrganizationalUnit[0..n] organizationalunit = join cms_persons.person_id
to cms_organizationalunits_person_map.person_id,
join cms_organizationalunits_person_map.organizationalunit_id
to cms_organizationalunits.organizationalunit_id;

View File

@ -181,6 +181,7 @@ public class GenericOrganizationalUnitChildrenCollection
* @return The GenericOrganizationalUnit at the cursors current position.
*/
public GenericOrganizationalUnit getOrgaUnitChild() {
return new GenericOrganizationalUnit(m_dataCollection.getDataObject());
return new GenericOrganizationalUnit(
m_dataCollection.getDataObject());
}
}

View File

@ -429,7 +429,31 @@ public class OID {
for(Iterator it = props.keySet().iterator(); it.hasNext(); ) {
Object key = it.next();
Object value = props.get(key);
sb.append(key.toString() + OID_SEPARATOR_CHAR + value.toString());
/*if ((key == null) || (value == null)) {
m_log.warn("key or value in OID.toString() are null");
m_log.warn(String.format("key = %s", key));
m_log.warn(String.format("value = %s", value));
}*/
/*
* Changed by Jens Pelzetter 2010-09-14. For unknown reasons
* the value is null for some properties, which causes
* a NPE in the line below the if.
*/
if (null == value) {
m_log.info(String.format("The value for prop \"%s\" " +
"is null. Ignoring.", key));
continue;
}
/*
* Changed by Jens Pelzetter 2010-09-14.
*
* The old method (see below) is very slow, because of this
* has been changed.
*/
sb.append(key.toString());
sb.append(OID_SEPARATOR_CHAR);
sb.append(value.toString());
//sb.append(key.toString() + OID_SEPARATOR_CHAR + value.toString());
if (it.hasNext()) {
sb.append(OID_SEPARATOR_CHAR);
}

View File

@ -35,7 +35,7 @@ object type Publication extends ContentPage {
//Assoication for the authors
association {
Publication[0..1] publication = join cms_persons.person_id
Publication[0..n] publication = join cms_persons.person_id
to ct_publications_authorship.person_id,
join ct_publications_authorship.publication_id
to ct_publications.publication_id;

View File

@ -0,0 +1,45 @@
//
// Copyright (C) 2010 Jens Pelzetter, for the Center of Social Politics (ZeS) 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
//
//
model com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentPage;
//PDL definition for the basic attributes of publication.
object type PublicationList extends ContentPage {
String[0..1] description = ct_publicationlists.description VARCHAR(2048);
reference key (ct_publicationlists.publicationlist_id);
}
//Association which links the publication list(s) and the publications
association {
PublicationList[0..n] publicationLists = join ct_publications.publication_id
to ct_publicationlists_map.publication_id,
join ct_publicationlists_map.publicationlist_id
to ct_publicationlists.publicationlist_id;
Publication[0..n] publications = join ct_publicationlists.publicationlist_id
to ct_publicationlists_map.publicationlist_id,
join ct_publicationlists_map.publication_id
to ct_publications.publication_id;
}

View File

@ -32,7 +32,7 @@ object type Series extends ContentPage {
//Assoication for the editship of a series
association {
Series[0..1] series = join cms_persons.person_id
Series[0..n] series = join cms_persons.person_id
to ct_series_editship.person_id,
join ct_series_editship.series_id
to ct_series.series_id;
@ -54,7 +54,7 @@ association {
//Assoication for the volumes in the series
association {
Series[0..1] series = join ct_publications.publication_id
Series[0..n] series = join ct_publications.publication_id
to ct_publications_volume_in_series.publication_id,
join ct_publications_volume_in_series.series_id
to ct_series.series_id;

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
<ctd:content-type
label="PublicationList"
description="A list of publications"
objectType="com.arsdigita.cms.contenttypes.PublicationList"
classname="com.arsdigita.cms.contenttypes.PublicationList">
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
<ctd:authoring-step
labelKey="publications.ui.publicationlist_properties.title"
labelBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
descriptionKey="publications.ui.publicationlist_properties.title.description"
descriptionBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
component="com.arsdigita.cms.contenttypes.ui.PublicationListPropertiesStep"
ordering="1"/>
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
</ctd:authoring-kit>
</ctd:content-type>
</ctd:content-types>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<xrd:adapters
xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator" >
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.ArticleInCollectedVolume"
extends="com.arsdigita.cms.contenttypes.PublicationWithPublisher">
<xrd:associations rule="include">
<xrd:property name="/object/collectedVolume"/>
</xrd:associations>
</xrd:adapter>
</xrd:context>
</xrd:adapters>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xrd:adapters
xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator" >
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.PublicationList"
extends="com.arsdigita.cms.ContentPage">
<xrd:associations rule="include">
<xrd:property name="/object/publications"/>
<xrd:property name="/object/publications/authors"/>
<xrd:property name="/object/publications/publisher"/>
</xrd:associations>
</xrd:adapter>
</xrd:context>
</xrd:adapters>

View File

@ -6,7 +6,7 @@
<initializer class="com.arsdigita.cms.Initializer"/>
</requires>
<provides>
<table name="ct_publication"/>
<table name="ct_publications"/>
<table name="ct_publication_with_publisher"/>
<table name="ct_series"/>
<table name="ct_publisher"/>
@ -21,6 +21,7 @@
<table name="ct_working_paper"/>
<table name="ct_expertise"/>
<table name="ct_review"/>
<table name="ct_publicationlists"/>
<initializer class="com.arsdigita.cms.contenttypes.PublicationInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.PublicationWithPublisherInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.SeriesInitializer"/>
@ -36,6 +37,7 @@
<initializer class="com.arsdigita.cms.contenttypes.WorkingPaperInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.ExpertiseInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.ReviewInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.PublicationListInitializer"/>
</provides>
<scripts>
<schema directory="ccm-sci-publications"/>
@ -54,5 +56,6 @@
<data class="com.arsdigita.cms.contenttypes.WorkingPaperLoader"/>
<data class="com.arsdigita.cms.contenttypes.ExpertiseLoader"/>
<data class="com.arsdigita.cms.contenttypes.ReviewLoader"/>
<data class="com.arsdigita.cms.contenttypes.PublicationListLoader"/>
</scripts>
</load>

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) 2010 Jens Pelzetter, for the Center of Social Politics of the University of Bremen
* Copyright (c) 2010 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

View File

@ -0,0 +1,93 @@
/*
* Copyright (c) 2010 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 java.math.BigDecimal;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.util.Assert;
/**
* This content type is used to create a simple list of {@link Publication}
* items. This is only a temporally solution. This content type be replaced by
* a more flexible portlet or application soon.
*
* @author Jens Pelzetter
*/
public class PublicationList extends ContentPage {
public static final String DESCRIPTION = "description";
public static final String PUBLICATIONS = "publications";
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.PublicationList";
public PublicationList() {
this(BASE_DATA_OBJECT_TYPE);
}
public PublicationList(BigDecimal id)
throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
public PublicationList(OID oid) throws DataObjectNotFoundException {
super(oid);
}
public PublicationList(DataObject obj) {
super(obj);
}
public PublicationList(String type) {
super(type);
}
public String getDescription() {
return (String) get(DESCRIPTION);
}
public void setDescription(String desc) {
set(DESCRIPTION, desc);
}
public PublicationCollection getPublications() {
return new PublicationCollection((DataCollection) get(PUBLICATIONS));
}
public void addPublication(Publication publication) {
Assert.exists (publication, Publication.class);
add(PUBLICATIONS, publication);
}
public void removePublication(Publication publication) {
Assert.exists (publication, Publication.class);
remove(PUBLICATIONS, publication);
}
public boolean hasPublications() {
return !getPublications().isEmpty();
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2010 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.persistence.DataCollection;
/**
*
* @author Jens Pelzetter
*/
public class PublicationListCollection extends DomainCollection {
public PublicationListCollection(DataCollection dataCollection) {
super(dataCollection);
}
public PublicationList getPublicationList() {
return new PublicationList(m_dataCollection.getDataObject());
}
}

View File

@ -0,0 +1,23 @@
package com.arsdigita.cms.contenttypes;
/**
*
* @author Jens Pelzetter
*/
public class PublicationListInitializer extends ContentTypeInitializer {
public PublicationListInitializer() {
super("empty.pdl.mf", PublicationList.BASE_DATA_OBJECT_TYPE);
}
@Override
public String[] getStylesheets() {
return new String[]{"/static/content-types/com/arsdigita/cms/contenttypes/PublicationList.xsl"};
}
@Override
public String getTraversalXML() {
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/PublicationList.xml";
}
}

View File

@ -0,0 +1,19 @@
package com.arsdigita.cms.contenttypes;
/**
*
* @author Jens Pelzetter
*/
public class PublicationListLoader extends AbstractContentTypeLoader {
private static final String[] TYPES = {"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/PublicationList.xml"};
public PublicationListLoader() {
super();
}
public String[] getTypes() {
return TYPES;
}
}

View File

@ -14,8 +14,7 @@ public class PublicationAuthorsPropertyStep extends SimpleEditStep {
private static final String ADD_AUTHOR_SHEET_NAME = "addAuthor";
public PublicationAuthorsPropertyStep(
ItemSelectionModel itemModel,
public PublicationAuthorsPropertyStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
this(itemModel, parent, null);
}

View File

@ -110,8 +110,7 @@ public class PublicationAuthorsTable
private AuthorshipCollection m_authorshipCollection;
private GenericPerson m_author;
private PublicationAuthorsTableModel(
Table table,
public PublicationAuthorsTableModel(Table table,
PageState state,
Publication publication) {
m_table = table;
@ -205,8 +204,7 @@ public class PublicationAuthorsTable
implements TableCellRenderer {
@Override
public Component getComponent(
Table table,
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,

View File

@ -0,0 +1,122 @@
package com.arsdigita.cms.contenttypes.ui;
import java.text.DateFormat;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.PublicationList;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
/**
*
* @author Jens Pelzetter
*/
public class PublicationListPropertiesStep extends SimpleEditStep {
public static final String EDIT_SHEET_NAME = "edit";
private SegmentedPanel segmentedPanel;
public PublicationListPropertiesStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
super(itemModel, parent);
segmentedPanel = new SegmentedPanel();
setDefaultEditKey(EDIT_SHEET_NAME);
addBasicProperties(itemModel, parent);
addSteps(itemModel, parent);
setDisplayComponent(segmentedPanel);
}
public static Component getPublicationListPropertySheet(
ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet =
new DomainObjectPropertySheet(itemModel);
sheet.add(PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.name"),
PublicationList.NAME);
sheet.add(PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.title"),
PublicationList.TITLE);
if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(ContenttypesGlobalizationUtil.globalize(
"cms.ui.authoring.page_launch_date"),
ContentPage.LAUNCH_DATE,
new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item,
String attribute,
PageState state) {
ContentPage page = (ContentPage) item;
if (page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG).
format(page.getLaunchDate());
} else {
return (String) ContenttypesGlobalizationUtil.globalize(
"cms.ui.unknown").localize();
}
}
});
}
return sheet;
}
protected SegmentedPanel getSegmentedPanel() {
return segmentedPanel;
}
protected void addBasicProperties(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
SimpleEditStep basicProperties = new SimpleEditStep(itemModel,
parent,
EDIT_SHEET_NAME);
BasicPageForm editBasicSheet =
new PublicationListPropertyForm(itemModel,
this);
basicProperties.add(EDIT_SHEET_NAME,
(String) PublicationGlobalizationUtil.globalize(
"publcations.ui.publicationlist_edit_basic_sheet").
localize(), new WorkflowLockedComponentAccess(editBasicSheet,
itemModel),
editBasicSheet.getSaveCancelSection().
getCancelButton());
basicProperties.setDisplayComponent(
getPublicationListPropertySheet(itemModel));
segmentedPanel.addSegment(
new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.basic_properties").
localize()), basicProperties);
}
protected void addSteps(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
addStep(new PublicationListPublicationsStep(itemModel, parent),
"publications.ui.publicationlist.publications");
}
protected void addStep(SimpleEditStep step, String labelKey) {
segmentedPanel.addSegment(
new Label((String) PublicationGlobalizationUtil.globalize(
labelKey).localize()),
step);
}
}

View File

@ -0,0 +1,93 @@
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.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.PublicationList;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
/**
*
* @author Jens Pelzetter
*/
public class PublicationListPropertyForm
extends BasicPageForm
implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
private PublicationListPropertiesStep m_step;
public static final String ID = "PublicationList_edit";
public PublicationListPropertyForm(ItemSelectionModel itemModel) {
this(itemModel, null);
}
public PublicationListPropertyForm(ItemSelectionModel itemModel,
PublicationListPropertiesStep step) {
super(ID, itemModel);
m_step = step;
addSubmissionListener(this);
}
@Override
protected void addWidgets() {
super.addWidgets();
add(new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.title").localize()));
ParameterModel titleParam = new StringParameter(PublicationList.TITLE);
TextField title = new TextField(titleParam);
add(title);
add(new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.description").localize()));
ParameterModel descParam =
new StringParameter(PublicationList.DESCRIPTION);
TextArea desc = new TextArea(descParam);
desc.setCols(60);
desc.setRows(16);
add(desc);
}
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PublicationList list = (PublicationList) super.initBasicWidgets(fse);
data.put(PublicationList.TITLE, list.getTitle());
data.put(PublicationList.DESCRIPTION, list.getDescription());
}
@Override
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PublicationList list = (PublicationList) super.processBasicWidgets(fse);
if ((list != null) && getSaveCancelSection().getSaveButton().
isSelected(fse.getPageState())) {
list.setTitle((String) data.get(PublicationList.TITLE));
list.setDescription((String) data.get(PublicationList.DESCRIPTION));
list.save();
}
}
@Override
public void submitted(FormSectionEvent fse) throws FormProcessException {
if ((m_step != null) && getSaveCancelSection().getCancelButton().
isSelected(fse.getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState());
}
}
}

View File

@ -0,0 +1,69 @@
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.PublicationList;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
/**
*
* @author Jens Pelzetter
*/
public class PublicationListPublicationAddForm
extends BasicItemForm
implements FormProcessListener,
FormInitListener {
private PublicationListPropertiesStep m_step;
private ItemSearchWidget m_itemSearch;
private final String ITEM_SEARCH = "publications";
private ItemSelectionModel m_itemModel;
public PublicationListPublicationAddForm(ItemSelectionModel itemModel) {
super("PublicationsEntryForm", itemModel);
m_itemModel = itemModel;
}
@Override
protected void addWidgets() {
add(new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.selectPublication").
localize()));
m_itemSearch = new ItemSearchWidget(
ITEM_SEARCH,
ContentType.findByAssociatedObjectType(
Publication.class.getName()));
add(m_itemSearch);
}
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
PageState state = fse.getPageState();
setVisible(state, true);
}
@Override
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
PublicationList list = (PublicationList) getItemSelectionModel().
getSelectedObject(state);
if (!(this.getSaveCancelSection().getCancelButton().
isSelected(state))) {
list.addPublication(
(Publication) data.get(ITEM_SEARCH));
}
init(fse);
}
}

View File

@ -0,0 +1,40 @@
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 PublicationListPublicationsStep extends SimpleEditStep {
private static final String ADD_PUBLICATION_SHEET_NAME = "addPublication";
public PublicationListPublicationsStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
this(itemModel, parent, null);
}
public PublicationListPublicationsStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent,
String prefix) {
super(itemModel, parent, prefix);
BasicItemForm addPublicationSheet =
new PublicationListPublicationAddForm(itemModel);
add(ADD_PUBLICATION_SHEET_NAME,
(String) PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.add_publication").localize(),
new WorkflowLockedComponentAccess(addPublicationSheet,
itemModel),
addPublicationSheet.getSaveCancelSection().getCancelButton());
PublicationListPublicationsTable publicationsTable =
new PublicationListPublicationsTable(itemModel);
setDisplayComponent(publicationsTable);
}
}

View File

@ -0,0 +1,234 @@
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.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.ItemSelectionModel;
import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.PublicationCollection;
import com.arsdigita.cms.contenttypes.PublicationList;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
/**
*
* @author Jens Pelzetter
*/
public class PublicationListPublicationsTable
extends Table
implements TableActionListener {
private static final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_DEL = "table_col_del";
private ItemSelectionModel m_itemModel;
public PublicationListPublicationsTable(ItemSelectionModel itemModel) {
super();
m_itemModel = itemModel;
setEmptyView(
new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.no_publications")));
TableColumnModel colModel = getColumnModel();
colModel.add(new TableColumn(
0,
PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.publication.title").
localize(),
TABLE_COL_EDIT));
colModel.add(new TableColumn(
1,
PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.publication.remove").
localize(),
TABLE_COL_DEL));
setModelBuilder(
new PublicationListPublicationsTableModelBuilder(itemModel));
colModel.get(0).setCellRenderer(new EditCellRenderer());
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
private class PublicationListPublicationsTableModelBuilder
extends LockableImpl
implements TableModelBuilder {
private ItemSelectionModel m_itemModel;
public PublicationListPublicationsTableModelBuilder(
ItemSelectionModel itemModel) {
m_itemModel = itemModel;
}
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
PublicationList list = (PublicationList) m_itemModel.
getSelectedObject(state);
return new PublicationListPublicationsTableModel(table,
state,
list);
}
}
private class PublicationListPublicationsTableModel implements TableModel {
private Table m_table;
private PublicationCollection m_publicationCollection;
private Publication m_publication;
public PublicationListPublicationsTableModel(Table table,
PageState state,
PublicationList list) {
m_table = table;
m_publicationCollection = list.getPublications();
}
@Override
public int getColumnCount() {
return m_table.getColumnModel().size();
}
@Override
public boolean nextRow() {
boolean ret;
if ((m_publicationCollection != null)
&& m_publicationCollection.next()) {
m_publication = m_publicationCollection.getPublication();
ret = true;
} else {
ret = false;
}
return ret;
}
@Override
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case 0:
return m_publication.getTitle();
case 1:
return PublicationGlobalizationUtil.globalize(
"publications.ui.publicationlist.publication.remove").
localize();
default:
return null;
}
}
public Object getKeyAt(int columnIndex) {
return m_publication.getID();
}
}
private class EditCellRenderer
extends LockableImpl
implements TableCellRenderer {
@Override
public Component getComponent(
Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int col) {
SecurityManager securityManager =
Utilities.getSecurityManager(state);
PublicationList list = (PublicationList) m_itemModel.
getSelectedObject(state);
boolean canEdit = securityManager.canAccess(
state.getRequest(),
SecurityManager.EDIT_ITEM,
list);
if (canEdit) {
ControlLink link = new ControlLink(value.toString());
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
private class DeleteCellRenderer
extends LockableImpl
implements TableCellRenderer {
@Override
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int col) {
SecurityManager securityManager =
Utilities.getSecurityManager(state);
PublicationList list = (PublicationList) m_itemModel.
getSelectedObject(state);
boolean canDelete = securityManager.canAccess(
state.getRequest(),
SecurityManager.DELETE_ITEM,
list);
if (canDelete) {
ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) PublicationGlobalizationUtil.
globalize(
"publications.ui.publicationlist.publication.confirm_remove").
localize());
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
@Override
public void cellSelected(TableActionEvent event) {
PageState state = event.getPageState();
Publication publication = new Publication(
new BigDecimal(event.getRowKey().toString()));
PublicationList list = (PublicationList) m_itemModel.getSelectedObject(
state);
PublicationCollection publications = list.getPublications();
TableColumn column = getColumnModel().get(event.getColumn().intValue());
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
list.removePublication(publication);
}
}
@Override
public void headSelected(TableActionEvent event) {
//Nothing to do
}
}

View File

@ -45,8 +45,11 @@ public class PublicationPropertiesStep extends SimpleEditStep {
itemModel);
sheet.add(PublicationGlobalizationUtil.globalize(
"publications.ui.publication.title"),
"publications.ui.publication.name"),
Publication.NAME);
sheet.add(PublicationGlobalizationUtil.globalize(
"publications.ui.publication.title"),
Publication.TITLE);
sheet.add(PublicationGlobalizationUtil.globalize(
"publications.ui.publication.year_of_publication"),
Publication.YEAR_OF_PUBLICATION);

View File

@ -49,7 +49,7 @@ public class PublicationPropertyForm
add(new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.publication.title").localize()));
ParameterModel titleParam = new StringParameter(Publication.NAME);
ParameterModel titleParam = new StringParameter(Publication.TITLE);
TextField title = new TextField(titleParam);
add(title);
@ -83,7 +83,7 @@ public class PublicationPropertyForm
FormData data = fse.getFormData();
Publication publication = (Publication) super.initBasicWidgets(fse);
data.put(Publication.NAME, publication.getTitle());
data.put(Publication.TITLE, publication.getTitle());
data.put(Publication.YEAR_OF_PUBLICATION, publication.
getYearOfPublication());
data.put(Publication.ABSTRACT, publication.getAbstract());
@ -97,7 +97,7 @@ public class PublicationPropertyForm
if ((publication != null) && getSaveCancelSection().getSaveButton().
isSelected(fse.getPageState())) {
publication.setTitle((String) data.get(Publication.NAME));
publication.setTitle((String) data.get(Publication.TITLE));
publication.setYearOfPublication((Integer) data.get(
Publication.YEAR_OF_PUBLICATION));
publication.setAbstract((String) data.get(Publication.ABSTRACT));

View File

@ -0,0 +1,19 @@
<!DOCTYPE stylesheet [
<!ENTITY nbsp "&#160;" ><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cms="http://www.arsdigita.com/cms/1.0"
version="1.0">
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.PublicationList']" mode="cms:CT_graphics"
name="cms:CT_graphics_com_arsdigita_cms_contenttypes_PublicationList">
<p><xsl:value-of select="./name"/></p>
</xsl:template>
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.PublicationList']" mode="cms:CT_text"
name="cms:CT_text_com_arsdigita_cms_contenttypes_PublicationList">
<p><xsl:value-of select="./name"/></p>
</xsl:template>
</xsl:stylesheet>