From 4e670ab7a800f1fac6e9f8e35fd8ed6cdbbfab69 Mon Sep 17 00:00:00 2001 From: jensp Date: Fri, 7 Oct 2011 09:57:55 +0000 Subject: [PATCH] =?UTF-8?q?Korrektur=20f=C3=BCr=20Fehler=20beim=20Bearbeit?= =?UTF-8?q?en=20der=20Publikation->Autor=20Verkn=C3=BCpfung=20(Ticket=2066?= =?UTF-8?q?3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@1147 8810af33-2d31-482b-a856-94f89814c4df --- .../ui/PublicationAuthorAddForm.java | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java index 33dc7ba9a..f1b0c680c 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java @@ -131,8 +131,7 @@ public class PublicationAuthorAddForm Publication publication = (Publication) getItemSelectionModel(). getSelectedObject(state); - if (!(this.getSaveCancelSection().getCancelButton(). - isSelected(state))) { + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { GenericPerson author; author = ((PublicationAuthorsPropertyStep) editStep). getSelectedAuthor(); @@ -194,32 +193,43 @@ public class PublicationAuthorAddForm public void validate(FormSectionEvent fse) throws FormProcessException { final PageState state = fse.getPageState(); final FormData data = fse.getFormData(); + boolean editing = false; //Are we editing the association if ((((PublicationAuthorsPropertyStep) editStep).getSelectedAuthor() == null) && (data.get(ITEM_SEARCH) == null)) { data.addError(PublicationGlobalizationUtil.globalize( - "publications.ui.authors.selectAuthor.no_author_selected")); + "publications.ui.authors.selectAuthor.no_author_selected")); return; } - - Publication publication = (Publication) getItemSelectionModel(). - getSelectedObject(state); - GenericPerson author = (GenericPerson) data.get(ITEM_SEARCH); - if (!(author.getContentBundle().hasInstance(publication.getLanguage()))) { - data.addError(PublicationGlobalizationUtil.globalize( - "publications.ui.authors.selectAuthor.no_suitable_language_variant")); + + Publication publication = (Publication) getItemSelectionModel(). + getSelectedObject(state); + GenericPerson author = (GenericPerson) data.get(ITEM_SEARCH); + if (author == null) { + author = ((PublicationAuthorsPropertyStep) editStep). + getSelectedAuthor(); + editing = true; + } + if (!(author.getContentBundle().hasInstance(publication.getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.authors.selectAuthor.no_suitable_language_variant")); return; - } - - author = (GenericPerson) author.getContentBundle().getInstance(publication.getLanguage()); - AuthorshipCollection authors = publication.getAuthors(); - authors.addFilter(String.format("id = %s", author.getID().toString())); - if (authors.size() > 0) { - data.addError(PublicationGlobalizationUtil.globalize( - "publications.ui.authors.selectAuthor.already_added")); - } - - authors.close(); + } + + if (!editing) { + author = (GenericPerson) author.getContentBundle().getInstance(publication. + getLanguage()); + AuthorshipCollection authors = publication.getAuthors(); + authors.addFilter( + String.format("id = %s", author.getID().toString())); + if (authors.size() > 0) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.authors.selectAuthor.already_added")); + } + + authors.close(); + } } }