Korrektur für Fehler beim Bearbeiten der Publikation->Autor Verknüpfung (Ticket 663)

git-svn-id: https://svn.libreccm.org/ccm/trunk@1147 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-10-07 09:57:55 +00:00
parent 646bff0b0d
commit 4e670ab7a8
1 changed files with 31 additions and 21 deletions

View File

@ -131,8 +131,7 @@ public class PublicationAuthorAddForm
Publication publication = (Publication) getItemSelectionModel(). Publication publication = (Publication) getItemSelectionModel().
getSelectedObject(state); getSelectedObject(state);
if (!(this.getSaveCancelSection().getCancelButton(). if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
isSelected(state))) {
GenericPerson author; GenericPerson author;
author = ((PublicationAuthorsPropertyStep) editStep). author = ((PublicationAuthorsPropertyStep) editStep).
getSelectedAuthor(); getSelectedAuthor();
@ -194,32 +193,43 @@ public class PublicationAuthorAddForm
public void validate(FormSectionEvent fse) throws FormProcessException { public void validate(FormSectionEvent fse) throws FormProcessException {
final PageState state = fse.getPageState(); final PageState state = fse.getPageState();
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
boolean editing = false; //Are we editing the association
if ((((PublicationAuthorsPropertyStep) editStep).getSelectedAuthor() if ((((PublicationAuthorsPropertyStep) editStep).getSelectedAuthor()
== null) == null)
&& (data.get(ITEM_SEARCH) == null)) { && (data.get(ITEM_SEARCH) == null)) {
data.addError(PublicationGlobalizationUtil.globalize( data.addError(PublicationGlobalizationUtil.globalize(
"publications.ui.authors.selectAuthor.no_author_selected")); "publications.ui.authors.selectAuthor.no_author_selected"));
return; return;
} }
Publication publication = (Publication) getItemSelectionModel(). Publication publication = (Publication) getItemSelectionModel().
getSelectedObject(state); getSelectedObject(state);
GenericPerson author = (GenericPerson) data.get(ITEM_SEARCH); GenericPerson author = (GenericPerson) data.get(ITEM_SEARCH);
if (!(author.getContentBundle().hasInstance(publication.getLanguage()))) { if (author == null) {
data.addError(PublicationGlobalizationUtil.globalize( author = ((PublicationAuthorsPropertyStep) editStep).
"publications.ui.authors.selectAuthor.no_suitable_language_variant")); getSelectedAuthor();
editing = true;
}
if (!(author.getContentBundle().hasInstance(publication.getLanguage()))) {
data.addError(
PublicationGlobalizationUtil.globalize(
"publications.ui.authors.selectAuthor.no_suitable_language_variant"));
return; return;
} }
author = (GenericPerson) author.getContentBundle().getInstance(publication.getLanguage()); if (!editing) {
AuthorshipCollection authors = publication.getAuthors(); author = (GenericPerson) author.getContentBundle().getInstance(publication.
authors.addFilter(String.format("id = %s", author.getID().toString())); getLanguage());
if (authors.size() > 0) { AuthorshipCollection authors = publication.getAuthors();
data.addError(PublicationGlobalizationUtil.globalize( authors.addFilter(
"publications.ui.authors.selectAuthor.already_added")); String.format("id = %s", author.getID().toString()));
} if (authors.size() > 0) {
data.addError(PublicationGlobalizationUtil.globalize(
authors.close(); "publications.ui.authors.selectAuthor.already_added"));
}
authors.close();
}
} }
} }