PublicPersonalProfile Owner Assoziation auf neue Struktur umgestellt (Ticket 1112)

git-svn-id: https://svn.libreccm.org/ccm/trunk@1490 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-02-06 08:39:58 +00:00
parent 9a3cced24e
commit 8e172f73e7
4 changed files with 126 additions and 81 deletions

View File

@ -14,17 +14,22 @@ object type PublicPersonalProfile extends ContentPage {
reference key (ct_public_personal_profiles.profile_id); reference key (ct_public_personal_profiles.profile_id);
} }
object type PublicPersonalProfileBundle extends ContentBundle {
reference key (ct_public_personal_profile_bundles.bundle_id);
}
association { association {
PublicPersonalProfile[0..n] profile = join cms_persons.person_id PublicPersonalProfileBundle[0..n] profile = join cms_person_bundles.bundle_id
to ct_public_personal_profile_owner_map.owner_id, to ct_public_personal_profile_owner_map.owner_id,
join ct_public_personal_profile_owner_map.profile_id join ct_public_personal_profile_owner_map.profile_id
to ct_public_personal_profiles.profile_id; to ct_public_personal_profile_bundles.bundle_id;
GenericPerson[0..n] owner = join ct_public_personal_profiles.profile_id GenericPersonBundle[0..n] owner = join ct_public_personal_profile_bundles.bundle_id
to ct_public_personal_profile_owner_map.profile_id, to ct_public_personal_profile_owner_map.profile_id,
join ct_public_personal_profile_owner_map.owner_id join ct_public_personal_profile_owner_map.owner_id
to cms_persons.person_id; to cms_person_bundles.bundle_id;
Integer[0..1] ownerOrder = ct_public_personal_profile_owner_map.owner_order INTEGER; Integer[0..1] ownerOrder = ct_public_personal_profile_owner_map.owner_order INTEGER;
} }

View File

@ -19,6 +19,7 @@
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ExtraXMLGenerator; import com.arsdigita.cms.ExtraXMLGenerator;
import com.arsdigita.cms.publicpersonalprofile.ContentGenerator; import com.arsdigita.cms.publicpersonalprofile.ContentGenerator;
@ -51,8 +52,9 @@ public class PublicPersonalProfile
extends ContentPage extends ContentPage
implements CustomizedPreviewLink { implements CustomizedPreviewLink {
private static final PublicPersonalProfileConfig config = PublicPersonalProfiles.getConfig(); private static final PublicPersonalProfileConfig config =
public static final String OWNER = "owner"; PublicPersonalProfiles.
getConfig();
public static final String PROFILE_URL = "profileUrl"; public static final String PROFILE_URL = "profileUrl";
public static final String LINK_LIST_NAME = "publicPersonalProfileNavItems"; public static final String LINK_LIST_NAME = "publicPersonalProfileNavItems";
public static final String POSITION = "position"; public static final String POSITION = "position";
@ -83,24 +85,33 @@ public class PublicPersonalProfile
super(type); super(type);
} }
public PublicPersonalProfileBundle getPublicPersonalProfileBundle() {
return (PublicPersonalProfileBundle) getContentBundle();
}
/** /**
* *
* @return The owner of the profile. * @return The owner of the profile.
*/ */
public GenericPerson getOwner() { public GenericPerson getOwner() {
final DataCollection collection = (DataCollection) get(OWNER); /*
* final DataCollection collection = (DataCollection)
if (0 == collection.size()) { * getContentBundle(). get(OWNER);
return null; *
} else { * if (0 == collection.size()) { return null; } else { DataObject dobj;
DataObject dobj; *
* collection.next(); dobj = collection.getDataObject();
collection.next(); * collection.close();
dobj = collection.getDataObject(); *
collection.close(); * final GenericPersonBundle bundle = (GenericPersonBundle)
* DomainObjectFactory. newInstance(dobj);
return (GenericPerson) DomainObjectFactory.newInstance(dobj); *
*
* return (GenericPerson) DomainObjectFactory.newInstance(dobj);
} }
*/
return (GenericPerson) getPublicPersonalProfileBundle().getOwner().
getPrimaryInstance();
} }
/** /**
@ -109,17 +120,17 @@ public class PublicPersonalProfile
* @param owner * @param owner
*/ */
public void setOwner(final GenericPerson owner) { public void setOwner(final GenericPerson owner) {
GenericPerson oldOwner; /*
* final ContentBundle bundle = getContentBundle(); final
oldOwner = getOwner(); * GenericPersonBundle oldOwner = (GenericPersonBundle) getOwner().
if (oldOwner != null) { * getContentBundle(); if (oldOwner != null) { bundle.remove(OWNER,
remove(OWNER, oldOwner); * oldOwner); }
} *
* if (null != owner) { Assert.exists(owner, GenericPerson.class);
if (null != owner) { * bundle.add(OWNER, owner.getContentBundle());
Assert.exists(owner, GenericPerson.class);
add(OWNER, owner);
} }
*/
getPublicPersonalProfileBundle().setOwner(owner);
} }
/** /**

View File

@ -24,7 +24,8 @@ import javax.servlet.ServletException;
* Generates the extra XML output for a profile for the embedded view. * Generates the extra XML output for a profile for the embedded view.
* *
* @author Jens Pelzetter * @author Jens Pelzetter
* @version $Id$ * @version $Id: PublicPersonalProfileExtraXmlGenerator.java 1466 2012-01-23
* 12:59:16Z jensp $
*/ */
public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator { public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator {
@ -44,17 +45,16 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
final PublicPersonalProfile profile = (PublicPersonalProfile) item; final PublicPersonalProfile profile = (PublicPersonalProfile) item;
final String showItem = state.getRequest().getParameter(SHOW_ITEM_PARAM); final String showItem = state.getRequest().getParameter(SHOW_ITEM_PARAM);
if (!config.getEmbedded() && state.getRequestURI().contains(profile.getName())) { if (!config.getEmbedded() && state.getRequestURI().contains(profile.
/*try { getName())) {
DispatcherHelper.forwardRequestByPath(getProfileUrl(profile), /*
state.getRequest(), * try {
state.getResponse()); * DispatcherHelper.forwardRequestByPath(getProfileUrl(profile),
return; * state.getRequest(), state.getResponse()); return; } catch
} catch (IOException ex) { * (IOException ex) { throw new UncheckedWrapperException(ex); }
throw new UncheckedWrapperException(ex); * catch (ServletException ex) { throw new
} catch (ServletException ex) { * UncheckedWrapperException(ex); }
throw new UncheckedWrapperException(ex); */
}*/
throw new RedirectSignal(getProfileUrl(profile), true); throw new RedirectSignal(getProfileUrl(profile), true);
} }
@ -72,7 +72,29 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
false); false);
} }
if ((showItem != null) && !showItem.trim().isEmpty()) { if ((showItem == null) || showItem.trim().isEmpty()) {
final Element profileOwner = element.newChildElement("profileOwner");
final GenericPerson owner = profile.getOwner();
final PublicPersonalProfileXmlGenerator generator =
new PublicPersonalProfileXmlGenerator(
owner);
generator.setItemElemName("owner", "");
generator.generateXML(state, profileOwner, "");
final Element contactsElem =
profileOwner.newChildElement("contacts");
final GenericPersonContactCollection contacts = owner.getContacts();
while (contacts.next()) {
PublicPersonalProfileXmlGenerator cGenerator =
new PublicPersonalProfileXmlGenerator(
contacts.getContact());
cGenerator.setItemElemName("contact", "");
cGenerator.generateXML(state, contactsElem, "");
}
} else {
final Element profileContent = element.newChildElement( final Element profileContent = element.newChildElement(
"profileContent"); "profileContent");
@ -88,7 +110,8 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
} else { } else {
PublicPersonalProfileNavItemCollection navItems = PublicPersonalProfileNavItemCollection navItems =
new PublicPersonalProfileNavItemCollection(); new PublicPersonalProfileNavItemCollection();
navItems.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). navItems.addLanguageFilter(GlobalizationHelper.
getNegotiatedLocale().
getLanguage()); getLanguage());
navItems.addKeyFilter(showItem); navItems.addKeyFilter(showItem);
navItems.next(); navItems.next();
@ -165,7 +188,7 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
final GenericPersonContactCollection contacts = owner.getContacts(); final GenericPersonContactCollection contacts = owner.getContacts();
String homepage = null; String homepage = null;
while(contacts.next() && (homepage == null)) { while (contacts.next() && (homepage == null)) {
homepage = getHomepageContactEntry(contacts.getContact()); homepage = getHomepageContactEntry(contacts.getContact());
} }
@ -174,10 +197,11 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
} }
private String getHomepageContactEntry(final GenericContact contact) { private String getHomepageContactEntry(final GenericContact contact) {
final GenericContactEntryCollection entries = contact.getContactEntries(); final GenericContactEntryCollection entries =
contact.getContactEntries();
String homepage = null; String homepage = null;
while(entries.next()) { while (entries.next()) {
if ("homepage".equals(entries.getKey())) { if ("homepage".equals(entries.getKey())) {
homepage = entries.getValue(); homepage = entries.getValue();
break; break;

View File

@ -5,16 +5,15 @@ import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.parameters.DateParameter; import com.arsdigita.bebop.parameters.DateParameter;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
@ -24,6 +23,7 @@ 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.GenericPerson;
import com.arsdigita.cms.contenttypes.PublicPersonalProfile; import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
import com.arsdigita.cms.contenttypes.PublicPersonalProfileBundle;
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig; import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig;
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles; import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection; import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
@ -76,7 +76,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize( add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.create.select_person"))); "publicpersonalprofile.ui.create.select_person")));
ParameterModel ownerModel = ParameterModel ownerModel =
new StringParameter(PublicPersonalProfile.OWNER); new StringParameter(PublicPersonalProfileBundle.OWNER);
SingleSelect ownerSelect = new SingleSelect(ownerModel); SingleSelect ownerSelect = new SingleSelect(ownerModel);
ownerSelect.addValidationListener(new NotNullValidationListener()); ownerSelect.addValidationListener(new NotNullValidationListener());
@ -104,7 +104,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
DataCollection persons = SessionManager.getSession(). DataCollection persons = SessionManager.getSession().
retrieve( retrieve(
personType); personType);
persons.addFilter("profile is null"); //persons.addFilter("profile is null");
persons.addFilter(String.format("version = '%s'", persons.addFilter(String.format("version = '%s'",
ContentItem.DRAFT)); ContentItem.DRAFT));
persons.addOrder("surname asc"); persons.addOrder("surname asc");
@ -121,6 +121,10 @@ public class PublicPersonalProfileCreate extends PageCreate {
newInstance(persons.getDataObject()); newInstance(persons.getDataObject());
if (processed.contains(person.getParent().getID())) { if (processed.contains(person.getParent().getID())) {
continue; continue;
} else {
if (person.getGenericPersonBundle().get("profile")
== null) {
continue;
} else { } else {
ownerSelect.addOption(new Option( ownerSelect.addOption(new Option(
person.getID().toString(), person.getID().toString(),
@ -131,6 +135,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
} }
} }
} }
}
}); });
} catch (TooManyListenersException ex) { } catch (TooManyListenersException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
@ -160,7 +165,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
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(
PublicPersonalProfile.OWNER); PublicPersonalProfileBundle.OWNER);
if ((id == null) || id.trim().isEmpty()) { if ((id == null) || id.trim().isEmpty()) {
fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil. fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil.
@ -187,7 +192,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
Assert.exists(section, ContentSection.class); Assert.exists(section, ContentSection.class);
String id = (String) fse.getFormData().get( String id = (String) fse.getFormData().get(
PublicPersonalProfile.OWNER); PublicPersonalProfileBundle.OWNER);
GenericPerson owner = new GenericPerson(new BigDecimal(id)); GenericPerson owner = new GenericPerson(new BigDecimal(id));
String name = String.format("%s-profile", String name = String.format("%s-profile",
@ -202,7 +207,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
item.setLaunchDate((Date) data.get(LAUNCH_DATE)); item.setLaunchDate((Date) data.get(LAUNCH_DATE));
} }
final ContentBundle bundle = new ContentBundle(item); final PublicPersonalProfileBundle bundle = new PublicPersonalProfileBundle(item);
bundle.setParent(folder); bundle.setParent(folder);
bundle.setContentSection(m_parent.getContentSection(state)); bundle.setContentSection(m_parent.getContentSection(state));
bundle.save(); bundle.save();