Removes the use of DataQueries in RolePartyAddForm and uses the PartyRepository instead.
Removes the filtering by user information and adds a note in the JavaDoc™. git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4355 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
55f5b8ef5f
commit
949414b7f1
|
|
@ -33,10 +33,16 @@ import org.libreccm.cdi.utils.CdiUtil;
|
||||||
import org.libreccm.security.*;
|
import org.libreccm.security.*;
|
||||||
import org.librecms.CmsConstants;
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Adds a form which can add {@link Party parties} to {@link Role roles}.
|
||||||
|
* Also enables searching for parties.
|
||||||
|
*
|
||||||
|
* NOTE: In earlier versions it was also possible to filter
|
||||||
|
* parties using {@link User} attributes such as username, name, last name, etc.
|
||||||
|
* This feature may be added later if still needed.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
|
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
|
||||||
* @author Michael Pih
|
* @author Michael Pih
|
||||||
|
|
@ -50,12 +56,7 @@ class RolePartyAddForm extends PartyAddForm {
|
||||||
|
|
||||||
private SingleSelectionModel m_roles;
|
private SingleSelectionModel m_roles;
|
||||||
|
|
||||||
private static final String NAME_FILTER =
|
RolePartyAddForm(SingleSelectionModel roles, TextField search) {
|
||||||
"(upper(name) like ('%' || upper(:search) || '%'))" +
|
|
||||||
" or " +
|
|
||||||
"(upper(email) like ('%' || upper(:search) || '%'))";
|
|
||||||
|
|
||||||
public RolePartyAddForm(SingleSelectionModel roles, TextField search) {
|
|
||||||
super(search);
|
super(search);
|
||||||
|
|
||||||
m_roles = roles;
|
m_roles = roles;
|
||||||
|
|
@ -64,54 +65,26 @@ class RolePartyAddForm extends PartyAddForm {
|
||||||
(new FormSecurityListener(CmsConstants.PRIVILEGE_ADMINISTER_ROLES));
|
(new FormSecurityListener(CmsConstants.PRIVILEGE_ADMINISTER_ROLES));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
protected DataQuery makeQuery(PageState s) {
|
|
||||||
Assert.isTrue(m_roles.isSelected(s));
|
|
||||||
|
|
||||||
Session session = SessionManager.getSession();
|
|
||||||
|
|
||||||
// XXX: Figure out how to use role directly here
|
|
||||||
DataQuery dq =
|
|
||||||
session.retrieveQuery("com.arsdigita.cms.searchToAddMemberParties");
|
|
||||||
|
|
||||||
BigDecimal roleId = new BigDecimal((String) m_roles.getSelectedKey(s));
|
|
||||||
String searchQuery = (String) getSearchWidget().getValue(s);
|
|
||||||
|
|
||||||
makeFilter(dq, roleId, searchQuery);
|
|
||||||
dq.addOrder("isUser desc, upper(name), upper(email)");
|
|
||||||
return dq;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Party> makeQuery(PageState state) {
|
protected List<Party> makeQuery(PageState s) {
|
||||||
return null;
|
Assert.isTrue(m_roles.isSelected(s));
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.class);
|
||||||
|
|
||||||
|
final String searchQuery = (String) getSearchWidget().getValue(s);
|
||||||
|
|
||||||
|
return partyRepository.searchByName(searchQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters out members of the current group and parties whose name or email
|
|
||||||
* address matches the search string.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
private void makeFilter(DataQuery dq, BigDecimal roleId, String search) {
|
|
||||||
|
|
||||||
dq.setParameter("excludedRoleId", roleId);
|
|
||||||
|
|
||||||
// Add the search filter if the search query is not null.
|
|
||||||
if (search != null) {
|
|
||||||
|
|
||||||
dq.clearFilter();
|
|
||||||
Filter filter = dq.addFilter(NAME_FILTER);
|
|
||||||
filter.set("search", search);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void process(FormSectionEvent event) throws FormProcessException {
|
public void process(FormSectionEvent event) throws FormProcessException {
|
||||||
FormData data = event.getFormData();
|
FormData data = event.getFormData();
|
||||||
PageState state = event.getPageState();
|
PageState state = event.getPageState();
|
||||||
Assert.isTrue(m_roles.isSelected(state));
|
Assert.isTrue(m_roles.isSelected(state));
|
||||||
|
|
||||||
String[] parties = (String[]) data.get("parties");
|
String[] parties = (String[]) data.get("parties");
|
||||||
s_log.debug("PARTIES = " + parties);
|
s_log.debug("PARTIES = " + Arrays.toString(parties));
|
||||||
if (parties == null) {
|
if (parties == null) {
|
||||||
throw new FormProcessException(GlobalizationUtil.globalize(
|
throw new FormProcessException(GlobalizationUtil.globalize(
|
||||||
"cms.ui.role.no_party_selected"));
|
"cms.ui.role.no_party_selected"));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue