Zwischenstand mit lokalen Änderungen - werden im nächsten Commit wieder gelöscht

git-svn-id: https://svn.libreccm.org/ccm/trunk@190 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2009-06-10 08:11:37 +00:00
parent 4f1a80d506
commit e6bcef3f88
32 changed files with 381 additions and 1800 deletions

View File

@ -29,9 +29,4 @@ object type GenericOrganization extends ContentPage {
String[0..1] description = ct_genericorganizations.description VARCHAR(2000); String[0..1] description = ct_genericorganizations.description VARCHAR(2000);
reference key (ct_genericorganizations.organization_id); reference key (ct_genericorganizations.organization_id);
}
association {
composite GenericOrganization[1..1] orga = join ct_genericorganization_roles.organization_id to ct_genericorganizations.organization_id;
composite OrganizationRole[0..n] roles = join ct_genericorganizations.organization_id to ct_genericorganization_roles.organization_id;
} }

View File

@ -1,9 +0,0 @@
model com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentPage;
object type OrganizationRole extends ContentPage {
String[1..1] rolename = ct_genericorganization_roles.rolename VARCHAR(512);
reference key (ct_genericorganization_roles.role_id);
}

View File

@ -18,16 +18,16 @@
labelBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources" labelBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
descriptionKey="genericorganization.authoring.basic_properties.description" descriptionKey="genericorganization.authoring.basic_properties.description"
descriptionBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources" descriptionBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
component="com.arsdigita.cms.contenttypes.ui.genericorganization.GenericOrganizationEdit" component="com.arsdigita.cms.contenttypes.ui.GenericOrganizationPropertiesStep"
ordering="1"/> ordering="1"/>
<ctd:authoring-step <!-- <ctd:authoring-step
labelKey="genericorganization.authoring.roles.title" labelKey="genericorganization.authoring.roles.title"
labelBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources" labelBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
descriptionKey="genericorganization.authoring.roles.description" descriptionKey="genericorganization.authoring.roles.description"
descriptionBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources" descriptionBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
component="com.arsdigita.cms.contenttypes.ui.genericorganization.GenericOrganizationViewRoles" component="com.arsdigita.cms.contenttypes.ui.genericorganization.GenericOrganizationViewRoles"
ordering="2"/> ordering="2"/> -->
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/> <ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
</ctd:authoring-kit> </ctd:authoring-kit>

View File

@ -1,9 +0,0 @@
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:define="/WEB-INF/bebop-define.tld"
xmlns:show="/WEB-INF/bebop-show.tld"
version="1.2">
<define:page name="itemPage" application="content-section" title="CMS" cache="true">
<define:component name="itemXML" classname="com.arsdigita.cms.dispatcher.ContentPanel"/>
<define:component name="sectionXML" classname="com.arsdigita.cms.contenttypes.ui.genericorganization.GenericOrganizationRolesPanel"/>
</define>
</jsp:root>

View File

@ -1,76 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.OrganizationRole"
extends="com.arsdigita.cms.ContentPage"
traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
<xrd:attributes rule="exclude">
</xrd:attributes>
<xrd:associations rule="include">
<xrd:property name="/object/rolename"/>
</xrd:associations>
</xrd:adapter>
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.GenericOrganization"
extends="com.arsdigita.cms.TextPage"
traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
<xrd:attributes rule="exclude">
<xrd:property name="/object/roles/id"/>
<xrd:property name="/object/roles/defaultDomainClass"/>
<xrd:property name="/object/roles/objectType"/>
<xrd:property name="/object/roles/displayName"/>
<xrd:property name="/object/roles/isDeleted"/>
<xrd:property name="/object/roles/ancestors"/>
<xrd:property name="/object/roles/version"/>
<xrd:property name="/object/roles/name"/>
<xrd:property name="/object/roles/language"/>
</xrd:attributes>
<xrd:associations rule="include">
<xrd:property name="/object/organizationroles"/>
</xrd:associations>
</xrd:adapter>
</xrd:context>
<xrd:context name="com.arsdigita.cms.search.ContentPageMetadataProvider">
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.GenericOrganization" extends="com.arsdigita.cms.ContentItem" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
<xrd:attributes rule="exclude">
<xrd:property name="/object/roles/id"/>
<xrd:property name="/object/roles/defaultDomainClass"/>
<xrd:property name="/object/roles/objectType"/>
<xrd:property name="/object/roles/displayName"/>
<xrd:property name="/object/roles/isDeleted"/>
<xrd:property name="/object/roles/ancestors"/>
<xrd:property name="/object/roles/version"/>
<xrd:property name="/object/roles/name"/>
<xrd:property name="/object/roles/language"/>
</xrd:attributes>
</xrd:adapter>
</xrd:context>
<xrd:context name="com.arsdigita.cms.contenttypes.OrganizationRoleMetadataProvider">
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.OrganizationRole"
traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
<xrd:attributes rule="exclude">
<xrd:property name="/object/id"/>
<xrd:property name="/object/defaultDomainClass"/>
<xrd:property name="/object/objectType"/>
<xrd:property name="/object/displayName"/>
<xrd:property name="/object/isDeleted"/>
<xrd:property name="/object/ancestors"/>
<xrd:property name="/object/version"/>
<xrd:property name="/object/name"/>
<xrd:property name="/object/language"/>
</xrd:attributes>
<xrd:associations rule="include">
<xrd:property name="/object/text"/>
</xrd:associations>
</xrd:adapter>
</xrd:context>
</xrd:adapters>

View File

@ -4,11 +4,11 @@
<table name="acs_objects" /> <table name="acs_objects" />
<table name="cms_items" /> <table name="cms_items" />
<table name="ct_persons" /> <table name="ct_persons" />
<table name="ct_organizationroles" />
<initializer class="com.arsdigita.cms.Initializer" /> <initializer class="com.arsdigita.cms.Initializer" />
</requires> </requires>
<provides> <provides>
<table name="ct_genericorganizations" /> <table name="ct_genericorganizations" />
<table name="ct_organizationroles" />
<initializer class="com.arsdigita.cms.contenttypes.GenericOrganizationInitializer"/> <initializer class="com.arsdigita.cms.contenttypes.GenericOrganizationInitializer"/>
</provides> </provides>
<scripts> <scripts>

View File

@ -25,6 +25,7 @@ import com.arsdigita.persistence.OID;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import java.math.BigDecimal; import java.math.BigDecimal;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.domain.DomainObjectFactory;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -154,7 +155,6 @@ public class GenericOrganization extends ContentPage {
set(ORGANIZATIONNAME, name); set(ORGANIZATIONNAME, name);
} }
/** /**
* *
* @return Addendum for the name of the organization. * @return Addendum for the name of the organization.

View File

@ -47,10 +47,10 @@ public class GenericOrganizationInitializer extends ContentTypeInitializer {
* *
* @return path of the traversal-adapter XML file. * @return path of the traversal-adapter XML file.
*/ */
@Override /*@Override
public String getTraversalXML() { public String getTraversalXML() {
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/GenericOrganization.xml"; return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/GenericOrganization.xml";
} }*/
/** /**
* *

View File

@ -56,10 +56,10 @@ public class GenericOrganizationLoader extends AbstractContentTypeLoader {
*/ */
public GenericOrganizationLoader() { public GenericOrganizationLoader() {
super(); super();
m_template = new ResourceParameter("com.arsdigita.cms.contenttypes.genericorganization.template", /*m_template = new ResourceParameter("com.arsdigita.cms.contenttypes.genericorganization.template",
Parameter.REQUIRED, Parameter.REQUIRED,
"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/genericorganization-item.jsp"); "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/genericorganization-item.jsp");
register(m_template); register(m_template);*/
} }
/** /**
@ -69,7 +69,7 @@ public class GenericOrganizationLoader extends AbstractContentTypeLoader {
* @param ld * @param ld
* @param wf * @param wf
*/ */
@Override /*@Override
protected void prepareSection(final ContentSection section, protected void prepareSection(final ContentSection section,
final ContentType type, final ContentType type,
final LifecycleDefinition ld, final LifecycleDefinition ld,
@ -83,5 +83,5 @@ public class GenericOrganizationLoader extends AbstractContentTypeLoader {
type, type,
ld, ld,
wf); wf);
} }*/
} }

View File

@ -1,116 +0,0 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import org.apache.log4j.Logger;
import java.math.BigDecimal;
/**
* ContentItem reprenting a role in a organization, e.g. CEO.
*
* @author Jens Pelzetter
*/
public class OrganizationRole extends ContentPage {
private static final Logger logger = Logger.getLogger(OrganizationRole.class);
/**
* Name of the role.
*/
public static final String ROLENAME = "rolename";
/**
* Type identifier.
*/
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationRole";
/**
* Default Constructor
*/
public OrganizationRole() {
super(BASE_DATA_OBJECT_TYPE);
}
/**
* Trys to find the role with the given id in the database.
*
* @param id of the role to find.
* @throws com.arsdigita.domain.DataObjectNotFoundException
*/
public OrganizationRole(BigDecimal id) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
/**
* Trys to find the role with the given id in the database.
*
* @param id
* @throws com.arsdigita.domain.DataObjectNotFoundException
*/
public OrganizationRole(OID id) throws DataObjectNotFoundException {
super(id);
}
/**
* Creates an OrganizationRole object based on a DataObject
*
* @param obj A object of DataObject class.
*/
public OrganizationRole(DataObject obj) {
super(obj);
}
/**
*
* @param type
*/
public OrganizationRole(String type) {
super(type);
}
public String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
//Accessors
/**
*
* @return The name of the role.
*/
public String getRolename() {
return (String) get(ROLENAME);
}
/**
* Sets the name of the role.
*
* @param rolename New name of the role.
*/
public void setRolename(String rolename) {
set(ROLENAME, rolename);
}
@Override
public ContentSection getContentSection() {
ContentSection ct = super.getContentSection();
if (ct != null) {
return ct;
} else {
ACSObject parent = getParent();
if ((parent != null) && parent instanceof GenericOrganization) {
ct = ((ContentItem) parent).getContentSection();
return ct;
}
}
return null;
}
}

View File

@ -1,36 +0,0 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.persistence.DataCollection;
/**
* Collection containing all roles associated to an organization.
*
* @author Jens Pelzetter
*/
public class OrganizationRoleCollection extends DomainCollection {
//public static final String versionId = "$Id: OrganizationRoleCollection.java 001 2009-05-28 12:40:00Z jensp $";
/**
* Creates an object of this class from an DataCollection object.
*
* @param dataCollection
*/
public OrganizationRoleCollection(DataCollection dataCollection) {
super(dataCollection);
}
@Override
public DomainObject getDomainObject() {
return new OrganizationRole(m_dataCollection.getDataObject());
}
/**
* @return the item at the current position
*/
public OrganizationRole getOrganizationRole() {
return (OrganizationRole) getDomainObject();
}
}

View File

@ -1,95 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
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.event.FormValidationListener;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
import com.arsdigita.cms.ui.authoring.CreationComponent;
import com.arsdigita.cms.ui.authoring.CreationSelector;
import com.arsdigita.ui.util.GlobalizationUtil;
/**
* Form for creating a new organization.
*
* @author Jens Pelzetter
*/
public class GenericOrganizationCreate extends GenericOrganizationForm implements FormInitListener, FormProcessListener, FormSubmissionListener, FormValidationListener, CreationComponent {
private CreationSelector m_parent;
private ApplyWorkflowFormSection m_workflowSection;
/**
* Constructor.
*
* @param itemModel
* @param parent
*/
public GenericOrganizationCreate(ItemSelectionModel itemModel, CreationSelector parent) {
super("GenericOrganizationCreate", itemModel);
m_parent = parent;
m_workflowSection.setCreationSelector(m_parent);
m_workflowSection.setContentType(m_itemModel.getContentType());
addSubmissionListener(this);
getSaveCancelSection().getSaveButton().setButtonLabel("Create");
}
/**
* Adds all widgets to the form.
*/
@Override
protected void addWidgets() {
m_workflowSection = new ApplyWorkflowFormSection();
add(m_workflowSection, ColumnPanel.INSERT);
super.addWidgets();
}
public ApplyWorkflowFormSection getWorkflowSection() {
return m_workflowSection;
}
public void init(FormSectionEvent event) throws FormProcessException {
//Nothing yet
}
public void submitted(FormSectionEvent event) throws FormProcessException {
PageState state = event.getPageState();
if(getSaveCancelSection().getCancelButton().isSelected(state)) {
m_parent.redirectBack(state);
throw new FormProcessException((String)GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.submission_canceled").localize());
}
}
public void validate(FormSectionEvent event) throws FormProcessException {
//Nothing yet
}
public void process(final FormSectionEvent event) throws FormProcessException {
final FormData data = event.getFormData();
final PageState state = event.getPageState();
final ContentSection section = m_parent.getContentSection(state);
final GenericOrganization orga = createGenericOrganization(state);
orga.setOrganizationName((String)data.get(ORGANIZATIONAME));
orga.setOrganizationNameAddendum((String)data.get(ORGANIZATIONNAMEADDENDUM));
orga.setDescription((String)data.get(DESCRIPTION));
final ContentBundle bundle = new ContentBundle(orga);
bundle.setParent(m_parent.getFolder(state));
bundle.setContentSection(section);
m_workflowSection.applyWorkflow(state, orga);
m_parent.editItem(state, orga);
}
}

View File

@ -1,59 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.Component;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.ui.util.GlobalizationUtil;
/**
* EditStep for editing an organization.
*
* @author Jens Pelzetter
*/
public class GenericOrganizationEdit extends SimpleEditStep {
/**
* Constructor.
*
* @param itemModel
* @param parent
*/
public GenericOrganizationEdit(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
super(itemModel, parent);
setDefaultEditKey("edit");
GenericOrganizationForm form = getForm(itemModel);
add("edit", "Edit", new WorkflowLockedComponentAccess(form, itemModel), form.getSaveCancelSection().getCancelButton());
setDisplayComponent(getGenericOrganizationPropertiesSheet(itemModel));
}
/**
*
* @param model
* @return A new instance of this class.
*/
protected GenericOrganizationForm getForm(ItemSelectionModel model) {
return new GenericOrganizationEditForm(model, this);
}
/**
*
* @param model
* @return A sheet with widgets for the properites of GenericOrgnization.
*/
public Component getGenericOrganizationPropertiesSheet(ItemSelectionModel model) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(model);
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.organizationname"), GenericOrganization.ORGANIZATIONNAME);
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.organizationnameaddendum"), GenericOrganization.ORGANIZATIONNAMEADDENDUM);
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.description"), GenericOrganization.DESCRIPTION);
return sheet;
}
}

View File

@ -1,84 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.Folder;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.util.Assert;
/**
* Form for editing a GenericOrganization.
*
* @author Jens Pelzetter
*/
public class GenericOrganizationEditForm extends GenericOrganizationForm implements FormSubmissionListener {
private SimpleEditStep m_step;
/**
* Constructor.
*
* @param itemModel
* @param step
*/
public GenericOrganizationEditForm(ItemSelectionModel itemModel, SimpleEditStep step) {
super("GenericOrganizationEditForm", itemModel);
addSubmissionListener(this);
m_step = step;
}
public void init(FormSectionEvent e) throws FormProcessException {
super.initBasicWidgets(e);
}
public void submitted(FormSectionEvent fse) {
if (getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState());
}
}
public void process(FormSectionEvent fse) throws FormProcessException {
PageState state = fse.getPageState();
GenericOrganization orga = processBasicWidgets(fse);
m_step.maybeForwardToNextStep(fse.getPageState());
}
/**
* This function does nothing real usefull yet. It will maybe removed later.
*
* @param fse
* @throws FormProcessException
*/
public void validate(FormSectionEvent fse) throws FormProcessException {
PageState state = fse.getPageState();
FormData data = fse.getFormData();
GenericOrganization orga = (GenericOrganization) m_itemModel.getSelectedObject(state);
Assert.exists(orga, GenericOrganization.class);
String newOrganizationName = (String)data.get(GenericOrganizationForm.ORGANIZATIONAME);
String oldOrganizationName = orga.getOrganizationName();
boolean valid = true;
if(!valid) {
throw new FormProcessException("error");
}
}
private Folder getParentFolder(GenericOrganization orga) {
ContentItem parent = (ContentItem)orga.getParent();
while((parent != null)
&& (!(parent instanceof Folder))) {
parent = (ContentItem)parent.getParent();
}
return (Folder)parent;
}
}

View File

@ -1,192 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.FormSection;
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.FormValidationListener;
import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.ui.util.GlobalizationUtil;
import com.arsdigita.util.Assert;
import javax.servlet.ServletException;
import org.apache.log4j.Logger;
/**
* A form section for editing an orgnization.
*
* @author Jens Pelzetter
*/
public abstract class GenericOrganizationForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener {
/**
* ItemSelectionModel for the form section
*/
protected ItemSelectionModel m_itemModel;
/**
* SaveCancelSection (Save and Cancel buttons) for this sections.
*/
protected SaveCancelSection m_saveCancelSection;
private Label m_script = new Label("<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>");
/**
* Organizationname.
*/
public static final String ORGANIZATIONAME = GenericOrganization.ORGANIZATIONNAME;
/**
* Addedum
*/
public static final String ORGANIZATIONNAMEADDENDUM = GenericOrganization.ORGANIZATIONNAMEADDENDUM;
/**
* Description
*/
public static final String DESCRIPTION = GenericOrganization.DESCRIPTION;
private static final Logger logger = Logger.getLogger(GenericOrganizationForm.class);
/**
* Creates the columnpanel, adds the widgets, the SaveCancelSection and the listeners.
*
* @param formName
* @param itemModel
*/
public GenericOrganizationForm(String formName, ItemSelectionModel itemModel) {
super(new ColumnPanel(2));
m_itemModel = itemModel;
ColumnPanel panel = (ColumnPanel) getPanel();
panel.setBorder(false);
panel.setPadColor("#ffffff");
panel.setColumnWidth(1, "20%");
panel.setColumnWidth(2, "80%");
panel.setWidth("100%");
addWidgets();
addSaveCancelSection();
addInitListener(this);
addProcessListener(this);
addValidationListener(this);
}
/**
* Adds the SavaCancelSection.
*/
public void addSaveCancelSection() {
m_saveCancelSection = new SaveCancelSection();
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
}
/**
*
* @return The SaveCancelSection of the form section.
*/
public SaveCancelSection getSaveCancelSection() {
return m_saveCancelSection;
}
/**
* Adds the widgets to the form.
*/
protected void addWidgets() {
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.genericorganization.ui.organizationname")));
TextField organizationName = new TextField(ORGANIZATIONAME);
organizationName.addValidationListener(new NotNullValidationListener());
add(organizationName);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.genericorganization.ui.organizationnameaddendum")));
TextField organizationNameAddendum = new TextField(ORGANIZATIONNAMEADDENDUM);
add(organizationNameAddendum);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.genericorganzation.ui.description")));
TextArea description = new TextArea(DESCRIPTION);
description.setRows(5);
description.setCols(30);
add(description);
}
public abstract void init (FormSectionEvent e) throws FormProcessException;
public abstract void process (FormSectionEvent e) throws FormProcessException;
public abstract void validate (FormSectionEvent e) throws FormProcessException;
/**
* Inits the widgets.
*
* @param e
* @return
*/
public GenericOrganization initBasicWidgets(FormSectionEvent e) {
Assert.exists(m_itemModel, ItemSelectionModel.class);
FormData data = e.getFormData();
PageState state = e.getPageState();
GenericOrganization orga = (GenericOrganization)m_itemModel.getSelectedObject(state);
if (orga != null) {
data.put(ORGANIZATIONAME, orga.getOrganizationName());
data.put(ORGANIZATIONNAMEADDENDUM, orga.getOrganizationNameAddendum());
data.put(DESCRIPTION, orga.getDescription());
}
return orga;
}
/**
* Processes the widgets.
*
* @param e
* @return
*/
public GenericOrganization processBasicWidgets(FormSectionEvent e) {
Assert.exists(m_itemModel, ItemSelectionModel.class);
FormData data = e.getFormData();
PageState state = e.getPageState();
GenericOrganization orga = (GenericOrganization)m_itemModel.getSelectedObject(state);
if(orga != null) {
orga.setOrganizationName((String)data.get(ORGANIZATIONAME));
orga.setOrganizationNameAddendum((String)data.get(ORGANIZATIONNAMEADDENDUM));
orga.setDescription((String)data.get(DESCRIPTION));
}
return orga;
}
/**
* Creates a new organization.
*
* @param state
* @return
* @throws com.arsdigita.bebop.FormProcessException
*/
public GenericOrganization createGenericOrganization(PageState state) throws FormProcessException {
Assert.exists(m_itemModel, ItemSelectionModel.class);
GenericOrganization orga = null;
try {
orga = (GenericOrganization)m_itemModel.createItem();
} catch(ServletException e) {
logger.error("ServletException: " + e.getMessage(), e);
throw new FormProcessException(e.getMessage(), e);
}
if(m_itemModel.getSelectedKey(state) == null) {
m_itemModel.setSelectedObject(state, orga);
}
return orga;
}
}

