Ergänzungen für GenericPerson und damit alle anderen Personentypen:
- Feld dabinId, vorübergehend für Import von DaBIn-Daten - Alias/Früherer Name für Personen. Es ist damit möglich von einem Personen-Datensatz auf einen anderen Personendatensatz mit einem früheren Namen der Person zu verweisen. Dies ist z.B. hilfreich bei Namensänderungen bei Heiraten etc. Verknüpfungen mit dem alten Personendatensatz (z.B. Publikation->Autor-Verknüpfungen) können bestehen bleiben, es ist aber möglich über die Alias-Beziehung vom neuen Namen auf die Vernüpfungen mit dem alten Namen zuzugreifen. Folgende Datenbank-Änderungen sind für vorhandene Datenbanken notwendig: ALTER TABLE cms_persons ADD COLUMN dabinId INTEGER; ALTER TABLE cms_persons ADD COLUMN aliasId INTEGER REFERENCES cms_persons; git-svn-id: https://svn.libreccm.org/ccm/trunk@1081 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
62139b6b88
commit
3502f9dd4e
|
|
@ -30,5 +30,10 @@ object type GenericPerson extends ContentPage {
|
|||
Date[0..1] birthdate = cms_persons.birthdate DATE;
|
||||
String[0..1] gender = cms_persons.gender CHAR(1);
|
||||
|
||||
GenericPerson[0..1] alias = join cms_persons.alias_id
|
||||
to cms_persons.person_id;
|
||||
|
||||
Integer[0..1] dabinId = cms_persons.dabin_id INTEGER;
|
||||
|
||||
reference key (cms_persons.person_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1076,3 +1076,12 @@ cms.ui.type.permissions.actions.restrict_to_this_role=Restrict to this role
|
|||
cms.ui.type.permissions.can_use.grant=Grant permissions to this role
|
||||
cms.ui.type.permissions.actions.revoke=Revoke permission
|
||||
cms.ui.type.permissions.can_use.no=No
|
||||
cms.contenttypes.ui.person.set_alias=Set former name
|
||||
cms.contenttypes.ui.person.delete_alias=Remove former name
|
||||
cms.contenttypes.ui.person.alias.none=No former name
|
||||
cms.contenttypes.ui.person.alias=Former name
|
||||
cms.contenttypes.ui.person.alias.select=Select former name
|
||||
cms.contenttypes.ui.contact.alias.select.add=Select former name
|
||||
cms.contenttypes.person.alias.select.wrong_type=No person selected
|
||||
cms.contenttypes.person.alias.select.same_as_person=Selected person is the same as the current person. Alias and person can't be identical.
|
||||
cms.contenttypes.person.alias.select.no_suitable_language_variant=The selected item has no suitable language variant.
|
||||
|
|
|
|||
|
|
@ -1067,3 +1067,12 @@ cms.ui.type.permissions.actions.restrict_to_this_role=Auf diese Rolle beschr\u00
|
|||
cms.ui.type.permissions.can_use.grant=Rolle berechtigen
|
||||
cms.ui.type.permissions.actions.revoke=Berechtigung widerrufen
|
||||
cms.ui.type.permissions.can_use.no=Nein
|
||||
cms.contenttypes.ui.person.set_alias=Fr\u00fcheren Namen setzen
|
||||
cms.contenttypes.ui.person.delete_alias=Fr\u00fcheren Namen entfernen
|
||||
cms.contenttypes.ui.person.alias.none=Kein fr\u00fcherer Name
|
||||
cms.contenttypes.ui.person.alias=Fr\u00fcherer Name
|
||||
cms.contenttypes.ui.person.alias.select=Fr\u00fcheren Namen ausw\u00e4hlen
|
||||
cms.contenttypes.ui.contact.alias.select.add=Fr\u00fcheren Namen ausw\u00e4hlen
|
||||
cms.contenttypes.person.alias.select.wrong_type=Kein Personendatensatz ausgew\u00e4hlt
|
||||
cms.contenttypes.person.alias.select.same_as_person=Der ausgew\u00e4hlte Datensatz ist der gleiche Datensatz wie der aktuelle Datensatz. Alias und Person k\u00f6nnen nicht identisch sein.
|
||||
cms.contenttypes.person.alias.select.no_suitable_language_variant=Das ausgew\u00e4hlte Item hat keine passende Sprachvariante.
|
||||
|
|
|
|||
|
|
@ -15,3 +15,12 @@ cms.ui.type.permissions.actions.restrict_to_this_role=
|
|||
cms.ui.type.permissions.can_use.grant=
|
||||
cms.ui.type.permissions.actions.revoke=
|
||||
cms.ui.type.permissions.can_use.no=
|
||||
cms.contenttypes.ui.person.set_alias=
|
||||
cms.contenttypes.ui.person.delete_alias=
|
||||
cms.contenttypes.ui.person.alias.none=
|
||||
cms.contenttypes.ui.person.alias=
|
||||
cms.contenttypes.ui.person.alias.select=
|
||||
cms.contenttypes.ui.contact.alias.select.add=
|
||||
cms.contenttypes.person.alias.select.wrong_type=
|
||||
cms.contenttypes.person.alias.select.same_as_person=
|
||||
cms.contenttypes.person.alias.select.no_suitable_language_variant=
|
||||
|
|
|
|||
|
|
@ -546,3 +546,12 @@ cms.ui.type.permissions.actions.restrict_to_this_role=
|
|||
cms.ui.type.permissions.can_use.grant=
|
||||
cms.ui.type.permissions.actions.revoke=
|
||||
cms.ui.type.permissions.can_use.no=
|
||||
cms.contenttypes.ui.person.set_alias=
|
||||
cms.contenttypes.ui.person.delete_alias=
|
||||
cms.contenttypes.ui.person.alias.none=
|
||||
cms.contenttypes.ui.person.alias=
|
||||
cms.contenttypes.ui.person.alias.select=
|
||||
cms.contenttypes.ui.contact.alias.select.add=
|
||||
cms.contenttypes.person.alias.select.wrong_type=
|
||||
cms.contenttypes.person.alias.select.same_as_person=
|
||||
cms.contenttypes.person.alias.select.no_suitable_language_variant=
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.arsdigita.cms.ContentType;
|
|||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.RelationAttributeInterface;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
|
|
@ -49,8 +50,10 @@ public class GenericPerson extends ContentPage implements
|
|||
public static final String CONTACTS = "contacts";
|
||||
public static final String CONTACTS_KEY = "link_key";
|
||||
public static final String CONTACTS_ORDER = "link_order";
|
||||
public static final String ALIAS = "alias";
|
||||
public static final String DABIN_ID = "dabinId";
|
||||
private static final String RELATION_ATTRIBUTES =
|
||||
"contacts.link_key:GenericContactType";
|
||||
"contacts.link_key:GenericContactType";
|
||||
/** Data object type for this domain object */
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.contenttypes.GenericPerson";
|
||||
|
|
@ -138,8 +141,28 @@ public class GenericPerson extends ContentPage implements
|
|||
set(GENDER, gender);
|
||||
}
|
||||
|
||||
public GenericPerson getAlias() {
|
||||
return (GenericPerson) DomainObjectFactory.newInstance((DataObject) get(ALIAS));
|
||||
}
|
||||
|
||||
public void setAlias(final GenericPerson alias) {
|
||||
set(ALIAS, alias);
|
||||
}
|
||||
|
||||
public void unsetAlias() {
|
||||
set(ALIAS, null);
|
||||
}
|
||||
|
||||
public Integer getDabinId() {
|
||||
return (Integer)get(DABIN_ID);
|
||||
}
|
||||
|
||||
public void setDabinId(final Integer dabinId) {
|
||||
set(DABIN_ID, dabinId);
|
||||
}
|
||||
|
||||
/**
|
||||
* A convinient method which combines {@code titlePre}, {@code givenName),
|
||||
* A convenient method which combines {@code titlePre}, {@code givenName),
|
||||
* {@code surname} and {@code titlePost}.
|
||||
*
|
||||
* @return {@code titlePre} {@code givenName) {@code surnameName} {@code titlePost}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import com.arsdigita.domain.DomainObject;
|
|||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.SimpleComponent;
|
||||
import com.arsdigita.cms.contenttypes.GenericAddress;
|
||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
|
|
@ -33,28 +32,54 @@ public class GenericContactAddressPropertiesStep extends SimpleEditStep {
|
|||
public static final String EDIT_ADDRESS_SHEET_NAME = "editAddress";
|
||||
public static final String CHANGE_ADDRESS_SHEET_NAME = "changeAddress";
|
||||
public static final String DELETE_ADDRESS_SHEET_NAME = "deleteAddress";
|
||||
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
/** Creates a new instance of GenericContactAddressPropertiesStep */
|
||||
public GenericContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||
public GenericContactAddressPropertiesStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, "");
|
||||
}
|
||||
|
||||
public GenericContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
|
||||
public GenericContactAddressPropertiesStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
this.itemModel = itemModel;
|
||||
|
||||
BasicPageForm attachAddressSheet = new GenericContactAttachAddressPropertyForm(itemModel, this);
|
||||
BasicPageForm reattachAddressSheet = new GenericContactAttachAddressPropertyForm(itemModel, this);
|
||||
BasicPageForm editAddressSheet = new GenericContactEditAddressPropertyForm(itemModel, this);
|
||||
BasicPageForm deleteAddressSheet = new GenericContactDeleteAddressForm(itemModel, this);
|
||||
BasicPageForm attachAddressSheet =
|
||||
new GenericContactAttachAddressPropertyForm(itemModel,
|
||||
this);
|
||||
BasicPageForm reattachAddressSheet =
|
||||
new GenericContactAttachAddressPropertyForm(itemModel,
|
||||
this);
|
||||
BasicPageForm editAddressSheet =
|
||||
new GenericContactEditAddressPropertyForm(itemModel, this);
|
||||
BasicPageForm deleteAddressSheet = new GenericContactDeleteAddressForm(
|
||||
itemModel, this);
|
||||
|
||||
add(ADD_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.attach_address").localize(), new AttachAddressWorkflowLockedComponentAccess(attachAddressSheet, itemModel), attachAddressSheet.getSaveCancelSection().getCancelButton());
|
||||
add(CHANGE_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.reattach_address").localize(), new EditAddressWorkflowLockedComponentAccess(reattachAddressSheet, itemModel), reattachAddressSheet.getSaveCancelSection().getCancelButton());
|
||||
add(EDIT_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.edit_address").localize(), new EditAddressWorkflowLockedComponentAccess(editAddressSheet, itemModel), editAddressSheet.getSaveCancelSection().getCancelButton());
|
||||
add(DELETE_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.delete_address").localize(), new EditAddressWorkflowLockedComponentAccess(deleteAddressSheet, itemModel), deleteAddressSheet.getSaveCancelSection().getCancelButton());
|
||||
add(ADD_ADDRESS_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.contact.attach_address").localize(),
|
||||
new AttachAddressWorkflowLockedComponentAccess(attachAddressSheet,
|
||||
itemModel),
|
||||
attachAddressSheet.getSaveCancelSection().getCancelButton());
|
||||
add(CHANGE_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.
|
||||
globalize("cms.contenttypes.ui.contact.reattach_address").
|
||||
localize(), new EditAddressWorkflowLockedComponentAccess(
|
||||
reattachAddressSheet, itemModel), reattachAddressSheet.
|
||||
getSaveCancelSection().getCancelButton());
|
||||
add(EDIT_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.
|
||||
globalize("cms.contenttypes.ui.contact.edit_address").localize(),
|
||||
new EditAddressWorkflowLockedComponentAccess(editAddressSheet,
|
||||
itemModel),
|
||||
editAddressSheet.getSaveCancelSection().getCancelButton());
|
||||
add(DELETE_ADDRESS_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.contact.delete_address").localize(),
|
||||
new EditAddressWorkflowLockedComponentAccess(deleteAddressSheet,
|
||||
itemModel),
|
||||
deleteAddressSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
/* Set the displayComponent for this step */
|
||||
setDisplayComponent(getAddressPropertySheet(itemModel));
|
||||
|
|
@ -63,53 +88,71 @@ public class GenericContactAddressPropertiesStep extends SimpleEditStep {
|
|||
|
||||
public static Component getAddressPropertySheet(ItemSelectionModel itemModel) {
|
||||
|
||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
|
||||
itemModel);
|
||||
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.address").localize(), "address." + GenericAddress.ADDRESS);
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.address.address").localize(),
|
||||
"address." + GenericAddress.ADDRESS);
|
||||
if (!GenericContact.getConfig().getHideAddressPostalCode()) {
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.postal_code").localize(), "address." + GenericAddress.POSTAL_CODE);
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.address.postal_code").localize(),
|
||||
"address." + GenericAddress.POSTAL_CODE);
|
||||
}
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.city").localize(), "address." + GenericAddress.CITY);
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.address.city").localize(),
|
||||
"address." + GenericAddress.CITY);
|
||||
if (!GenericContact.getConfig().getHideAddressState()) {
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.state").localize(), "address." + GenericAddress.STATE);
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.address.state").localize(),
|
||||
"address." + GenericAddress.STATE);
|
||||
}
|
||||
|
||||
if (!GenericContact.getConfig().getHideAddressCountry()) {
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.iso_country_code").localize(),
|
||||
"address." + GenericAddress.ISO_COUNTRY_CODE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.address.iso_country_code").localize(),
|
||||
"address." + GenericAddress.ISO_COUNTRY_CODE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
@Override
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
GenericAddress Address = ((GenericContact) item).getAddress();
|
||||
if (Address != null && Address.getIsoCountryCode() != null) {
|
||||
return GenericAddress.getCountryNameFromIsoCode(Address.getIsoCountryCode());
|
||||
} else {
|
||||
return (String) ContenttypesGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
GenericAddress Address =
|
||||
((GenericContact) item).getAddress();
|
||||
if (Address != null && Address.getIsoCountryCode() != null) {
|
||||
return GenericAddress.getCountryNameFromIsoCode(Address.
|
||||
getIsoCountryCode());
|
||||
} else {
|
||||
return (String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return sheet;
|
||||
|
||||
}
|
||||
|
||||
public static Component getEmptyBaseAddressPropertySheet(ItemSelectionModel itemModel) {
|
||||
return new Label(((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.emptyAddress").localize()));
|
||||
public static Component getEmptyBaseAddressPropertySheet(
|
||||
ItemSelectionModel itemModel) {
|
||||
return new Label(
|
||||
((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.contact.emptyAddress").localize()));
|
||||
}
|
||||
|
||||
private class EditAddressWorkflowLockedComponentAccess extends WorkflowLockedComponentAccess {
|
||||
|
||||
public EditAddressWorkflowLockedComponentAccess(Component c, ItemSelectionModel i) {
|
||||
public EditAddressWorkflowLockedComponentAccess(Component c,
|
||||
ItemSelectionModel i) {
|
||||
super(c, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(PageState state) {
|
||||
GenericContact contact = (GenericContact) itemModel.getSelectedObject(state);
|
||||
GenericContact contact = (GenericContact) itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
return contact.hasAddress();
|
||||
}
|
||||
|
|
@ -117,13 +160,15 @@ public class GenericContactAddressPropertiesStep extends SimpleEditStep {
|
|||
|
||||
private class AttachAddressWorkflowLockedComponentAccess extends WorkflowLockedComponentAccess {
|
||||
|
||||
public AttachAddressWorkflowLockedComponentAccess(Component c, ItemSelectionModel i) {
|
||||
public AttachAddressWorkflowLockedComponentAccess(Component c,
|
||||
ItemSelectionModel i) {
|
||||
super(c, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(PageState state) {
|
||||
GenericContact contact = (GenericContact) itemModel.getSelectedObject(state);
|
||||
GenericContact contact = (GenericContact) itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
return !contact.hasAddress();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class GenericPersonAliasDeleteForm
|
||||
extends BasicPageForm
|
||||
implements FormProcessListener {
|
||||
|
||||
public static final String ID = "GenericPersonAliasDeleteForm";
|
||||
|
||||
public GenericPersonAliasDeleteForm(
|
||||
final ItemSelectionModel itemModel,
|
||||
final GenericPersonAliasPropertiesStep step) {
|
||||
super(ID, itemModel);
|
||||
addSaveCancelSection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
add(new Label((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.person.alias.delete.label").localize()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent fse) throws FormProcessException {
|
||||
final PageState state = fse.getPageState();
|
||||
final GenericPerson person = (GenericPerson) getItemSelectionModel().getSelectedObject(state);
|
||||
|
||||
if ((person != null) && (person.getAlias() != null)) {
|
||||
person.unsetAlias();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSaveCancelSection() {
|
||||
try {
|
||||
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
|
||||
|
||||
public void prepare(final PrintEvent event) {
|
||||
GenericPerson person =
|
||||
(GenericPerson) getItemSelectionModel().
|
||||
getSelectedObject(event.getPageState());
|
||||
Submit target = (Submit) event.getTarget();
|
||||
target.setButtonLabel((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
"cms.contenttypes.ui.person.alias.delete.label").
|
||||
localize());
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
throw new UncheckedWrapperException("this cannot happen", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class GenericPersonAliasPropertiesStep extends SimpleEditStep {
|
||||
|
||||
public static final String SET_ALIAS_SHEET_NAME = "setAlias";
|
||||
public static final String CHANGE_ALIAS_SHEET_NAME = "changeAlias";
|
||||
public static final String DELETE_ALIAS_SHEET_NAME = "deleteAlias";
|
||||
private final ItemSelectionModel itemModel;
|
||||
|
||||
public GenericPersonAliasPropertiesStep(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, "");
|
||||
}
|
||||
|
||||
public GenericPersonAliasPropertiesStep(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent,
|
||||
final String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
this.itemModel = itemModel;
|
||||
|
||||
final BasicPageForm setAliasSheet = new GenericPersonAliasSetForm(
|
||||
itemModel,
|
||||
this);
|
||||
/*final BasicPageForm changeAliasSheet =
|
||||
new GenericPersonAliasSetForm(itemModel,
|
||||
this);*/
|
||||
final BasicPageForm deleteAliasSheet = new GenericPersonAliasDeleteForm(
|
||||
itemModel,
|
||||
this);
|
||||
|
||||
add(SET_ALIAS_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.person.set_alias").localize(),
|
||||
new GenericPersonAliasSetWorkflowLockedComponentAccess(setAliasSheet,
|
||||
itemModel),
|
||||
setAliasSheet.getSaveCancelSection().getCancelButton());
|
||||
/*add(CHANGE_ALIAS_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.person.change_alias").localize(),
|
||||
new GenericPersonAliasEditWorkflowLockedComponentAccess(
|
||||
changeAliasSheet,
|
||||
itemModel),
|
||||
changeAliasSheet.getSaveCancelSection().getCancelButton());*/
|
||||
add(DELETE_ALIAS_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.person.delete_alias").localize(),
|
||||
new GenericPersonAliasEditWorkflowLockedComponentAccess(
|
||||
deleteAliasSheet,
|
||||
itemModel),
|
||||
deleteAliasSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
setDisplayComponent(getAliasPropertySheet(itemModel));
|
||||
}
|
||||
|
||||
public static Component getAliasPropertySheet(
|
||||
final ItemSelectionModel itemModel) {
|
||||
final Label label = new Label(new PrintListener() {
|
||||
|
||||
public void prepare(final PrintEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final GenericPerson person = (GenericPerson) itemModel.
|
||||
getSelectedObject(state);
|
||||
final GenericPerson alias = person.getAlias();
|
||||
|
||||
if (alias == null) {
|
||||
((Label) event.getTarget()).setLabel(ContenttypesGlobalizationUtil.
|
||||
globalize("cms.contenttypes.ui.person.alias.none"));
|
||||
} else {
|
||||
((Label) event.getTarget()).setLabel(alias.getFullName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public static Component getEmptyAliasPropertySheet(
|
||||
final ItemSelectionModel itemModel) {
|
||||
return new Label((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.person.alias.none").localize());
|
||||
}
|
||||
|
||||
private class GenericPersonAliasSetWorkflowLockedComponentAccess
|
||||
extends WorkflowLockedComponentAccess {
|
||||
|
||||
public GenericPersonAliasSetWorkflowLockedComponentAccess(
|
||||
final Component component, final ItemSelectionModel itemModel) {
|
||||
super(component, itemModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(final PageState state) {
|
||||
final GenericPerson person = (GenericPerson) itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
if (person.getAlias() == null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class GenericPersonAliasEditWorkflowLockedComponentAccess
|
||||
extends WorkflowLockedComponentAccess {
|
||||
|
||||
public GenericPersonAliasEditWorkflowLockedComponentAccess(
|
||||
final Component component, final ItemSelectionModel itemModel) {
|
||||
super(component, itemModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(final PageState state) {
|
||||
final GenericPerson person = (GenericPerson) itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
if (person.getAlias() == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
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;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class GenericPersonAliasSetForm
|
||||
extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener {
|
||||
|
||||
private ItemSearchWidget itemSearch;
|
||||
private SaveCancelSection saveCancelSection;
|
||||
private final String ITEM_SEARCH = "personAlias";
|
||||
public static final String ID = "GenericPersonAliasSetForm";
|
||||
|
||||
public GenericPersonAliasSetForm(final ItemSelectionModel itemModel) {
|
||||
this(itemModel, null);
|
||||
}
|
||||
|
||||
public GenericPersonAliasSetForm(final ItemSelectionModel itemModel,
|
||||
final GenericPersonAliasPropertiesStep step) {
|
||||
super(ID, itemModel);
|
||||
|
||||
addSaveCancelSection();
|
||||
|
||||
addInitListener(this);
|
||||
addProcessListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
add(new Label((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.person.alias.select").localize()));
|
||||
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
|
||||
findByAssociatedObjectType(
|
||||
"com.arsdigita.cms.contenttypes.GenericPerson"));
|
||||
add(itemSearch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
final GenericPerson person = (GenericPerson) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
setVisible(state, true);
|
||||
|
||||
if (person != null) {
|
||||
data.put(ITEM_SEARCH, person.getAlias());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent fse) throws FormProcessException {
|
||||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
final GenericPerson person = (GenericPerson) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
GenericPerson alias = (GenericPerson) data.get(ITEM_SEARCH);
|
||||
|
||||
alias = (GenericPerson) alias.getContentBundle().getInstance(person.
|
||||
getLanguage());
|
||||
|
||||
person.setAlias(alias);
|
||||
}
|
||||
|
||||
init(fse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSaveCancelSection() {
|
||||
try {
|
||||
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
|
||||
|
||||
@Override
|
||||
public void prepare(PrintEvent event) {
|
||||
GenericPerson person =
|
||||
(GenericPerson) getItemSelectionModel().
|
||||
getSelectedObject(event.getPageState());
|
||||
Submit target = (Submit) event.getTarget();
|
||||
|
||||
if (person.getAlias() != null) {
|
||||
target.setButtonLabel((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
"cms.contenttypes.ui.contact.alias.select.change").
|
||||
localize());
|
||||
} else {
|
||||
target.setButtonLabel((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
"cms.contenttypes.ui.contact.alias.select.add").
|
||||
localize());
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
throw new UncheckedWrapperException("this cannot happen", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final FormSectionEvent fse)
|
||||
throws FormProcessException {
|
||||
final PageState state = fse.getPageState();
|
||||
final FormData data = fse.getFormData();
|
||||
|
||||
final GenericPerson person = (GenericPerson) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
final GenericPerson alias = (GenericPerson) data.get(ITEM_SEARCH);
|
||||
|
||||
if (data.get(ITEM_SEARCH) == null) {
|
||||
data.addError(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.person.alias.select.wrong_type"));
|
||||
} else if (person.equals(data.get(ITEM_SEARCH))) {
|
||||
data.addError(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.person.alias.select.same_as_person"));
|
||||
} else if (!alias.getContentBundle().hasInstance(person.getLanguage())) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.person.alias.select.no_suitable_language_variant"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -56,11 +56,13 @@ public class GenericPersonPropertiesStep extends SimpleEditStep {
|
|||
/* Create the edit component for this SimpleEditStep and the corresponding link */
|
||||
BasicPageForm editBasicSheet = new GenericPersonPropertyForm(itemModel,
|
||||
this);
|
||||
basicProperties.add(EDIT_SHEET_NAME, (String) ContenttypesGlobalizationUtil.
|
||||
globalize("cms.contenttypes.ui.person.edit_basic_properties").
|
||||
basicProperties.add(EDIT_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.person.edit_basic_properties").
|
||||
localize(), new WorkflowLockedComponentAccess(editBasicSheet,
|
||||
itemModel), editBasicSheet.
|
||||
getSaveCancelSection().getCancelButton());
|
||||
itemModel),
|
||||
editBasicSheet.getSaveCancelSection().
|
||||
getCancelButton());
|
||||
|
||||
/* Set the displayComponent for this step */
|
||||
basicProperties.setDisplayComponent(getGenericPersonPropertySheet(
|
||||
|
|
@ -75,6 +77,13 @@ public class GenericPersonPropertiesStep extends SimpleEditStep {
|
|||
// GenericPersonContactPropertiesStep contactProperties = new GenericPersonContactPropertiesStep(itemModel, parent);
|
||||
// segmentedPanel.addSegment(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact").localize()), contactProperties);
|
||||
|
||||
GenericPersonAliasPropertiesStep aliasStep =
|
||||
new GenericPersonAliasPropertiesStep(
|
||||
itemModel, parent);
|
||||
segmentedPanel.addSegment(new Label((String) ContenttypesGlobalizationUtil.
|
||||
globalize("cms.contenttypes.ui.person.alias").localize()),
|
||||
aliasStep);
|
||||
|
||||
/* Sets the composed segmentedPanel as display component */
|
||||
setDisplayComponent(segmentedPanel);
|
||||
|
||||
|
|
@ -104,7 +113,7 @@ public class GenericPersonPropertiesStep extends SimpleEditStep {
|
|||
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
PageState state) {
|
||||
GenericPerson person = (GenericPerson) item;
|
||||
if (person.getBirthdate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG).format(person.
|
||||
|
|
@ -127,7 +136,8 @@ public class GenericPersonPropertiesStep extends SimpleEditStep {
|
|||
//ContentPage page = (ContentPage) item;
|
||||
GenericPerson person = (GenericPerson) item;
|
||||
if (person.getGender() != null) {
|
||||
return (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.gender." + person.
|
||||
return (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.gender."
|
||||
+ person.
|
||||
getGender().toLowerCase()).localize();
|
||||
} else {
|
||||
return (String) ContenttypesGlobalizationUtil.globalize(
|
||||
|
|
|
|||
Loading…
Reference in New Issue