diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties index 907521385..568952b58 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties @@ -134,3 +134,14 @@ cms.contenttypes.ui.genericorgaunit.contact.up=Up cms.contenttypes.ui.genericorgaunit.contact.down=Down cms.contenttypes.ui.genericorgaunit.contact.edit=Edit association cms.contenttypes.ui.genericorganunit.persons.edit=Edit association +cms.contenttypes.ui.contact.select_address.no_suitable_language_variant=The selected address item is not available in the language of the current contact. +cms.contenttypes.ui.contact.select_person.no_suitable_language_variant=The selected person item is not available in the langauge of the current contact. +cms.contenttypes.ui.genericorgaunit.select_contact.no_suitable_language_variant=The selected contact item is not available in the language of the current item. +cms.contenttypes.ui.genericorgaunit.select_contact.already_added=The selected contact item has already been added to the current item. +cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected=No contact selected. +cms.contenttypes.ui.genericorgaunit.person.no_person_selected=No person selected +cms.contenttypes.ui.genericorgaunit.person.no_suitable_language_variant=The selected person item is not availabe in the language of the current item. +cms.contenttypes.ui.genericorgaunit.person.already_added=The selected person has already been added to the current item. +cms.contenttypes.ui.person.select_contact.no_contact_selected=No contact selected. +cms.contenttypes.ui.person.select_contact.no_suitable_language_variant=The selected contact item is not avilable in the language of the current item. +cms.contenttypes.ui.person.select_contact.already_added=The selected contact has already been added to current item. diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties index 39e43540e..fd09f9f72 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties @@ -145,3 +145,14 @@ cms.contenttypes.ui.genericorgaunit.contact.up=Hoch cms.contenttypes.ui.genericorgaunit.contact.down=Runter cms.contenttypes.ui.genericorgaunit.contact.edit=Verkn\u00fcpfung bearbeiten cms.contenttypes.ui.genericorganunit.persons.edit=Verkn\u00fcpfung bearbeiten +cms.contenttypes.ui.contact.select_address.no_suitable_language_variant=Das ausgew\u00e4hlte Address-Item ist nicht in der Sprache des aktuellen Kontaktes verf\u00fcgbar. +cms.contenttypes.ui.contact.select_person.no_suitable_language_variant=Das ausgew\u00e4hlte Personen-Item ist nicht in der Sprache des aktuellen Kontaktes verf\u00fcgbar. +cms.contenttypes.ui.genericorgaunit.select_contact.no_suitable_language_variant=Das ausgew\u00e4hlte Kontakt-Item ist nicht in der Sprache der des aktuellen Items verf\u00fcgbar. +cms.contenttypes.ui.genericorgaunit.select_contact.already_added=Das ausgew\u00e4hlte Kontakt-Item wurde dem aktuellen Item bereits hinzugef\u00fcgt. +cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected=Kein Kontakt ausgew\u00e4hlt. +cms.contenttypes.ui.genericorgaunit.person.no_person_selected=Keine Person ausgew\u00e4hlt. +cms.contenttypes.ui.genericorgaunit.person.no_suitable_language_variant=Das ausgew\u00e4hlte Personen-Item ist nicht in der Sprache des aktuellen Items verf\u00fcgbar. +cms.contenttypes.ui.genericorgaunit.person.already_added=Das ausgew\u00e4hlte Personen-Item wurde dem aktuellen Item bereits hinzugef\u00fcgt. +cms.contenttypes.ui.person.select_contact.no_contact_selected=Kein Kontakt ausgew\u00e4hlt. +cms.contenttypes.ui.person.select_contact.no_suitable_language_variant=Das ausgew\u00e4hlte Kontakt-Item ist nicht in der Sprache des aktuellen Items verf\u00fcgbar. +cms.contenttypes.ui.person.select_contact.already_added=Das ausgew\u00e4hlte Kontakt-Item wurde dem aktuellen Item bereits hinzugef\u00fcgt. diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachAddressPropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachAddressPropertyForm.java index d459f883f..3051c6f80 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachAddressPropertyForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachAddressPropertyForm.java @@ -1,12 +1,3 @@ -/* - * ContactEditAddressPropertyForm.java - * - * Created on 8. Juli 2009, 10:27 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.FormData; @@ -36,15 +27,16 @@ import org.apache.log4j.Logger; * * @author quasi */ -public class GenericContactAttachAddressPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener { - - private static final Logger logger = Logger.getLogger(GenericContactPropertyForm.class); +public class GenericContactAttachAddressPropertyForm extends BasicPageForm + implements FormProcessListener, FormInitListener, FormSubmissionListener { + private static final Logger logger = + Logger.getLogger( + GenericContactPropertyForm.class); private GenericContactAddressPropertiesStep m_step; private ItemSearchWidget m_itemSearch; private SaveCancelSection m_saveCancelSection; private final String ITEM_SEARCH = "contactAddress"; - /** * ID of the form */ @@ -55,7 +47,7 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple * * @param itemModel */ - public GenericContactAttachAddressPropertyForm(ItemSelectionModel itemModel) { + public GenericContactAttachAddressPropertyForm(ItemSelectionModel itemModel) { this(itemModel, null); } @@ -65,7 +57,8 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple * @param itemModel * @param step */ - public GenericContactAttachAddressPropertyForm(ItemSelectionModel itemModel, GenericContactAddressPropertiesStep step) { + public GenericContactAttachAddressPropertyForm(ItemSelectionModel itemModel, + GenericContactAddressPropertiesStep step) { super(ID, itemModel); addSubmissionListener(this); @@ -73,22 +66,26 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple addInitListener(this); addSubmissionListener(this); - + } @Override public void addWidgets() { - add(new Label((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_address").localize())); - this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.GenericAddress")); - add(this.m_itemSearch); + add(new Label((String) ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.contact.select_address").localize())); + this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. + findByAssociatedObjectType( + "com.arsdigita.cms.contenttypes.GenericAddress")); + add(this.m_itemSearch); } - + @Override public void init(FormSectionEvent fse) { - FormData data = fse.getFormData(); + FormData data = fse.getFormData(); PageState state = fse.getPageState(); - GenericContact contact = (GenericContact)getItemSelectionModel().getSelectedObject(state); - + GenericContact contact = (GenericContact) getItemSelectionModel(). + getSelectedObject(state); + setVisible(state, true); if (contact != null) { @@ -98,17 +95,23 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple @Override public void process(FormSectionEvent fse) { - FormData data = fse.getFormData(); + FormData data = fse.getFormData(); PageState state = fse.getPageState(); - GenericContact contact = (GenericContact)getItemSelectionModel().getSelectedObject(state); + GenericContact contact = (GenericContact) getItemSelectionModel(). + getSelectedObject(state); if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) { - contact.setAddress((GenericAddress)data.get(ITEM_SEARCH)); + GenericAddress address = (GenericAddress) data.get(ITEM_SEARCH); + + address = (GenericAddress) address.getContentBundle().getInstance( + contact.getLanguage()); + + contact.setAddress(address); } + init(fse); } - /** * Creates the section with the save and the cancel button. */ @@ -119,13 +122,21 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple @Override public void prepare(PrintEvent e) { - GenericContact contact = (GenericContact)getItemSelectionModel().getSelectedObject(e.getPageState()); + GenericContact contact = + (GenericContact) getItemSelectionModel(). + getSelectedObject(e.getPageState()); Submit target = (Submit) e.getTarget(); if (contact.getAddress() != null) { - target.setButtonLabel((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_address.change").localize()); + target.setButtonLabel((String) ContenttypesGlobalizationUtil. + globalize( + "cms.contenttypes.ui.contact.select_address.change"). + localize()); } else { - target.setButtonLabel((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_address.add").localize()); + target.setButtonLabel((String) ContenttypesGlobalizationUtil. + globalize( + "cms.contenttypes.ui.contact.select_address.add"). + localize()); } } }); @@ -136,16 +147,35 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple @Override public void validate(FormSectionEvent e) throws FormProcessException { - if (e.getFormData().get(ITEM_SEARCH) == null) { - throw new FormProcessException((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_address.wrong_type").localize()); + final PageState state = e.getPageState(); + final FormData data = e.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + throw new FormProcessException((String) ContenttypesGlobalizationUtil. + globalize( + "cms.contenttypes.ui.contact.select_address.wrong_type"). + localize()); } + + GenericContact contact = (GenericContact) getItemSelectionModel(). + getSelectedObject(state); + + GenericAddress address = (GenericAddress) data.get(ITEM_SEARCH); + + if (!(address.getContentBundle().hasInstance(contact.getLanguage()))) { + data.addError( ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.contact.select_address.no_suitable_language_variant")); + } } @Override public void submitted(FormSectionEvent e) throws FormProcessException { if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) { init(e); - throw new FormProcessException((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_address.cancelled").localize()); + throw new FormProcessException((String) ContenttypesGlobalizationUtil. + globalize( + "cms.contenttypes.ui.contact.select_address.cancelled"). + localize()); } } } \ No newline at end of file diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachPersonPropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachPersonPropertyForm.java index f6b6a245e..4c288c0af 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachPersonPropertyForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachPersonPropertyForm.java @@ -1,11 +1,3 @@ -/* - * ContactEditPersonPropertyForm.java - * - * Created on 8. Juli 2009, 10:27 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.FormData; @@ -44,14 +36,18 @@ import org.apache.log4j.Logger; * * @author quasi */ -public class GenericContactAttachPersonPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener { - - private static final Logger logger = Logger.getLogger(GenericContactPropertyForm.class); +public class GenericContactAttachPersonPropertyForm extends BasicPageForm + implements FormProcessListener, FormInitListener, FormSubmissionListener { + + private static final Logger logger = + Logger.getLogger( + GenericContactPropertyForm.class); private GenericContactPersonPropertiesStep m_step; private ItemSearchWidget m_itemSearch; private SaveCancelSection m_saveCancelSection; private final String ITEM_SEARCH = "contactPerson"; - private final String CONTACTS_KEY = GenericPersonContactCollection.CONTACTS_KEY; + private final String CONTACTS_KEY = + GenericPersonContactCollection.CONTACTS_KEY; /** * ID of the form */ @@ -72,62 +68,78 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem * @param itemModel * @param step */ - public GenericContactAttachPersonPropertyForm(ItemSelectionModel itemModel, GenericContactPersonPropertiesStep step) { + public GenericContactAttachPersonPropertyForm(ItemSelectionModel itemModel, + GenericContactPersonPropertiesStep step) { super(ID, itemModel); addSubmissionListener(this); - + addSaveCancelSection(); - + addInitListener(this); addSubmissionListener(this); - + } - + @Override public void addWidgets() { - add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_person").localize())); - this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.GenericPerson")); + add(new Label((String) ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.contact.select_person").localize())); + this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. + findByAssociatedObjectType( + "com.arsdigita.cms.contenttypes.GenericPerson")); add(this.m_itemSearch); // GenericContact type field - add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type"))); + add(new Label(ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.person.contact.type"))); ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY); SingleSelect contactType = new SingleSelect(contactTypeParam); contactType.addValidationListener(new NotNullValidationListener()); - contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize()))); + contactType.addOption(new Option("", + new Label((String) ContenttypesGlobalizationUtil. + globalize("cms.ui.select_one").localize()))); // Add the Options to the SingleSelect widget - GenericContactTypeCollection contacttypes = new GenericContactTypeCollection(); - contacttypes.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().getLanguage()); - + GenericContactTypeCollection contacttypes = + new GenericContactTypeCollection(); + contacttypes.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). + getLanguage()); + while (contacttypes.next()) { RelationAttribute ct = contacttypes.getRelationAttribute(); contactType.addOption(new Option(ct.getKey(), ct.getName())); } - + add(contactType); } - + public void init(FormSectionEvent fse) { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - GenericContact contact = (GenericContact) getItemSelectionModel().getSelectedObject(state); - + GenericContact contact = (GenericContact) getItemSelectionModel(). + getSelectedObject(state); + setVisible(state, true); - + if (contact != null) { data.put(ITEM_SEARCH, contact.getPerson()); data.put(CONTACTS_KEY, contact.getContactType()); } } - + public void process(FormSectionEvent fse) { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - GenericContact contact = (GenericContact) getItemSelectionModel().getSelectedObject(state); - + GenericContact contact = (GenericContact) getItemSelectionModel(). + getSelectedObject(state); + if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) { - contact.setPerson((GenericPerson) data.get(ITEM_SEARCH), (String) data.get(CONTACTS_KEY)); + GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH); + + person = (GenericPerson) person.getContentBundle().getInstance(contact. + getLanguage()); + + contact.setPerson(person, (String) data.get(CONTACTS_KEY)); } init(fse); } @@ -139,15 +151,23 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem public void addSaveCancelSection() { try { getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() { - + public void prepare(PrintEvent e) { - GenericContact contact = (GenericContact) getItemSelectionModel().getSelectedObject(e.getPageState()); + GenericContact contact = + (GenericContact) getItemSelectionModel(). + getSelectedObject(e.getPageState()); Submit target = (Submit) e.getTarget(); - + if (contact.getPerson() != null) { - target.setButtonLabel((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_person.change").localize()); + target.setButtonLabel((String) ContenttypesGlobalizationUtil. + globalize( + "cms.contenttypes.ui.contact.select_person.change"). + localize()); } else { - target.setButtonLabel((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_person.add").localize()); + target.setButtonLabel((String) ContenttypesGlobalizationUtil. + globalize( + "cms.contenttypes.ui.contact.select_person.add"). + localize()); } } }); @@ -155,18 +175,36 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem throw new UncheckedWrapperException("this cannot happen", ex); } } - + @Override public void validate(FormSectionEvent e) throws FormProcessException { - if (e.getFormData().get(ITEM_SEARCH) == null) { - throw new FormProcessException((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_person.wrong_type").localize()); + final PageState state = e.getPageState(); + final FormData data = e.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + throw new FormProcessException((String) ContenttypesGlobalizationUtil. + globalize( + "cms.contenttypes.ui.contact.select_person.wrong_type"). + localize()); } + + GenericContact contact = (GenericContact) getItemSelectionModel(). + getSelectedObject(state); + GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH); + + if (!(person.getContentBundle().hasInstance(contact.getLanguage()))) { + data.addError("cms.contenttypes.ui.contact.select_person.no_suitable_language_variant"); + } + } - + public void submitted(FormSectionEvent e) throws FormProcessException { if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) { init(e); - throw new FormProcessException((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_person.cancelled").localize()); + throw new FormProcessException((String) ContenttypesGlobalizationUtil. + globalize( + "cms.contenttypes.ui.contact.select_person.cancelled"). + localize()); } } } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java index 82e7aa342..6e0b7de0b 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java @@ -88,7 +88,8 @@ public class GenericOrganizationalUnitContactAddForm GenericOrganizationalUnit.CONTACT_TYPE); SingleSelect contactType = new SingleSelect(contactTypeParam); contactType.addValidationListener(new NotNullValidationListener()); - contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil. + contactType.addOption(new Option("", + new Label((String) ContenttypesGlobalizationUtil. globalize("cms.ui.select_one").localize()))); GenericContactTypeCollection contacttypes = @@ -131,17 +132,21 @@ public class GenericOrganizationalUnitContactAddForm public void process(FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel(). + GenericOrganizationalUnit orgaunit = + (GenericOrganizationalUnit) getItemSelectionModel(). getSelectedObject(state); - - if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { GenericContact selectedContact; selectedContact = editStep.getSelectedContact(); if (selectedContact == null) { - orgaunit.addContact((GenericContact) data.get(ITEM_SEARCH), + GenericContact contact = (GenericContact) data.get(ITEM_SEARCH); + + contact = (GenericContact) contact.getContentBundle(). + getInstance(orgaunit.getLanguage()); + + orgaunit.addContact(contact, (String) data.get( GenericOrganizationalUnit.CONTACT_TYPE)); } else { @@ -176,4 +181,49 @@ public class GenericOrganizationalUnitContactAddForm init(fse); } } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if ((editStep.getSelectedContact() == null) + && (data.get(ITEM_SEARCH) == null)) { + data.addError( + "cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected"); + + return; + } + + if (editStep.getSelectedContact() == null) { + GenericOrganizationalUnit orgaunit = + (GenericOrganizationalUnit) getItemSelectionModel(). + getSelectedObject(state); + + GenericContact contact = (GenericContact) data.get(ITEM_SEARCH); + + if (!(contact.getContentBundle().hasInstance(orgaunit.getLanguage()))) { + data.addError( + ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.genericorgaunit.select_contact.no_suitable_language_variant")); + + return; + } + + contact = (GenericContact) contact.getContentBundle().getInstance(orgaunit. + getLanguage()); + GenericOrganizationalUnitContactCollection contacts = orgaunit. + getContacts(); + + contacts.addFilter(String.format("id = %s", + contact.getID().toString())); + if (contacts.size() > 0) { + data.addError( + ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.genericorgaunit.select_contact.already_added")); + } + + contacts.close(); + } + } } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java index 090caedd8..b047c0c3f 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java @@ -67,7 +67,7 @@ public class GenericOrganizationalUnitPersonAddForm public GenericOrganizationalUnitPersonAddForm(ItemSelectionModel itemModel, GenericOrganizationalUnitPersonSelector selector) { super("PersonAddForm", itemModel); - this.selector = selector; + this.selector = selector; addSubmissionListener(this); } @@ -78,7 +78,7 @@ public class GenericOrganizationalUnitPersonAddForm m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. findByAssociatedObjectType(getPersonType())); /*m_itemSearch.getItemField().addValidationListener( - new NotNullValidationListener());*/ + new NotNullValidationListener());*/ add(this.m_itemSearch); selectedPersonNameLabel = new Label(""); @@ -116,7 +116,8 @@ public class GenericOrganizationalUnitPersonAddForm statusSelect.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil. globalize("cms.ui.select_one").localize()))); - RelationAttributeCollection statusColl = new RelationAttributeCollection( + RelationAttributeCollection statusColl = + new RelationAttributeCollection( getStatusAttributeName()); statusColl.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). getLanguage()); @@ -164,7 +165,8 @@ public class GenericOrganizationalUnitPersonAddForm public void process(FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel(). + GenericOrganizationalUnit orga = + (GenericOrganizationalUnit) getItemSelectionModel(). getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { @@ -173,11 +175,14 @@ public class GenericOrganizationalUnitPersonAddForm person = selector.getSelectedPerson(); if (person == null) { - logger.debug(String.format("Adding person %s", - ((GenericPerson) data.get(ITEM_SEARCH)). - getFullName())); + GenericPerson personToAdd = + (GenericPerson) data.get(ITEM_SEARCH); + personToAdd.getContentBundle().getInstance(orga.getLanguage()); - orga.addPerson((GenericPerson) data.get(ITEM_SEARCH), + logger.debug(String.format("Adding person %s", + personToAdd.getFullName())); + + orga.addPerson(personToAdd, (String) data.get( GenericOrganizationalUnitPersonCollection.PERSON_ROLE), (String) data.get( @@ -220,6 +225,51 @@ public class GenericOrganizationalUnitPersonAddForm } } + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if ((selector.getSelectedPerson() == null) + && (data.get(ITEM_SEARCH) == null)) { + data.addError( + ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.genericorgaunit.person.no_person_selected")); + return; + } + + if (selector.getSelectedPerson() == null) { + GenericOrganizationalUnit orga = + (GenericOrganizationalUnit) getItemSelectionModel(). + getSelectedObject(state); + + GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH); + + if (!(person.getContentBundle().hasInstance(orga.getLanguage()))) { + data.addError( + ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.genericorgaunit.person.no_suitable_language_variant")); + + return; + } + + person = (GenericPerson) person.getContentBundle().getInstance(orga. + getLanguage()); + GenericOrganizationalUnitPersonCollection persons = + orga.getPersons(); + + persons.addFilter(String.format("id = %s", + person.getID().toString())); + if (persons.size() > 0) { + data.addError( + ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.genericorgaunit.person.already_added")); + } + + persons.close(); + } + } + protected String getPersonType() { return GenericPerson.class.getName(); } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactAddForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactAddForm.java index 639288660..d08ca6acf 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactAddForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactAddForm.java @@ -19,6 +19,7 @@ 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.SaveCancelSection; @@ -52,7 +53,9 @@ import org.apache.log4j.Logger; */ public class GenericPersonContactAddForm extends BasicItemForm { - private static final Logger s_log = Logger.getLogger(GenericPersonContactAddForm.class); + private static final Logger s_log = + Logger.getLogger( + GenericPersonContactAddForm.class); private GenericPersonPropertiesStep m_step; private ItemSearchWidget m_itemSearch; private SaveCancelSection m_saveCancelSection; @@ -71,20 +74,30 @@ public class GenericPersonContactAddForm extends BasicItemForm { protected void addWidgets() { // Attach a GenericContact object - add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.select_contact").localize())); - this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.GenericContact")); + add(new Label((String) ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.person.select_contact").localize())); + this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. + findByAssociatedObjectType( + "com.arsdigita.cms.contenttypes.GenericContact")); add(this.m_itemSearch); // GenericContact type field - add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type"))); - ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACTS_KEY); + add(new Label(ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.person.contact.type"))); + ParameterModel contactTypeParam = + new StringParameter( + GenericPersonContactCollection.CONTACTS_KEY); SingleSelect contactType = new SingleSelect(contactTypeParam); contactType.addValidationListener(new NotNullValidationListener()); - contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize()))); + contactType.addOption(new Option("", + new Label((String) ContenttypesGlobalizationUtil. + globalize("cms.ui.select_one").localize()))); // Add the Options to the SingleSelect widget - GenericContactTypeCollection contacttypes = new GenericContactTypeCollection(); - contacttypes.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().getLanguage()); + GenericContactTypeCollection contacttypes = + new GenericContactTypeCollection(); + contacttypes.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). + getLanguage()); while (contacttypes.next()) { RelationAttribute ct = contacttypes.getRelationAttribute(); @@ -94,6 +107,7 @@ public class GenericPersonContactAddForm extends BasicItemForm { add(contactType); } + @Override public void init(FormSectionEvent fse) { FormData data = fse.getFormData(); PageState state = fse.getPageState(); @@ -102,16 +116,63 @@ public class GenericPersonContactAddForm extends BasicItemForm { setVisible(state, true); } + @Override public void process(FormSectionEvent fse) { - FormData data = fse.getFormData(); - PageState state = fse.getPageState(); - GenericPerson person = (GenericPerson) getItemSelectionModel().getSelectedObject(state); + final FormData data = fse.getFormData(); + final PageState state = fse.getPageState(); + GenericPerson person = (GenericPerson) getItemSelectionModel(). + getSelectedObject(state); - // if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) { - person.addContact((GenericContact) data.get(ITEM_SEARCH), (String) data.get(GenericPersonContactCollection.CONTACTS_KEY)); + GenericContact contact = (GenericContact) data.get(ITEM_SEARCH); + + contact = (GenericContact) contact.getContentBundle().getInstance( + person.getLanguage()); + + person.addContact(contact, + (String) data.get( + GenericPersonContactCollection.CONTACTS_KEY)); } init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.person.select_contact.no_contact_selected")); + + return; + } + + GenericPerson person = (GenericPerson) getItemSelectionModel(). + getSelectedObject(state); + + GenericContact contact = (GenericContact) data.get(ITEM_SEARCH); + + if (!(contact.getContentBundle().hasInstance(person.getLanguage()))) { + data.addError( + ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.person.select_contact.no_suitable_language_variant")); + + return; + } + + contact = (GenericContact) contact.getContentBundle().getInstance(person.getLanguage()); + GenericPersonContactCollection contacts = person.getContacts(); + + contacts.addFilter(String.format("id = %s", contact.getID().toString())); + if (contacts.size() > 0) { + data.addError( + ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.person.select_contact.already_added")); + } + + contacts.close(); + } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java index 39594fcd2..173c7e7e7 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java @@ -79,10 +79,39 @@ public class ArticleInCollectedVolumeCollectedVolumeForm getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - article.setCollectedVolume((CollectedVolume) data.get(ITEM_SEARCH)); + CollectedVolume collectedVolume = (CollectedVolume) data.get( + ITEM_SEARCH); + collectedVolume = + (CollectedVolume) collectedVolume.getContentBundle().getInstance( + article.getLanguage()); - init(fse); + article.setCollectedVolume(collectedVolume); } + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.articleInCollectedVolume.selectCollectedVolume.no_collected_volume_selected")); + return; + } + + ArticleInCollectedVolume article = (ArticleInCollectedVolume) getItemSelectionModel().getSelectedObject(state); + + CollectedVolume collectedVolume = (CollectedVolume) data.get(ITEM_SEARCH); + + if (!(collectedVolume.getContentBundle().hasInstance(article.getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.articleInCollectedVolume.selectCollectedVolume.no_suitable_language_variant")); + return; + } } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalForm.java index 0a6ebe9c4..2729183d8 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalForm.java @@ -55,7 +55,7 @@ public class ArticleInJournalJournalForm add(new Label(PublicationGlobalizationUtil.globalize( "publications.ui.articleInJournal.selectJournal"))); itemSearch = new ItemSearchWidget(ITEM_SEARCH, - ContentType.findByAssociatedObjectType( + ContentType.findByAssociatedObjectType( Journal.class.getName())); add(itemSearch); } @@ -71,14 +71,39 @@ public class ArticleInJournalJournalForm public void process(FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - ArticleInJournal article = (ArticleInJournal) getItemSelectionModel().getSelectedObject(state); + ArticleInJournal article = (ArticleInJournal) getItemSelectionModel(). + getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - article.setJournal((Journal) data.get(ITEM_SEARCH)); + Journal journal = (Journal) data.get(ITEM_SEARCH); + journal = (Journal) journal.getContentBundle().getInstance(article. + getLanguage()); - init(fse); + article.setJournal(journal); } + init(fse); } + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state= fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.articleInJournal.selectJournal.no_journal_selected")); + return; + } + + ArticleInJournal article = (ArticleInJournal) getItemSelectionModel().getSelectedObject( + state); + Journal journal = (Journal) data.get(ITEM_SEARCH); + + if (!(journal.getContentBundle().hasInstance(article.getLanguage()))) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.articleInJournal.selectJournal.no_suitable_language_variant")); + return; + } + } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticleAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticleAddForm.java index 51ce2aae6..293f222b9 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticleAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticleAddForm.java @@ -29,6 +29,7 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume; +import com.arsdigita.cms.contenttypes.ArticleInCollectedVolumeCollection; import com.arsdigita.cms.contenttypes.CollectedVolume; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -86,10 +87,47 @@ public class CollectedVolumeArticleAddForm if (!(this.getSaveCancelSection().getCancelButton(). isSelected(state))) { - collectedVolume.addArticle((ArticleInCollectedVolume) data.get( - ITEM_SEARCH)); + ArticleInCollectedVolume article = (ArticleInCollectedVolume) data. + get(ITEM_SEARCH); + article = (ArticleInCollectedVolume) article.getContentBundle(). + getInstance(collectedVolume.getLanguage()); + + collectedVolume.addArticle(article); } init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.articles.select_article.no_article_selected")); + return; + } + + CollectedVolume collectedVolume = (CollectedVolume) getItemSelectionModel().getSelectedObject(state); + ArticleInCollectedVolume article = (ArticleInCollectedVolume) data.get(ITEM_SEARCH); + + if (!(article.getContentBundle().hasInstance(collectedVolume.getLanguage()))) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.articles.select_article.no_suitable_language_variant")); + return; + } + + article = (ArticleInCollectedVolume) article.getContentBundle().getInstance(collectedVolume.getLanguage()); + ArticleInCollectedVolumeCollection articles = collectedVolume.getArticles(); + + articles.addFilter(String.format("id = %s", article.getID().toString())); + if (articles.size() > 0) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.articles.select_article.already_added")); + return; + } + + articles.close(); + } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererForm.java index 244cedfc2..cd6cc98e2 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererForm.java @@ -41,7 +41,7 @@ public class ExpertiseOrdererForm } @Override - public void init(final FormSectionEvent fse) throws FormProcessException{ + public void init(final FormSectionEvent fse) throws FormProcessException { PageState state = fse.getPageState(); setVisible(state, true); @@ -51,12 +51,40 @@ public class ExpertiseOrdererForm public void process(final FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - Expertise expertise = (Expertise) getItemSelectionModel().getSelectedObject(state); + Expertise expertise = (Expertise) getItemSelectionModel(). + getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - expertise.setOrderer((GenericOrganizationalUnit) data.get(ITEM_SEARCH)); + GenericOrganizationalUnit orderer = + (GenericOrganizationalUnit) data.get( + ITEM_SEARCH); + orderer = (GenericOrganizationalUnit) orderer.getContentBundle(). + getInstance(expertise.getLanguage()); - init(fse); + expertise.setOrderer(orderer); + } + + init(fse); + } + + @Override public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.expertise.orderer.no_orderer_selected")); + + return; + } + + Expertise expertise = (Expertise) getItemSelectionModel().getSelectedObject(state); + GenericOrganizationalUnit orderer = (GenericOrganizationalUnit) data.get(ITEM_SEARCH); + if (!(orderer.getContentBundle().hasInstance(expertise.getLanguage()))) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.expertise.orderer.no_suitable_langauge_variant")); + + return; } } } \ No newline at end of file diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationForm.java index f718373a8..940250b56 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationForm.java @@ -41,7 +41,7 @@ public class ExpertiseOrganizationForm } @Override - public void init(final FormSectionEvent fse) throws FormProcessException{ + public void init(final FormSectionEvent fse) throws FormProcessException { PageState state = fse.getPageState(); setVisible(state, true); @@ -51,12 +51,40 @@ public class ExpertiseOrganizationForm public void process(final FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - Expertise expertise = (Expertise) getItemSelectionModel().getSelectedObject(state); + Expertise expertise = (Expertise) getItemSelectionModel(). + getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - expertise.setOrganization((GenericOrganizationalUnit) data.get(ITEM_SEARCH)); + GenericOrganizationalUnit orga = (GenericOrganizationalUnit) data. + get(ITEM_SEARCH); + orga = (GenericOrganizationalUnit) orga.getContentBundle(). + getInstance(expertise.getLanguage()); + + expertise.setOrganization(orga); - init(fse); } + + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.expertise.organization.no_orga_selected")); + return; + } + + Expertise expertise = (Expertise) getItemSelectionModel().getSelectedObject(state); + GenericOrganizationalUnit orga = (GenericOrganizationalUnit) data.get(ITEM_SEARCH); + if (!(orga.getContentBundle().hasInstance(expertise.getLanguage()))) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.expertise.organization.no_suitable_language_variant")); + return; + } + } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsForm.java index 6fb43837e..10a2fbbfb 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsForm.java @@ -77,10 +77,37 @@ public class InProceedingsProceedingsForm getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - inProceedings.setProceedings((Proceedings) data.get(ITEM_SEARCH)); + Proceedings proceedings = (Proceedings) data.get(ITEM_SEARCH); + proceedings = (Proceedings) proceedings.getContentBundle(). + getInstance(inProceedings.getLanguage()); - init(fse); + inProceedings.setProceedings(proceedings); } + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.inProceedings.selectProceedings.no_proceedings_selected")); + return; + } + + InProceedings inProceedings = (InProceedings) getItemSelectionModel(). + getSelectedObject(state); + Proceedings proceedings = (Proceedings) data.get(ITEM_SEARCH); + if (!(proceedings.getContentBundle().hasInstance(inProceedings. + getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.inProceedings.selectProceedings.no_suitable_language_variant")); + return; + } } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationForm.java index ef92b799e..259d6a4f5 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationForm.java @@ -51,13 +51,42 @@ public class InternetArticleOrganizationForm public void process(final FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - InternetArticle article = (InternetArticle) getItemSelectionModel().getSelectedObject(state); + InternetArticle article = (InternetArticle) getItemSelectionModel(). + getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - article.setOrganization((GenericOrganizationalUnit) data.get(ITEM_SEARCH)); + GenericOrganizationalUnit orga = (GenericOrganizationalUnit) data. + get(ITEM_SEARCH); + orga = (GenericOrganizationalUnit) orga.getContentBundle(). + getInstance(article.getLanguage()); - init(fse); + article.setOrganization(orga); } + init(fse); + } + + @Override + public void validate(final FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.internetarticle.select_organization.no_orga_selected")); + return; + } + + InternetArticle article = (InternetArticle) getItemSelectionModel(). + getSelectedObject(state); + GenericOrganizationalUnit orga = (GenericOrganizationalUnit) data.get( + ITEM_SEARCH); + if (!(orga.getContentBundle().hasInstance(article.getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.internetarticle.select_organization.no_suitable_language_variant")); + return; + } } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticleAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticleAddForm.java index 0adf760c0..b1ecc96ef 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticleAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticleAddForm.java @@ -29,6 +29,7 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.ArticleInJournal; +import com.arsdigita.cms.contenttypes.ArticleInJournalCollection; import com.arsdigita.cms.contenttypes.Journal; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -57,7 +58,7 @@ public class JournalArticleAddForm @Override public void addWidgets() { - add(new Label((String) PublicationGlobalizationUtil.globalize( + add(new Label((String) PublicationGlobalizationUtil.globalize( "publications.ui.journal.articles.select_article"). localize())); m_itemSearch = new ItemSearchWidget( @@ -83,9 +84,48 @@ public class JournalArticleAddForm state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - journal.addArticle((ArticleInJournal) data.get(ITEM_SEARCH)); + ArticleInJournal article = (ArticleInJournal) data.get(ITEM_SEARCH); + article = (ArticleInJournal) article.getContentBundle().getInstance(journal. + getLanguage()); + + journal.addArticle(article); } init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.journal.articles.select_article.no_article_selected")); + return; + } + + Journal journal = (Journal) getItemSelectionModel().getSelectedObject( + state); + ArticleInJournal article = (ArticleInJournal) data.get(ITEM_SEARCH); + if (!(article.getContentBundle().hasInstance(journal.getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.journal.articles.select_article.no_suitable_language_variant")); + return; + } + + article = (ArticleInJournal) article.getContentBundle().getInstance(journal. + getLanguage()); + ArticleInJournalCollection articles = journal.getArticles(); + articles.addFilter(String.format("id = %s", article.getID().toString())); + if (articles.size() > 0) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.journal.articles.select_article.already_added")); + } + + articles.close(); + } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerForm.java index 0afe98726..0dd89736e 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerForm.java @@ -55,10 +55,38 @@ public class ProceedingsOrganizerForm getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - proceedings.setOrganizerOfConference((GenericOrganizationalUnit) data. - get(ITEM_SEARCH)); + GenericOrganizationalUnit organizer = + (GenericOrganizationalUnit) data.get( + ITEM_SEARCH); + organizer = (GenericOrganizationalUnit) organizer.getContentBundle(). + getInstance(proceedings.getLanguage()); - init(fse); + proceedings.setOrganizerOfConference(organizer); + + } + + init(fse); + } + + @Override + public void validate(final FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.proceedings.organizer.no_orga_selected")); + return; + } + + Proceedings proceedings = (Proceedings) getItemSelectionModel(). + getSelectedObject(state); + GenericOrganizationalUnit organizer = (GenericOrganizationalUnit) data. + get(ITEM_SEARCH); + if (!(organizer.getContentBundle().hasInstance(proceedings.getLanguage()))) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.proceedings.organizer.no_suitable_language_variant")); + return; } } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersAddForm.java index 3ab60dd9f..ef4016ff2 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersAddForm.java @@ -29,6 +29,7 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.InProceedings; +import com.arsdigita.cms.contenttypes.InProceedingsCollection; import com.arsdigita.cms.contenttypes.Proceedings; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -78,10 +79,47 @@ public class ProceedingsPapersAddForm getSelectedObject(state); if (!(this.getSaveCancelSection().getCancelButton(). - isSelected(state))) { - proceedings.addPaper((InProceedings) data.get(ITEM_SEARCH)); + isSelected(state))) { + InProceedings paper = (InProceedings) data.get(ITEM_SEARCH); + paper = (InProceedings) paper.getContentBundle().getInstance(proceedings. + getLanguage()); + + proceedings.addPaper(paper); } init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.proceedings.select_paper.no_paper_selected")); + return; + } + + Proceedings proceedings = (Proceedings) getItemSelectionModel(). + getSelectedObject(state); + InProceedings paper = (InProceedings) data.get(ITEM_SEARCH); + if (!(paper.getContentBundle().hasInstance(proceedings.getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.proceedings.select_paper.no_suitable_language_variant")); + return; + } + + paper = (InProceedings) paper.getContentBundle().getInstance(proceedings.getLanguage()); + InProceedingsCollection papers = proceedings.getPapers(); + papers.addFilter(String.format("id = %s", paper.getID().toString())); + if (papers.size() > 0) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.proceedings.select_paper.already_added")); + return; + } + } } 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 230b73c4d..33dc7ba9a 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 @@ -52,7 +52,7 @@ public class PublicationAuthorAddForm private static final Logger s_log = Logger.getLogger( PublicationAuthorAddForm.class); private PublicationPropertiesStep m_step; - private ItemSearchWidget m_itemSearch; + private ItemSearchWidget m_itemSearch; private final String ITEM_SEARCH = "authors"; private ItemSelectionModel m_itemModel; private SimpleEditStep editStep; @@ -82,7 +82,7 @@ public class PublicationAuthorAddForm add(selectedAuthorLabel); add(new Label((String) PublicationGlobalizationUtil.globalize( - "publications.ui.authors.author.is_editor").localize())); + "publications.ui.authors.author.is_editor").localize())); isEditor = new CheckboxGroup("isEditorGroup"); isEditor.addOption(new Option(ISEDITOR, "")); add(isEditor); @@ -146,9 +146,12 @@ public class PublicationAuthorAddForm } if (author == null) { - publication.addAuthor( - (GenericPerson) data.get(ITEM_SEARCH), - editor); + GenericPerson authorToAdd = + (GenericPerson) data.get(ITEM_SEARCH); + authorToAdd = (GenericPerson) authorToAdd.getContentBundle(). + getInstance(publication.getLanguage()); + + publication.addAuthor(authorToAdd, editor); } else { AuthorshipCollection authors; @@ -161,7 +164,7 @@ public class PublicationAuthorAddForm } authors.setEditor(editor); - + ((PublicationAuthorsPropertyStep) editStep).setSelectedAuthor( null); ((PublicationAuthorsPropertyStep) editStep). @@ -174,6 +177,7 @@ public class PublicationAuthorAddForm init(fse); } + @Override public void submitted(FormSectionEvent fse) throws FormProcessException { if (getSaveCancelSection().getCancelButton().isSelected( fse.getPageState())) { @@ -185,4 +189,37 @@ public class PublicationAuthorAddForm init(fse); } } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if ((((PublicationAuthorsPropertyStep) editStep).getSelectedAuthor() + == null) + && (data.get(ITEM_SEARCH) == null)) { + data.addError(PublicationGlobalizationUtil.globalize( + "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")); + 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(); + } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationResources.properties b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationResources.properties index 22a4732b6..301508793 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationResources.properties +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationResources.properties @@ -320,3 +320,42 @@ publications.ui.workingpaper.reviewed.yes=Yes publications.ui.workingpaper.reviewed.no=No publication.ui.publisher.name=Name of publisher publications.ui.publisher.name=Name of publisher +publications.ui.articleInCollectedVolume.selectCollectedVolume.no_collected_volume_selected=No collected volume selected. +publications.ui.articleInCollectedVolume.selectCollectedVolume.no_suitable_language_variant=The selected collected volume item is not available in the language of the current article. +publications.ui.articleInJournal.selectJournal.no_journal_selected=No journal selected +publications.ui.articleInJournal.selectJournal.no_suitable_language_variant=The selected journal item is not available in the language of the current article. +publications.ui.collected_volume.articles.select_article.no_article_selected=No article selected. +publications.ui.collected_volume.articles.select_article.no_suitable_language_variant=The selected article item is not avialable in the language of the current collected volume item. +publications.ui.collected_volume.articles.select_article.already_added=The selected article has already been added to the current collected volume. +publications.ui.expertise.orderer.no_orderer_selected=No orderer selected. +publications.ui.expertise.orderer.no_suitable_langauge_variant=The item selected as orderer is not available in the language of the current expertise item. +publications.ui.expertise.organization.no_orga_selected=No organization selected. +publications.ui.expertise.organization.no_suitable_language_variant=The selected item is not avaialable for the language of the current expertise. +publications.ui.inProceedings.selectProceedings.no_proceedings_selected=No proceedings selected. +publications.ui.inProceedings.selectProceedings.no_suitable_language_variant=The selected proceedings publiciation item is not avialable for the language of the current in proceedings publication item. +publications.ui.internetarticle.select_organization.no_orga_selected=No organization selected. +publications.ui.internetarticle.select_organization.no_suitable_language_variant=The selected item is not avilable for the langauge of the current internet article. +publications.ui.journal.articles.select_article.no_article_selected=No article selected. +publications.ui.journal.articles.select_article.no_suitable_language_variant=The selected article in journal item is not available for the language of the current journal item. +publications.ui.journal.articles.select_article.already_added=The selected article has already been added to the current journal. +publications.ui.proceedings.organizer.no_orga_selected=No orderer selected. +publications.ui.proceedings.organizer.no_suitable_language_variant=The selected item is not avialable for the language of the current proceedings item. +publications.ui.proceedings.select_paper.no_paper_selected=No paper selected. +publications.ui.proceedings.select_paper.no_suitable_language_variant=The selected InProceedings-Item is not avaiable for the language of the current proceedings item. +publications.ui.proceedings.select_paper.already_added=The selected item has already been added to the current Proceedings item +publications.ui.authors.selectAuthor.no_author_selected=No author selected. +publications.ui.authors.selectAuthor.no_suitable_language_variant=The person item selected as author is not available for the language of the current publication item. +publications.ui.authors.selectAuthor.already_added=The selected person has already been added as author to the current publication. +publications.ui.series.select_series.no_series_selected=No series selected. +publications.ui.series.select_series.no_suitable_language_variant=The selected series item is not available for the language of the current publication item. +publications.ui.series.select_series.already_added=The current publication has already been added to the selected series. +publications.ui.with_publisher.publisher.no_publisher_selected=No publisher selected. +publications.ui.with_publisher.publisher.no_suitable_language_variant=The selected publisher item is not available for the language of the current publication item. +publications.ui.series.editship.no_editor_selected=No editor selected. +publications.ui.series.editship.no_suitable_language_variant=The person item selected as editor in not available for the language of the current series item. +publications.ui.series.editship.already_added=The selected person has already been added to the series as editor. +publications.ui.series.volume_of_series.no_volume_selected=No publication selected. +publications.ui.series.volume_of_series.no_suitable_language_variant=The selected publication item is not available for the language of the current series item. +publications.ui.series.volume_of_series.already_added=The selected publication has already been added to the series. +publications.ui.unpublished.organization.no_orga_selected=No organization selected. +publications.ui.unpublished.organization.no_suitable_language_variant=The selected organization item is not available for the language of the current item. diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationResources_de.properties b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationResources_de.properties index 6f3352b7c..2710fad55 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationResources_de.properties +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationResources_de.properties @@ -319,3 +319,42 @@ publications.ui.workingpaper.reviewed.yes=Ja publications.ui.workingpaper.reviewed.no=Nein publication.ui.publisher.name=Name des Verlages publications.ui.publisher.name=Name des Verlages +publications.ui.articleInCollectedVolume.selectCollectedVolume.no_collected_volume_selected=Kein Sammelband ausgew\u00e4hlt. +publications.ui.articleInCollectedVolume.selectCollectedVolume.no_suitable_language_variant=Das ausgew\u00e4hlte Sammelband-Item ist nicht in der Sprache des aktuellen Artikels verf\u00fcgbar. +publications.ui.articleInJournal.selectJournal.no_journal_selected=Keine Zeitschrift ausgew\u00e4hlt. +publications.ui.articleInJournal.selectJournal.no_suitable_language_variant=Das ausgew\u00e4hlte Zeitschriften-Item ist nicht in der Sprache des aktuellen Artikels verf\u00fcgbar. +publications.ui.collected_volume.articles.select_article.no_article_selected=Kein Artikel ausgew\u00e4hlt. +publications.ui.collected_volume.articles.select_article.no_suitable_language_variant=Das ausgew\u00e4hlte Artikel-Item ist nicht in der Sprache des aktuellen Sammelband-Items verf\u00fcbar. +publications.ui.collected_volume.articles.select_article.already_added=Der ausgew\u00e4hlte Artikel wurde dem aktuellen Sammelband bereits hinzugef\u00fcgt. +publications.ui.expertise.orderer.no_orderer_selected=Ein Auftraggeber ausgew\u00e4hlt. +publications.ui.expertise.orderer.no_suitable_langauge_variant=Das als Auftraggeber ausgew\u00e4hlte Item ist nicht f\u00fcr die Sprache des aktuellen Gutachtens verf\u00fcgbar. +publications.ui.expertise.organization.no_orga_selected=Keine Organisation ausgew\u00e4hlt. +publications.ui.expertise.organization.no_suitable_language_variant=Das ausgew\u00e4hlte Item ist nicht in der Sprache des aktuellen Gutachtens verf\u00fcgbar. +publications.ui.inProceedings.selectProceedings.no_proceedings_selected=Kein Tagungsband ausgew\u00e4hlt. +publications.ui.inProceedings.selectProceedings.no_suitable_language_variant=Das ausgew\u00e4hlte Tagungsband-Item ist f\u00fcr die Sprache des aktuellen Tagungsbandbeitrag-Items nicht verf\u00fcgbar. +publications.ui.internetarticle.select_organization.no_orga_selected=Keine Organisation ausgew\u00e4hlt. +publications.ui.internetarticle.select_organization.no_suitable_language_variant=Das ausgew\u00e4hlte Item ist nicht f\u00fcr die Sprache des aktuellen Internet-Artikels verf\u00fcgbar. +publications.ui.journal.articles.select_article.no_article_selected=Kein Artikel ausgew\u00e4hlt. +publications.ui.journal.articles.select_article.no_suitable_language_variant=Das ausgew\u00e4hlte ArticleInJournal-Item ist nicht f\u00fcr die Sprache des aktuellen Journal-Items verf\u00fcgbar. +publications.ui.journal.articles.select_article.already_added=Der ausgew\u00e4hlte Artikel ist dem aktuellen Journal-Item bereits hinzugef\u00fcgt worden. +publications.ui.proceedings.organizer.no_orga_selected=Kein Auftraggeber ausgew\u00e4hlt. +publications.ui.proceedings.organizer.no_suitable_language_variant=Das ausgew\u00e4hlte Item ist nicht f\u00fcr die Sprache des aktuellen Proceedings-Items verf\u00fcgbar. +publications.ui.proceedings.select_paper.no_paper_selected=Keine Paper ausgew\u00e4hlt. +publications.ui.proceedings.select_paper.no_suitable_language_variant=Das ausgew\u00e4hlte InProceedingsItem ist nicht f\u00fcr die Sprache des aktuellen Proceedings-Items verf\u00fcgbar. +publications.ui.proceedings.select_paper.already_added=Das ausgewh\u00e4hlte Item wurde dem aktuellen Proceedings-Item bereits zugeordnet. +publications.ui.authors.selectAuthor.no_author_selected=Kein Autor ausgew\u00e4hlt. +publications.ui.authors.selectAuthor.no_suitable_language_variant=Das als Autor ausgew\u00e4hlte Personen-Item ist nicht f\u00fcr die Sprache des aktuellen Publikations-Items verf\u00fcgbar. +publications.ui.authors.selectAuthor.already_added=Die als Autor ausgew\u00e4hlte Person wurde der aktuellen Publikation bereits als Autor hinzugef\u00fcgt. +publications.ui.series.select_series.no_series_selected=Keine Reihe ausgew\u00e4hlt. +publications.ui.series.select_series.no_suitable_language_variant=Das ausgew\u00e4hlte Series-Item ist nicht f\u00fcr die Sprache des aktuellen Publikations-Items verf\u00fcgbar. +publications.ui.series.select_series.already_added=Die aktuelle Publikation wurde der ausgew\u00e4hlten Reihe bereits hinzugef\u00fcgt. +publications.ui.with_publisher.publisher.no_publisher_selected=Kein Verlag ausgew\u00e4hlt. +publications.ui.with_publisher.publisher.no_suitable_language_variant=Das ausgew\u00e4hlte Publisher-Item ist nicht f\u00fcr die Sprache des aktuellen Publikations-Items verf\u00fcgbar. +publications.ui.series.editship.no_editor_selected=Kein Herausgeber ausgew\u00e4hlt. +publications.ui.series.editship.no_suitable_language_variant=Das als Herausgeber ausgew\u00e4hlte Personen-Item ist nicht f\u00fc die Sprache der des aktuellen Series-Items verf\u00fcgbar. +publications.ui.series.editship.already_added=Die ausgew\u00e4hlte Person wurde der aktuellen Reihe bereits als Herausgeber zugeordnet. +publications.ui.series.volume_of_series.no_volume_selected=Keine Publikation ausgew\u00e4hlt. +publications.ui.series.volume_of_series.no_suitable_language_variant=Das ausgew\u00e4hlte Publikations-Item ist nicht f\u00fcr die Sprache des aktuellen Series-Items verf\u00fcgbar. +publications.ui.series.volume_of_series.already_added=Die ausgew\u00e4hlte Publikation wurde der aktuellen Reihe bereits hinzugef\u00fcgt. +publications.ui.unpublished.organization.no_orga_selected=Keine Organisation ausgew\u00e4hlt. +publications.ui.unpublished.organization.no_suitable_language_variant=Das ausgew\u00e4hlte Item ist nicht f\u00fcr die Sprache des aktuellen Items verf\u00fcgbar. diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationSeriesAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationSeriesAddForm.java index 07692f02e..785e5246e 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationSeriesAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationSeriesAddForm.java @@ -32,6 +32,7 @@ import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Series; +import com.arsdigita.cms.contenttypes.SeriesCollection; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -83,10 +84,46 @@ public class PublicationSeriesAddForm if (!(this.getSaveCancelSection().getCancelButton(). isSelected(state))) { - publication.addSeries( - (Series) data.get(ITEM_SEARCH)); + Series series = (Series) data.get(ITEM_SEARCH); + series = (Series) series.getContentBundle().getInstance(publication. + getLanguage()); + + publication.addSeries(series); } init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.series.select_series.no_series_selected")); + return; + } + + Publication publication = (Publication) getItemSelectionModel(). + getSelectedObject(state); + Series series = (Series) data.get(ITEM_SEARCH); + if (!(series.getContentBundle().hasInstance(publication.getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.series.select_series.no_suitable_language_variant")); + return; + } + + series = (Series) series.getContentBundle().getInstance(publication. + getLanguage()); + SeriesCollection seriesColl = publication.getSeries(); + seriesColl.addFilter(String.format("id = %s", series.getID().toString())); + if (seriesColl.size() > 0) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.series.select_series.already_added")); + } + + seriesColl.close(); + } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherForm.java index 4b6233e7c..46bc1e747 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherForm.java @@ -54,14 +54,42 @@ public class PublicationWithPublisherSetPublisherForm public void process(final FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - PublicationWithPublisher publication = (PublicationWithPublisher) getItemSelectionModel(). + PublicationWithPublisher publication = + (PublicationWithPublisher) getItemSelectionModel(). getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - publication.setPublisher((Publisher) data.get(ITEM_SEARCH)); + Publisher publisher = (Publisher) data.get(ITEM_SEARCH); + publisher = (Publisher) publisher.getContentBundle().getInstance(publication. + getLanguage()); - init(fse); + publication.setPublisher(publisher); } + init(fse); + } + + @Override + public void validate(final FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.with_publisher.publisher.no_publisher_selected")); + return; + } + + PublicationWithPublisher publication = + (PublicationWithPublisher) getItemSelectionModel(). + getSelectedObject(state); + Publisher publisher = (Publisher) data.get(ITEM_SEARCH); + if (!(publisher.getContentBundle().hasInstance(publication.getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.with_publisher.publisher.no_suitable_language_variant")); + return; + } } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipAddForm.java index ecfdc3f7e..1d5ab37b8 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipAddForm.java @@ -139,7 +139,11 @@ public class SeriesEditshipAddForm editor = editStep.getSelectedEditor(); if (editor == null) { - series.addEditor((GenericPerson) data.get(ITEM_SEARCH), + GenericPerson editorToAdd = + (GenericPerson) data.get(ITEM_SEARCH); + editorToAdd.getContentBundle().getInstance(series.getLanguage()); + + series.addEditor(editorToAdd, (Date) data.get(EditshipCollection.FROM), (Date) data.get(EditshipCollection.TO)); } else { @@ -166,16 +170,46 @@ public class SeriesEditshipAddForm init(fse); } + @Override public void submitted(FormSectionEvent fse) throws FormProcessException { if (getSaveCancelSection().getCancelButton().isSelected( fse.getPageState())) { editStep.setSelectedEditor(null); editStep.setSelectedEditorDateFrom(null); - editStep.setSelectedEditorDateTo(null); - - init(fse); + editStep.setSelectedEditorDateTo(null); } - + + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.series.editship.no_editor_selected")); + return; + } + + Series series = (Series) getItemSelectionModel().getSelectedObject(state); + GenericPerson editor = (GenericPerson) data.get(ITEM_SEARCH); + if (!(editor.getContentBundle().hasInstance(series.getLanguage()))) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.series.editship.no_suitable_language_variant")); + return; + } + + editor = (GenericPerson) editor.getContentBundle().getInstance(series.getLanguage()); + EditshipCollection editors = series.getEditors(); + editors.addFilter(String.format("id = %s", editor.getID().toString())); + if (editors.size() > 0) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.series.editship.already_added")); + } + + editors.close(); } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesVolumeAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesVolumeAddForm.java index b122ab26b..ce553c3e3 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesVolumeAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesVolumeAddForm.java @@ -92,12 +92,49 @@ public class SeriesVolumeAddForm extends BasicItemForm { if (!(this.getSaveCancelSection().getCancelButton(). isSelected(state))) { - series.addVolume( - (Publication) data.get(ITEM_SEARCH), - (Integer) data.get( + Publication volume = (Publication) data.get(ITEM_SEARCH); + volume = (Publication) volume.getContentBundle().getInstance(series. + getLanguage()); + + series.addVolume(volume, + (Integer) data.get( VolumeInSeriesCollection.VOLUME_OF_SERIES)); } init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.series.volume_of_series.no_volume_selected")); + return; + } + + Series series = (Series) getItemSelectionModel(). + getSelectedObject(state); + Publication volume = (Publication) data.get(ITEM_SEARCH); + if (!(volume.getContentBundle().hasInstance(series.getLanguage()))) { + data.addError( + PublicationGlobalizationUtil.globalize( + "publications.ui.series.volume_of_series.no_suitable_language_variant")); + return; + } + + volume = (Publication) volume.getContentBundle().getInstance(series. + getLanguage()); + VolumeInSeriesCollection volumes = series.getVolumes(); + volumes.addFilter(String.format("id = %s", volume.getID().toString())); + if (volumes.size() > 0) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.series.volume_of_series.already_added")); + } + + volumes.close(); + } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationForm.java index 1e2943ef9..8c2e3c659 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationForm.java @@ -55,9 +55,37 @@ public class UnPublishedOrganizationForm getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - unPublished.setOrganization((GenericOrganizationalUnit) data.get(ITEM_SEARCH)); + GenericOrganizationalUnit orga = (GenericOrganizationalUnit) data. + get(ITEM_SEARCH); + orga = (GenericOrganizationalUnit) orga.getContentBundle(). + getInstance(unPublished.getLanguage()); - init(fse); + unPublished.setOrganization(orga); + + } + + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.unpublished.organization.no_orga_selected")); + return; + } + + UnPublished unPublished = (UnPublished) getItemSelectionModel(). + getSelectedObject(state); + GenericOrganizationalUnit orga = (GenericOrganizationalUnit) data.get( + ITEM_SEARCH); + if (!(orga.getContentBundle().hasInstance(unPublished.getLanguage()))) { + data.addError(PublicationGlobalizationUtil.globalize( + "publications.ui.unpublished.organization.no_suitable_language_variant")); + return; } } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentOrganizationForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentOrganizationForm.java index 7226471c3..d4e217d95 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentOrganizationForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentOrganizationForm.java @@ -93,6 +93,14 @@ public class SciDepartmentOrganizationForm final PageState state = fse.getPageState(); final FormData data = fse.getFormData(); + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.organization.add.no_organization_selected")); + + return; + } + SciDepartment department = (SciDepartment) getItemSelectionModel(). getSelectedObject(state); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectAddForm.java index 27d446570..ddab81c50 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectAddForm.java @@ -29,6 +29,7 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciDepartment; +import com.arsdigita.cms.contenttypes.SciDepartmentProjectsCollection; import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -79,11 +80,48 @@ public class SciDepartmentProjectAddForm if (!(this.getSaveCancelSection().getCancelButton(). isSelected(state))) { - department.addProject((SciProject) data.get(ITEM_SEARCH)); + SciProject project = (SciProject) data.get(ITEM_SEARCH); + project = (SciProject) project.getContentBundle().getInstance(department. + getLanguage()); + + department.addProject(project); } init(fse); + } + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_project.no_project_selected")); + return; + } + + SciDepartment department = (SciDepartment) getItemSelectionModel(). + getSelectedObject(state); + SciProject project = (SciProject) data.get(ITEM_SEARCH); + if (!(project.getContentBundle().hasInstance(department.getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_project.no_suitable_language_variant")); + return; + } + + project = (SciProject) project.getContentBundle().getInstance(department. + getLanguage()); + SciDepartmentProjectsCollection projects = department.getProjects(); + projects.addFilter(String.format("id = %s", project.getID().toString())); + if (projects.size() > 0) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_project.already_added")); + } + + projects.close(); } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSubDepartmentAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSubDepartmentAddForm.java index b5ae2eed7..6e5531233 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSubDepartmentAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSubDepartmentAddForm.java @@ -29,6 +29,7 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciDepartment; +import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -76,11 +77,56 @@ public class SciDepartmentSubDepartmentAddForm getSelectedObject(state); if (!(this.getSaveCancelSection().getCancelButton(). - isSelected(state))) { - department.addSubDepartment((SciDepartment) data.get(ITEM_SEARCH)); + isSelected(state))) { + SciDepartment subDepartment = (SciDepartment) data.get(ITEM_SEARCH); + subDepartment = (SciDepartment) subDepartment.getContentBundle(). + getInstance(department.getLanguage()); + + department.addSubDepartment(subDepartment); } init(fse); + } + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_subdepartment.no_department_selected")); + return; + } + + SciDepartment department = (SciDepartment) getItemSelectionModel(). + getSelectedObject(state); + SciDepartment subDepartment = (SciDepartment) data.get(ITEM_SEARCH); + if (!(subDepartment.getContentBundle().hasInstance(department.getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_subdepartment.no_suitable_language_variant")); + return; + } + + subDepartment = (SciDepartment) subDepartment.getContentBundle().getInstance(department.getLanguage()); + + if (department.getID().equals(subDepartment.getID())) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_subdepartment.adding_to_itself")); + return; + } + + SciDepartmentSubDepartmentsCollection subDepartments = department.getSubDepartments(); + subDepartments.addFilter(String.format("id = %s", subDepartment.getID().toString())); + if (subDepartments.size() > 0) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_subdepartment.already_added")); + } + + subDepartments.close(); } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSuperDepartmentForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSuperDepartmentForm.java index 0855a1924..04cac9c04 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSuperDepartmentForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSuperDepartmentForm.java @@ -77,10 +77,48 @@ public class SciDepartmentSuperDepartmentForm getSelectedObject(state); if ((this.getSaveCancelSection().getSaveButton().isSelected(state))) { - department.setSuperDepartment( - (SciDepartment) data.get(ITEM_SEARCH)); + SciDepartment superDepartment = + (SciDepartment) data.get(ITEM_SEARCH); + superDepartment = (SciDepartment) superDepartment.getContentBundle(). + getInstance(department.getLanguage()); - init(fse); + department.setSuperDepartment(superDepartment); } + + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_superdepartment.no_department_selected")); + return; + } + + SciDepartment department = (SciDepartment) getItemSelectionModel(). + getSelectedObject(state); + SciDepartment superDepartment = + (SciDepartment) data.get(ITEM_SEARCH); + if (!(superDepartment.getContentBundle().hasInstance(department. + getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_superdepartment.no_suitable_language_variant")); + return; + } + + superDepartment = (SciDepartment) superDepartment.getContentBundle(). + getInstance(department.getLanguage()); + if (superDepartment.getID().equals(department.getID())) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.department.select_superdepartment.same_department")); + return; + } } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciDepartmentAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciDepartmentAddForm.java index 1224ac652..86a689f12 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciDepartmentAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciDepartmentAddForm.java @@ -90,7 +90,8 @@ public class SciMemberSciDepartmentAddForm statusSelect.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil. globalize("cms.ui.select_one").localize()))); - RelationAttributeCollection statusColl = new RelationAttributeCollection( + RelationAttributeCollection statusColl = + new RelationAttributeCollection( "GenericOrganizationalUnitMemberStatus"); statusColl.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). getLanguage()); @@ -143,7 +144,13 @@ public class SciMemberSciDepartmentAddForm department = step.getSelectedDepartment(); if (department == null) { - member.addDepartment((SciDepartment) data.get(ITEM_SEARCH), + SciDepartment departmentToAdd = (SciDepartment) data.get( + ITEM_SEARCH); + departmentToAdd = (SciDepartment) departmentToAdd. + getContentBundle().getInstance( + member.getLanguage()); + + member.addDepartment(departmentToAdd, (String) data.get( SciMemberSciDepartmentsCollection.MEMBER_ROLE), (String) data.get( @@ -177,7 +184,8 @@ public class SciMemberSciDepartmentAddForm @Override public void submitted(FormSectionEvent fse) throws FormProcessException { - if (getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) { + if (getSaveCancelSection().getCancelButton().isSelected( + fse.getPageState())) { step.setSelectedDepartment(null); step.setSelectedDepartmentRole(null); step.setSelectedDepartmentStatus(null); @@ -185,4 +193,39 @@ public class SciMemberSciDepartmentAddForm init(fse); } } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.department.select_department.no_department_selected")); + return; + } + + SciMember member = (SciMember) getItemSelectionModel().getSelectedObject( + state); + SciDepartment department = (SciDepartment) data.get(ITEM_SEARCH); + if (!(department.getContentBundle().hasInstance(member.getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.department.select_department.no_suitable_language_variant")); + return; + } + + department = (SciDepartment) department.getContentBundle().getInstance(member. + getLanguage()); + SciMemberSciDepartmentsCollection departments = member.getDepartments(); + departments.addFilter(String.format("id = %s", department.getID().toString())); + if (departments.size() > 0) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.department.select_department.already_added")); + } + + departments.close(); + } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciOrganizationAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciOrganizationAddForm.java index 73b06290e..260a86725 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciOrganizationAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciOrganizationAddForm.java @@ -90,7 +90,8 @@ public class SciMemberSciOrganizationAddForm statusSelect.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil. globalize("cms.ui.select_one").localize()))); - RelationAttributeCollection statusColl = new RelationAttributeCollection( + RelationAttributeCollection statusColl = + new RelationAttributeCollection( "GenericOrganizationalUnitMemberStatus"); statusColl.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). getLanguage()); @@ -144,7 +145,12 @@ public class SciMemberSciOrganizationAddForm orga = step.getSelectedOrganization(); if (orga == null) { - member.addOrganization((SciOrganization) data.get(ITEM_SEARCH), + SciOrganization orgaToAdd = (SciOrganization) data.get( + ITEM_SEARCH); + orgaToAdd = (SciOrganization) orgaToAdd.getContentBundle(). + getInstance(member.getLanguage()); + + member.addOrganization(orga, (String) data.get( SciMemberSciOrganizationsCollection.MEMBER_ROLE), (String) data.get( @@ -187,4 +193,42 @@ public class SciMemberSciOrganizationAddForm init(fse); } } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.organization.select_organization.no_orga_selected")); + return; + } + + SciMember member = (SciMember) getItemSelectionModel().getSelectedObject( + state); + SciOrganization orga = (SciOrganization) data.get( + ITEM_SEARCH); + if (!(orga.getContentBundle().hasInstance(member.getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.organization.select_organization.no_suitable_language_variant")); + return; + } + + orga = (SciOrganization) orga.getContentBundle().getInstance(member. + getLanguage()); + SciMemberSciOrganizationsCollection organizations = member. + getOrganizations(); + organizations.addFilter(String.format("id = %s", + orga.getID().toString())); + if (organizations.size() > 0) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.organization.select_organization.already_added")); + } + + organizations.close(); + } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciProjectAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciProjectAddForm.java index ca72c5189..136cb29cf 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciProjectAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciMemberSciProjectAddForm.java @@ -42,7 +42,7 @@ public class SciMemberSciProjectAddForm private Label selectedProjectNameLabel; public SciMemberSciProjectAddForm(ItemSelectionModel itemModel, - SciMemberSciProjectsStep step) { + SciMemberSciProjectsStep step) { super("sciMemberProjectAddForm", itemModel); this.step = step; } @@ -90,7 +90,8 @@ public class SciMemberSciProjectAddForm statusSelect.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil. globalize("cms.ui.select_one").localize()))); - RelationAttributeCollection statusColl = new RelationAttributeCollection( + RelationAttributeCollection statusColl = + new RelationAttributeCollection( "GenericOrganizationalUnitMemberStatus"); statusColl.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). getLanguage()); @@ -143,10 +144,14 @@ public class SciMemberSciProjectAddForm project = step.getSelectedProject(); if (project == null) { - member.addProject((SciProject) data.get(ITEM_SEARCH), - (String) data.get( + SciProject projectToAdd = (SciProject) data.get(ITEM_SEARCH); + projectToAdd = (SciProject) projectToAdd.getContentBundle(). + getInstance(member.getLanguage()); + + member.addProject(projectToAdd, + (String) data.get( SciMemberSciProjectsCollection.MEMBER_ROLE), - (String) data.get( + (String) data.get( SciMemberSciProjectsCollection.STATUS)); } else { SciMemberSciProjectsCollection projects; @@ -177,7 +182,8 @@ public class SciMemberSciProjectAddForm @Override public void submitted(FormSectionEvent fse) throws FormProcessException { - if (getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) { + if (getSaveCancelSection().getCancelButton().isSelected( + fse.getPageState())) { step.setSelectedProject(null); step.setSelectedProjectRole(null); step.setSelectedProjectStatus(null); @@ -185,4 +191,35 @@ public class SciMemberSciProjectAddForm init(fse); } } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.project.select_project.no_project_selected")); + return; + } + + SciMember member = (SciMember) getItemSelectionModel().getSelectedObject( + state); + SciProject project = (SciProject) data.get(ITEM_SEARCH); + if (!(project.getContentBundle().hasInstance(member.getLanguage()))) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.project.select_project.no_suitable_language_variant")); + return; + } + + project = (SciProject) project.getContentBundle().getInstance(member.getLanguage()); + SciMemberSciProjectsCollection projects = member.getProjects(); + projects.addFilter(String.format("id = %s", project.getID().toString())); + if (projects.size() > 0) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "scimember.ui.project.select_project.already_added")); + } + + projects.close(); + } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationDepartmentAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationDepartmentAddForm.java index 29116e822..5d3b68713 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationDepartmentAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationDepartmentAddForm.java @@ -30,6 +30,7 @@ import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciDepartment; import com.arsdigita.cms.contenttypes.SciOrganization; +import com.arsdigita.cms.contenttypes.SciOrganizationDepartmentsCollection; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -96,15 +97,36 @@ public class SciOrganizationDepartmentAddForm final PageState state = fse.getPageState(); final FormData data = fse.getFormData(); + if (data.get(ITEM_SEARCH) == null) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.organization.department.add.no_department_selected")); + + return; + } + SciOrganization orga = (SciOrganization) getItemSelectionModel(). getSelectedObject(state); - - SciDepartment department = (SciDepartment) data.get(ITEM_SEARCH); + SciDepartment department = (SciDepartment) data.get(ITEM_SEARCH); if (!(department.getContentBundle().hasInstance(orga.getLanguage()))) { data.addError( SciOrganizationGlobalizationUtil.globalize( "sciorganization.ui.organization.department.add.no_suitable_language_variant")); + + return; } + + department = (SciDepartment) department.getContentBundle().getInstance(orga. + getLanguage()); + SciOrganizationDepartmentsCollection departments = orga.getDepartments(); + departments.addFilter(String.format("id = %s", + department.getID().toString())); + if (departments.size() > 0) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.organization.department.add.already_added")); + } + + departments.close(); } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationProjectAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationProjectAddForm.java index 1ea63a249..61aedfc6e 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationProjectAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationProjectAddForm.java @@ -29,6 +29,7 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciOrganization; +import com.arsdigita.cms.contenttypes.SciOrganizationProjectsCollection; import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -80,9 +81,48 @@ public class SciOrganizationProjectAddForm if (!(this.getSaveCancelSection().getCancelButton(). isSelected(state))) { - orga.addProject((SciProject) data.get(ITEM_SEARCH)); + SciProject project = (SciProject) data.get(ITEM_SEARCH); + project = (SciProject) project.getContentBundle().getInstance(orga. + getLanguage()); + + orga.addProject(project); } init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.organization.select_project.no_project_selected")); + return; + } + + SciOrganization orga = (SciOrganization) getItemSelectionModel(). + getSelectedObject(state); + SciProject project = (SciProject) data.get(ITEM_SEARCH); + if (!(project.getContentBundle().hasInstance(orga.getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.organization.select_project.no_suitable_language_variant")); + return; + } + + project = (SciProject) project.getContentBundle().getInstance(orga. + getLanguage()); + SciOrganizationProjectsCollection projects = orga.getProjects(); + projects.addFilter(String.format("id = %s", project.getID().toString())); + if (projects.size() > 0) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.organization.select_project.already_added")); + } + + projects.close(); + } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationResources.properties b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationResources.properties index cfebff613..836c6ffce 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationResources.properties +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationResources.properties @@ -180,3 +180,53 @@ scimember.ui.projects.edit_assoc=Edit association sciorganization.ui.project.description=Description of project sciorganization.ui.organization.department.add.no_suitable_language_variant=The selected item has no language variant for the language of the current item. Please add an suitable language variant to the item to add before adding it. sciorganization.ui.department.organization.add.no_suitable_language_variant=The selected item has no language variant for the language of the current item. Please add an suitable language variant to the item to add before adding it. +sciorganization.ui.organization.department.add.already_added=The selected department has already been added to the current organization. +sciorganization.ui.organization.department.add.no_department_selected=No department selected. +sciorganization.ui.department.organization.add.no_organization_selected=No organization selected. +sciorganization.ui.department.select_project.no_project_selected=No project selected. +sciorganization.ui.department.select_project.no_suitable_language_variant=The select project is no available for the language of the current department item.. +sciorganization.ui.department.select_project.already_added=The selected project has already been added to the projects of the current department item. +sciorganization.ui.department.select_subdepartment.no_department_selected=No department selected. +sciorganization.ui.department.select_subdepartment.no_suitable_language_variant=The selected department to add as subdepartment is not available for the language of the current department. +sciorganization.ui.department.select_subdepartment.adding_to_itself=It is not possible to add a department to itself as a sub department. +sciorganization.ui.department.select_subdepartment.already_added=The selected department is already an sub department of the current department. +sciorganization.ui.department.select_superdepartment.no_department_selected=No department selected. +sciorganization.ui.department.select_superdepartment.no_suitable_language_variant=The department selected to set as super department is not available in the language of the current department. +sciorganization.ui.department.select_superdepartment.same_department=It is not possible to set the super department of a department to itself. +scimember.ui.department.select_department.no_department_selected=No department selected. +scimember.ui.department.select_department.no_suitable_language_variant=The department to add is not available for the language of the current member item. +scimember.ui.department.select_department.already_added=The current member is already a member of the selected department. +scimember.ui.organization.select_organization.no_orga_selected=No organization selected. +scimember.ui.organization.select_organization.no_suitable_language_variant=The selected organization is not available for the language of the current member item. +scimember.ui.organization.select_organization.already_added=The current member is already a member of the selected organization. +scimember.ui.project.select_project.no_project_selected=No project selected. +scimember.ui.project.select_project.no_suitable_language_variant=The selected project is not available for the language of the current member item. +scimember.ui.project.select_project.already_added=The current member is already a member of the selected project. +sciorganization.ui.organization.select_project.no_project_selected=No project selected. +sciorganization.ui.organization.select_project.no_suitable_language_variant=The selected project is not available for the language of the current organization item. +sciorganization.ui.organization.select_project.already_added=The selected project is already a project of the current organization. +sciorganization.ui.project.select_department.no_department_selected=No department selected. +sciorganization.ui.project.select_department.no_suitable_language_variant=The selected department is not available for the language of the current project item. +sciorganization.ui.project.select_department.already_added=The current project is already a project of the selected department. +sciorganization.ui.project.select_organization.no_organization_selected=No organization selected. +sciorganization.ui.project.select_organization.no_suitable_language_variant=The selected organization is not available for the language of the current project item. +sciorganization.ui.project.select_organization.already_added=The current project is already a project of the selected organization. +sciorganization.ui.project.select_subproject.no_project_selected=No project selected. +sciorganization.ui.project.select_subproject.no_suitable_language_variant=The selected sub project is not available for the language of the current project. +sciorganization.ui.project.select_subproject.same_project=A project can't be a sub project of itself. +sciorganization.ui.project.select_subproject.already_added=The selected project is already a sub project of the current project. +sciorganization.ui.project.select_superproject.no_project_selected=No project selected. +sciorganization.ui.project.select_superproject.no_suitable_language_variant=The selected super project is not available for the language of the current project item. +sciorganization.ui.project.select_superproject.same_project=A project can't be the super project of itself. +sciorganization.ui.selectDepartment.no_department_selected=No department selected. +sciorganization.ui.selectDepartment.no_suitable_language_variant=The selected department is not avaiable for the language of the current publication item. +sciorganization.ui.selectDepartment.already_added=The current publications has already been added to the list of publications of the selected department. +sciorganization.ui.selectOrganization.no_orga_selected=No organization selected. +sciorganization.ui.selectOrganization.no_suitable_language_variant=The selected organization is not avaiable for the language of the current publication item. +sciorganization.ui.selectOrganization.already_added=The current publication has already been added to the list of publications of the selected organization. +sciorganization.ui.selectProject.no_project_selected=No project selected. +sciorganization.ui.selectProject.no_suitable_language_variant=The selected project is not available for the language of the current publication item. +sciorganization.ui.selectProject.already_added=The current publications has already been added to the publication list of the selected project. +sciorganization.ui.selectPublication.no_publication_selected=No publication selected. +sciorganization.ui.selectPublication.no_suitable_language_variant=The selected publication is not available for the language of the current item. +sciorganization.ui.selectPublication.already_added=The selected publication has already been added to the publication list of the current item. diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationResources_de.properties b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationResources_de.properties index 21caea601..50bd4fdf6 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationResources_de.properties +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationResources_de.properties @@ -180,3 +180,53 @@ scimember.ui.projects.edit_assoc=Verkn\u00fcpfung bearbeiten sciorganization.ui.project.description=Projektbeschreibung sciorganization.ui.organization.department.add.no_suitable_language_variant=Das ausgew\u00e4hlte ContentItem besitzt keine Sprachvariante f\u00fcr die Sprache dieses Items und kann daher nicht hinzugef\u00fcgt werden. sciorganization.ui.department.organization.add.no_suitable_language_variant=Das ausgew\u00e4hlte ContentItem besitzt keine Sprachvariante f\u00fcr die Sprache dieses Items und kann daher nicht hinzugef\u00fcgt werden. +sciorganization.ui.organization.department.add.already_added=Die ausgew\u00e4hlte Abteilung wurde der aktuellen Organisation bereits hinzugef\u00fcgt. +sciorganization.ui.organization.department.add.no_department_selected=Keine Abteilung ausgew\u00e4hlt. +sciorganization.ui.department.organization.add.no_organization_selected=Keine Organisation ausgew\u00e4hlt. +sciorganization.ui.department.select_project.no_project_selected=Kein Project ausgew\u00e4hlt. +sciorganization.ui.department.select_project.no_suitable_language_variant=Das ausgew\u00e4hlte Projekt ist f\u00fcr die Sprache des aktuellen Abteilungs-Items nicht verf\u00fcgbar. +sciorganization.ui.department.select_project.already_added=Das ausgew\u00e4hlte Projekt wurde dem aktuellen Abteilungs-Item bereits hinzugef\u00fcgt. +sciorganization.ui.department.select_subdepartment.no_department_selected=Keine Abteilung ausgew\u00e4hlt. +sciorganization.ui.department.select_subdepartment.no_suitable_language_variant=Die zum hinzuf\u00fcgen als Unterabteilung ausw\u00e4hlte Abteilung ist f\u00fcr die Sprache der aktuellen Abteilung nicht verf\u00fcgbar. +sciorganization.ui.department.select_subdepartment.adding_to_itself=Eine Abteilung kann nicht sich selbst als Unterabteilung zugewiesen werden. +sciorganization.ui.department.select_subdepartment.already_added=Die ausgew\u00e4hlte Abteilung ist bereits eine Unterabteilung der aktuellen Abteilung. +sciorganization.ui.department.select_superdepartment.no_department_selected=Keine Abteilung ausgew\u00e4hlt. +sciorganization.ui.department.select_superdepartment.no_suitable_language_variant=Die als \u00fcbergeordnete Abteilung ausgew\u00e4hlte Abteilung ist nicht in der Sprache der aktuellen Abteilung verf\u00fcgbar. +sciorganization.ui.department.select_superdepartment.same_department=Eine Abteilung kann nicht ihre eigene \u00fcbergeordnete Abteilung sein. +scimember.ui.department.select_department.no_department_selected=Keine Abteilung ausgew\u00e4hlt. +scimember.ui.department.select_department.no_suitable_language_variant=Die ausgew\u00e4hlte Abteilung ist nicht f\u00fcr die Sprache des aktuellen Mitglieds-Items verf\u00fcgbar. +scimember.ui.department.select_department.already_added=Das aktuelle Mitglieder ist bereits ein Mitglied der ausgew\u00e4hlten Abteilung. +scimember.ui.organization.select_organization.no_orga_selected=Keine Organisation ausgew\u00e4hlt. +scimember.ui.organization.select_organization.no_suitable_language_variant=Die ausgew\u00e4hlte Organisation ist f\u00fcr die Sprache des aktuellen Mitglieds-Items nicht verf\u00fcgbar. +scimember.ui.organization.select_organization.already_added=Das aktuelle Mitglied ist bereits Mitglied der ausgew\u00e4hlten Organisation. +scimember.ui.project.select_project.no_project_selected=Kein Projekt ausgew\u00e4hlt. +scimember.ui.project.select_project.no_suitable_language_variant=Das ausgew\u00e4hlte Projekt ist f\u00fcr die Sprache des aktuellen Mitglieds-Items nicht verf\u00fcgbar. +scimember.ui.project.select_project.already_added=Das aktuelle Mitglied ist bereits ein Mitglied des ausgew\u00e4hlten Projektes. +sciorganization.ui.organization.select_project.no_project_selected=Kein Projekt ausgew\u00e4hlt. +sciorganization.ui.organization.select_project.no_suitable_language_variant=Das ausgew\u00e4hlte Projekt ist nicht f\u00fcr die Sprache des aktuellen Organisations-Items verf\u00fcgbar. +sciorganization.ui.organization.select_project.already_added=Das ausgew\u00e4hlte Projekt ist bereits ein Projekt der aktuellen Organisation. +sciorganization.ui.project.select_department.no_department_selected=Kein Projekt ausgew\u00e4hlt. +sciorganization.ui.project.select_department.no_suitable_language_variant=Die ausgew\u00e4hlte Abteilung ist nicht f\u00fcr die Sprache des aktuellen Projekt-Items verf\u00fcgbar. +sciorganization.ui.project.select_department.already_added=Das aktuelle Projekt ist bereits ein Projekt der ausgew\u00e4hlten Abteilung. +sciorganization.ui.project.select_organization.no_organization_selected=Keine Organisation ausgew\u00e4hlt. +sciorganization.ui.project.select_organization.no_suitable_language_variant=Die ausgew\u00e4hlte Organisation ist nicht f\u00fcr die Sprache des aktuellen Projekt-Items verf\u00fcgbar. +sciorganization.ui.project.select_organization.already_added=Das aktuelle Projekt is bereits ein Projekt der der ausgew\u00e4hlten Organisation. +sciorganization.ui.project.select_subproject.no_project_selected=Kein Projekt ausgew\u00e4hlt. +sciorganization.ui.project.select_subproject.no_suitable_language_variant=Das ausgew\u00e4hlte Unterprojekt ist nicht f\u00fcr die Sprache des aktuellen Projektes verf\u00fcgbar. +sciorganization.ui.project.select_subproject.same_project=Ein Projekt kann kein Unterprojekt von sich selbst sein. +sciorganization.ui.project.select_subproject.already_added=Das ausgew\u00e4hlte Projekt ist bereits ein Unterprojekt des aktuellen Projektes. +sciorganization.ui.project.select_superproject.no_project_selected=Kein Projekt ausgew\u00e4hlt. +sciorganization.ui.project.select_superproject.no_suitable_language_variant=Das ausgew\u00e4hlte Hauptprojekt ist nicht f\u00fcr die Sprache des aktuellen Projektes verf\u00fcgbar. +sciorganization.ui.project.select_superproject.same_project=Ein Projekt kann nicht sein eigenes Hauptprojekt sein. +sciorganization.ui.selectDepartment.no_department_selected=Keine Abteilung ausgew\u00e4hlt. +sciorganization.ui.selectDepartment.no_suitable_language_variant=Die ausgew\u00e4hlte Abteilung ist nicht f\u00fcr die Sprache des aktuellen Publikations-Items verf\u00fcgbar. +sciorganization.ui.selectDepartment.already_added=Die aktuelle Publikation wurde bereits der Publikationsliste der ausgew\u00e4hlten Abteilung hinzugef\u00fcgt. +sciorganization.ui.selectOrganization.no_orga_selected=Keine Organisation ausgew\u00e4hlt. +sciorganization.ui.selectOrganization.no_suitable_language_variant=Die ausgew\u00e4hlte Organisation ist nicht f\u00fcr die Sprache der aktuellen Publikation verf\u00fcgbar. +sciorganization.ui.selectOrganization.already_added=Die aktuelle Publikation wurde bereits der Liste der Publikationen der ausgew\u00e4hlten Organisation hinzugef\u00fcgt. +sciorganization.ui.selectProject.no_project_selected=Kein Projekt ausgew\u00e4hlt. +sciorganization.ui.selectProject.no_suitable_language_variant=Das ausgew\u00e4hlte Projekt ist nicht f\u00fcr die Sprache des aktuellen Publikations-Items verf\u00fcgbar. +sciorganization.ui.selectProject.already_added=Die aktuelle Publikation wurde bereits der Publikationsliste des ausgew\u00e4hlten Projektes hinzugef\u00fcgt. +sciorganization.ui.selectPublication.no_publication_selected=Keine Publikation ausgew\u00e4hlt. +sciorganization.ui.selectPublication.no_suitable_language_variant=Die ausgew\u00e4hlte Publikation ist nicht f\u00fcr die Sprache des aktuellen Items verf\u00fcgbar. +sciorganization.ui.selectPublication.already_added=Die ausgew\u00e4hlte Publikation ist bereits Teil der Publikationsliste des aktuellen Items. diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDepartmentAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDepartmentAddForm.java index 8eba6fecf..d0fa62f67 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDepartmentAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDepartmentAddForm.java @@ -30,6 +30,7 @@ import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciDepartment; import com.arsdigita.cms.contenttypes.SciProject; +import com.arsdigita.cms.contenttypes.SciProjectDepartmentsCollection; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -77,10 +78,50 @@ public class SciProjectDepartmentAddForm getSelectedObject(state); if (!(this.getSaveCancelSection().getCancelButton(). - isSelected(state))) { - project.addDepartment((SciDepartment) data.get(ITEM_SEARCH)); + isSelected(state))) { + SciDepartment department = (SciDepartment) data.get(ITEM_SEARCH); + department = (SciDepartment) department.getContentBundle(). + getInstance(project.getLanguage()); - init(fse); + project.addDepartment(department); } + + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_department.no_department_selected")); + return; + } + + SciProject project = (SciProject) getItemSelectionModel(). + getSelectedObject(state); + SciDepartment department = (SciDepartment) data.get(ITEM_SEARCH); + if (!(department.getContentBundle().hasInstance(project.getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_department.no_suitable_language_variant")); + return; + } + + department = (SciDepartment) department.getContentBundle().getInstance(project. + getLanguage()); + SciProjectDepartmentsCollection departments = project.getDepartments(); + departments.addFilter(String.format("id = %s", department.getID(). + toString())); + if (departments.size() > 0) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_department.already_added")); + } + + departments.close(); } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectOrganizationsAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectOrganizationsAddForm.java index a28267ba8..4c580873c 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectOrganizationsAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectOrganizationsAddForm.java @@ -30,6 +30,7 @@ import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciOrganization; import com.arsdigita.cms.contenttypes.SciProject; +import com.arsdigita.cms.contenttypes.SciProjectOrganizationsCollection; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -78,9 +79,44 @@ public class SciProjectOrganizationsAddForm if (!(this.getSaveCancelSection().getCancelButton(). isSelected(state))) { - project.addOrganization((SciOrganization) data.get(ITEM_SEARCH)); + SciOrganization orga = (SciOrganization) data.get(ITEM_SEARCH); + orga = (SciOrganization) orga.getContentBundle().getInstance(project. + getLanguage()); - init(fse); - } + project.addOrganization(orga); + } + + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_organization.no_organization_selected")); + return; + } + + SciProject project = (SciProject) getItemSelectionModel(). + getSelectedObject(state); + SciOrganization orga = (SciOrganization) data.get(ITEM_SEARCH); + if (!(orga.getContentBundle().hasInstance(project.getLanguage()))) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_organization.no_suitable_language_variant")); + return; + } + + orga = (SciOrganization) orga.getContentBundle().getInstance(project.getLanguage()); + SciProjectOrganizationsCollection organizations = project.getOrganizations(); + organizations.addFilter(String.format("id = %s", orga.getID().toString())); + if (organizations.size() > 0) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_organization.already_added")); + } + + organizations.close(); } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSubprojectAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSubprojectAddForm.java index b10a97d81..eabf5e335 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSubprojectAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSubprojectAddForm.java @@ -29,6 +29,7 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciProject; +import com.arsdigita.cms.contenttypes.SciProjectSubProjectsCollection; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -76,9 +77,54 @@ public class SciProjectSubprojectAddForm if (!(this.getSaveCancelSection().getCancelButton(). isSelected(state))) { - project.addSubProject((SciProject) data.get(ITEM_SEARCH)); + SciProject subProject = (SciProject) data.get(ITEM_SEARCH); + subProject = (SciProject) subProject.getContentBundle(). + getInstance(project.getLanguage()); - init(fse); - } + project.addSubProject(subProject); + } + + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_subproject.no_project_selected")); + return; + } + + SciProject project = (SciProject) getItemSelectionModel(). + getSelectedObject(state); + SciProject subProject = (SciProject) data.get(ITEM_SEARCH); + if (!(subProject.getContentBundle().hasInstance(project.getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_subproject.no_suitable_language_variant")); + return; + } + + subProject = (SciProject) subProject.getContentBundle().getInstance(project. + getLanguage()); + if (subProject.getID().equals(project.getID())) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_subproject.same_project")); + return; + } + + SciProjectSubProjectsCollection subProjects = project.getSubProjects(); + subProjects.addFilter(String.format("id = %s", subProject.getID(). + toString())); + if(subProjects.size() > 0) { + data.addError(SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_subproject.already_added")); + } + + subProjects.close(); } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSuperProjectSetForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSuperProjectSetForm.java index c66c30dd8..68ade854c 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSuperProjectSetForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSuperProjectSetForm.java @@ -69,16 +69,53 @@ public class SciProjectSuperProjectSetForm @Override public void process(FormSectionEvent fse) throws FormProcessException { - FormData data = fse.getFormData(); - PageState state = fse.getPageState(); - SciProject project = (SciProject) getItemSelectionModel(). - getSelectedObject(state); + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + SciProject project = (SciProject) getItemSelectionModel(). + getSelectedObject(state); - if (this.getSaveCancelSection().getSaveButton(). - isSelected(state)) { - project.setSuperProject((SciProject) data.get(ITEM_SEARCH)); + if (this.getSaveCancelSection().getSaveButton(). + isSelected(state)) { + SciProject superProject = (SciProject) data.get(ITEM_SEARCH); + superProject = (SciProject) superProject.getContentBundle(). + getInstance(project.getLanguage()); + + project.setSuperProject(superProject); + } + + init(fse); + } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_superproject.no_project_selected")); + return; + } + + SciProject project = (SciProject) getItemSelectionModel(). + getSelectedObject(state); + SciProject superProject = (SciProject) data.get(ITEM_SEARCH); + if (!(superProject.getContentBundle().hasInstance(project.getLanguage()))) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_superproject.no_suitable_language_variant")); + return; + } + + superProject = (SciProject) superProject.getContentBundle().getInstance(project. + getLanguage()); + if (superProject.getID().equals(project.getID())) { + data.addError( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.select_superproject.same_project")); + return; + } - init(fse); - } } } diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentAddForm.java index 83ea4ee52..429970882 100644 --- a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentAddForm.java +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciDepartmentAddForm.java @@ -29,9 +29,12 @@ 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.PublicationSciDepartmentCollection; +import com.arsdigita.cms.contenttypes.SciDepartmentPublicationsCollection; import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; /** @@ -78,8 +81,9 @@ public class PublicationSciDepartmentAddForm if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { SciDepartmentWithPublications department = (SciDepartmentWithPublications) data. - get( - ITEM_SEARCH); + get(ITEM_SEARCH); + department = (SciDepartmentWithPublications) department. + getContentBundle().getInstance(publication.getLanguage()); DataObject link = publication.add("departments", department); link.set("publicationOrder", Integer.valueOf((int) department. getPublications().size())); @@ -89,4 +93,41 @@ public class PublicationSciDepartmentAddForm init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectDepartment.no_department_selected")); + return; + } + + Publication publication = (Publication) getItemSelectionModel(). + getSelectedObject(state); + SciDepartmentWithPublications department = + (SciDepartmentWithPublications) data.get( + ITEM_SEARCH); + if (!(department.getContentBundle().hasInstance(publication.getLanguage()))) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectDepartment.no_suitable_language_variant")); + return; + } + + department = (SciDepartmentWithPublications) department.getContentBundle().getInstance(publication.getLanguage()); + PublicationSciDepartmentCollection departments = new PublicationSciDepartmentCollection((DataCollection) publication. + get("departments")); + departments.addFilter(String.format("id = %s", department.getID().toString())); + if (departments.size() > 0) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectDepartment.already_added")); + } + + departments.close(); + } } diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationAddForm.java index d66d5e5f2..8332009b8 100644 --- a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationAddForm.java +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciOrganizationAddForm.java @@ -29,9 +29,11 @@ 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.PublicationSciOrganizationCollection; import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; /** @@ -78,13 +80,55 @@ public class PublicationSciOrganizationAddForm if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { SciOrganizationWithPublications organization = (SciOrganizationWithPublications) data. - get( - ITEM_SEARCH); + get(ITEM_SEARCH); + organization = (SciOrganizationWithPublications) organization. + getContentBundle().getInstance(publication.getLanguage()); DataObject link = publication.add("organizations", organization); - link.set("publicationOrder", Integer.valueOf((int)organization.getPublications().size())); + link.set("publicationOrder", Integer.valueOf((int) organization. + getPublications().size())); link.save(); } init(fse); } + + @Override + public void validate(final FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganization.ui.selectOrganization.no_orga_selected")); + return; + } + + Publication publication = (Publication) getItemSelectionModel(). + getSelectedObject(state); + SciOrganizationWithPublications organization = + (SciOrganizationWithPublications) data. + get(ITEM_SEARCH); + if (!(organization.getContentBundle().hasInstance(publication. + getLanguage()))) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectOrganization.no_suitable_language_variant")); + return; + } + + organization = (SciOrganizationWithPublications) organization. + getContentBundle().getInstance(publication.getLanguage()); + PublicationSciOrganizationCollection organizations = + new PublicationSciOrganizationCollection((DataCollection) publication. + get("organizations")); + organizations.addFilter(String.format("id = %s", organization.getID().toString())); + if (organizations.size() > 0 ) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectOrganization.already_added")); + } + + organizations.close(); + } } diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectAddForm.java index 8d56ee065..27397cf59 100644 --- a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectAddForm.java +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationSciProjectAddForm.java @@ -29,9 +29,11 @@ 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.PublicationSciProjectCollection; import com.arsdigita.cms.contenttypes.SciProjectWithPublications; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; /** @@ -79,6 +81,8 @@ public class PublicationSciProjectAddForm SciProjectWithPublications project = (SciProjectWithPublications) data.get( ITEM_SEARCH); + project = (SciProjectWithPublications) project.getContentBundle(). + getInstance(publication.getLanguage()); DataObject link = publication.add("projects", project); link.set("publicationOrder", Integer.valueOf((int) project. getPublications().size())); @@ -87,4 +91,41 @@ public class PublicationSciProjectAddForm init(fse); } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganization.ui.selectProject.no_project_selected")); + return; + } + + Publication publication = (Publication) getItemSelectionModel(). + getSelectedObject(state); + SciProjectWithPublications project = + (SciProjectWithPublications) data.get( + ITEM_SEARCH); + if (!(project.getContentBundle().hasInstance(publication.getLanguage()))) { + data.addError(SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganization.ui.selectProject.no_suitable_language_variant")); + return; + } + + project = (SciProjectWithPublications) project.getContentBundle().getInstance(publication.getLanguage()); + PublicationSciProjectCollection projects = new PublicationSciProjectCollection((DataCollection) publication. + get("projects")); + projects.addFilter(String.format("id = %s", project.getID().toString())); + if (projects.size() > 0) { + data.addError(SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganization.ui.selectProject.already_added")); + } + + projects.close(); + } } diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsAddForm.java index af2a92ab1..b669e25fe 100644 --- a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsAddForm.java +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentPublicationsAddForm.java @@ -29,6 +29,7 @@ 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.SciDepartmentPublicationsCollection; import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -69,14 +70,57 @@ public class SciDepartmentPublicationsAddForm public void process(final FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - SciDepartmentWithPublications organization = + SciDepartmentWithPublications department = (SciDepartmentWithPublications) getItemSelectionModel(). getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - organization.addPublication((Publication) data.get(ITEM_SEARCH)); + Publication publication = (Publication) data.get(ITEM_SEARCH); + publication = (Publication) publication.getContentBundle(). + getInstance(department.getLanguage()); + + department.addPublication(publication); } init(fse); } + + @Override + public void validate(final FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectPublication.no_publication_selected")); + return; + } + + SciDepartmentWithPublications department = + (SciDepartmentWithPublications) getItemSelectionModel(). + getSelectedObject(state); + Publication publication = (Publication) data.get(ITEM_SEARCH); + if (!(publication.getContentBundle().hasInstance( + department.getLanguage()))) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectPublication.no_suitable_language_variant")); + return; + } + + publication = (Publication) publication.getContentBundle().getInstance( + department.getLanguage()); + SciDepartmentPublicationsCollection publications = department. + getPublications(); + publications.addFilter(String.format("id = %s", publication.getID(). + toString())); + if (publications.size() > 0) { + data.addError(SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganization.ui.selectPublication.already_added")); + } + + publications.close(); + } } diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsAddForm.java index 2024b075a..8d50e8642 100644 --- a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsAddForm.java +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationPublicationsAddForm.java @@ -29,6 +29,7 @@ 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.SciOrganizationPublicationsCollection; import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -74,9 +75,51 @@ public class SciOrganizationPublicationsAddForm getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - organization.addPublication((Publication) data.get(ITEM_SEARCH)); + Publication publication = (Publication) data.get(ITEM_SEARCH); + publication = (Publication) publication.getContentBundle(). + getInstance(organization.getLanguage()); + organization.addPublication(publication); } init(fse); } + + @Override + public void validate(final FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectPublication.no_publication_selected")); + return; + } + + SciOrganizationWithPublications organization = + (SciOrganizationWithPublications) getItemSelectionModel(). + getSelectedObject(state); + Publication publication = (Publication) data.get(ITEM_SEARCH); + if (!(publication.getContentBundle().hasInstance( + organization.getLanguage()))) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciorganization.ui.selectPublication.no_suitable_language_variant")); + return; + } + + publication = (Publication) publication.getContentBundle().getInstance( + organization.getLanguage()); + SciOrganizationPublicationsCollection publications = organization. + getPublications(); + publications.addFilter(String.format("id = %s", publication.getID(). + toString())); + if (publications.size() > 0) { + data.addError(SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciorganization.ui.selectPublication.already_added")); + } + + publications.close(); + } } diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsAddForm.java b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsAddForm.java index 76d3910c8..ee51c5bd9 100644 --- a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsAddForm.java +++ b/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/SciProjectPublicationsAddForm.java @@ -29,6 +29,7 @@ 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.SciProjectPublicationsCollection; import com.arsdigita.cms.contenttypes.SciProjectWithPublications; import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -74,9 +75,51 @@ public class SciProjectPublicationsAddForm getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - project.addPublication((Publication) data.get(ITEM_SEARCH)); + Publication publication = (Publication) data.get(ITEM_SEARCH); + publication = (Publication) publication.getContentBundle(). + getInstance(project.getLanguage()); + project.addPublication(publication); } init(fse); } + + @Override + public void validate(final FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciproject.ui.selectPublication.no_publication_selected")); + return; + } + + SciProjectWithPublications project = + (SciProjectWithPublications) getItemSelectionModel(). + getSelectedObject(state); + Publication publication = (Publication) data.get(ITEM_SEARCH); + if (!(publication.getContentBundle().hasInstance( + project.getLanguage()))) { + data.addError( + SciOrganizationWithPublicationsGlobalizationUtil.globalize( + "sciproject.ui.selectPublication.no_suitable_language_variant")); + return; + } + + publication = (Publication) publication.getContentBundle().getInstance( + project.getLanguage()); + SciProjectPublicationsCollection publications = + project.getPublications(); + publications.addFilter(String.format("id = %s", publication.getID(). + toString())); + if (publications.size() > 0) { + data.addError(SciOrganizationWithPublicationsGlobalizationUtil. + globalize( + "sciproject.ui.selectPublication.already_added")); + } + + publications.close(); + } }