Aus der Oberfläche für ein SciMember kann das SciMember jetzt einer Organisation (SciOrganization), einer Abteilung (SciDepartment) und einem Projekt (SciProject)

zugeordnet werden.


git-svn-id: https://svn.libreccm.org/ccm/trunk@842 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-04-08 19:12:17 +00:00
parent 51fa4c275b
commit 7b9cb0cb30
16 changed files with 1634 additions and 13 deletions

View File

@ -76,10 +76,16 @@ public class SciMember extends GenericPerson {
ORGANIZATIONS));
}
public void addOrganization(SciOrganization organization) {
public void addOrganization(SciOrganization organization,
String role,
String status) {
Assert.exists(organization, SciOrganization.class);
add(ORGANIZATIONS, organization);
DataObject link = add(ORGANIZATIONS, organization);
link.set(SciMemberSciOrganizationsCollection.MEMBER_ROLE, role);
link.set(SciMemberSciOrganizationsCollection.STATUS, status);
link.save();
}
public void removeOrganization(SciOrganization organization) {
@ -88,6 +94,50 @@ public class SciMember extends GenericPerson {
remove(ORGANIZATIONS, organization);
}
public SciMemberSciDepartmentsCollection getDepartments() {
return new SciMemberSciDepartmentsCollection((DataCollection) get(DEPARTMENTS));
}
public void addDepartment(SciDepartment department,
String role,
String status) {
Assert.exists(department, SciDepartment.class);
DataObject link = add(DEPARTMENTS, department);
link.set(SciMemberSciDepartmentsCollection.MEMBER_ROLE, role);
link.set(SciMemberSciDepartmentsCollection.STATUS, status);
link.save();
}
public void removeDepartment(SciDepartment department) {
Assert.exists(department, SciDepartment.class);
remove(DEPARTMENTS, department);
}
public SciMemberSciProjectsCollection getProjects() {
return new SciMemberSciProjectsCollection((DataCollection) get(PROJECTS));
}
public void addProject(SciProject project,
String role,
String status) {
Assert.exists(project, SciProject.class);
DataObject link = add(PROJECTS, project);
link.set(SciMemberSciDepartmentsCollection.MEMBER_ROLE, role);
link.set(SciMemberSciDepartmentsCollection.STATUS, status);
link.save();
}
public void removeProject(SciProject project) {
Assert.exists(project, SciProject.class);
remove(PROJECTS, project);
}
public static SciOrganizationConfig getConfig() {
return s_config;
}

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentType;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
/**
*
* @author Jens Pelzetter
* @version $Id$
*/
public class SciMemberSciDepartmentsCollection extends DomainCollection {
public static final String LINK_MEMBER_ROLE = "link.role_name";
public static final String LINK_STATUS = "link.status";
public static final String MEMBER_ROLE = "role_name";
public static final String STATUS = "status";
public SciMemberSciDepartmentsCollection(DataCollection dataCollection) {
super(dataCollection);
m_dataCollection.addFilter(String.format("type = %s",
ContentType.
findByAssociatedObjectType(SciDepartment.class.getName()).getID().
toString()));
m_dataCollection.addOrder("title");
}
public String getRoleName() {
return (String) m_dataCollection.get(LINK_MEMBER_ROLE);
}
public void setRoleName(String roleName) {
DataObject link = (DataObject) this.get("link");
link.set(MEMBER_ROLE, roleName);
}
public String getStatus() {
return (String) m_dataCollection.get(LINK_STATUS);
}
public void setStatus(String status) {
DataObject link = (DataObject) this.get("link");
link.set(STATUS, status);
}
public SciDepartment getDepartment() {
return (SciDepartment) DomainObjectFactory.newInstance(m_dataCollection.
getDataObject());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentType;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
/**
*
* @author Jens Pelzetter
* @version $Id$
*/
public class SciMemberSciProjectsCollection extends DomainCollection {
public static final String LINK_MEMBER_ROLE = "link.role_name";
public static final String LINK_STATUS = "link.status";
public static final String MEMBER_ROLE = "role_name";
public static final String STATUS = "status";
public SciMemberSciProjectsCollection(DataCollection dataCollection) {
super(dataCollection);
m_dataCollection.addFilter(String.format("type = %s",
ContentType.
findByAssociatedObjectType(SciProject.class.getName()).getID().
toString()));
m_dataCollection.addOrder("title");
}
public String getRoleName() {
return (String) m_dataCollection.get(LINK_MEMBER_ROLE);
}
public void setRoleName(String roleName) {
DataObject link = (DataObject) this.get("link");
link.set(MEMBER_ROLE, roleName);
}
public String getStatus() {
return (String) m_dataCollection.get(LINK_STATUS);
}
public void setStatus(String status) {
DataObject link = (DataObject) this.get("link");
link.set(STATUS, status);
}
public SciProject getProject() {
return (SciProject) DomainObjectFactory.newInstance(m_dataCollection.
getDataObject());
}
}

View File

@ -74,6 +74,15 @@ public class SciMemberPropertiesStep extends SimpleEditStep {
new SciMemberSciOrganizationsStep(itemModel,
parent));
segmentedPanel.addSegment(new Label((String) SciOrganizationGlobalizationUtil.
globalize("scimember.ui.departments").localize()),
new SciMemberSciDepartmentsStep(itemModel,
parent));
segmentedPanel.addSegment(new Label((String) SciOrganizationGlobalizationUtil.
globalize("scimember.ui.projects").localize()),
new SciMemberSciProjectsStep(itemModel,
parent));
setDisplayComponent(segmentedPanel);
}

View File

@ -0,0 +1,188 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.RelationAttribute;
import com.arsdigita.cms.RelationAttributeCollection;
import com.arsdigita.cms.contenttypes.SciDepartment;
import com.arsdigita.cms.contenttypes.SciMember;
import com.arsdigita.cms.contenttypes.SciMemberSciDepartmentsCollection;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.dispatcher.DispatcherHelper;
/**
*
* @author Jens Pelzetter
* @version $Id$
*/
public class SciMemberSciDepartmentAddForm
extends BasicItemForm
implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
private ItemSearchWidget itemSearch;
private final String ITEM_SEARCH = "sciMemberDepartment";
private SciMemberSciDepartmentsStep step;
private Label selectedDepartmentNameLabel;
public SciMemberSciDepartmentAddForm(ItemSelectionModel itemModel,
SciMemberSciDepartmentsStep step) {
super("sciMemberDepartmentAddForm", itemModel);
this.step = step;
}
@Override
public void addWidgets() {
add(new Label(SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.department.select_department")));
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(SciDepartment.class.getName()));
add(itemSearch);
selectedDepartmentNameLabel = new Label("");
add(selectedDepartmentNameLabel);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.role")));
ParameterModel roleParam =
new StringParameter(
SciMemberSciDepartmentsCollection.MEMBER_ROLE);
SingleSelect roleSelect = new SingleSelect(roleParam);
roleSelect.addValidationListener(new NotNullValidationListener());
roleSelect.addOption(
new Option("",
new Label((String) ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one").localize())));
RelationAttributeCollection roles = new RelationAttributeCollection(
"SciDepartmentRole");
roles.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage());
while (roles.next()) {
RelationAttribute role;
role = roles.getRelationAttribute();
roleSelect.addOption(new Option(role.getKey(), role.getName()));
}
add(roleSelect);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.status")));
ParameterModel statusModel =
new StringParameter(
SciMemberSciDepartmentsCollection.STATUS);
SingleSelect statusSelect = new SingleSelect(statusModel);
statusSelect.addValidationListener(new NotNullValidationListener());
statusSelect.addOption(new Option("",
new Label((String) ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one").localize())));
RelationAttributeCollection statusColl = new RelationAttributeCollection(
"GenericOrganizationalUnitMemberStatus");
statusColl.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage());
while (statusColl.next()) {
RelationAttribute status;
status = statusColl.getRelationAttribute();
statusSelect.addOption(new Option(status.getKey(), status.getName()));
}
add(statusSelect);
}
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
SciDepartment department;
String role;
String status;
department = step.getSelectedDepartment();
role = step.getSelectedDepartmentRole();
status = step.getSelectedDepartmentStatus();
if (department == null) {
itemSearch.setVisible(state, true);
selectedDepartmentNameLabel.setVisible(state, false);
} else {
data.put(ITEM_SEARCH, department);
data.put(SciMemberSciDepartmentsCollection.MEMBER_ROLE, role);
data.put(SciMemberSciDepartmentsCollection.STATUS, status);
itemSearch.setVisible(state, false);
selectedDepartmentNameLabel.setVisible(state, true);
selectedDepartmentNameLabel.setLabel(department.getTitle(), state);
}
setVisible(state, true);
}
@Override
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
SciMember member = (SciMember) getItemSelectionModel().getSelectedObject(
state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
SciDepartment department;
department = step.getSelectedDepartment();
if (department == null) {
member.addDepartment((SciDepartment) data.get(ITEM_SEARCH),
(String) data.get(
SciMemberSciDepartmentsCollection.MEMBER_ROLE),
(String) data.get(
SciMemberSciDepartmentsCollection.STATUS));
} else {
SciMemberSciDepartmentsCollection departments;
departments = member.getDepartments();
while (departments.next()) {
if (departments.getDepartment().equals(department)) {
break;
}
}
departments.setRoleName((String) data.get(
SciMemberSciDepartmentsCollection.MEMBER_ROLE));
departments.setStatus((String) data.get(
SciMemberSciDepartmentsCollection.STATUS));
step.setSelectedDepartment(null);
step.setSelectedDepartmentRole(null);
step.setSelectedDepartmentStatus(null);
departments.close();
}
init(fse);
}
}
@Override
public void submitted(FormSectionEvent fse) throws FormProcessException {
if (getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
step.setSelectedDepartment(null);
step.setSelectedDepartmentRole(null);
step.setSelectedDepartmentStatus(null);
init(fse);
}
}
}

View File

@ -0,0 +1,70 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.SciDepartment;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
/**
*
* @author Jens Pelzetter
* @version $Id$
*/
public class SciMemberSciDepartmentsStep extends SimpleEditStep {
private String MEMBER_ADD_DEPARTMENT_SHEET_NAME = "memberAddDepartment";
private SciDepartment selectedDepartment;
private String selectedDepartmentRole;
private String selectedDepartmentStatus;
public SciMemberSciDepartmentsStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
this(itemModel, parent, null);
}
public SciMemberSciDepartmentsStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent,
String prefix) {
super(itemModel, parent, prefix);
BasicItemForm addDepartmentForm = new SciMemberSciDepartmentAddForm(itemModel, this);
add(MEMBER_ADD_DEPARTMENT_SHEET_NAME,
(String) SciOrganizationGlobalizationUtil.globalize("scimember.ui.department.add").localize(),
new WorkflowLockedComponentAccess(addDepartmentForm, itemModel),
addDepartmentForm.getSaveCancelSection().getCancelButton());
setDisplayComponent(new SciMemberSciDepartmentsTable(itemModel, this));
}
protected SciDepartment getSelectedDepartment() {
return selectedDepartment;
}
protected void setSelectedDepartment(SciDepartment selectedDepartment) {
this.selectedDepartment = selectedDepartment;
}
protected String getSelectedDepartmentRole() {
return selectedDepartmentRole;
}
protected void setSelectedDepartmentRole(String selectedDepartmentRole) {
this.selectedDepartmentRole = selectedDepartmentRole;
}
protected String getSelectedDepartmentStatus() {
return selectedDepartmentStatus;
}
protected void setSelectedDepartmentStatus(String selectedDepartmentStatus) {
this.selectedDepartmentStatus = selectedDepartmentStatus;
}
protected void showEditComponent(PageState state) {
showComponent(state, MEMBER_ADD_DEPARTMENT_SHEET_NAME);
}
}

View File

@ -0,0 +1,337 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.RelationAttributeCollection;
import com.arsdigita.cms.contenttypes.SciMember;
import com.arsdigita.cms.contenttypes.SciMemberSciDepartmentsCollection;
import com.arsdigita.cms.contenttypes.SciDepartment;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.dispatcher.ItemResolver;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter
*/
public class SciMemberSciDepartmentsTable
extends Table
implements TableActionListener {
private static final Logger logger = Logger.getLogger(
SciMemberSciDepartmentsTable.class);
private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_EDIT_LINK = "table_col_edit_link";
private final String TABLE_COL_DEL = "table_col_del";
private final String TABLE_COL_UP = "table_col_up";
private final String TABLE_COL_DOWN = "table_col_down";
private ItemSelectionModel itemModel;
private SciMemberSciDepartmentsStep step;
public SciMemberSciDepartmentsTable(ItemSelectionModel itemModel,
SciMemberSciDepartmentsStep step) {
super();
this.itemModel = itemModel;
this.step = step;
setEmptyView(new Label(SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.departments.none")));
TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn(
0,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.department").localize(),
TABLE_COL_EDIT));
columnModel.add(new TableColumn(
1,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.department.role").localize()));
columnModel.add(new TableColumn(
2,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.department.status").localize()));
columnModel.add(new TableColumn(
3,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.department.edit").localize(),
TABLE_COL_EDIT_LINK));
columnModel.add(new TableColumn(
4,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.department.remove").localize(),
TABLE_COL_DEL));
setModelBuilder(
new SciMemberSciDepartmentsTableModelBuilder(itemModel));
columnModel.get(0).setCellRenderer(new EditCellRenderer());
columnModel.get(3).setCellRenderer(new EditLinkCellRenderer());
columnModel.get(4).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
private class SciMemberSciDepartmentsTableModelBuilder
extends LockableImpl
implements TableModelBuilder {
public SciMemberSciDepartmentsTableModelBuilder(
ItemSelectionModel itemModel) {
SciMemberSciDepartmentsTable.this.itemModel = itemModel;
}
@Override
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
SciMember member = (SciMember) itemModel.getSelectedObject(state);
return new SciMemberSciDepartmentsTableModel(table,
state,
member);
}
}
private class SciMemberSciDepartmentsTableModel implements TableModel {
private Table table;
private SciMemberSciDepartmentsCollection departments;
private SciDepartment department;
public SciMemberSciDepartmentsTableModel(Table table,
PageState state,
SciMember member) {
this.table = table;
this.departments = member.getDepartments();
}
@Override
public int getColumnCount() {
return table.getColumnModel().size();
}
@Override
public boolean nextRow() {
boolean ret;
if ((departments != null) && departments.next()) {
department = departments.getDepartment();
ret = true;
} else {
ret = false;
}
return ret;
}
@Override
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case 0:
return department.getTitle();
case 1:
RelationAttributeCollection role = new RelationAttributeCollection(
"SciDepartmentRole",
departments.getRoleName());
if (role.next()) {
String roleName = role.getName();
role.close();
return roleName;
} else {
return ContenttypesGlobalizationUtil.globalize(
"cms.ui.unknownRole").localize();
}
case 2:
RelationAttributeCollection status = new RelationAttributeCollection(
"GenericOrganizationalUnitMemberStatus",
departments.getStatus());
if (status.next()) {
String statusName = status.getName();
status.close();
return statusName;
} else {
return ContenttypesGlobalizationUtil.globalize(
"cms.ui.unknownStatus").localize();
}
case 3:
return SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.departments.edit_assoc").localize();
case 4:
return SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.departments.remove").localize();
default:
return null;
}
}
@Override
public Object getKeyAt(int columnIndex) {
return department.getID();
}
}
private class EditCellRenderer
extends LockableImpl
implements TableCellRenderer {
@Override
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state);
SciMember member = (SciMember) itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess(state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
member);
if (canEdit) {
SciDepartment department;
try {
department = new SciDepartment((BigDecimal) key);
} catch (DataObjectNotFoundException ex) {
logger.warn(String.format("No object with key '%s' found.",
key),
ex);
return new Label(value.toString());
}
ContentSection section = CMS.getContext().getContentSection();
ItemResolver resolver = section.getItemResolver();
Link link = new Link(value.toString(),
resolver.generateItemURL(state,
department,
section, department.
getVersion()));
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
private class EditLinkCellRenderer
extends LockableImpl
implements TableCellRenderer {
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
com.arsdigita.cms.SecurityManager securityManager =
Utilities.getSecurityManager(state);
SciMember member = (SciMember) itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess(state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
member);
if (canEdit) {
ControlLink link = new ControlLink(value.toString());
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
private class DeleteCellRenderer
extends LockableImpl
implements TableCellRenderer {
@Override
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int col) {
com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state);
SciMember member = (SciMember) itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess(state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
member);
if (canEdit) {
ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) SciOrganizationGlobalizationUtil.
globalize(
"scimember.ui.department."
+ "confirm_remove").
localize());
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
@Override
public void cellSelected(TableActionEvent event) {
PageState state = event.getPageState();
SciDepartment department = new SciDepartment(new BigDecimal(event.
getRowKey().toString()));
SciMember member = (SciMember) itemModel.getSelectedObject(state);
SciMemberSciDepartmentsCollection departments = member.
getDepartments();
TableColumn column = getColumnModel().get(event.getColumn().intValue());
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
} else if (TABLE_COL_EDIT_LINK.equals(
column.getHeaderKey().toString())) {
while (departments.next()) {
if (departments.getDepartment().equals(department)) {
break;
}
}
step.setSelectedDepartment(departments.getDepartment());
step.setSelectedDepartmentRole(departments.getRoleName());
step.setSelectedDepartmentStatus(departments.getStatus());
departments.close();
step.showEditComponent(state);
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
member.removeDepartment(department);
}
}
@Override
public void headSelected(TableActionEvent event) {
//Nothing to do
}
}

View File

@ -7,12 +7,23 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.RelationAttribute;
import com.arsdigita.cms.RelationAttributeCollection;
import com.arsdigita.cms.contenttypes.SciMember;
import com.arsdigita.cms.contenttypes.SciMemberSciOrganizationsCollection;
import com.arsdigita.cms.contenttypes.SciOrganization;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.dispatcher.DispatcherHelper;
/**
*
@ -21,13 +32,19 @@ import com.arsdigita.cms.ui.authoring.BasicItemForm;
public class SciMemberSciOrganizationAddForm
extends BasicItemForm
implements FormProcessListener,
FormInitListener {
FormInitListener,
FormSubmissionListener {
private ItemSearchWidget itemSearch;
private final String ITEM_SEARCH = "sciMemberOrganization";
private SciMemberSciOrganizationsStep step;
private Label selectedOrganizationNameLabel;
public SciMemberSciOrganizationAddForm(ItemSelectionModel itemModel) {
public SciMemberSciOrganizationAddForm(ItemSelectionModel itemModel,
SciMemberSciOrganizationsStep step) {
super("sciMemberOrganizationAddForm", itemModel);
this.step = step;
}
@Override
@ -37,12 +54,80 @@ public class SciMemberSciOrganizationAddForm
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(SciOrganization.class.getName()));
add(itemSearch);
selectedOrganizationNameLabel = new Label("");
add(selectedOrganizationNameLabel);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.role")));
ParameterModel roleParam =
new StringParameter(
SciMemberSciOrganizationsCollection.MEMBER_ROLE);
SingleSelect roleSelect = new SingleSelect(roleParam);
roleSelect.addValidationListener(new NotNullValidationListener());
roleSelect.addOption(
new Option("",
new Label((String) ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one").localize())));
RelationAttributeCollection roles = new RelationAttributeCollection(
"SciOrganizationRole");
roles.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage());
while (roles.next()) {
RelationAttribute role;
role = roles.getRelationAttribute();
roleSelect.addOption(new Option(role.getKey(), role.getName()));
}
add(roleSelect);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.status")));
ParameterModel statusModel =
new StringParameter(
SciMemberSciOrganizationsCollection.STATUS);
SingleSelect statusSelect = new SingleSelect(statusModel);
statusSelect.addValidationListener(new NotNullValidationListener());
statusSelect.addOption(new Option("",
new Label((String) ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one").localize())));
RelationAttributeCollection statusColl = new RelationAttributeCollection(
"GenericOrganizationalUnitMemberStatus");
statusColl.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage());
while (statusColl.next()) {
RelationAttribute status;
status = statusColl.getRelationAttribute();
statusSelect.addOption(new Option(status.getKey(), status.getName()));
}
add(statusSelect);
}
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
SciOrganization orga;
String role;
String status;
orga = step.getSelectedOrganization();
role = step.getSelectedOrganizationRole();
status = step.getSelectedOrganizationStatus();
if (orga == null) {
itemSearch.setVisible(state, true);
selectedOrganizationNameLabel.setVisible(state, false);
} else {
data.put(ITEM_SEARCH, orga);
data.put(SciMemberSciOrganizationsCollection.MEMBER_ROLE, role);
data.put(SciMemberSciOrganizationsCollection.STATUS, status);
itemSearch.setVisible(state, false);
selectedOrganizationNameLabel.setVisible(state, true);
selectedOrganizationNameLabel.setLabel(orga.getTitle(), state);
}
setVisible(state, true);
}
@ -54,10 +139,52 @@ public class SciMemberSciOrganizationAddForm
state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
member.addOrganization((SciOrganization) data.get(ITEM_SEARCH));
SciOrganization orga;
orga = step.getSelectedOrganization();
if (orga == null) {
member.addOrganization((SciOrganization) data.get(ITEM_SEARCH),
(String) data.get(
SciMemberSciOrganizationsCollection.MEMBER_ROLE),
(String) data.get(
SciMemberSciOrganizationsCollection.STATUS));
} else {
SciMemberSciOrganizationsCollection orgas;
orgas = member.getOrganizations();
while (orgas.next()) {
if (orgas.getOrganization().equals(orga)) {
break;
}
}
orgas.setRoleName((String) data.get(
SciMemberSciOrganizationsCollection.MEMBER_ROLE));
orgas.setStatus((String) data.get(
SciMemberSciOrganizationsCollection.STATUS));
step.setSelectedOrganization(null);
step.setSelectedOrganizationRole(null);
step.setSelectedOrganizationStatus(null);
orgas.close();
}
init(fse);
}
}
@Override
public void submitted(FormSectionEvent fse) throws FormProcessException {
if (getSaveCancelSection().getCancelButton().isSelected(
fse.getPageState())) {
step.setSelectedOrganization(null);
step.setSelectedOrganizationRole(null);
step.setSelectedOrganizationStatus(null);
init(fse);
}
}
}

View File

@ -30,7 +30,8 @@ public class SciMemberSciOrganizationsStep extends SimpleEditStep {
super(itemModel, parent, prefix);
BasicItemForm addOrganizationForm = new SciMemberSciOrganizationAddForm(
itemModel);
itemModel,
this);
add(MEMBER_ADD_ORGANIZATION_SHEET_NAME,
(String) SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.organization.add").localize(),
@ -40,14 +41,26 @@ public class SciMemberSciOrganizationsStep extends SimpleEditStep {
setDisplayComponent(new SciMemberSciOrganizationsTable(itemModel, this));
}
protected SciOrganization getSelectedOrganization() {
return selectedOrganization;
}
protected void setSelectedOrganization(SciOrganization organization) {
this.selectedOrganization = organization;
}
protected String getSelectedOrganizationRole() {
return selectedOrganizationRole;
}
protected void setSelectedOrganizationRole(String role) {
this.selectedOrganizationRole = role;
}
protected String getSelectedOrganizationStatus() {
return selectedOrganizationStatus;
}
protected void setSelectedOrganizationStatus(String status) {
this.selectedOrganizationStatus = status;
}

View File

@ -16,7 +16,6 @@ import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.RelationAttribute;
import com.arsdigita.cms.RelationAttributeCollection;
import com.arsdigita.cms.contenttypes.SciMember;
import com.arsdigita.cms.contenttypes.SciMemberSciOrganizationsCollection;
@ -48,7 +47,7 @@ public class SciMemberSciOrganizationsTable
private SciMemberSciOrganizationsStep step;
public SciMemberSciOrganizationsTable(ItemSelectionModel itemModel,
SciMemberSciOrganizationsStep step) {
SciMemberSciOrganizationsStep step) {
super();
this.itemModel = itemModel;
this.step = step;
@ -160,7 +159,7 @@ public class SciMemberSciOrganizationsTable
}
case 2:
RelationAttributeCollection status = new RelationAttributeCollection(
"SciOrganizationStatus",
"GenericOrganizationalUnitMemberStatus",
organizations.getStatus());
if (status.next()) {
String statusName = status.getName();
@ -287,7 +286,7 @@ public class SciMemberSciOrganizationsTable
link.setConfirmation((String) SciOrganizationGlobalizationUtil.
globalize(
"scimember.ui.organization."
+ ".confirm_remove").
+ "confirm_remove").
localize());
return link;
} else {
@ -312,13 +311,20 @@ public class SciMemberSciOrganizationsTable
TableColumn column = getColumnModel().get(event.getColumn().intValue());
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
} else if(TABLE_COL_EDIT_LINK.equals(column.getHeaderKey().toString())) {
while(organizations.next()) {
} else if (TABLE_COL_EDIT_LINK.equals(
column.getHeaderKey().toString())) {
while (organizations.next()) {
if (organizations.getOrganization().equals(organization)) {
break;
}
}
step.setSelectedOrganization(organizations.getOrganization());
step.setSelectedOrganizationRole(organizations.getRoleName());
step.setSelectedOrganizationStatus(organizations.getStatus());
organizations.close();
step.showEditComponent(state);
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
member.removeOrganization(organization);
}

View File

@ -0,0 +1,188 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.RelationAttribute;
import com.arsdigita.cms.RelationAttributeCollection;
import com.arsdigita.cms.contenttypes.SciProject;
import com.arsdigita.cms.contenttypes.SciMember;
import com.arsdigita.cms.contenttypes.SciMemberSciProjectsCollection;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.dispatcher.DispatcherHelper;
/**
*
* @author Jens Pelzetter
* @version $Id$
*/
public class SciMemberSciProjectAddForm
extends BasicItemForm
implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
private ItemSearchWidget itemSearch;
private final String ITEM_SEARCH = "sciMemberProject";
private SciMemberSciProjectsStep step;
private Label selectedProjectNameLabel;
public SciMemberSciProjectAddForm(ItemSelectionModel itemModel,
SciMemberSciProjectsStep step) {
super("sciMemberProjectAddForm", itemModel);
this.step = step;
}
@Override
public void addWidgets() {
add(new Label(SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.project.select_project")));
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(SciProject.class.getName()));
add(itemSearch);
selectedProjectNameLabel = new Label("");
add(selectedProjectNameLabel);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.role")));
ParameterModel roleParam =
new StringParameter(
SciMemberSciProjectsCollection.MEMBER_ROLE);
SingleSelect roleSelect = new SingleSelect(roleParam);
roleSelect.addValidationListener(new NotNullValidationListener());
roleSelect.addOption(
new Option("",
new Label((String) ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one").localize())));
RelationAttributeCollection roles = new RelationAttributeCollection(
"SciProjectRole");
roles.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage());
while (roles.next()) {
RelationAttribute role;
role = roles.getRelationAttribute();
roleSelect.addOption(new Option(role.getKey(), role.getName()));
}
add(roleSelect);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.status")));
ParameterModel statusModel =
new StringParameter(
SciMemberSciProjectsCollection.STATUS);
SingleSelect statusSelect = new SingleSelect(statusModel);
statusSelect.addValidationListener(new NotNullValidationListener());
statusSelect.addOption(new Option("",
new Label((String) ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one").localize())));
RelationAttributeCollection statusColl = new RelationAttributeCollection(
"GenericOrganizationalUnitMemberStatus");
statusColl.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage());
while (statusColl.next()) {
RelationAttribute status;
status = statusColl.getRelationAttribute();
statusSelect.addOption(new Option(status.getKey(), status.getName()));
}
add(statusSelect);
}
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
SciProject project;
String role;
String status;
project = step.getSelectedProject();
role = step.getSelectedProjectRole();
status = step.getSelectedProjectStatus();
if (project == null) {
itemSearch.setVisible(state, true);
selectedProjectNameLabel.setVisible(state, false);
} else {
data.put(ITEM_SEARCH, project);
data.put(SciMemberSciProjectsCollection.MEMBER_ROLE, role);
data.put(SciMemberSciProjectsCollection.STATUS, status);
itemSearch.setVisible(state, false);
selectedProjectNameLabel.setVisible(state, true);
selectedProjectNameLabel.setLabel(project.getTitle(), state);
}
setVisible(state, true);
}
@Override
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
SciMember member = (SciMember) getItemSelectionModel().getSelectedObject(
state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
SciProject project;
project = step.getSelectedProject();
if (project == null) {
member.addProject((SciProject) data.get(ITEM_SEARCH),
(String) data.get(
SciMemberSciProjectsCollection.MEMBER_ROLE),
(String) data.get(
SciMemberSciProjectsCollection.STATUS));
} else {
SciMemberSciProjectsCollection projects;
projects = member.getProjects();
while (projects.next()) {
if (projects.getProject().equals(project)) {
break;
}
}
projects.setRoleName((String) data.get(
SciMemberSciProjectsCollection.MEMBER_ROLE));
projects.setStatus((String) data.get(
SciMemberSciProjectsCollection.STATUS));
step.setSelectedProject(null);
step.setSelectedProjectRole(null);
step.setSelectedProjectStatus(null);
projects.close();
}
init(fse);
}
}
@Override
public void submitted(FormSectionEvent fse) throws FormProcessException {
if (getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
step.setSelectedProject(null);
step.setSelectedProjectRole(null);
step.setSelectedProjectStatus(null);
init(fse);
}
}
}

View File

@ -0,0 +1,70 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.SciProject;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
/**
*
* @author Jens Pelzetter
* @version $Id$
*/
public class SciMemberSciProjectsStep extends SimpleEditStep {
private String MEMBER_ADD_project_SHEET_NAME = "memberAddproject";
private SciProject selectedProject;
private String selectedProjectRole;
private String selectedProjectStatus;
public SciMemberSciProjectsStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
this(itemModel, parent, null);
}
public SciMemberSciProjectsStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent,
String prefix) {
super(itemModel, parent, prefix);
BasicItemForm addprojectForm = new SciMemberSciProjectAddForm(itemModel, this);
add(MEMBER_ADD_project_SHEET_NAME,
(String) SciOrganizationGlobalizationUtil.globalize("scimember.ui.project.add").localize(),
new WorkflowLockedComponentAccess(addprojectForm, itemModel),
addprojectForm.getSaveCancelSection().getCancelButton());
setDisplayComponent(new SciMemberSciProjectsTable(itemModel, this));
}
protected SciProject getSelectedProject() {
return selectedProject;
}
protected void setSelectedProject(SciProject selectedProject) {
this.selectedProject = selectedProject;
}
protected String getSelectedProjectRole() {
return selectedProjectRole;
}
protected void setSelectedProjectRole(String selectedProjectRole) {
this.selectedProjectRole = selectedProjectRole;
}
protected String getSelectedProjectStatus() {
return selectedProjectStatus;
}
protected void setSelectedProjectStatus(String selectedProjectStatus) {
this.selectedProjectStatus = selectedProjectStatus;
}
protected void showEditComponent(PageState state) {
showComponent(state, MEMBER_ADD_project_SHEET_NAME);
}
}

View File

@ -0,0 +1,337 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.RelationAttributeCollection;
import com.arsdigita.cms.contenttypes.SciMember;
import com.arsdigita.cms.contenttypes.SciMemberSciProjectsCollection;
import com.arsdigita.cms.contenttypes.SciProject;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.dispatcher.ItemResolver;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter
*/
public class SciMemberSciProjectsTable
extends Table
implements TableActionListener {
private static final Logger logger = Logger.getLogger(
SciMemberSciProjectsTable.class);
private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_EDIT_LINK = "table_col_edit_link";
private final String TABLE_COL_DEL = "table_col_del";
private final String TABLE_COL_UP = "table_col_up";
private final String TABLE_COL_DOWN = "table_col_down";
private ItemSelectionModel itemModel;
private SciMemberSciProjectsStep step;
public SciMemberSciProjectsTable(ItemSelectionModel itemModel,
SciMemberSciProjectsStep step) {
super();
this.itemModel = itemModel;
this.step = step;
setEmptyView(new Label(SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.projects.none")));
TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn(
0,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.project").localize(),
TABLE_COL_EDIT));
columnModel.add(new TableColumn(
1,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.project.role").localize()));
columnModel.add(new TableColumn(
2,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.project.status").localize()));
columnModel.add(new TableColumn(
3,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.project.edit").localize(),
TABLE_COL_EDIT_LINK));
columnModel.add(new TableColumn(
4,
SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.project.remove").localize(),
TABLE_COL_DEL));
setModelBuilder(
new SciMemberSciProjectsTableModelBuilder(itemModel));
columnModel.get(0).setCellRenderer(new EditCellRenderer());
columnModel.get(3).setCellRenderer(new EditLinkCellRenderer());
columnModel.get(4).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
private class SciMemberSciProjectsTableModelBuilder
extends LockableImpl
implements TableModelBuilder {
public SciMemberSciProjectsTableModelBuilder(
ItemSelectionModel itemModel) {
SciMemberSciProjectsTable.this.itemModel = itemModel;
}
@Override
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
SciMember member = (SciMember) itemModel.getSelectedObject(state);
return new SciMemberSciProjectsTableModel(table,
state,
member);
}
}
private class SciMemberSciProjectsTableModel implements TableModel {
private Table table;
private SciMemberSciProjectsCollection projects;
private SciProject project;
public SciMemberSciProjectsTableModel(Table table,
PageState state,
SciMember member) {
this.table = table;
this.projects = member.getProjects();
}
@Override
public int getColumnCount() {
return table.getColumnModel().size();
}
@Override
public boolean nextRow() {
boolean ret;
if ((projects != null) && projects.next()) {
project = projects.getProject();
ret = true;
} else {
ret = false;
}
return ret;
}
@Override
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case 0:
return project.getTitle();
case 1:
RelationAttributeCollection role = new RelationAttributeCollection(
"SciProjectRole",
projects.getRoleName());
if (role.next()) {
String roleName = role.getName();
role.close();
return roleName;
} else {
return ContenttypesGlobalizationUtil.globalize(
"cms.ui.unknownRole").localize();
}
case 2:
RelationAttributeCollection status = new RelationAttributeCollection(
"GenericOrganizationalUnitMemberStatus",
projects.getStatus());
if (status.next()) {
String statusName = status.getName();
status.close();
return statusName;
} else {
return ContenttypesGlobalizationUtil.globalize(
"cms.ui.unknownStatus").localize();
}
case 3:
return SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.projects.edit_assoc").localize();
case 4:
return SciOrganizationGlobalizationUtil.globalize(
"scimember.ui.projects.remove").localize();
default:
return null;
}
}
@Override
public Object getKeyAt(int columnIndex) {
return project.getID();
}
}
private class EditCellRenderer
extends LockableImpl
implements TableCellRenderer {
@Override
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state);
SciMember member = (SciMember) itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess(state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
member);
if (canEdit) {
SciProject project;
try {
project = new SciProject((BigDecimal) key);
} catch (DataObjectNotFoundException ex) {
logger.warn(String.format("No object with key '%s' found.",
key),
ex);
return new Label(value.toString());
}
ContentSection section = CMS.getContext().getContentSection();
ItemResolver resolver = section.getItemResolver();
Link link = new Link(value.toString(),
resolver.generateItemURL(state,
project,
section, project.
getVersion()));
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
private class EditLinkCellRenderer
extends LockableImpl
implements TableCellRenderer {
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
com.arsdigita.cms.SecurityManager securityManager =
Utilities.getSecurityManager(state);
SciMember member = (SciMember) itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess(state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
member);
if (canEdit) {
ControlLink link = new ControlLink(value.toString());
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
private class DeleteCellRenderer
extends LockableImpl
implements TableCellRenderer {
@Override
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int col) {
com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state);
SciMember member = (SciMember) itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess(state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
member);
if (canEdit) {
ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) SciOrganizationGlobalizationUtil.
globalize(
"scimember.ui.project."
+ "confirm_remove").
localize());
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
@Override
public void cellSelected(TableActionEvent event) {
PageState state = event.getPageState();
SciProject project = new SciProject(new BigDecimal(event.
getRowKey().toString()));
SciMember member = (SciMember) itemModel.getSelectedObject(state);
SciMemberSciProjectsCollection projects = member.
getProjects();
TableColumn column = getColumnModel().get(event.getColumn().intValue());
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
} else if (TABLE_COL_EDIT_LINK.equals(
column.getHeaderKey().toString())) {
while (projects.next()) {
if (projects.getProject().equals(project)) {
break;
}
}
step.setSelectedProject(projects.getProject());
step.setSelectedProjectRole(projects.getRoleName());
step.setSelectedProjectStatus(projects.getStatus());
projects.close();
step.showEditComponent(state);
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
member.removeProject(project);
}
}
@Override
public void headSelected(TableActionEvent event) {
//Nothing to do
}
}

View File

@ -139,3 +139,41 @@ sciorganizations.ui.department.title=Name of the department
sciorganizations.ui.organization.title=Name of the organization
sciorganizations.ui.project.title=Name of the project
sciorganization.ui.project.funding_volume=Volume of funding
scimember.ui.basic_properties=Basic properties
scimember.ui.organization=Organization
scimember.ui.organization.role=Role
scimember.ui.organization.status=Status
scimember.ui.organization.edit=Edit
scimember.ui.organization.remove=Remove
scimember.ui.organizations.edit_assoc=Edit association
scimember.ui.organizations.remove=Remove assoication
scimember.ui.organization.add=Add member to organization
scimember.ui.organization.select_organization=Organization
scimember.ui.organization.confirm_remove=Do you really want to remove this association?
scimember.ui.departments=Departments
scimember.ui.projects=Projects
scimember.ui.organizations=Organizations
scimember.ui.department=Department
scimember.ui.department.role=Role
scimember.ui.department.status=Status
scimember.ui.department.edit=Edit
scimember.ui.department.remove=Remove
scimember.ui.departments.edit_assoc=Edit association
scimember.ui.departments.remove=Remove association
scimember.ui.department.add=Add member to department
scimember.ui.organizations.none=This member is not associated to any organization
scimember.ui.departments.none=This member is not associated to any department
scimember.ui.projects.none=This member is not associated to any project
scimember.ui.project.add=Add member to project
scimember.ui.project=Project
scimember.ui.project.role=Role
scimember.ui.project.status=Status
scimember.ui.project.edit=Edit
scimember.ui.project.remove=Remove
scimember.ui.project.edit_assoc=Edit association
scimember.ui.projects.remove=Remove association
scimember.ui.department.select_department=Department
scimember.ui.department.confirm_remove=Do you really want to remove this association?
scimember.ui.project.confirm_remove=Do you really want to remove this association?
scimember.ui.project.select_project=Project
scimember.ui.projects.edit_assoc=Edit association

View File

@ -139,3 +139,41 @@ sciorganizations.ui.department.title=Bezeichnung der Abteilung
sciorganizations.ui.organization.title=Name der Organisation
sciorganizations.ui.project.title=Name des Projektes
sciorganization.ui.project.funding_volume=Volumen der Finanzierung
scimember.ui.basic_properties=Basiseigenschaften
scimember.ui.organization=Organisation
scimember.ui.organization.role=Rolle
scimember.ui.organization.status=Status
scimember.ui.organization.edit=Bearbeiten
scimember.ui.organization.remove=Entfernen
scimember.ui.organizations.edit_assoc=Verkn\u00fcpfung bearbeiten
scimember.ui.organizations.remove=Verkn\u00fcpfung entfernen
scimember.ui.organization.add=Mitglied einer Organisation hinzuf\u00fcgen
scimember.ui.organization.select_organization=Organisation
scimember.ui.organization.confirm_remove=Wollen Sie diese Verkn\u00fcpfung wirklich entfernen?
scimember.ui.departments=Abteilungen
scimember.ui.projects=Projekte
scimember.ui.organizations=Organisationen
scimember.ui.department=Abteilung
scimember.ui.department.role=Rolle
scimember.ui.department.status=Status
scimember.ui.department.edit=Bearbeiten
scimember.ui.department.remove=Entfernen
scimember.ui.departments.edit_assoc=Verkn\u00fcpfung bearbeiten
scimember.ui.departments.remove=Verkn\u00fcpfung entfernen
scimember.ui.department.add=Mitglied einer Abteilung hinzuf\u00fcgen
scimember.ui.organizations.none=Dieses Mitglied ist keinen Organisationen zugeordnet
scimember.ui.departments.none=Dieses Mitglied ist keinen Abteilungen zugeordnet
scimember.ui.projects.none=Dieses Mitglied ist keinen Projekten zugeordnet
scimember.ui.project.add=Mitglied einem Projekt hinzuf\u00fcgen
scimember.ui.project=Projekt
scimember.ui.project.role=Rolle
scimember.ui.project.status=Status
scimember.ui.project.edit=Bearbeiten
scimember.ui.project.remove=Entfernen
scimember.ui.project.edit_assoc=Verkn\u00fcpfung bearbeiten
scimember.ui.projects.remove=Verkn\u00fcpfung entfernen
scimember.ui.department.select_department=Abteilung
scimember.ui.department.confirm_remove=Wollen Sie diese Verkn\u00fcpfung wirklich entfernen?
scimember.ui.project.confirm_remove=Wollen Sie diese Verkn\u00fcpfung wirklich entfernen?
scimember.ui.project.select_project=Projekt
scimember.ui.projects.edit_assoc=Verkn\u00fcpfung bearbeiten