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

@ -14,14 +14,14 @@ object type SciPublicPersonalProfile extends ContentPage {
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,
join ct_sci_public_personal_profile_owner_map.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,
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);
}
public SciMember getOwner() {
public GenericPerson getOwner() {
final DataCollection collection = (DataCollection) get(OWNER);
if (0 == collection.size()) {
@ -55,12 +55,12 @@ public class SciPublicPersonalProfile extends ContentPage {
dobj = collection.getDataObject();
collection.close();
return (SciMember) DomainObjectFactory.newInstance(dobj);
return (GenericPerson) DomainObjectFactory.newInstance(dobj);
}
}
public void setOwner(SciMember owner) {
SciMember oldOwner;
public void setOwner(GenericPerson owner) {
GenericPerson oldOwner;
oldOwner = getOwner();
if (oldOwner != null) {
@ -68,7 +68,7 @@ public class SciPublicPersonalProfile extends ContentPage {
}
if (null != owner) {
Assert.exists(owner, SciMember.class);
Assert.exists(owner, GenericPerson.class);
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.StringParameter;
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 {
private final Parameter showUnfinishedParts;
private final Parameter personType;
public SciPublicPersonalProfileConfig() {
showUnfinishedParts =
@ -21,8 +21,12 @@ public class SciPublicPersonalProfileConfig extends AbstractConfig {
"com.arsdigita.cms.contenttypes.SciPublicPersonalProfile.show_unfinished_parts",
Parameter.REQUIRED,
Boolean.FALSE);
personType = new StringParameter("com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_class",
Parameter.REQUIRED,
"com.arsdigita.cms.contenttypes.GenericPerson");
register(showUnfinishedParts);
register(personType);
loadInfo();
}
@ -30,4 +34,8 @@ public class SciPublicPersonalProfileConfig extends AbstractConfig {
public final boolean getShowUnFinishedParts() {
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.example = false
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.ContentSection;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentTypeCollection;
import com.arsdigita.cms.Folder;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.SciMember;
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.CreationSelector;
import com.arsdigita.cms.ui.authoring.LanguageWidget;
@ -40,6 +43,8 @@ import java.util.Date;
public class SciPublicPersonalProfileCreate extends PageCreate {
private static final String SELECTED_PERSON = "selectedPerson";
private static final SciPublicPersonalProfileConfig config =
new SciPublicPersonalProfileConfig();
public SciPublicPersonalProfileCreate(final ItemSelectionModel itemModel,
final CreationSelector parent) {
@ -65,14 +70,27 @@ public class SciPublicPersonalProfileCreate extends PageCreate {
new StringParameter(SciPublicPersonalProfile.OWNER);
SingleSelect ownerSelect = new SingleSelect(ownerModel);
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(
SciMember.BASE_DATA_OBJECT_TYPE);
personType);
persons.addFilter("profile is null");
while (persons.next()) {
SciMember member =
(SciMember) DomainObjectFactory.newInstance(persons.
GenericPerson person =
(GenericPerson) DomainObjectFactory.newInstance(persons.
getDataObject());
ownerSelect.addOption(new Option(member.getID().toString(), member.
ownerSelect.addOption(new Option(person.getID().toString(), person.
getFullName()));
}
add(ownerSelect);
@ -122,7 +140,7 @@ public class SciPublicPersonalProfileCreate extends PageCreate {
String id = (String) fse.getFormData().get(
SciPublicPersonalProfile.OWNER);
SciMember owner = new SciMember(new BigDecimal(id));
GenericPerson owner = new GenericPerson(new BigDecimal(id));
String name = String.format("%s-profile",
SciMember.urlSave(owner.getFullName()));
String title = String.format("%s (Profil)", owner.getFullName());
@ -140,7 +158,8 @@ public class SciPublicPersonalProfileCreate extends PageCreate {
bundle.setContentSection(m_parent.getContentSection(state));
bundle.save();
SciPublicPersonalProfile profile = new SciPublicPersonalProfile(item.getOID());
SciPublicPersonalProfile profile = new SciPublicPersonalProfile(item.
getOID());
profile.setOwner(owner);
profile.save();

View File

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