Der Eigentümer eines PublicPersonalProfiles lässt sich jetzt ändern. Die Auswahl ist auf den aktuellen Eigentümer und
Personen-Items mit denen der aktuelle Eigentümer als Alias verknüpft ist, beschränkt. git-svn-id: https://svn.libreccm.org/ccm/trunk@1933 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
6498c02337
commit
a350d6fb05
|
|
@ -6,6 +6,9 @@ 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.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
import com.arsdigita.bebop.parameters.DateParameter;
|
import com.arsdigita.bebop.parameters.DateParameter;
|
||||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
|
@ -15,36 +18,42 @@ 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;
|
||||||
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.GenericPerson;
|
||||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
||||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileBundle;
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileBundle;
|
||||||
|
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig;
|
||||||
|
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
|
||||||
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
|
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
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;
|
||||||
import com.arsdigita.cms.ui.authoring.PageCreate;
|
import com.arsdigita.cms.ui.authoring.PageCreate;
|
||||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
* @version $Id: PublicPersonalProfileCreate.java 1384 2011-12-20 18:07:11Z
|
* @version $Id$
|
||||||
* jensp $
|
|
||||||
*/
|
*/
|
||||||
public class PublicPersonalProfileCreate extends PageCreate {
|
public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
|
|
||||||
//private static final String SELECTED_PERSON = "selectedPerson";
|
//private static final String SELECTED_PERSON = "selectedPerson";
|
||||||
//private static final PublicPersonalProfileConfig config =
|
private static final PublicPersonalProfileConfig config =
|
||||||
// PublicPersonalProfiles. getConfig();
|
PublicPersonalProfiles.getConfig();
|
||||||
|
|
||||||
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
|
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
|
||||||
final CreationSelector parent) {
|
final CreationSelector parent) {
|
||||||
super(itemModel, parent);
|
super(itemModel, parent);
|
||||||
|
|
@ -69,63 +78,46 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
ownerSelect.addValidationListener(new NotNullValidationListener());
|
ownerSelect.addValidationListener(new NotNullValidationListener());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ownerSelect.addPrintListener(new PPPOwnerSelectPrintListener());
|
|
||||||
// ownerSelect.addPrintListener(new PrintListener() {
|
ownerSelect.addPrintListener(new PrintListener() {
|
||||||
//
|
public void prepare(final PrintEvent event) {
|
||||||
// public void prepare(final PrintEvent event) {
|
final SingleSelect ownerSelect = (SingleSelect) event.getTarget();
|
||||||
// final SingleSelect ownerSelect = (SingleSelect) event.
|
|
||||||
// getTarget();
|
String personType = config.getPersonType();
|
||||||
//
|
if ((personType == null) || (personType.isEmpty())) {
|
||||||
// String personType = config.getPersonType();
|
personType = "com.arsdigita.cms.contenttypes.GenericPerson";
|
||||||
// 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) {
|
||||||
// ContentTypeCollection types =
|
personType = "com.arsdigita.cms.contenttypes.GenericPerson";
|
||||||
// ContentType.getAllContentTypes();
|
}
|
||||||
// types.addFilter(
|
DataCollection persons = SessionManager.getSession().retrieve(personType);
|
||||||
// String.format("className = '%s'", personType));
|
//persons.addFilter("profile is null");
|
||||||
// if (types.size() == 0) {
|
persons.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
|
||||||
// personType =
|
persons.addOrder("surname asc");
|
||||||
// "com.arsdigita.cms.contenttypes.GenericPerson";
|
persons.addOrder("givenname asc");
|
||||||
// }
|
persons.addOrder("language asc");
|
||||||
// DataCollection persons = SessionManager.getSession().
|
ownerSelect.addOption(new Option("", ""));
|
||||||
// retrieve(
|
|
||||||
// personType);
|
//Store the parent ids of processed items to remove double entries.
|
||||||
// //persons.addFilter("profile is null");
|
final List<BigDecimal> processed = new ArrayList<BigDecimal>();
|
||||||
// persons.addFilter(String.format("version = '%s'",
|
while (persons.next()) {
|
||||||
// ContentItem.DRAFT));
|
GenericPerson person = (GenericPerson) DomainObjectFactory.newInstance(persons.getDataObject());
|
||||||
// persons.addOrder("surname asc");
|
if (processed.contains(person.getParent().getID())) {
|
||||||
// persons.addOrder("givenname asc");
|
continue;
|
||||||
// persons.addOrder("language asc");
|
} else {
|
||||||
// ownerSelect.addOption(new Option("", ""));
|
if (person.getGenericPersonBundle().get("profile") == null) {
|
||||||
//
|
continue;
|
||||||
// //Store the parent ids of processed items to remove double entries.
|
} else {
|
||||||
// final List<BigDecimal> processed =
|
ownerSelect.addOption(new Option(person.getID().toString(), person.getFullName()));
|
||||||
// new ArrayList<BigDecimal>();
|
processed.add(person.getParent().getID());
|
||||||
// while (persons.next()) {
|
}
|
||||||
// GenericPerson person =
|
}
|
||||||
// (GenericPerson) DomainObjectFactory.
|
}
|
||||||
// newInstance(persons.getDataObject());
|
}
|
||||||
// if (processed.contains(person.getParent().getID())) {
|
});
|
||||||
// continue;
|
|
||||||
// } else {
|
|
||||||
// if (person.getGenericPersonBundle().get("profile")
|
|
||||||
// == null) {
|
|
||||||
// continue;
|
|
||||||
// } else {
|
|
||||||
// ownerSelect.addOption(new Option(
|
|
||||||
// person.getID().toString(),
|
|
||||||
// String.format("%s (%s)",
|
|
||||||
// person.getFullName(),
|
|
||||||
// person.getLanguage())));
|
|
||||||
// processed.add(person.getParent().getID());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
} catch (TooManyListenersException ex) {
|
} catch (TooManyListenersException ex) {
|
||||||
throw new UncheckedWrapperException(ex);
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
|
|
@ -133,8 +125,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
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")));
|
|
||||||
final ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
|
final ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
|
||||||
final com.arsdigita.bebop.form.Date launchDate = new com.arsdigita.bebop.form.Date(launchDateParam);
|
final com.arsdigita.bebop.form.Date launchDate = new com.arsdigita.bebop.form.Date(launchDateParam);
|
||||||
if (ContentSection.getConfig().getRequireLaunchDate()) {
|
if (ContentSection.getConfig().getRequireLaunchDate()) {
|
||||||
|
|
@ -148,9 +139,9 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure name uniqueness. Note: We can't call {@code super.validate(FormSectionEvent)} here
|
* Ensure name uniqueness. Note: We can't call {@code super.validate(FormSectionEvent)} here because the super
|
||||||
* because the super method {@link BasicPageForm#validate(com.arsdigita.bebop.event.FormSectionEvent)} tries
|
* method {@link BasicPageForm#validate(com.arsdigita.bebop.event.FormSectionEvent)} tries to access properties
|
||||||
* to access properties which are not set yet.
|
* which are not set yet.
|
||||||
*
|
*
|
||||||
* @param fse
|
* @param fse
|
||||||
*/
|
*/
|
||||||
|
|
@ -231,5 +222,4 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
|
|
||||||
return GenericPerson.urlSave(profileUrl).toLowerCase();
|
return GenericPerson.urlSave(profileUrl).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,29 @@ import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.event.FormValidationListener;
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
import com.arsdigita.bebop.event.PrintEvent;
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
import com.arsdigita.bebop.event.PrintListener;
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
import com.arsdigita.bebop.form.TextField;
|
import com.arsdigita.bebop.form.TextField;
|
||||||
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.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.ContentTypeCollection;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
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.contenttypes.PublicPersonalProfileBundle;
|
||||||
|
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -62,12 +67,57 @@ public class PublicPersonalProfilePropertyForm extends BasicPageForm implements
|
||||||
final ParameterModel ownerModel = new StringParameter(PublicPersonalProfileBundle.OWNER);
|
final ParameterModel ownerModel = new StringParameter(PublicPersonalProfileBundle.OWNER);
|
||||||
final SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
final SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
||||||
ownerSelect.addValidationListener(new NotNullValidationListener());
|
ownerSelect.addValidationListener(new NotNullValidationListener());
|
||||||
|
add(ownerSelect);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ownerSelect.addPrintListener(new PrintListener() {
|
ownerSelect.addPrintListener(new PrintListener() {
|
||||||
|
public void prepare(final PrintEvent event) {
|
||||||
|
final SingleSelect ownerSelect = (SingleSelect) event.getTarget();
|
||||||
|
|
||||||
public void prepare(PrintEvent e) {
|
final PublicPersonalProfile profile = (PublicPersonalProfile) itemModel.getSelectedItem(event.
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
getPageState());
|
||||||
|
final GenericPerson owner = profile.getOwner();
|
||||||
|
|
||||||
|
String personType = PublicPersonalProfiles.getConfig().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(personType);
|
||||||
|
//persons.addFilter("profile is null");
|
||||||
|
persons.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
|
||||||
|
persons.addFilter(String.format("alias.id = '%s'", owner.getID().toString()));
|
||||||
|
persons.addOrder("surname asc");
|
||||||
|
persons.addOrder("givenname asc");
|
||||||
|
persons.addOrder("language asc");
|
||||||
|
|
||||||
|
|
||||||
|
// final GenericPerson owner = profile.getOwner();
|
||||||
|
// final GenericPerson alias = owner.getAlias();
|
||||||
|
|
||||||
|
ownerSelect.addOption(new Option(owner.getID().toString(), owner.getFullName()));
|
||||||
|
|
||||||
|
if (!persons.isEmpty()) {
|
||||||
|
final List<BigDecimal> processed = new ArrayList<BigDecimal>();
|
||||||
|
while(persons.next()) {
|
||||||
|
GenericPerson person = (GenericPerson) DomainObjectFactory.newInstance(persons.getDataObject());
|
||||||
|
if (processed.contains(person.getParent().getID())) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if (person.getGenericPersonBundle().get("profile") == null) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
ownerSelect.addOption(new Option(person.getID().toString(), person.getFullName()));
|
||||||
|
processed.add(person.getParent().getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (TooManyListenersException ex) {
|
} catch (TooManyListenersException ex) {
|
||||||
|
|
@ -82,7 +132,6 @@ public class PublicPersonalProfilePropertyForm extends BasicPageForm implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||||
//final PageState state = fse.getPageState();
|
|
||||||
final FormData data = fse.getFormData();
|
final FormData data = fse.getFormData();
|
||||||
final PublicPersonalProfile profile = (PublicPersonalProfile) super.initBasicWidgets(fse);
|
final PublicPersonalProfile profile = (PublicPersonalProfile) super.initBasicWidgets(fse);
|
||||||
|
|
||||||
|
|
@ -97,9 +146,10 @@ public class PublicPersonalProfilePropertyForm extends BasicPageForm implements
|
||||||
|
|
||||||
if ((profile != null) && getSaveCancelSection().getSaveButton().isSelected(state)) {
|
if ((profile != null) && getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
|
||||||
final String ownerId = (String)data.get(PublicPersonalProfileBundle.OWNER);
|
final String ownerId = (String) data.get(PublicPersonalProfileBundle.OWNER);
|
||||||
if (!profile.getOwner().getID().equals(new BigDecimal(ownerId))) {
|
if (!profile.getOwner().getID().equals(new BigDecimal(ownerId))) {
|
||||||
|
final GenericPerson newOwner = new GenericPerson(new BigDecimal(ownerId));
|
||||||
|
profile.setOwner(newOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.setProfileUrl(((String) data.get(PublicPersonalProfile.PROFILE_URL)).toLowerCase());
|
profile.setProfileUrl(((String) data.get(PublicPersonalProfile.PROFILE_URL)).toLowerCase());
|
||||||
|
|
@ -146,5 +196,4 @@ public class PublicPersonalProfilePropertyForm extends BasicPageForm implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue