Added an input field for the volume of series to the PublicationSeriesForm (Ticket #1558).
git-svn-id: https://svn.libreccm.org/ccm/trunk@2081 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
d9ee3f77a8
commit
c5b9f93351
|
|
@ -260,11 +260,11 @@ public class Publication extends ContentPage {
|
|||
return getPublicationBundle().getSeries();
|
||||
}
|
||||
|
||||
public void addSeries(final Series series) {
|
||||
public void addSeries(final Series series, final Integer volumeOfSeries) {
|
||||
//Assert.exists(series, Series.class);
|
||||
|
||||
//add(SERIES, series);
|
||||
getPublicationBundle().addSeries(series);
|
||||
getPublicationBundle().addSeries(series, volumeOfSeries);
|
||||
}
|
||||
|
||||
public void removeSeries(final Series series) {
|
||||
|
|
|
|||
|
|
@ -333,10 +333,11 @@ public class PublicationBundle extends ContentBundle {
|
|||
return new SeriesCollection((DataCollection) get(SERIES));
|
||||
}
|
||||
|
||||
public void addSeries(final Series series) {
|
||||
public void addSeries(final Series series, final Integer volumeOfSeries) {
|
||||
Assert.exists(series, Series.class);
|
||||
|
||||
add(SERIES, series.getSeriesBundle());
|
||||
final DataObject link = add(SERIES, series.getSeriesBundle());
|
||||
link.set(SeriesBundle.VOLUME_OF_SERIES, volumeOfSeries);
|
||||
}
|
||||
|
||||
public void removeSeries(final Series series) {
|
||||
|
|
|
|||
|
|
@ -23,17 +23,32 @@ import com.arsdigita.cms.ContentBundle;
|
|||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SeriesCollection extends DomainCollection {
|
||||
|
||||
public static final String LINK_VOLUME_OF_SERIES = "link.volumeOfSeries";
|
||||
public static final String VOLUME_OF_SERIES = "volumeOfSeries";
|
||||
|
||||
public SeriesCollection(DataCollection dataCollection) {
|
||||
super(dataCollection);
|
||||
}
|
||||
|
||||
public Integer getVolumeOfSeries() {
|
||||
return (Integer) m_dataCollection.get(LINK_VOLUME_OF_SERIES);
|
||||
}
|
||||
|
||||
public void setVolumeOfSeries(Integer volumeOfSeries) {
|
||||
DataObject link = (DataObject) this.get("link");
|
||||
|
||||
link.set(VOLUME_OF_SERIES, volumeOfSeries);
|
||||
}
|
||||
|
||||
public Series getSeries() {
|
||||
final ContentBundle bundle = (ContentBundle) DomainObjectFactory.
|
||||
newInstance(m_dataCollection.getDataObject());
|
||||
|
|
@ -47,4 +62,5 @@ public class SeriesCollection extends DomainCollection {
|
|||
|
||||
return (Series) bundle.getInstance(language);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,3 +414,4 @@ organization.ui.publications.columns.type=Type
|
|||
publications.ui.journal.symbol=Symbol of the journal
|
||||
publications.ui.publication.first_published=First published
|
||||
publications.ui.publication.language=Language of publication
|
||||
publications.ui.series.number=Volume of series
|
||||
|
|
|
|||
|
|
@ -413,3 +413,4 @@ organization.ui.publications.columns.type=Typ
|
|||
publications.ui.journal.symbol=K\u00fcrzel der Zeitschrift
|
||||
publications.ui.publication.first_published=Erste Ver\u00f6ffentlichung
|
||||
publications.ui.publication.language=Sprache der Publikation
|
||||
publications.ui.series.number=Band der Reihe
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ 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.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
|
|
@ -33,6 +36,7 @@ import com.arsdigita.cms.contenttypes.Publication;
|
|||
import com.arsdigita.cms.contenttypes.PublicationsConfig;
|
||||
import com.arsdigita.cms.contenttypes.Series;
|
||||
import com.arsdigita.cms.contenttypes.SeriesCollection;
|
||||
import com.arsdigita.cms.contenttypes.VolumeInSeriesCollection;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
|
|
@ -55,13 +59,13 @@ public class PublicationSeriesAddForm
|
|||
private ItemSearchWidget m_itemSearch;
|
||||
private final String ITEM_SEARCH = "series";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
private final static PublicationsConfig config = new PublicationsConfig();
|
||||
private TextField volumeOfSeries;
|
||||
private final static PublicationsConfig config = new PublicationsConfig();
|
||||
|
||||
static {
|
||||
config.load();
|
||||
}
|
||||
|
||||
|
||||
public PublicationSeriesAddForm(ItemSelectionModel itemModel) {
|
||||
super("SeriesEntryForm", itemModel);
|
||||
m_itemModel = itemModel;
|
||||
|
|
@ -78,6 +82,13 @@ public class PublicationSeriesAddForm
|
|||
m_itemSearch.setDefaultCreationFolder(new Folder(new BigDecimal(config.getDefaultSeriesFolder())));
|
||||
}
|
||||
add(m_itemSearch);
|
||||
|
||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.series.volume_of_series").localize()));
|
||||
ParameterModel volumeOfSeriesParam = new IntegerParameter(
|
||||
VolumeInSeriesCollection.VOLUME_OF_SERIES);
|
||||
volumeOfSeries = new TextField(volumeOfSeriesParam);
|
||||
add(volumeOfSeries);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -101,7 +112,7 @@ public class PublicationSeriesAddForm
|
|||
series = (Series) series.getContentBundle().getInstance(publication.
|
||||
getLanguage());
|
||||
|
||||
publication.addSeries(series);
|
||||
publication.addSeries(series, (Integer) data.get(VolumeInSeriesCollection.VOLUME_OF_SERIES));
|
||||
m_itemSearch.publishCreatedItem(data, series);
|
||||
}
|
||||
|
||||
|
|
@ -142,4 +153,5 @@ public class PublicationSeriesAddForm
|
|||
|
||||
seriesColl.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import com.arsdigita.cms.dispatcher.Utilities;
|
|||
import com.arsdigita.dispatcher.ObjectNotFoundException;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Iterator;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -54,38 +55,40 @@ public class PublicationSeriesTable
|
|||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(PublicationSeriesTable.class);
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
private static final Logger LOGGER = Logger.getLogger(PublicationSeriesTable.class);
|
||||
private final static String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final static String TABLE_COL_NUMBER = "table_col_edit";
|
||||
private final static String TABLE_COL_DEL = "table_col_del";
|
||||
private final ItemSelectionModel m_itemModel;
|
||||
|
||||
public PublicationSeriesTable(ItemSelectionModel itemModel) {
|
||||
public PublicationSeriesTable(final ItemSelectionModel itemModel) {
|
||||
super();
|
||||
m_itemModel = itemModel;
|
||||
|
||||
setEmptyView(new Label(PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.series.none")));
|
||||
setEmptyView(new Label(PublicationGlobalizationUtil.globalize("publications.ui.series.none")));
|
||||
|
||||
TableColumnModel colModel = getColumnModel();
|
||||
final TableColumnModel colModel = getColumnModel();
|
||||
colModel.add(new TableColumn(
|
||||
0,
|
||||
PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.series.title").localize(),
|
||||
PublicationGlobalizationUtil.globalize("publications.ui.series.title").localize(),
|
||||
TABLE_COL_EDIT));
|
||||
colModel.add(new TableColumn(
|
||||
1,
|
||||
PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.series.remove").localize(),
|
||||
PublicationGlobalizationUtil.globalize("publications.ui.series.number").localize(),
|
||||
TABLE_COL_NUMBER));
|
||||
colModel.add(new TableColumn(
|
||||
2,
|
||||
PublicationGlobalizationUtil.globalize("publications.ui.series.remove").localize(),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(
|
||||
new PublicationSeriesTableModelBuilder(itemModel));
|
||||
|
||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
colModel.get(1).setCellRenderer(new NumberCellRenderer());
|
||||
colModel.get(2).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
s_log.info("Adding table action listener...");
|
||||
LOGGER.info("Adding table action listener...");
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +96,7 @@ public class PublicationSeriesTable
|
|||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
private final ItemSelectionModel m_itemModel;
|
||||
|
||||
public PublicationSeriesTableModelBuilder(
|
||||
ItemSelectionModel itemModel) {
|
||||
|
|
@ -107,6 +110,7 @@ public class PublicationSeriesTable
|
|||
getSelectedObject(state);
|
||||
return new PublicationSeriesTableModel(table, state, publication);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class PublicationSeriesTableModel implements TableModel {
|
||||
|
|
@ -148,6 +152,8 @@ public class PublicationSeriesTable
|
|||
case 0:
|
||||
return m_series.getTitle();
|
||||
case 1:
|
||||
return m_series.getTitle();
|
||||
case 2:
|
||||
return PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.series.remove").localize();
|
||||
default:
|
||||
|
|
@ -159,6 +165,7 @@ public class PublicationSeriesTable
|
|||
public Object getKeyAt(int columnIndex) {
|
||||
return m_series.getID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditCellRenderer
|
||||
|
|
@ -188,9 +195,9 @@ public class PublicationSeriesTable
|
|||
try {
|
||||
series = new Series((BigDecimal) key);
|
||||
} catch (ObjectNotFoundException ex) {
|
||||
s_log.warn(String.format("No object with key '%s' found.",
|
||||
key),
|
||||
ex);
|
||||
LOGGER.warn(String.format("No object with key '%s' found.",
|
||||
key),
|
||||
ex);
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
|
|
@ -211,19 +218,52 @@ public class PublicationSeriesTable
|
|||
try {
|
||||
series = new Series((BigDecimal) key);
|
||||
} catch (ObjectNotFoundException ex) {
|
||||
s_log.warn(String.format("No object with key '%s' found.",
|
||||
key),
|
||||
ex);
|
||||
LOGGER.warn(String.format("No object with key '%s' found.",
|
||||
key),
|
||||
ex);
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
Label label = new Label(String.format("%s (%s)",
|
||||
|
||||
Label label = new Label(String.format("%s (%s)",
|
||||
value.toString(),
|
||||
series.getLanguage()));
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NumberCellRenderer 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) {
|
||||
final Publication publication = (Publication) m_itemModel.getSelectedObject(state);
|
||||
|
||||
final BigDecimal seriesId = (BigDecimal) key;
|
||||
|
||||
final SeriesCollection seriesCol = publication.getSeries();
|
||||
|
||||
Integer volumeOfSeries = null;
|
||||
while(seriesCol.next()) {
|
||||
if (seriesId.equals(seriesCol.getSeries().getID())) {
|
||||
volumeOfSeries = seriesCol.getVolumeOfSeries();
|
||||
break;
|
||||
}
|
||||
}
|
||||
seriesCol.close();
|
||||
|
||||
if (volumeOfSeries == null) {
|
||||
return new Label("");
|
||||
} else {
|
||||
return new Label(volumeOfSeries.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer
|
||||
extends LockableImpl
|
||||
|
|
@ -259,13 +299,14 @@ public class PublicationSeriesTable
|
|||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
s_log.info("cellSelected!");
|
||||
LOGGER.info("cellSelected!");
|
||||
|
||||
Series series =
|
||||
new Series(new BigDecimal(event.getRowKey().
|
||||
|
|
@ -288,4 +329,5 @@ public class PublicationSeriesTable
|
|||
public void headSelected(TableActionEvent event) {
|
||||
//Nothing to do here.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue