JavaDoc für GenericOrganization und OrganizationRole und zugehoeriges AuthoringKit
git-svn-id: https://svn.libreccm.org/ccm/trunk@194 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
2b282dcdd8
commit
c2e48682b3
|
|
@ -35,10 +35,9 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
* It is also possible to add roles to the organization, e.g. CEO, mayor or others.
|
* It is also possible to add roles to the organization, e.g. CEO, mayor or others.
|
||||||
* The following features are planned to implement in one of the next commits:
|
* The following features are planned to implement in one of the next commits:
|
||||||
* - Ability to add persons (ccm-cms-types-person) to a role
|
|
||||||
* - Adding OrganizationUnits
|
* - Adding OrganizationUnits
|
||||||
*
|
*
|
||||||
* The current version of this contenttype is modeled on base on the MultipartArticle
|
* The current version of this contenttype is modeled on base of the MultipartArticle
|
||||||
* contenttype.
|
* contenttype.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
import com.arsdigita.runtime.AbstractConfig;
|
||||||
import com.arsdigita.util.parameter.Parameter;
|
|
||||||
import com.arsdigita.util.parameter.BooleanParameter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration for GenericOrganization. Not used yet.
|
* Configuration for GenericOrganization. Not used yet.
|
||||||
|
|
|
||||||
|
|
@ -20,46 +20,101 @@ import java.math.BigDecimal;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This class represents an role in a organization. Examples for roles
|
||||||
|
* are CEO, chairmen, mayor, speaker etc.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
public class OrganizationRole extends ACSObject {
|
public class OrganizationRole extends ACSObject {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(OrganizationRole.class);
|
private static final Logger logger = Logger.getLogger(OrganizationRole.class);
|
||||||
|
/**
|
||||||
|
* PDL identifier of the name property of the role
|
||||||
|
*/
|
||||||
public static final String ROLENAME = "roleName";
|
public static final String ROLENAME = "roleName";
|
||||||
|
/**
|
||||||
|
* PDL identifier for the targetItem - the person assoicated with the role.
|
||||||
|
*/
|
||||||
public static final String TARGETITEM = "targetItem";
|
public static final String TARGETITEM = "targetItem";
|
||||||
|
/**
|
||||||
|
* PDL for identifier for the organization associated with this role.
|
||||||
|
*/
|
||||||
public static final String ROLEOWNER = "roleOwner";
|
public static final String ROLEOWNER = "roleOwner";
|
||||||
|
/**
|
||||||
|
* PDL id for the property for ordering the roles of an organization.
|
||||||
|
*/
|
||||||
public static final String ORDER = "roleOrder";
|
public static final String ORDER = "roleOrder";
|
||||||
|
/**
|
||||||
|
* Type of this object.
|
||||||
|
*/
|
||||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationRole";
|
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationRole";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty construtor creating a new role
|
||||||
|
*/
|
||||||
public OrganizationRole() {
|
public OrganizationRole() {
|
||||||
this(BASE_DATA_OBJECT_TYPE);
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to get the role with @id from the database.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @throws com.arsdigita.domain.DataObjectNotFoundException
|
||||||
|
*/
|
||||||
public OrganizationRole(BigDecimal id) throws DataObjectNotFoundException {
|
public OrganizationRole(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to get the role with @id from the database.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @throws com.arsdigita.domain.DataObjectNotFoundException
|
||||||
|
*/
|
||||||
public OrganizationRole(OID id) throws DataObjectNotFoundException {
|
public OrganizationRole(OID id) throws DataObjectNotFoundException {
|
||||||
super(id);
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to find obj in the database.
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
*/
|
||||||
public OrganizationRole(DataObject obj) {
|
public OrganizationRole(DataObject obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new role.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
public OrganizationRole(String type) {
|
public OrganizationRole(String type) {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The name of the role.
|
||||||
|
*/
|
||||||
public String getRolename() {
|
public String getRolename() {
|
||||||
return (String) get(ROLENAME);
|
return (String) get(ROLENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the role
|
||||||
|
*
|
||||||
|
* @param rolename
|
||||||
|
*/
|
||||||
public void setRolename(String rolename) {
|
public void setRolename(String rolename) {
|
||||||
set(ROLENAME, rolename);
|
set(ROLENAME, rolename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The owning organization.
|
||||||
|
*/
|
||||||
public GenericOrganization getRoleOwner() {
|
public GenericOrganization getRoleOwner() {
|
||||||
DataObject obj = (DataObject) get(ROLEOWNER);
|
DataObject obj = (DataObject) get(ROLEOWNER);
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
|
|
@ -69,30 +124,58 @@ public class OrganizationRole extends ACSObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the owing organization.
|
||||||
|
*
|
||||||
|
* @param orga
|
||||||
|
*/
|
||||||
public void setRoleOwner(GenericOrganization orga) {
|
public void setRoleOwner(GenericOrganization orga) {
|
||||||
Assert.exists(orga, GenericOrganization.class);
|
Assert.exists(orga, GenericOrganization.class);
|
||||||
logger.debug(String.format("Setting role owner to %s", orga.getOrganizationName()));
|
logger.debug(String.format("Setting role owner to %s", orga.getOrganizationName()));
|
||||||
setAssociation(ROLEOWNER, orga);
|
setAssociation(ROLEOWNER, orga);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The person associated with the role.
|
||||||
|
*/
|
||||||
public Person getTargetItem() {
|
public Person getTargetItem() {
|
||||||
DataObject object = (DataObject) get(TARGETITEM);
|
DataObject object = (DataObject) get(TARGETITEM);
|
||||||
return (Person) DomainObjectFactory.newInstance(object);
|
return (Person) DomainObjectFactory.newInstance(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the person associated with the role
|
||||||
|
*
|
||||||
|
* @param item
|
||||||
|
*/
|
||||||
public void setTargetItem(Person item) {
|
public void setTargetItem(Person item) {
|
||||||
setAssociation(TARGETITEM, item);
|
setAssociation(TARGETITEM, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The order of the role.
|
||||||
|
*/
|
||||||
public Integer getOrder() {
|
public Integer getOrder() {
|
||||||
return (Integer) get(ORDER);
|
return (Integer) get(ORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the order of the role
|
||||||
|
*
|
||||||
|
* @param order
|
||||||
|
*/
|
||||||
public void setOrder(Integer order) {
|
public void setOrder(Integer order) {
|
||||||
Assert.exists(order);
|
Assert.exists(order);
|
||||||
set(ORDER, order);
|
set(ORDER, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* @param s Current PageState
|
||||||
|
* @return The URI of the target item.
|
||||||
|
*/
|
||||||
public String getURI(PageState s) {
|
public String getURI(PageState s) {
|
||||||
Person item = getTargetItem();
|
Person item = getTargetItem();
|
||||||
|
|
||||||
|
|
@ -108,6 +191,11 @@ public class OrganizationRole extends ACSObject {
|
||||||
return URL.there(s.getRequest(), url).toString();
|
return URL.there(s.getRequest(), url).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param person
|
||||||
|
* @return All roles a person is associated with.
|
||||||
|
*/
|
||||||
public static DataCollection getReferingRoles(Person person) {
|
public static DataCollection getReferingRoles(Person person) {
|
||||||
Session session = SessionManager.getSession();
|
Session session = SessionManager.getSession();
|
||||||
DataCollection roles = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
DataCollection roles = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
@ -117,6 +205,11 @@ public class OrganizationRole extends ACSObject {
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param orga
|
||||||
|
* @return all roles an organization is associated with.
|
||||||
|
*/
|
||||||
public static DataCollection getRoles(GenericOrganization orga) {
|
public static DataCollection getRoles(GenericOrganization orga) {
|
||||||
logger.debug("Getting roles for an organization...");
|
logger.debug("Getting roles for an organization...");
|
||||||
Session session = SessionManager.getSession();
|
Session session = SessionManager.getSession();
|
||||||
|
|
@ -126,34 +219,75 @@ public class OrganizationRole extends ACSObject {
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps an role with the next in the order.
|
||||||
|
*
|
||||||
|
* @throws java.lang.UnsupportedOperationException
|
||||||
|
*/
|
||||||
public void swapWithNext() throws UnsupportedOperationException {
|
public void swapWithNext() throws UnsupportedOperationException {
|
||||||
swapWithNext("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup");
|
swapWithNext("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps a role with the previous in the order.
|
||||||
|
*
|
||||||
|
* @throws java.lang.UnsupportedOperationException
|
||||||
|
*/
|
||||||
public void swapWithPrevious() throws UnsupportedOperationException {
|
public void swapWithPrevious() throws UnsupportedOperationException {
|
||||||
swapWithNext("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup");
|
swapWithNext("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps an role with the next in the order.
|
||||||
|
*
|
||||||
|
* @param queryName
|
||||||
|
* @param operationName
|
||||||
|
*/
|
||||||
public void swapWithNext(String queryName, String operationName) {
|
public void swapWithNext(String queryName, String operationName) {
|
||||||
swapKeys(true, queryName, operationName);
|
swapKeys(true, queryName, operationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps a role with the previous in the order.
|
||||||
|
*
|
||||||
|
* @param queryName
|
||||||
|
* @param operationName
|
||||||
|
*/
|
||||||
public void swapWithPrevious(String queryName, String operationName) {
|
public void swapWithPrevious(String queryName, String operationName) {
|
||||||
swapKeys(false, queryName, operationName);
|
swapKeys(false, queryName, operationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the query for swaping roles definied in the PDL.
|
||||||
|
*
|
||||||
|
* @param queryName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
protected DataQuery getSwapQuery(String queryName) {
|
protected DataQuery getSwapQuery(String queryName) {
|
||||||
DataQuery query = SessionManager.getSession().retrieveQuery(queryName);
|
DataQuery query = SessionManager.getSession().retrieveQuery(queryName);
|
||||||
query.setParameter("ownerID", getRoleOwner().getID());
|
query.setParameter("ownerID", getRoleOwner().getID());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the PDL operation for swaping.
|
||||||
|
*
|
||||||
|
* @param operationName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
protected DataOperation getSwapOperation(String operationName) {
|
protected DataOperation getSwapOperation(String operationName) {
|
||||||
DataOperation operation = SessionManager.getSession().retrieveDataOperation(operationName);
|
DataOperation operation = SessionManager.getSession().retrieveDataOperation(operationName);
|
||||||
operation.setParameter("ownerID", getRoleOwner().getID());
|
operation.setParameter("ownerID", getRoleOwner().getID());
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps the keys of two roles.
|
||||||
|
*
|
||||||
|
* @param swapNext
|
||||||
|
* @param queryName
|
||||||
|
* @param operationName
|
||||||
|
*/
|
||||||
protected void swapKeys(boolean swapNext, String queryName, String operationName) {
|
protected void swapKeys(boolean swapNext, String queryName, String operationName) {
|
||||||
String methodName = null;
|
String methodName = null;
|
||||||
if (swapNext) {
|
if (swapNext) {
|
||||||
|
|
@ -202,6 +336,9 @@ public class OrganizationRole extends ACSObject {
|
||||||
operation.execute();
|
operation.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected void alphabetize() {
|
protected void alphabetize() {
|
||||||
Session session = SessionManager.getSession();
|
Session session = SessionManager.getSession();
|
||||||
DataCollection roles = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
DataCollection roles = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
@ -216,6 +353,10 @@ public class OrganizationRole extends ACSObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public int maxOrder() {
|
public int maxOrder() {
|
||||||
GenericOrganization roleOwner = getRoleOwner();
|
GenericOrganization roleOwner = getRoleOwner();
|
||||||
if (roleOwner == null) {
|
if (roleOwner == null) {
|
||||||
|
|
@ -236,6 +377,9 @@ public class OrganizationRole extends ACSObject {
|
||||||
return returnOrder;
|
return returnOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before the object is saved to the database.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void beforeSave() {
|
public void beforeSave() {
|
||||||
super.beforeSave();
|
super.beforeSave();
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ import java.text.DateFormat;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* AuthoringStep for the basic properties of an organization (name, name addendum and
|
||||||
|
* a short description).
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
|
|
@ -25,8 +27,18 @@ public class GenericOrganizationPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(GenericOrganizationPropertiesStep.class);
|
private static final Logger logger = Logger.getLogger(GenericOrganizationPropertiesStep.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the this edit sheet (Don't know if this this really needed.
|
||||||
|
* It has the same value in almost all PropertiesStep classes)
|
||||||
|
*/
|
||||||
public static final String EDIT_SHEET_NAME = "edit";
|
public static final String EDIT_SHEET_NAME = "edit";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for the PropertiesStep.
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
* @param parent
|
||||||
|
*/
|
||||||
public GenericOrganizationPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
public GenericOrganizationPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
super(itemModel, parent);
|
super(itemModel, parent);
|
||||||
|
|
||||||
|
|
@ -39,6 +51,13 @@ public class GenericOrganizationPropertiesStep extends SimpleEditStep {
|
||||||
setDisplayComponent(getGenericOrganizationPropertySheet(itemModel));
|
setDisplayComponent(getGenericOrganizationPropertySheet(itemModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns the sheet for editing the basic properties
|
||||||
|
* of an organization. (@see GenericOrganizationPropertyForm).
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
* @return The sheet for editing the properties of the organization.
|
||||||
|
*/
|
||||||
public static Component getGenericOrganizationPropertySheet(ItemSelectionModel itemModel) {
|
public static Component getGenericOrganizationPropertySheet(ItemSelectionModel itemModel) {
|
||||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Form for editing the basic properties of an organization.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,12 +43,26 @@ public class GenericOrganizationPropertyForm extends BasicPageForm implements Fo
|
||||||
*/
|
*/
|
||||||
public static final String DESCRIPTION = GenericOrganization.DESCRIPTION;
|
public static final String DESCRIPTION = GenericOrganization.DESCRIPTION;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the form
|
||||||
|
*/
|
||||||
public static final String ID = "GenericOrganization_edit";
|
public static final String ID = "GenericOrganization_edit";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constrctor taking an ItemSelectionModel
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
*/
|
||||||
public GenericOrganizationPropertyForm(ItemSelectionModel itemModel) {
|
public GenericOrganizationPropertyForm(ItemSelectionModel itemModel) {
|
||||||
this(itemModel, null);
|
this(itemModel, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constrctor taking an ItemSelectionModel and an instance of GenericOrganizationPropertiesStep.
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
* @param step
|
||||||
|
*/
|
||||||
public GenericOrganizationPropertyForm(ItemSelectionModel itemModel, GenericOrganizationPropertiesStep step) {
|
public GenericOrganizationPropertyForm(ItemSelectionModel itemModel, GenericOrganizationPropertiesStep step) {
|
||||||
super(ID, itemModel);
|
super(ID, itemModel);
|
||||||
m_step = step;
|
m_step = step;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer;
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Authoring step for adding roles (e.g. chairmen) to an organization.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
|
|
@ -22,6 +23,12 @@ public class OrganizationRolePropertiesStep extends ResettableContainer {
|
||||||
private BigDecimalParameter m_roleParam = new BigDecimalParameter("organizationrole");
|
private BigDecimalParameter m_roleParam = new BigDecimalParameter("organizationrole");
|
||||||
private OrganizationRoleSelectionModel m_roleModel = new OrganizationRoleSelectionModel(m_roleParam);
|
private OrganizationRoleSelectionModel m_roleModel = new OrganizationRoleSelectionModel(m_roleParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for creating an new instance of this authoring step.
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
* @param parent
|
||||||
|
*/
|
||||||
public OrganizationRolePropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
public OrganizationRolePropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
this.m_itemModel = itemModel;
|
this.m_itemModel = itemModel;
|
||||||
this.m_parent = parent;
|
this.m_parent = parent;
|
||||||
|
|
@ -36,28 +43,53 @@ public class OrganizationRolePropertiesStep extends ResettableContainer {
|
||||||
add(edit);
|
add(edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an new instance of OrganizationRoleSelectionModel and calls
|
||||||
|
* setOrganizationRole(OrganizationRoleSelectionModel model) with the new
|
||||||
|
* instance.
|
||||||
|
*/
|
||||||
protected void setOrganizationRoleSelectionModel() {
|
protected void setOrganizationRoleSelectionModel() {
|
||||||
setOrganizationRoleSelectionModel(new OrganizationRoleSelectionModel(m_roleParam));
|
setOrganizationRoleSelectionModel(new OrganizationRoleSelectionModel(m_roleParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the OrganizationRoleSelectionModel.
|
||||||
|
*
|
||||||
|
* @param model
|
||||||
|
*/
|
||||||
protected void setOrganizationRoleSelectionModel(OrganizationRoleSelectionModel model) {
|
protected void setOrganizationRoleSelectionModel(OrganizationRoleSelectionModel model) {
|
||||||
m_roleModel = model;
|
m_roleModel = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The OrganizationRoleSelectionModel instance of this authoring step.
|
||||||
|
*/
|
||||||
protected OrganizationRoleSelectionModel getOrganizationRoleSelectionModel() {
|
protected OrganizationRoleSelectionModel getOrganizationRoleSelectionModel() {
|
||||||
return m_roleModel;
|
return m_roleModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The value of the m_roleParam property.
|
||||||
|
*/
|
||||||
protected BigDecimalParameter getRoleParam() {
|
protected BigDecimalParameter getRoleParam() {
|
||||||
return this.m_roleParam;
|
return this.m_roleParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The component displaying the authoring step
|
||||||
|
*/
|
||||||
public Component getDisplayComponent() {
|
public Component getDisplayComponent() {
|
||||||
SimpleContainer container = new SimpleContainer();
|
SimpleContainer container = new SimpleContainer();
|
||||||
container.add(new OrganizationRoleTable(m_itemModel, m_roleModel));
|
container.add(new OrganizationRoleTable(m_itemModel, m_roleModel));
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The form for editing the roles of the organization
|
||||||
|
*/
|
||||||
protected FormSection getEditSheet() {
|
protected FormSection getEditSheet() {
|
||||||
return new OrganizationRolePropertyForm(this.m_itemModel, this.m_roleModel);
|
return new OrganizationRolePropertyForm(this.m_itemModel, this.m_roleModel);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,19 @@ import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Form for editing a role.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
public class OrganizationRolePropertyForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
|
public class OrganizationRolePropertyForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logger for this class.
|
||||||
|
*/
|
||||||
public final static Logger logger = Logger.getLogger(OrganizationRolePropertyForm.class);
|
public final static Logger logger = Logger.getLogger(OrganizationRolePropertyForm.class);
|
||||||
|
/**
|
||||||
|
* ID of the form
|
||||||
|
*/
|
||||||
public final static String ID = "organizationrole_edit";
|
public final static String ID = "organizationrole_edit";
|
||||||
//public final static String SSL_PROTOCOL = "https://";
|
//public final static String SSL_PROTOCOL = "https://";
|
||||||
//public final static String HTTP_PROTOCOL = "http://";
|
//public final static String HTTP_PROTOCOL = "http://";
|
||||||
|
|
@ -45,6 +52,12 @@ public class OrganizationRolePropertyForm extends FormSection implements FormIni
|
||||||
private SaveCancelSection m_saveCancelSection;
|
private SaveCancelSection m_saveCancelSection;
|
||||||
private final String ITEM_SEARCH = "organizationRole";
|
private final String ITEM_SEARCH = "organizationRole";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an new instance of the form.
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
* @param roleModel
|
||||||
|
*/
|
||||||
public OrganizationRolePropertyForm(ItemSelectionModel itemModel, OrganizationRoleSelectionModel roleModel) {
|
public OrganizationRolePropertyForm(ItemSelectionModel itemModel, OrganizationRoleSelectionModel roleModel) {
|
||||||
super(new ColumnPanel(2));
|
super(new ColumnPanel(2));
|
||||||
this.m_itemModel = itemModel;
|
this.m_itemModel = itemModel;
|
||||||
|
|
@ -59,6 +72,10 @@ public class OrganizationRolePropertyForm extends FormSection implements FormIni
|
||||||
addSubmissionListener(this);
|
addSubmissionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the widgets to the form. For choosing the associated person,
|
||||||
|
* an ItemSearchWidget is used.
|
||||||
|
*/
|
||||||
protected void addWidgets() {
|
protected void addWidgets() {
|
||||||
this.m_rolename = new TextField("rolename");
|
this.m_rolename = new TextField("rolename");
|
||||||
this.m_rolename.addValidationListener(new NotNullValidationListener());
|
this.m_rolename.addValidationListener(new NotNullValidationListener());
|
||||||
|
|
@ -66,12 +83,18 @@ public class OrganizationRolePropertyForm extends FormSection implements FormIni
|
||||||
add(this.m_rolename);
|
add(this.m_rolename);
|
||||||
|
|
||||||
add(new Label("Person"));
|
add(new Label("Person"));
|
||||||
//logger.error(String.format("Person.CONTENT_TYPE = %s", Person.CONTENT_TYPE));
|
/* Create the ItemSearchWidget. The ContentType.findByAssociatedObjecType
|
||||||
//logger.error(String.format("Article.CONTENT_TYPE = %s", Article.CONTENT_TYPE));
|
* gets the ContentType of com.arsdigita.cms.contenttypes.Person and passes
|
||||||
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.Person"));
|
* it to the constructor of the ItemSearchWidget. The ItemSearchWidget will only
|
||||||
|
* display object of type Person or derivated types.
|
||||||
|
*/
|
||||||
|
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.Person"));
|
||||||
add(this.m_itemSearch);
|
add(this.m_itemSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the Save and Cancel buttons.
|
||||||
|
*/
|
||||||
public void addSaveCancelSection() {
|
public void addSaveCancelSection() {
|
||||||
this.m_saveCancelSection = new SaveCancelSection();
|
this.m_saveCancelSection = new SaveCancelSection();
|
||||||
try {
|
try {
|
||||||
|
|
@ -104,22 +127,40 @@ public class OrganizationRolePropertyForm extends FormSection implements FormIni
|
||||||
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH);
|
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The section with the Save and Cancel buttons.
|
||||||
|
*/
|
||||||
public SaveCancelSection getSaveCancelSection() {
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
return this.m_saveCancelSection;
|
return this.m_saveCancelSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return The RoleSelectionModel of the form.
|
||||||
|
*/
|
||||||
protected OrganizationRoleSelectionModel getRoleSelectionModel() {
|
protected OrganizationRoleSelectionModel getRoleSelectionModel() {
|
||||||
return this.m_roleModel;
|
return this.m_roleModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*protected Person getPerson(PageState s) {
|
/*protected Person getPerson(PageState s) {
|
||||||
return (Person) m_itemModel.getSelectedObject(s);
|
return (Person) m_itemModel.getSelectedObject(s);
|
||||||
}*/
|
}*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param s
|
||||||
|
* @return * The organization which roles are edited.
|
||||||
|
*/
|
||||||
protected GenericOrganization getOrganization(PageState s) {
|
protected GenericOrganization getOrganization(PageState s) {
|
||||||
return (GenericOrganization)m_itemModel.getSelectedObject(s);
|
return (GenericOrganization) m_itemModel.getSelectedObject(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new OrganizationRole.
|
||||||
|
*
|
||||||
|
* @param s
|
||||||
|
* @return Newly created OrganizationRole.
|
||||||
|
*/
|
||||||
protected OrganizationRole createOrganizationRole(PageState s) {
|
protected OrganizationRole createOrganizationRole(PageState s) {
|
||||||
//Person person = this.getPerson(s);
|
//Person person = this.getPerson(s);
|
||||||
//Assert.exists(person);
|
//Assert.exists(person);
|
||||||
|
|
@ -130,12 +171,18 @@ public class OrganizationRolePropertyForm extends FormSection implements FormIni
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the properties of an instance of OrganizationRole.
|
||||||
|
*
|
||||||
|
* @param role
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
protected void setOrganizationRoleProperties(OrganizationRole role, FormSectionEvent e) {
|
protected void setOrganizationRoleProperties(OrganizationRole role, FormSectionEvent e) {
|
||||||
PageState state = e.getPageState();
|
PageState state = e.getPageState();
|
||||||
FormData data = e.getFormData();
|
FormData data = e.getFormData();
|
||||||
|
|
||||||
role.setRolename((String)m_rolename.getValue(state));
|
role.setRolename((String) m_rolename.getValue(state));
|
||||||
role.setTargetItem((Person)data.get(ITEM_SEARCH));
|
role.setTargetItem((Person) data.get(ITEM_SEARCH));
|
||||||
|
|
||||||
role.save();
|
role.save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,37 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.OrganizationRole;
|
import com.arsdigita.cms.contenttypes.OrganizationRole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* SelectionModel for OrganizationRole.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
public class OrganizationRoleSelectionModel extends ACSObjectSelectionModel {
|
public class OrganizationRoleSelectionModel extends ACSObjectSelectionModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor taking a parameter.
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
public OrganizationRoleSelectionModel(BigDecimalParameter param) {
|
public OrganizationRoleSelectionModel(BigDecimalParameter param) {
|
||||||
super(OrganizationRole.class.getName(), OrganizationRole.BASE_DATA_OBJECT_TYPE, param);
|
super(OrganizationRole.class.getName(), OrganizationRole.BASE_DATA_OBJECT_TYPE, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor taking an itemClass, an objectType and a parameter.
|
||||||
|
*
|
||||||
|
* @param itemClass
|
||||||
|
* @param objectType
|
||||||
|
* @param parameter
|
||||||
|
*/
|
||||||
public OrganizationRoleSelectionModel(String itemClass, String objectType, BigDecimalParameter parameter) {
|
public OrganizationRoleSelectionModel(String itemClass, String objectType, BigDecimalParameter parameter) {
|
||||||
super(itemClass, objectType, parameter);
|
super(itemClass, objectType, parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
* @return The selected role.
|
||||||
|
*/
|
||||||
public OrganizationRole getSelectedRole(PageState state) {
|
public OrganizationRole getSelectedRole(PageState state) {
|
||||||
return (OrganizationRole) getSelectedObject(state);
|
return (OrganizationRole) getSelectedObject(state);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import java.math.BigDecimal;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Table for displaying the existings roles associated with an organization.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,11 +42,29 @@ public class OrganizationRoleTable extends Table {
|
||||||
private TableColumn m_delCol;
|
private TableColumn m_delCol;
|
||||||
private RequestLocal m_size;
|
private RequestLocal m_size;
|
||||||
private RequestLocal m_editor;
|
private RequestLocal m_editor;
|
||||||
|
/**
|
||||||
|
* Identifier for an Edit event.
|
||||||
|
*/
|
||||||
protected final static String EDIT_EVENT = "Edit";
|
protected final static String EDIT_EVENT = "Edit";
|
||||||
|
/**
|
||||||
|
* ID for an Delete event.
|
||||||
|
*/
|
||||||
protected final static String DELETE_EVENT = "Delete";
|
protected final static String DELETE_EVENT = "Delete";
|
||||||
|
/**
|
||||||
|
* ID for an Up event.
|
||||||
|
*/
|
||||||
protected final static String UP_EVENT = "up";
|
protected final static String UP_EVENT = "up";
|
||||||
|
/**
|
||||||
|
* ID for an down event.
|
||||||
|
*/
|
||||||
protected final static String DOWN_EVENT = "down";
|
protected final static String DOWN_EVENT = "down";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Creates a new table a sets the column headers.
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
* @param roleModel
|
||||||
|
*/
|
||||||
public OrganizationRoleTable(ItemSelectionModel itemModel, OrganizationRoleSelectionModel roleModel) {
|
public OrganizationRoleTable(ItemSelectionModel itemModel, OrganizationRoleSelectionModel roleModel) {
|
||||||
super();
|
super();
|
||||||
this.m_itemModel = itemModel;
|
this.m_itemModel = itemModel;
|
||||||
|
|
@ -72,6 +91,9 @@ public class OrganizationRoleTable extends Table {
|
||||||
setModelBuilder(new OrganizationRoleTableModelBuilder(itemModel));
|
setModelBuilder(new OrganizationRoleTableModelBuilder(itemModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the constructor to add the columns of the table.
|
||||||
|
*/
|
||||||
protected void addColumns() {
|
protected void addColumns() {
|
||||||
TableColumnModel model = getColumnModel();
|
TableColumnModel model = getColumnModel();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
@ -181,7 +203,7 @@ public class OrganizationRoleTable extends Table {
|
||||||
try {
|
try {
|
||||||
logger.debug("About to delete");
|
logger.debug("About to delete");
|
||||||
m_roleModel.clearSelection(state);
|
m_roleModel.clearSelection(state);
|
||||||
role.delete();;
|
role.delete();
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
throw new UncheckedWrapperException(ex);
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganization;
|
import com.arsdigita.cms.contenttypes.GenericOrganization;
|
||||||
import com.arsdigita.cms.contenttypes.OrganizationRole;
|
import com.arsdigita.cms.contenttypes.OrganizationRole;
|
||||||
import com.arsdigita.cms.contenttypes.Person;
|
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
|
@ -16,6 +15,7 @@ import com.arsdigita.util.LockableImpl;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TableModelBuilder for the OrganizationRoleTable.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
|
|
@ -25,6 +25,11 @@ public class OrganizationRoleTableModelBuilder extends LockableImpl implements T
|
||||||
|
|
||||||
private ItemSelectionModel m_itemModel;
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to create a new instance. Needs an ItemSelectionModel instance.
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
*/
|
||||||
public OrganizationRoleTableModelBuilder(ItemSelectionModel itemModel) {
|
public OrganizationRoleTableModelBuilder(ItemSelectionModel itemModel) {
|
||||||
this.m_itemModel = itemModel;
|
this.m_itemModel = itemModel;
|
||||||
}
|
}
|
||||||
|
|
@ -41,17 +46,29 @@ public class OrganizationRoleTableModelBuilder extends LockableImpl implements T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param s
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public DataCollection getRoles(PageState s) {
|
public DataCollection getRoles(PageState s) {
|
||||||
Assert.isTrue(this.m_itemModel.isSelected(s), "item selected");
|
Assert.isTrue(this.m_itemModel.isSelected(s), "item selected");
|
||||||
GenericOrganization orga = (GenericOrganization) m_itemModel.getSelectedItem(s);
|
GenericOrganization orga = (GenericOrganization) m_itemModel.getSelectedItem(s);
|
||||||
return OrganizationRole.getRoles(orga);
|
return OrganizationRole.getRoles(orga);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TableModel for the OrganizationRoleTable.
|
||||||
|
*/
|
||||||
public static class OrganizationRoleTableModel implements TableModel {
|
public static class OrganizationRoleTableModel implements TableModel {
|
||||||
|
|
||||||
OrganizationRole m_role;
|
OrganizationRole m_role;
|
||||||
DataCollection m_roles;
|
DataCollection m_roles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param roles
|
||||||
|
*/
|
||||||
public OrganizationRoleTableModel(DataCollection roles) {
|
public OrganizationRoleTableModel(DataCollection roles) {
|
||||||
m_roles = roles;
|
m_roles = roles;
|
||||||
m_role = null;
|
m_role = null;
|
||||||
|
|
@ -79,6 +96,10 @@ public class OrganizationRoleTableModelBuilder extends LockableImpl implements T
|
||||||
return m_role.getID();
|
return m_role.getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Number of roles in the table.
|
||||||
|
*/
|
||||||
public long size() {
|
public long size() {
|
||||||
return m_roles.size();
|
return m_roles.size();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue