PublicPersonalProfile: Typ der Person ist nun konfigurierbar.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1024 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-07-19 13:12:14 +00:00
parent 9a21b549ea
commit cd321662c6
7 changed files with 72 additions and 41 deletions

View File

@ -144,7 +144,7 @@ final class ContentTypeItemPane extends BaseItemPane {
connect(m_elementAddForm, elementSelect, connect(m_elementAddForm, elementSelect,
AddElement.CONTENT_ITEM_ELEMENT, itemForm); AddElement.CONTENT_ITEM_ELEMENT, itemForm);
connect(itemForm); connect(itemForm);
} }
// XXX A temporary, low-impact fix. // XXX A temporary, low-impact fix.
@ -175,7 +175,7 @@ final class ContentTypeItemPane extends BaseItemPane {
group.setSubject(new ContentTypePropertyList(m_type)); group.setSubject(new ContentTypePropertyList(m_type));
group.addAction(new TypeSecurityContainer(editLink)); group.addAction(new TypeSecurityContainer(editLink));
group.addAction(new TypeSecurityContainer(deleteLink)); group.addAction(new TypeSecurityContainer(deleteLink));
} }
} }

View File

@ -14,14 +14,14 @@ object type SciPublicPersonalProfile extends ContentPage {
association { association {
SciPublicPersonalProfile[0..n] profile = join ct_sciorga_members.member_id SciPublicPersonalProfile[0..n] profile = join cms_persons.person_id
to ct_sci_public_personal_profile_owner_map.owner_id, to ct_sci_public_personal_profile_owner_map.owner_id,
join ct_sci_public_personal_profile_owner_map.profile_id join ct_sci_public_personal_profile_owner_map.profile_id
to ct_sci_public_personal_profiles.profile_id; to ct_sci_public_personal_profiles.profile_id;
SciMember[0..n] owner = join ct_sci_public_personal_profiles.profile_id GenericPerson[0..n] owner = join ct_sci_public_personal_profiles.profile_id
to ct_sci_public_personal_profile_owner_map.profile_id, to ct_sci_public_personal_profile_owner_map.profile_id,
join ct_sci_public_personal_profile_owner_map.owner_id join ct_sci_public_personal_profile_owner_map.owner_id
to ct_sciorga_members.member_id; to cms_persons.person_id;
} }

View File

@ -43,7 +43,7 @@ public class SciPublicPersonalProfile extends ContentPage {
super(type); super(type);
} }
public SciMember getOwner() { public GenericPerson getOwner() {
final DataCollection collection = (DataCollection) get(OWNER); final DataCollection collection = (DataCollection) get(OWNER);
if (0 == collection.size()) { if (0 == collection.size()) {
@ -55,12 +55,12 @@ public class SciPublicPersonalProfile extends ContentPage {
dobj = collection.getDataObject(); dobj = collection.getDataObject();
collection.close(); collection.close();
return (SciMember) DomainObjectFactory.newInstance(dobj); return (GenericPerson) DomainObjectFactory.newInstance(dobj);
} }
} }
public void setOwner(SciMember owner) { public void setOwner(GenericPerson owner) {
SciMember oldOwner; GenericPerson oldOwner;
oldOwner = getOwner(); oldOwner = getOwner();
if (oldOwner != null) { if (oldOwner != null) {
@ -68,7 +68,7 @@ public class SciPublicPersonalProfile extends ContentPage {
} }
if (null != owner) { if (null != owner) {
Assert.exists(owner, SciMember.class); Assert.exists(owner, GenericPerson.class);
add(OWNER, owner); add(OWNER, owner);
} }
} }

View File

@ -4,7 +4,6 @@ import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.BooleanParameter; import com.arsdigita.util.parameter.BooleanParameter;
import com.arsdigita.util.parameter.StringParameter; import com.arsdigita.util.parameter.StringParameter;
import com.arsdigita.util.parameter.Parameter; import com.arsdigita.util.parameter.Parameter;
import javax.swing.text.StyledEditorKit.BoldAction;
/** /**
* *
@ -14,6 +13,7 @@ import javax.swing.text.StyledEditorKit.BoldAction;
public class SciPublicPersonalProfileConfig extends AbstractConfig { public class SciPublicPersonalProfileConfig extends AbstractConfig {
private final Parameter showUnfinishedParts; private final Parameter showUnfinishedParts;
private final Parameter personType;
public SciPublicPersonalProfileConfig() { public SciPublicPersonalProfileConfig() {
showUnfinishedParts = showUnfinishedParts =
@ -21,8 +21,12 @@ public class SciPublicPersonalProfileConfig extends AbstractConfig {
"com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts", "com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.FALSE); Boolean.FALSE);
personType = new StringParameter("com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_class",
Parameter.REQUIRED,
"com.arsdigita.cms.contenttypes.GenericPerson");
register(showUnfinishedParts); register(showUnfinishedParts);
register(personType);
loadInfo(); loadInfo();
} }
@ -30,4 +34,8 @@ public class SciPublicPersonalProfileConfig extends AbstractConfig {
public final boolean getShowUnFinishedParts() { public final boolean getShowUnFinishedParts() {
return (Boolean) get(showUnfinishedParts); return (Boolean) get(showUnfinishedParts);
} }
public final String getPersonType() {
return (String) get(personType);
}
} }

View File

@ -2,3 +2,8 @@ com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts.ti
com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts.purpose = Show parts of the SciPublicPersonalProfile which do not work yet. com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts.purpose = Show parts of the SciPublicPersonalProfile which do not work yet.
com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts.example = false com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts.example = false
com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts.format = [boolean] com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts.format = [boolean]
com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.person_type.title = Class to restrict the selectable persons to.
com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.person_type.purpose = Class to restrict the selectable persons to.
com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.person_type.example = com.arsdigita.cms.contenttypes.GenericPerson
com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.person_type.format = [String]

View File

@ -16,10 +16,13 @@ import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentTypeCollection;
import com.arsdigita.cms.Folder; import com.arsdigita.cms.Folder;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.SciMember; import com.arsdigita.cms.contenttypes.SciMember;
import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile; import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile;
import com.arsdigita.cms.contenttypes.SciPublicPersonalProfileConfig;
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection; import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
import com.arsdigita.cms.ui.authoring.CreationSelector; import com.arsdigita.cms.ui.authoring.CreationSelector;
import com.arsdigita.cms.ui.authoring.LanguageWidget; import com.arsdigita.cms.ui.authoring.LanguageWidget;
@ -38,14 +41,16 @@ import java.util.Date;
* @version $Id$ * @version $Id$
*/ */
public class SciPublicPersonalProfileCreate extends PageCreate { public class SciPublicPersonalProfileCreate extends PageCreate {
private static final String SELECTED_PERSON = "selectedPerson"; private static final String SELECTED_PERSON = "selectedPerson";
private static final SciPublicPersonalProfileConfig config =
new SciPublicPersonalProfileConfig();
public SciPublicPersonalProfileCreate(final ItemSelectionModel itemModel, public SciPublicPersonalProfileCreate(final ItemSelectionModel itemModel,
final CreationSelector parent) { final CreationSelector parent) {
super(itemModel, parent); super(itemModel, parent);
} }
@Override @Override
public void addWidgets() { public void addWidgets() {
//super.addWidgets(); //super.addWidgets();
@ -58,25 +63,38 @@ public class SciPublicPersonalProfileCreate extends PageCreate {
add(new Label(type.getLabel())); add(new Label(type.getLabel()));
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field"))); add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
add(new LanguageWidget(LANGUAGE)); add(new LanguageWidget(LANGUAGE));
add(new Label(SciPublicPersonalProfileGlobalizationUtil.globalize( add(new Label(SciPublicPersonalProfileGlobalizationUtil.globalize(
"scipublicpersonalprofile.ui.create.select_person"))); "scipublicpersonalprofile.ui.create.select_person")));
ParameterModel ownerModel = ParameterModel ownerModel =
new StringParameter(SciPublicPersonalProfile.OWNER); new StringParameter(SciPublicPersonalProfile.OWNER);
SingleSelect ownerSelect = new SingleSelect(ownerModel); SingleSelect ownerSelect = new SingleSelect(ownerModel);
ownerSelect.addValidationListener(new NotNullValidationListener()); ownerSelect.addValidationListener(new NotNullValidationListener());
//DataCollection persons = SessionManager.getSession().retrieve(
// SciMember.BASE_DATA_OBJECT_TYPE);
String personType = config.getPersonType();
if ((personType == null) || (personType.isEmpty()) ) {
personType = "com.arsdigita.cms.contenttypes.GenericPerson";
}
ContentTypeCollection types = ContentType.getAllContentTypes();
types.addFilter(String.format("className = '%s'", personType));
if (types.size() == 0) {
personType = "com.arsdigita.cms.contenttypes.GenericPerson";
}
DataCollection persons = SessionManager.getSession().retrieve( DataCollection persons = SessionManager.getSession().retrieve(
SciMember.BASE_DATA_OBJECT_TYPE); personType);
persons.addFilter("profile is null"); persons.addFilter("profile is null");
while (persons.next()) { while (persons.next()) {
SciMember member = GenericPerson person =
(SciMember) DomainObjectFactory.newInstance(persons. (GenericPerson) DomainObjectFactory.newInstance(persons.
getDataObject()); getDataObject());
ownerSelect.addOption(new Option(member.getID().toString(), member. ownerSelect.addOption(new Option(person.getID().toString(), person.
getFullName())); getFullName()));
} }
add(ownerSelect); add(ownerSelect);
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
"cms.ui.authoring.page_launch_date"))); "cms.ui.authoring.page_launch_date")));
@ -93,57 +111,58 @@ public class SciPublicPersonalProfileCreate extends PageCreate {
add(launchDate); add(launchDate);
} }
} }
@Override @Override
public void validate(FormSectionEvent fse) throws FormProcessException { public void validate(FormSectionEvent fse) throws FormProcessException {
Folder folder = m_parent.getFolder(fse.getPageState()); Folder folder = m_parent.getFolder(fse.getPageState());
Assert.exists(folder); Assert.exists(folder);
String id = (String) fse.getFormData().get( String id = (String) fse.getFormData().get(
SciPublicPersonalProfile.OWNER); SciPublicPersonalProfile.OWNER);
SciMember owner = new SciMember(new BigDecimal(id)); SciMember owner = new SciMember(new BigDecimal(id));
validateNameUniqueness(folder, validateNameUniqueness(folder,
fse, fse,
String.format("%s-profile", String.format("%s-profile",
SciMember.urlSave( SciMember.urlSave(
owner.getFullName()))); owner.getFullName())));
} }
@Override @Override
public void process(FormSectionEvent fse) throws FormProcessException { public void process(FormSectionEvent fse) throws FormProcessException {
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
final PageState state = fse.getPageState(); final PageState state = fse.getPageState();
final ContentSection section = m_parent.getContentSection(state); final ContentSection section = m_parent.getContentSection(state);
final Folder folder = m_parent.getFolder(state); final Folder folder = m_parent.getFolder(state);
Assert.exists(section, ContentSection.class); Assert.exists(section, ContentSection.class);
String id = (String) fse.getFormData().get( String id = (String) fse.getFormData().get(
SciPublicPersonalProfile.OWNER); SciPublicPersonalProfile.OWNER);
SciMember owner = new SciMember(new BigDecimal(id)); GenericPerson owner = new GenericPerson(new BigDecimal(id));
String name = String.format("%s-profile", String name = String.format("%s-profile",
SciMember.urlSave(owner.getFullName())); SciMember.urlSave(owner.getFullName()));
String title = String.format("%s (Profil)", owner.getFullName()); String title = String.format("%s (Profil)", owner.getFullName());
final ContentPage item = createContentPage(state); final ContentPage item = createContentPage(state);
item.setLanguage((String) data.get(LANGUAGE)); item.setLanguage((String) data.get(LANGUAGE));
item.setName(name); item.setName(name);
item.setTitle(title); item.setTitle(title);
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
item.setLaunchDate((Date) data.get(LAUNCH_DATE)); item.setLaunchDate((Date) data.get(LAUNCH_DATE));
} }
final ContentBundle bundle = new ContentBundle(item); final ContentBundle bundle = new ContentBundle(item);
bundle.setParent(folder); bundle.setParent(folder);
bundle.setContentSection(m_parent.getContentSection(state)); bundle.setContentSection(m_parent.getContentSection(state));
bundle.save(); bundle.save();
SciPublicPersonalProfile profile = new SciPublicPersonalProfile(item.getOID()); SciPublicPersonalProfile profile = new SciPublicPersonalProfile(item.
getOID());
profile.setOwner(owner); profile.setOwner(owner);
profile.save(); profile.save();
m_parent.editItem(state, item); m_parent.editItem(state, item);
} }
} }

View File

@ -5,15 +5,14 @@ import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SegmentedPanel; import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile; import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.domain.DomainObject; import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep; import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.cms.contenttypes.SciMember;
/** /**
* *
@ -83,7 +82,7 @@ public class SciPublicPersonalProfilePropertiesStep extends SimpleEditStep {
public String format(DomainObject obj, String attribute, PageState state) { public String format(DomainObject obj, String attribute, PageState state) {
SciPublicPersonalProfile profile = (SciPublicPersonalProfile) obj; SciPublicPersonalProfile profile = (SciPublicPersonalProfile) obj;
SciMember owner = profile.getOwner(); GenericPerson owner = profile.getOwner();
if (owner == null) { if (owner == null) {
return ""; return "";