Erster Teil einer Lösung für Ticket #1838 (ItemCreatePane und nicht vorhandener Standard-Order).

git-svn-id: https://svn.libreccm.org/ccm/trunk@2458 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-11-25 12:24:18 +00:00
parent 8a3bb4c295
commit 5070517f5a
6 changed files with 140 additions and 45 deletions

View File

@ -815,10 +815,11 @@ public class Folder extends ContentItem {
}
/**
* Retrieves a folder of the current content section by its path. The path is given in a UNIX like synatax and must
* be an absolute path starting with '/'. The path may be precceded with the name of content section, separated by
* ':'. If a content section if given, the path is relative to this content section. If the no content section is
* given, the current content section returned by {@code CMS.getContext().getContentSection()}. Please note that
* Retrieves a folder of the current content section by its path. The path is given in a UNIX
* like syntax and must be an absolute path starting with '/'. The path may be preceeded with
* the name of content section, separated by * ':'. If a content section if given, the path is
* relative to this content section. If the no content section is given, the current content
* section returned by {@code CMS.getContext().getContentSection()}. Please note that
* {@code CMS.getContext().getContentSection()} may return null.
*
* Examples for valid paths:
@ -830,8 +831,9 @@ public class Folder extends ContentItem {
* </pre>
*
* @param path The path of the folder to retrieve relative to the current content section.
* @return The folder with the given path from the content section. If there is no such folder, {@code null} is
* returned. It is up to the caller to check the returned value for {@code null} and take appropriate actions.
* @return The folder with the given path from the content section. If there is no such folder,
* {@code null} is returned. It is up to the caller to check the returned value for {@code null}
* and take appropriate actions.
*/
public static Folder retrieveFolder(final String path) {
final String[] tokens = path.split(":");

View File

@ -18,19 +18,25 @@
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.Folder;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.BooleanParameter;
import com.arsdigita.util.parameter.IntegerParameter;
import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.StringParameter;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter
* @author Jens Pelzetter
* @version $Id$
*/
public class PublicationsConfig extends AbstractConfig {
private static final Logger LOGGER = Logger.getLogger(PublicationsConfig.class);
private final Parameter attachOrgaUnitsStep;
private final Parameter orgaUnitsStepSortKey;
private final Parameter attachOrganizationPublicationsStepTo;
@ -41,7 +47,8 @@ public class PublicationsConfig extends AbstractConfig {
private final Parameter publicationsStepSortKey;
private final Parameter attachPublisherPublicationsStep;
private final Parameter publisherPublicationsStepSortKey;
private final Parameter defaultAuthorsFolder;
private final Parameter defaultAuthorsFolderID;
private final Parameter defaultAuthorsFolderPath;
private final Parameter defaultSeriesFolder;
private final Parameter defaultPublisherFolder;
private final Parameter defaultCollectedVolumesFolder;
@ -111,15 +118,20 @@ public class PublicationsConfig extends AbstractConfig {
"com.arsdigita.cms.contenttypes.publications.attach_publisher_publications_step",
Parameter.REQUIRED,
Boolean.TRUE);
publisherPublicationsStepSortKey =
new IntegerParameter(
"com.arsdigita.cms.contenttypes.publications.publisher_publications_step_sort_key",
Parameter.REQUIRED,
10);
defaultAuthorsFolder = new IntegerParameter(
"com.arsdigita.cms.contenttypes.publications.default_authors_folder",
defaultAuthorsFolderID = new IntegerParameter(
"com.arsdigita.cms.contenttypes.publications.default_authors_folder_id",
Parameter.OPTIONAL,
null);
defaultAuthorsFolderPath = new StringParameter(
"com.arsdigita.cms.contenttypes.publications.default_authors_folder_path",
Parameter.OPTIONAL,
null);
@ -201,8 +213,9 @@ public class PublicationsConfig extends AbstractConfig {
register(attachPublicationsStepTo);
register(publicationsStepSortKey);
register(attachPublisherPublicationsStep);
register(publisherPublicationsStepSortKey);
register(defaultAuthorsFolder);
register(publisherPublicationsStepSortKey);
register(defaultAuthorsFolderID);
register(defaultAuthorsFolderPath);
register(defaultSeriesFolder);
register(defaultPublisherFolder);
register(defaultCollectedVolumesFolder);
@ -224,7 +237,7 @@ public class PublicationsConfig extends AbstractConfig {
public Boolean getAttachOrgaUnitsStep() {
return (Boolean) get(attachOrgaUnitsStep);
}
public Integer getOrgaUnitsStepSortKey() {
return (Integer) get(orgaUnitsStepSortKey);
}
@ -232,7 +245,7 @@ public class PublicationsConfig extends AbstractConfig {
public String getAttachOrganizationPublicationsStepTo() {
return (String) get(attachOrganizationPublicationsStepTo);
}
public Integer getOrganizationPublicationsStepSortKey() {
return (Integer) get(organizationPublicationsStepSortKey);
}
@ -240,7 +253,7 @@ public class PublicationsConfig extends AbstractConfig {
public Boolean getAttachPersonPublicationsStep() {
return (Boolean) get(attachPersonPublicationsStep);
}
public Integer getPersonPublicationsStepSortKey() {
return (Integer) get(personPublicationsStepSortKey);
}
@ -252,23 +265,82 @@ public class PublicationsConfig extends AbstractConfig {
public Integer getPublicationsStepSortKey() {
return (Integer) get(publicationsStepSortKey);
}
public Boolean getPublisherPublicationsStep() {
return (Boolean) get(attachPublisherPublicationsStep);
}
public Integer getPublisherPublicationsStepSortKey() {
return (Integer) get(publisherPublicationsStepSortKey);
}
public Integer getDefaultAuthorsFolder() {
if (get(defaultAuthorsFolder) == null) {
/**
*
* @return
* @deprecated Use {@link #getDefaultAuthorsFolderPath()} or {@link #getDefaultAuthorsFolder()}
* instead.
*/
@Deprecated
public Integer getDefaultAuthorsFolderID() {
if (get(defaultAuthorsFolderID) == null) {
return null;
} else {
return (Integer) get(defaultAuthorsFolder);
return (Integer) get(defaultAuthorsFolderID);
}
}
public String getDefaultAuthorsFolderPath() {
if (get(defaultAuthorsFolderPath) == null) {
return null;
} else {
return (String) get(defaultAuthorsFolderPath);
}
}
/**
* Retrieves the default folder for storing authors created using the
* {@link ItemSearchCreateItemPane}.
*
* If both {@link #getDefaultAuthorsFolderPath()} and {@link #getDefaultAuthorsFolderID()}
* are not set, the method will return {@code null}. If {@link #getDefaultAuthorsFolderPath()}
* is set the path returned by that method is used to retrieve the folder. If there is no folder
* with this path, the method will return the root folder of the default content section.
*
* If the default authors folder path property is not set, the
* {@link #getDefaultAuthorsFolderID()} is used as a fallback. If there is no folder with the
* provided id, the root folder of the default content section is returned. Please note
* that {@link #getDefaultAuthorsFolderID()} is marked as deprecated and will be removed in
* one of the next releases. Instead the path property should be used.
*
* @return {@code null} if {@link #getDefaultAuthorsFolderPath()} and
* {@link #getDefaultAuthorsFolderID()} both are not set, otherwise a {@link Folder} object.
*/
public Folder getDefaultAuthorsFolder() {
if (getDefaultAuthorsFolderPath() != null) {
final Folder folder = Folder.retrieveFolder(getDefaultAuthorsFolderPath());
if (folder == null) {
LOGGER.warn(String.format("There is no folder with the path '%s'.",
getDefaultAuthorsFolderPath()));
return ContentSection.getDefaultSection().getRootFolder();
} else {
return folder;
}
}
if (getDefaultAuthorsFolderID() != null) {
try {
return new Folder(new BigDecimal(getDefaultAuthorsFolderID()));
} catch (DataObjectNotFoundException ex) {
LOGGER.warn(String.format("Failed to retrieve folder with id %s.",
getDefaultAuthorsFolderID().toString()),
ex);
return ContentSection.getDefaultSection().getRootFolder();
}
}
return null;
}
public Integer getDefaultSeriesFolder() {
if (get(defaultSeriesFolder) == null) {
return null;
@ -364,5 +436,4 @@ public class PublicationsConfig extends AbstractConfig {
public Boolean getEnableLanguageProperty() {
return (Boolean) get(enableLanguageProperty);
}
}

View File

@ -48,10 +48,15 @@ com.arsdigita.cms.contenttypes.publications.publisher_publications_step_sort_key
com.arsdigita.cms.contenttypes.publications.publisher_publications_step_sort_key.example = 10
com.arsdigita.cms.contenttypes.publications.publisher_publications_step_sort_key = [Integer]
com.arsdigita.cms.contenttypes.publications.default_authors_folder.title = ID of the default folder for items created using the create pane of the ItemSearchWidget
com.arsdigita.cms.contenttypes.publications.default_authors_folder.purpose = Default folder for items created using the create pane of the ItemSearchWidget
com.arsdigita.cms.contenttypes.publications.default_authors_folder.example = 10002
com.arsdigita.cms.contenttypes.publications.default_authors_folder.format = [Integer]
com.arsdigita.cms.contenttypes.publications.default_authors_folder_id.title = ID of the default folder for items created using the create pane of the ItemSearchWidget
com.arsdigita.cms.contenttypes.publications.default_authors_folder_id.purpose = Default folder for items created using the create pane of the ItemSearchWidget
com.arsdigita.cms.contenttypes.publications.default_authors_folder_id.example = 10002
com.arsdigita.cms.contenttypes.publications.default_authors_folder_id.format = [Integer]
com.arsdigita.cms.contenttypes.publications.default_authors_folder_path.title = Default authors folder
com.arsdigita.cms.contenttypes.publications.default_authors_folder_path.purpose = Path of the default folder for person items created using the create pane of the ItemSearchWidget when assigning authors or editors. The path *must* include the content section.
com.arsdigita.cms.contenttypes.publications.default_authors_folder_path.example = main:/path/to/authors/folder
com.arsdigita.cms.contenttypes.publications.default_authors_folder_path.format = [String]
com.arsdigita.cms.contenttypes.publications.default_series_folder.title = ID of the default folder for items created using the create pane of the ItemSearchWidget
com.arsdigita.cms.contenttypes.publications.default_series_folder.purpose = Default folder for items created using the create pane of the ItemSearchWidget

View File

@ -29,7 +29,6 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.CheckboxGroup;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.Folder;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
@ -38,7 +37,6 @@ import com.arsdigita.cms.contenttypes.PublicationsConfig;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
/**
@ -51,7 +49,7 @@ public class PublicationAuthorAddForm
FormInitListener,
FormSubmissionListener {
private static final Logger s_log = Logger.getLogger(
private static final Logger LOGGER = Logger.getLogger(
PublicationAuthorAddForm.class);
private PublicationPropertiesStep m_step;
private ItemSearchWidget m_itemSearch;
@ -77,14 +75,24 @@ public class PublicationAuthorAddForm
@Override
protected void addWidgets() {
add(new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.authors.selectAuthor").localize()));
add(new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.authors.selectAuthor")));
m_itemSearch = new ItemSearchWidget(
ITEM_SEARCH,
ContentType.findByAssociatedObjectType(GenericPerson.class.getName()));
if ((config.getDefaultAuthorsFolder() != null) && (config.getDefaultAuthorsFolder() != 0)) {
m_itemSearch.setDefaultCreationFolder(new Folder(new BigDecimal(config.getDefaultAuthorsFolder())));
}
// if ((config.getDefaultAuthorsFolderID() != null)
// && (config.getDefaultAuthorsFolderID() != 0)) {
// try {
// m_itemSearch.setDefaultCreationFolder(new Folder(new BigDecimal(config.getDefaultAuthorsFolderID())));
// } catch (DataObjectNotFoundException ex) {
// s_log.warn(String.format("Failed to retrieve folder with id %s.",
// config.getDefaultAuthorsFolderID().toString()),
// ex);
// final ContentSection section = ContentSection.getDefaultSection();
// m_itemSearch.setDefaultCreationFolder(section.getRootFolder());
// }
// }
m_itemSearch.setDefaultCreationFolder(config.getDefaultAuthorsFolder());
m_itemSearch.setEditAfterCreate(false);
add(m_itemSearch);
@ -110,12 +118,12 @@ public class PublicationAuthorAddForm
editor = ((PublicationAuthorsPropertyStep) editStep).isSelectedAuthorEditor();
if (author == null) {
s_log.warn("No author selected.");
LOGGER.warn("No author selected.");
m_itemSearch.setVisible(state, true);
selectedAuthorLabel.setVisible(state, false);
} else {
s_log.warn(String.format("Author is here: %s", author.getFullName()));
LOGGER.warn(String.format("Author is here: %s", author.getFullName()));
data.put(ITEM_SEARCH, author);
//data.put(AuthorshipCollection.EDITOR, editor);
@ -256,5 +264,4 @@ public class PublicationAuthorAddForm
authors.close();
}
}
}

View File

@ -29,6 +29,7 @@ import com.arsdigita.bebop.form.Hidden;
import com.arsdigita.bebop.parameters.BooleanParameter;
import com.arsdigita.bebop.parameters.IncompleteDateParameter;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.Folder;
import com.arsdigita.cms.ItemSelectionModel;
@ -38,6 +39,7 @@ import com.arsdigita.cms.contenttypes.PublicationsConfig;
import com.arsdigita.cms.contenttypes.Series;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.domain.DataObjectNotFoundException;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
@ -53,7 +55,7 @@ public class SeriesEditshipAddForm
extends BasicItemForm
implements FormSubmissionListener {
private static final Logger s_log =
private static final Logger LOGGER =
Logger.getLogger(SeriesEditshipAddForm.class);
private SeriesPropertiesStep m_step;
private ItemSearchWidget m_itemSearch;
@ -78,14 +80,22 @@ public class SeriesEditshipAddForm
@Override
protected void addWidgets() {
add(new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.selectEditors").localize()));
add(new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.selectEditors")));
m_itemSearch = new ItemSearchWidget(
ITEM_SEARCH,
ContentType.findByAssociatedObjectType(GenericPerson.class.
getName()));
if ((config.getDefaultAuthorsFolder() != null) && (config.getDefaultAuthorsFolder() != 0)) {
m_itemSearch.setDefaultCreationFolder(new Folder(new BigDecimal(config.getDefaultAuthorsFolder())));
if ((config.getDefaultAuthorsFolderID() != null) && (config.getDefaultAuthorsFolderID() != 0)) {
try {
m_itemSearch.setDefaultCreationFolder(new Folder(new BigDecimal(config.getDefaultAuthorsFolderID())));
} catch (DataObjectNotFoundException ex) {
LOGGER.warn(String.format("Failed to retrieve folder with id %s.",
config.getDefaultAuthorsFolderID().toString()),
ex);
final ContentSection section = ContentSection.getDefaultSection();
m_itemSearch.setDefaultCreationFolder(section.getRootFolder());
}
}
m_itemSearch.setEditAfterCreate(false);
add(m_itemSearch);
@ -172,7 +182,7 @@ public class SeriesEditshipAddForm
final FormData data = fse.getFormData();
final PageState state = fse.getPageState();
final Series series =
(Series) getItemSelectionModel().getSelectedObject(state);
(Series) getItemSelectionModel().getSelectedObject(state);
if (this.getSaveCancelSection().
getSaveButton().isSelected(state)) {
@ -181,7 +191,7 @@ public class SeriesEditshipAddForm
if (editor == null) {
final GenericPerson editorToAdd =
(GenericPerson) data.get(ITEM_SEARCH);
(GenericPerson) data.get(ITEM_SEARCH);
editorToAdd.getContentBundle().getInstance(series.getLanguage());
series.addEditor(editorToAdd,

View File

@ -87,7 +87,7 @@ public class ImporterUtil {
if (collection.isEmpty()) {
if (!pretend) {
final Integer folderId = Publication.getConfig().getDefaultAuthorsFolder();
final Integer folderId = Publication.getConfig().getDefaultAuthorsFolderID();
final Folder folder = new Folder(new BigDecimal(folderId));
if (folder == null) {
throw new IllegalArgumentException("Error getting folders for authors.");