View File

@ -1,327 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Container;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.ChangeEvent;
import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.contenttypes.OrganizationRole;
import com.arsdigita.cms.contenttypes.ui.ResettableContainer;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.ui.util.GlobalizationUtil;
import com.arsdigita.util.Assert;
/**
*
* @author Jens Pelzetter
*/
public class GenericOrganizationViewRoles extends ResettableContainer {
/* Ids for the editing panels */
/**
* Identifier for the table of roles
*/
public static final String ROLES_TABLE = "rolesTable";
/**
* Identifier for the role edit form
*/
public static final String ROLES_EDIT = "rolesEdit";
/**
* Identifier for the role delete form
*/
public static final String ROLES_DELETE = "rolesDelete";
/* class attributes */
/**
* Identifier for the data table
*/
public static final String DATA_TABLE = "dataTable";
/**
* Identifier for the action link
*/
public static final String ACTION_LINK = "actionLink";
/**
* The authoring wizard
*/
protected AuthoringKitWizard m_wizard;
/**
* ItemSelectionModel for the organization
*/
protected ItemSelectionModel m_selectionOrganization;
/**
* ItemSelection for the role
*/
protected ItemSelectionModel m_selectionRole;
/**
* ItemSelectionModel for moving the role position (currently not used)
*/
protected ItemSelectionModel m_moveRole;
/**
* Move parameter (not used yet)
*/
protected BigDecimalParameter m_moveParameter;
/* Visual components doing the word */
/**
* Table with all roles associated with the organization.
*/
protected RoleTable m_roleTable;
/**
* Form for editing a role
*/
protected RoleEditForm m_roleEdit;
/**
* Form for deleting a role
*/
protected RoleDeleteForm m_roleDelete;
/**
* Begin link
*/
protected ActionLink m_beginLink;
private Label m_moveRoleLabel;
private String m_typeIdStr;
/**
* Constructor.
*
* @param selOrga
* @param wizard
*/
public GenericOrganizationViewRoles(ItemSelectionModel selOrga, AuthoringKitWizard wizard) {
super();
m_selectionOrganization = selOrga;
m_wizard = wizard;
m_typeIdStr = wizard.getContentType().getID().toString();
Assert.exists(m_selectionOrganization, ItemSelectionModel.class);
add(buildRoleTable(), true);
add(buildRoleEdit(), false);
add(buildRoleDelete(), false);
}
/**
* Builds the table of roles.
*
* @return The table of roles.
*/
protected Container buildRoleTable() {
ColumnPanel c = new ColumnPanel(1);
c.setKey(ROLES_TABLE + m_typeIdStr);
c.setBorderColor("#ffffff");
c.setPadColor("#ffffff");
m_moveParameter = new BigDecimalParameter("moveRole");
m_moveRole = new ItemSelectionModel(OrganizationRole.class.getName(), OrganizationRole.BASE_DATA_OBJECT_TYPE, m_moveParameter);
m_roleTable = new RoleTable(m_selectionOrganization, m_moveRole);
m_roleTable.setClassAttr(DATA_TABLE);
m_selectionRole = new ItemSelectionModel(OrganizationRole.class.getName(), OrganizationRole.BASE_DATA_OBJECT_TYPE, m_roleTable.getRowSelectionModel());
m_roleTable.setRoleModel(m_selectionRole);
Label emptyView = new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.no_roles_yet"));
m_roleTable.setEmptyView(emptyView);
m_moveRoleLabel = new Label("Role Name");
c.add(m_moveRoleLabel, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
m_beginLink = new ActionLink((String) GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.move_to_beginning").localize());
c.add(m_beginLink);
m_beginLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
PageState state = event.getPageState();
GenericOrganization orga = (GenericOrganization) m_selectionOrganization.getSelectedObject(state);
m_moveRole.setSelectedKey(state, null);
}
});
m_moveRole.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
PageState state = e.getPageState();
if (m_moveRole.getSelectedKey(state) == null) {
m_beginLink.setVisible(state, false);
m_moveRoleLabel.setVisible(state, false);
} else {
m_beginLink.setVisible(state, true);
m_moveRoleLabel.setVisible(state, true);
m_moveRoleLabel.setLabel((String) GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.move_role_name").localize() + ((OrganizationRole) m_moveRole.getSelectedObject(state)).getRolename(), state);
}
}
});
m_roleTable.addTableActionListener(new TableActionListener() {
public void cellSelected(TableActionEvent e) {
PageState state = e.getPageState();
TableColumn col = m_roleTable.getColumnModel().get(e.getColumn().intValue());
String colName = (String) col.getHeaderValue();
if (RoleTable.COL_DEL.equals(colName)) {
onlyShowComponent(state, ROLES_DELETE + m_typeIdStr);
} else if (RoleTable.COL_EDIT.equals(colName)) {
onlyShowComponent(state, ROLES_EDIT + m_typeIdStr);
}
}
public void headSelected(TableActionEvent e) {
//Nothing
}
});
c.add(m_roleTable);
c.add(buildAddLink());
return c;
}
/**
* Builds the edit form.
*
* @return The edit form.
*/
protected Container buildRoleEdit() {
ColumnPanel c = new ColumnPanel(1);
c.setKey(ROLES_EDIT + m_typeIdStr);
c.setBorderColor("#ffffff");
c.setPadColor("#ffffff");
c.add(new Label(new PrintListener() {
public void prepare(PrintEvent event) {
PageState state = event.getPageState();
Label label = (Label) event.getTarget();
if (m_selectionRole.getSelectedKey(state) == null) {
label.setLabel((String) GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.add_role").localize());
} else {
label.setLabel((String) GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.edit_role").localize());
}
}
}));
m_roleEdit = new RoleEditForm(m_selectionOrganization, m_selectionRole, this);
c.add(m_roleEdit);
c.add(buildViewAllLink());
c.add(buildAddLink());
return c;
}
/**
* Builds the delete form
*
* @return The delete form.
*/
protected Container buildRoleDelete() {
ColumnPanel c = new ColumnPanel(1);
c.setKey(ROLES_DELETE + m_typeIdStr);
c.setBorderColor("#ffffff");
c.setPadColor("#ffffff");
c.add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.delete_role")));
m_roleDelete = new RoleDeleteForm(m_selectionOrganization, m_selectionRole);
m_roleDelete.addSubmissionListener(new FormSubmissionListener() {
public void submitted(FormSectionEvent e) throws FormProcessException {
PageState state = e.getPageState();
onlyShowComponent(state, ROLES_TABLE + m_typeIdStr);
}
});
c.add(m_roleDelete);
c.add(buildViewAllLink());
return c;
}
/**
* Builds the view all roles link.
*
* @return The ViewAllLink.
*/
protected ActionLink buildViewAllLink() {
ActionLink viewAllLink = new ActionLink((String) GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.view_all_roles").localize());
viewAllLink.setClassAttr(ACTION_LINK);
viewAllLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onlyShowComponent(e.getPageState(), ROLES_TABLE + m_typeIdStr);
}
});
return viewAllLink;
}
/**
* Builds the add link.
*
* @return The add link.
*/
protected ActionLink buildAddLink() {
ActionLink addLink = new ActionLink((String) GlobalizationUtil.globalize("cms.contenttypes.ui.genericorgnization.add_new_role").localize()) {
@Override
public boolean isVisible(PageState state) {
SecurityManager sm = Utilities.getSecurityManager(state);
ContentItem item = (ContentItem) m_selectionOrganization.getSelectedObject(state);
return (super.isVisible(state) && sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM, item));
}
};
addLink.setClassAttr(ACTION_LINK);
addLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState();
m_selectionRole.clearSelection(state);
onlyShowComponent(state, ROLES_EDIT + m_typeIdStr);
}
});
return addLink;
}
@Override
public void register(Page p) {
super.register(p);
p.addGlobalStateParam(m_moveParameter);
p.setVisibleDefault(m_beginLink, false);
p.setVisibleDefault(m_moveRoleLabel, false);
}
/**
*
* @return The typeIdStr.
*/
public String getTypeIdStr() {
return m_typeIdStr;
}
}

View File

@ -1,182 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.CMSContext;
import com.arsdigita.cms.CMSExcursion;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.contenttypes.OrganizationRole;
import com.arsdigita.cms.contenttypes.OrganizationRoleCollection;
import com.arsdigita.cms.dispatcher.XMLGenerator;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.xml.Element;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.log4j.Logger;
/**
* Panel for editing roles.
*
* @author Jens Pelzetter
*/
public class OrganizationRolePanel extends SimpleComponent {
private static final Logger logger = Logger.getLogger(OrganizationRolePanel.class);
//private PageParameter m_page;
private boolean m_showAllRoles = false;
//private static final String versionId = "$Id: OrganizationRolePanel.java 2009-06-01T10:42+02:00";
/**
* Constructor.
*/
public OrganizationRolePanel() {
super();
}
@Override
public void register(Page p) {
super.register(p);
addGlobalStateParams(p);
}
/**
* Adds a global state param. Not in use yet.
*
* @param p
*/
public void addGlobalStateParams(Page p) {
}
/**
*
* @param state
* @param item
* @return The XMLGenerator for the panel.
*/
protected XMLGenerator getXMLGenerator(PageState state, ContentItem item) {
ContentSection section = null;
try {
section = CMS.getContext().getContentSection();
} catch (Exception e) {
}
if (section == null) {
logger.debug(String.format("Item id %s-%s-%s", item.getOID().toString(), item.getContentSection().toString(), item.toString()));
section = item.getContentSection();
CMS.getContext().setContentSection(section);
}
return section.getXMLGenerator();
}
/**
* Sets the value of the showAllRoles property.
*
* @param showAll
*/
public void setShowAllRoles(boolean showAll) {
this.m_showAllRoles = showAll;
}
/**
* Returns the current ContentItem.
*
* @param state
* @return
*/
protected ContentItem getContentItem(PageState state) {
CMSContext context = CMS.getContext();
if (!context.hasContentItem()) {
return null;
}
return context.getContentItem();
}
/**
*
* @param item
* @param state
* @return An array with all roles associated with the organization.
*/
protected OrganizationRole[] getOrganizationRoles(ContentItem item, final PageState state) {
GenericOrganization orga = (GenericOrganization) item;
OrganizationRoleCollection roles = orga.getOrganizationRoles();
OrganizationRole[] page = new OrganizationRole[(int) roles.size()];
int i = 0;
while (roles.next()) {
page[i] = roles.getOrganizationRole();
i++;
}
return page;
}
@Override
public void generateXML(final PageState state, final Element parent) {
ContentItem item = getContentItem(state);
if (!isVisible(state) ||
(item == null) ||
!(item instanceof GenericOrganization)) {
logger.debug("Skipping");
return;
}
generateXML(item, parent, state);
}
/**
* Creates the XML for the panel.
*
* @param item
* @param element
* @param state
*/
public void generateXML(ContentItem item, Element element, PageState state) {
Element content = element.newChildElement("cms:organizationRolePanel", CMS.CMS_XML_NS);
exportAttributes(content);
XMLGenerator xmlGenerator = getXMLGenerator(state, item);
OrganizationRole roles[] = getOrganizationRoles(item, state);
for(int i = 0; i < roles.length; i++) {
generateRoleXML(state, content, roles[i], xmlGenerator);
}
}
/**
* Creates the XML for a role.
*
* @param state
* @param parent
* @param role
* @param xmlGenerator
*/
protected void generateRoleXML(final PageState state, final Element parent, final ContentItem role, final XMLGenerator xmlGenerator) {
CMSExcursion excursion = new CMSExcursion() {
@Override
protected void excurse() throws ServletException, IOException {
setContentItem(role);
xmlGenerator.generateXML(state, parent, null);
}
};
try {
excursion.run();
} catch(ServletException e) {
throw new UncheckedWrapperException("excursion failed", e);
} catch(IOException e) {
throw new UncheckedWrapperException("excursion failed", e);
}
}
}

View File

@ -1,116 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection;
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.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.contenttypes.OrganizationRole;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.util.Assert;
import org.apache.log4j.Logger;
/**
* Form for deleting a role.
*
* @author Jens Pelzetter
*/
public class RoleDeleteForm extends Form implements FormInitListener, FormSubmissionListener, FormProcessListener {
private static final Logger logger = Logger.getLogger(RoleDeleteForm.class);
/**
* ItemSelectionModel for the organization.
*/
protected ItemSelectionModel m_selectionOrganization;
/**
* ItemSelectionModle for the role
*/
protected ItemSelectionModel m_selectionRole;
/**
* SaveCancelSection of this form
*/
protected SaveCancelSection m_saveCancelSection;
private Label m_roleNameLabel;
/**
* Constructor.
*
* @param selectionOrganization
* @param selectionRole
*/
public RoleDeleteForm(ItemSelectionModel selectionOrganization, ItemSelectionModel selectionRole) {
super("RoleDeleteForm", new ColumnPanel(2));
m_selectionOrganization = selectionOrganization;
m_selectionRole = selectionRole;
ColumnPanel panel = (ColumnPanel) getPanel();
panel.setBorder(false);
panel.setPadColor("#ffffff");
panel.setColumnWidth(1, "20%");
panel.setColumnWidth(2, "80%");
panel.setWidth("100%");
m_roleNameLabel = new Label("Role Name");
add(m_roleNameLabel, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
addSaveCancelSection();
addInitListener(this);
addSubmissionListener(this);
addProcessListener(this);
}
/**
* Adds the SaveCancelSection of this form.
*
* @return
*/
protected SaveCancelSection addSaveCancelSection() {
m_saveCancelSection = new SaveCancelSection();
m_saveCancelSection.getSaveButton().setButtonLabel("Delete");
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
return m_saveCancelSection;
}
public void init(FormSectionEvent e) throws FormProcessException {
PageState state = e.getPageState();
OrganizationRole role = (OrganizationRole) m_selectionRole.getSelectedObject(state);
if(role == null) {
logger.error("No role selected");
}
else {
m_roleNameLabel.setLabel(role.getRolename(), state);
}
}
public void submitted(FormSectionEvent e) throws FormProcessException {
PageState state = e.getPageState();
if (m_saveCancelSection.getCancelButton().isSelected(state)) {
throw new FormProcessException((String) GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.submission_canceled").localize());
}
}
public void process(FormSectionEvent e) throws FormProcessException {
PageState state = e.getPageState();
GenericOrganization orga = (GenericOrganization) m_selectionOrganization.getSelectedObject(state);
OrganizationRole role = (OrganizationRole) m_selectionRole.getSelectedObject(state);
Assert.exists(orga, GenericOrganization.class);
Assert.exists(role, OrganizationRole.class);
orga.removeOrganizationRole(role);
logger.info(String.format("role %s delete", m_selectionRole.getSelectedKey(state)));
}
}

View File

@ -1,207 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection;
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.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.contenttypes.OrganizationRole;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.util.UncheckedWrapperException;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
/**
* Form for editing a role.
*
* @author Jens Pelzetter
*/
public class RoleEditForm extends Form {
private static final Logger logger = Logger.getLogger(RoleEditForm.class);
private ItemSelectionModel m_selectionOrganization;
private ItemSelectionModel m_selectionRole;
//private BigDecimalParameter m_textParam;
private GenericOrganizationViewRoles m_container;
private SaveCancelSection m_saveCancelSection;
/**
* Rolename identifier string.
*/
public static final String ROLENAME = OrganizationRole.ROLENAME;
/**
* Constructor.
*
* @param selectionOrganization
* @param selectionRole
*/
public RoleEditForm(ItemSelectionModel selectionOrganization, ItemSelectionModel selectionRole) {
this(selectionOrganization, selectionRole, null);
}
/**
* Constructor.
*
* @param selectionOrganization
* @param selectionRole
* @param container
*/
public RoleEditForm(ItemSelectionModel selectionOrganization, ItemSelectionModel selectionRole, GenericOrganizationViewRoles container) {
super("RoleEditForm", new ColumnPanel(2));
m_selectionOrganization = selectionOrganization;
m_selectionRole = selectionRole;
m_container = container;
setMethod(Form.POST);
setEncType("multipart/form-data");
ColumnPanel panel = (ColumnPanel)getPanel();
panel.setBorder(false);
panel.setPadColor("#ffffff");
panel.setColumnWidth(1, "20%");
panel.setColumnWidth(2, "80%");
panel.setWidth("100%");
addWidgets();
addSaveCancelSection();
addInitListener(new RoleInitListener());
addSubmissionListener(new RoleSubmissionListener());
addProcessListener(new RoleProcessListener());
}
/**
* Adds the SaveCancelSection to the form.
*
* @return
*/
protected SaveCancelSection addSaveCancelSection() {
m_saveCancelSection = new SaveCancelSection();
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
return m_saveCancelSection;
}
/**
*
* @return The SaveCancelSection of this form.
*/
public SaveCancelSection getSaveCancelSection() {
return m_saveCancelSection;
}
/**
* Adds the widgets to the form.
*/
protected void addWidgets() {
logger.info("Adding widgets for role form...");
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.rolename")));
TextField nameWidget = new TextField(new TrimmedStringParameter(ROLENAME));
nameWidget.addValidationListener(new NotNullValidationListener());
add(nameWidget);
}
private class RoleInitListener implements FormInitListener {
public void init(FormSectionEvent event) throws FormProcessException {
PageState state = event.getPageState();
FormData data = event.getFormData();
if(m_selectionRole.getSelectedKey(state) != null) {
BigDecimal id = new BigDecimal(m_selectionRole.getSelectedKey(state).toString());
try {
OrganizationRole role = new OrganizationRole(id);
data.put(ROLENAME, role.getRolename());
} catch(DataObjectNotFoundException e) {
logger.error(String.format("Role(%d) could not be found", id));
}
}
}
}
private class RoleSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent event) throws FormProcessException {
PageState state = event.getPageState();
if((m_saveCancelSection.getCancelButton().isSelected(state)) &&
(m_container != null)) {
m_container.onlyShowComponent(state, GenericOrganizationViewRoles.ROLES_TABLE + m_container.getTypeIdStr());
throw new FormProcessException((String)GlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.submission_canceled").localize());
}
}
}
private class RoleProcessListener implements FormProcessListener {
public void process(FormSectionEvent event) throws FormProcessException {
logger.info("Processing edit event...");
PageState state = event.getPageState();
FormData data = event.getFormData();
BigDecimal id = new BigDecimal(m_selectionOrganization.getSelectedKey(state).toString());
GenericOrganization orga = null;
try {
orga = new GenericOrganization(id);
} catch(DataObjectNotFoundException e) {
throw new UncheckedWrapperException(e);
}
//Get role or create new one if role is not existing yet
OrganizationRole role = (OrganizationRole)m_selectionRole.getSelectedObject(state);
if(role == null) {
role = createRole(event, orga);
orga.addOrganizationRole(role);
}
role.setRolename((String)data.get(OrganizationRole.ROLENAME));
if(m_container != null) {
m_container.onlyShowComponent(state, GenericOrganizationViewRoles.ROLES_TABLE + m_container.getTypeIdStr());
}
}
}
/**
* Creates a new role.
*
* @param event
* @param orga
* @return The role.
*/
protected OrganizationRole createRole(FormSectionEvent event, GenericOrganization orga) {
logger.info("creating new role...");
PageState state = event.getPageState();
FormData data = event.getFormData();
OrganizationRole role = new OrganizationRole();
role.setRolename((String)data.get(ROLENAME));
role.setName(orga.getName() + ": " + (String)data.get(OrganizationRole.ROLENAME));
logger.info("new role created");
return role;
}
@Override
public void register(Page page) {
super.register(page);
}
}

View File

@ -1,276 +0,0 @@
package com.arsdigita.cms.contenttypes.ui.genericorganization;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
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.ContentItem;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.contenttypes.OrganizationRole;
import com.arsdigita.cms.contenttypes.OrganizationRoleCollection;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.OID;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
/**
* Table listing all Roles associated with a organization.
*
* @author Jens Pelzetter
*/
public class RoleTable extends Table {
private final static Logger logger = Logger.getLogger(RoleTable.class);
// columns headings
/**
* Heading for first column
*/
public static final String COL_TITLE = "Role";
/**
* Heading for second column
*/
public static final String COL_EDIT = "Edit";
/**
* Heading for third column
*/
public static final String COL_MOVE = "Move";
/**
* Heading for last column
*/
public static final String COL_DEL = "Delete";
private ItemSelectionModel m_selectionOrganization;
private ItemSelectionModel m_selectionRole;
private ItemSelectionModel m_moveRole;
/**
* Constructor.
*
* @param selOrga
* @param moveRole
*/
public RoleTable(ItemSelectionModel selOrga, ItemSelectionModel moveRole) {
super();
m_selectionOrganization = selOrga;
m_moveRole = moveRole;
TableColumnModel model = getColumnModel();
model.add(new TableColumn(0, COL_TITLE));
model.add(new TableColumn(1, COL_EDIT));
model.add(new TableColumn(2, COL_MOVE));
model.add(new TableColumn(3, COL_DEL));
model.get(1).setCellRenderer(new RoleTableCellRenderer(true));
model.get(2).setCellRenderer(new RoleTableCellRenderer(true));
model.get(3).setCellRenderer(new RoleTableCellRenderer(true));
setModelBuilder(new RoleTableModelBuilder(m_selectionOrganization, m_moveRole));
addTableActionListener(new TableActionListener() {
public void cellSelected(TableActionEvent e) {
PageState state = e.getPageState();
TableColumn col = getColumnModel().get(e.getColumn().intValue());
String colName = (String) col.getHeaderValue();
if (COL_MOVE.equals(colName)) {
if (m_moveRole.getSelectedKey(state) == null) {
m_moveRole.setSelectedKey(state, m_selectionRole.getSelectedKey(state));
} else {
GenericOrganization orga = (GenericOrganization) m_selectionOrganization.getSelectedObject(state);
BigDecimal id = (BigDecimal) m_moveRole.getSelectedKey(state);
OrganizationRole role = (OrganizationRole) DomainObjectFactory.newInstance(new OID(OrganizationRole.BASE_DATA_OBJECT_TYPE, id));
BigDecimal dest = new BigDecimal((String) e.getRowKey());
OrganizationRole destRole = (OrganizationRole) DomainObjectFactory.newInstance(new OID(OrganizationRole.BASE_DATA_OBJECT_TYPE, "dest"));
m_moveRole.setSelectedKey(state, null);
}
}
}
public void headSelected(TableActionEvent e) {
//Nothing
}
});
}
/**
* Sets the ItemSelectionModel.
*
* @param itemModel
*/
public void setRoleModel(ItemSelectionModel itemModel) {
if (itemModel == null) {
logger.warn("null item model");
}
m_selectionRole = itemModel;
}
/**
* Builder class for the table model.
*/
protected class RoleTableModelBuilder extends LockableImpl implements TableModelBuilder {
/**
* ItemSelectionModel for the organization.
*/
protected ItemSelectionModel m_selectionOrganization;
/**
* ItemSelectionModel for moving the role (feature not implemented yet)
*/
protected ItemSelectionModel m_moveRole;
/**
* Constructor.
*
* @param selectionOrganization
* @param moveRole
*/
public RoleTableModelBuilder(ItemSelectionModel selectionOrganization, ItemSelectionModel moveRole) {
m_selectionOrganization = selectionOrganization;
m_moveRole = moveRole;
}
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
GenericOrganization orga = (GenericOrganization) m_selectionOrganization.getSelectedObject(state);
return new RoleTableModel(table, state, orga, m_moveRole);
}
}
/**
* TableModel for the RoleTable.
*/
protected class RoleTableModel implements TableModel {
private TableColumnModel m_colModel;
private RoleTable m_table;
private PageState m_state;
private OrganizationRoleCollection m_roles;
private ItemSelectionModel m_moveRole;
private OrganizationRole m_role;
/**
* Constructor.
*
* @param table
* @param state
* @param orga
* @param moveRole
*/
public RoleTableModel(Table table, PageState state, GenericOrganization orga, ItemSelectionModel moveRole) {
m_colModel = table.getColumnModel();
m_table = (RoleTable) table;
m_state = state;
m_roles = orga.getOrganizationRoles();
m_moveRole = moveRole;
}
public int getColumnCount() {
return m_colModel.size();
}
public boolean nextRow() {
if (m_roles.next()) {
m_role = m_roles.getOrganizationRole();
return true;
}
return false;
}
public Object getElementAt(int columnIndex) {
if (m_colModel == null) {
return null;
}
TableColumn col = m_colModel.get(columnIndex);
String colName = (String) col.getHeaderValue();
if (COL_TITLE.equals(colName)) {
return m_role.getRolename();
} else if(COL_EDIT.equals(colName)) {
return "edit";
} else if(COL_DEL.equals(colName)) {
return "delete";
} else if(COL_MOVE.equals(colName)) {
if(m_moveRole.getSelectedKey(m_state) == null) {
return "move";
} else {
return "move below here";
}
}
return null;
}
public Object getKeyAt(int columnIndex) {
return m_role.getID();
}
}
/**
* Renderer for the cells of the RoleTable.
*/
public class RoleTableCellRenderer extends LockableImpl implements TableCellRenderer {
private boolean m_active;
/**
* Constructor.
*/
public RoleTableCellRenderer() {
this(false);
}
/**
* Constructor.
*
* @param active
*/
public RoleTableCellRenderer(boolean active) {
m_active = active;
}
public Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column) {
Component ret = null;
SecurityManager sm = Utilities.getSecurityManager(state);
ContentItem item = (ContentItem) m_selectionOrganization.getSelectedObject(state);
boolean active = m_active && sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM, item);
if (value instanceof Component) {
ret = (Component) value;
} else {
if (value == null) {
ret = new Label("", false);
} else {
if (active) {
ret = new ControlLink(value.toString());
} else {
ret = new Label(value.toString());
}
}
}
return ret;
}
}
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name="ccm-cms-types-organizationrole"
prettyName="CCM Content Types"
version="6.6.0"
release="1"
webapp="ROOT">
<ccm:dependencies>
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
</ccm:dependencies>
<ccm:directories>
<ccm:directory name="pdl"/>
<ccm:directory name="sql"/>
<ccm:directory name="src"/>
</ccm:directories>
<ccm:contacts>
<ccm:contact uri="mailto:ccm@barkhof.uni-bremen.de" type="support"/>
</ccm:contacts>
<ccm:description>
Content type representing a role in a organization (eg CEO). For use with the GenericOrganization type.
</ccm:description>
</ccm:application>

View File

@ -0,0 +1,26 @@
//
// Copyright (C) 2009 Jens Pelzetter/Center for Social Poltics, University of Bremen. All Rights Reserved.
//
// 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
model com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentPage;
object type OrganizationRole extends ContentPage {
String[0..1] rolename = ct_organizationroles.rolename VARCHAR(512);
reference key (ct_organizationroles.role_id);
}

View File

@ -0,0 +1,3 @@
begin;
\i ddl/postgres/create.sql
end;

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
<ctd:content-type
label="OrganizationRole"
description="An OrganizationRole type"
objectType="com.arsdigita.cms.contenttypes.OrganizationRole"
classname="com.arsdigita.cms.contenttypes.OrganizationRole">
<ctd:authoring-kit
createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
<ctd:authoring-step
labelKey="organizationrole.authoring.basic_properties.title"
labelBundle="com.arsdigita.cms.contenttypes.OrganizationRoleResources"
descriptionKey="organizationrole.authoring.basic_properties.description"
descriptionBundle="com.arsdigita.cms.contenttypes.OrganizationRoleResources"
component="com.arsdigita.cms.contenttypes.ui.OrganizationRolePropertiesStep"
ordering="1"/>
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
</ctd:authoring-kit>
</ctd:content-type>
</ctd:content-types>

View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<registry>
</registry>

View File

@ -0,0 +1,15 @@
<load>
<requires>
<table name="inits"/>
<table name="acs_objects"/>
<table name="cms_items"/>
</requires>
<provides>
<table name="ct_organizationroles"/>
<initializer class="com.arsdigita.cms.contenttypes.OrganizationRoleInitializer"/>
</provides>
<scripts>
<schema directory="ccm-cms-types-organizationrole"/>
<data class="com.arsdigita.cms.contenttypes.OrganizationRoleLoader"/>
</scripts>
</load>

View File

@ -0,0 +1,52 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentPage;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.DataObject;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class OrganizationRole extends ContentPage {
public static final String ROLENAME = "rolename";
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationRole";
public static final Logger logger = Logger.getLogger(OrganizationRole.class);
public OrganizationRole() {
super(BASE_DATA_OBJECT_TYPE);
}
public OrganizationRole(BigDecimal id) throws DataObjectNotFoundException {
super(id);
}
public OrganizationRole(OID oid) {
super(oid);
}
public OrganizationRole(DataObject obj) {
super(obj);
}
public OrganizationRole(String type) {
super(type);
}
public String getRoleName() {
return (String) get(ROLENAME);
}
public void setRoleName(String rolename) {
logger.error(String.format("Setting rolename to %s", rolename));
set(ROLENAME, rolename);
}
}

View File

@ -0,0 +1,27 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.runtime.DomainInitEvent;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class OrganizationRoleInitializer extends ContentTypeInitializer {
private final static Logger logger = Logger.getLogger(OrganizationRoleInitializer.class);
public OrganizationRoleInitializer() {
super("ccm-cms-types-organizationrole.pdl.mf", OrganizationRole.BASE_DATA_OBJECT_TYPE);
}
@Override
public void init(DomainInitEvent evt) {
super.init(evt);
}
@Override
public String[] getStylesheets() {
return new String[]{"/static/content-types/com/arsdigita/cms/contenttypes/OrganizationRole.xsl"};
}
}

View File

@ -0,0 +1,20 @@
package com.arsdigita.cms.contenttypes;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class OrganizationRoleLoader extends AbstractContentTypeLoader {
private static final Logger logger = Logger.getLogger(OrganizationRoleLoader.class);
private static final String TYPES[] = { "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/OrganizationRole.xml" };
@Override
protected String[] getTypes() {
return TYPES;
}
}

View File

@ -0,0 +1,61 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.OrganizationRole;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.ui.util.GlobalizationUtil;
import java.text.DateFormat;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class OrganizationRolePropertiesStep extends SimpleEditStep {
public static final String EDIT_SHEET_NAME = "edit";
public OrganizationRolePropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
super(itemModel, parent);
setDefaultEditKey(EDIT_SHEET_NAME);
BasicPageForm editSheet;
editSheet = new OrganizationRolePropertyForm(itemModel, this);
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getOrganizationRolePropertySheet(itemModel));
}
public static Component getOrganizationRolePropertySheet(ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.organizationrole.rolename"), OrganizationRole.ROLENAME);
if(!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item, String attribute, PageState state) {
ContentPage page = (ContentPage)item;
if(page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
}
else {
return (String)GlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
}
return sheet;
}
}

View File

@ -0,0 +1,83 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.OrganizationRole;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.FormData;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class OrganizationRolePropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
private static final Logger logger = Logger.getLogger(OrganizationRolePropertyForm.class);
private OrganizationRolePropertiesStep m_step;
public static final String ROLENAME = OrganizationRole.ROLENAME;
public static final String ID = "OrganizationRole_edit";
public OrganizationRolePropertyForm(ItemSelectionModel itemModel) {
this(itemModel, null);
}
public OrganizationRolePropertyForm(ItemSelectionModel itemModel, OrganizationRolePropertiesStep step) {
super(ID, itemModel);
m_step = step;
addSubmissionListener(this);
}
@Override
protected void addWidgets() {
super.addWidgets();
add(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.organizationrole.rolename").localize()));
//ParameterModel rolenameParameter = new StringParameter(ROLENAME);
//TextField rolename = new TextField(rolenameParameter);
TextField rolename = new TextField(ROLENAME);
add(rolename);
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
OrganizationRole role = (OrganizationRole)super.initBasicWidgets(fse);
data.put(ROLENAME, role.getRoleName());
}
public void submitted(FormSectionEvent fse) {
logger.error("submitted");
if((m_step != null) &&
(getSaveCancelSection().getCancelButton().isSelected(fse.getPageState()))) {
m_step.cancelStreamlinedCreation(fse.getPageState());
}
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
OrganizationRole role = (OrganizationRole)super.processBasicWidgets(fse);
if((role != null) &&
(getSaveCancelSection().getSaveButton().isSelected(fse.getPageState()))) {
logger.error(String.format("Setting rolename to %s", data.get(ROLENAME)));
role.setRoleName((String)data.get(ROLENAME));
role.save();
}
if(m_step != null) {
m_step.maybeForwardToNextStep(fse.getPageState());
}
}
}

View File

@ -0,0 +1,29 @@
<!DOCTYPE stylesheet [
<!ENTITY nbsp "&#160;" ><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
]>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cms="http://www.arsdigita.com/cms/1.0"
version="1.0">
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.OrganizationRole']"
mode="cms:CT_graphics"
name="cms:CT_graphics_com_arsdigita_cms_contenttypes_OrganizationRole">
<xsl:if test="./rolename">
<p>
<xsl:value-of select="./rolename"/>
</p>
</xsl:if>
</xsl:template>
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.OrganizationRole']"
mode="cms:CT_text"
name="cms:CT_text_com_arsdigita_cms_contenttypes_OrganizationRole">
<xsl:if test="./rolename">
<p>
<xsl:value-of select="./rolename"/>
</p>
</xsl:if>
</xsl:template>
</xsl:stylesheet>