Verknüpfung zwischen GenericOrganization und OrganizationalUnit. Kompliert, Bundle wird geladen, UI noch NICHT getestet.
git-svn-id: https://svn.libreccm.org/ccm/trunk@196 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
c99939ff5e
commit
a7ccfb0079
|
|
@ -9,7 +9,7 @@
|
||||||
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
|
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
|
||||||
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
|
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
|
||||||
<ccm:requires name="ccm-cms-types-person" version="6.6.0" relation="ge"/>
|
<ccm:requires name="ccm-cms-types-person" version="6.6.0" relation="ge"/>
|
||||||
<ccm:requires name="ccm-cms-types-article" version="6.6.0" requires="ge"/>
|
<ccm:requires name="ccm-cms-types-organizationalunit" version="6.6.0" relation="ge"/>
|
||||||
</ccm:dependencies>
|
</ccm:dependencies>
|
||||||
<ccm:directories>
|
<ccm:directories>
|
||||||
<ccm:directory name="pdl"/>
|
<ccm:directory name="pdl"/>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
//
|
||||||
|
// Copyright (C) 2009 Center of Socialpolitics, University of Bremen
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 2.1 of
|
||||||
|
// the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
model com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
|
||||||
|
object type Orga2OrgaUnit extends ACSObject {
|
||||||
|
OrganizationalUnit[0..1] targetItem = join ct_orga2orgaunits.target_item_id to ct_organizationalunits.organizationalunit_id;
|
||||||
|
|
||||||
|
Integer[0..1] unitOrder = ct_orga2orgaunits.unit_order INTEGER;
|
||||||
|
|
||||||
|
reference key(ct_orga2orgaunits.orga2orgaunit_id);
|
||||||
|
aggressive load (unitOwner.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
association {
|
||||||
|
composite GenericOrganization[0..1] unitOwner = join ct_orga2orgaunits.unit_owner to ct_genericorganizations.organization_id;
|
||||||
|
composite Orga2OrgaUnit[0..n] units = join ct_genericorganizations.organization_id to ct_orga2orgaunits.owner_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
query getReferingUnits {
|
||||||
|
BigDecimal id;
|
||||||
|
|
||||||
|
do {
|
||||||
|
select u.organizationalunit_id from orga2orgaunits u where u.target_item_id = :itemID
|
||||||
|
} map {
|
||||||
|
id = u.orga2orgaunit_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data operation swapOrga2OrgaUnitWithNextInGroup {
|
||||||
|
do {
|
||||||
|
update ct_orga2orgaunits
|
||||||
|
set unit_order = CASE WHEN (unit_order = :unitOrder) THEN
|
||||||
|
(:nextUnitOrder)
|
||||||
|
ELSE
|
||||||
|
(:unitOrder)
|
||||||
|
END
|
||||||
|
where (unit_order = :unitOrder or unit_order = :nextUnitOrder)
|
||||||
|
and owner_id = :ownerID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query allUnitsOrderForOrganization {
|
||||||
|
Integer unitOrder;
|
||||||
|
|
||||||
|
do {
|
||||||
|
select u.unit_order from ct_orga2orgaunits u where u.owner_id = :ownerID
|
||||||
|
}
|
||||||
|
map {
|
||||||
|
unitOrder = u.unit_order;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -29,6 +29,15 @@
|
||||||
component="com.arsdigita.cms.contenttypes.ui.OrganizationRolePropertiesStep"
|
component="com.arsdigita.cms.contenttypes.ui.OrganizationRolePropertiesStep"
|
||||||
ordering="2"/>
|
ordering="2"/>
|
||||||
|
|
||||||
|
<ctd:authoring-step
|
||||||
|
labelKey="genericorganization.authoring.units.title"
|
||||||
|
labelBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
|
||||||
|
descriptionKey="genericorganization.authoring.units.description"
|
||||||
|
descriptionBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
|
||||||
|
component="com.arsdigita.cms.contenttypes.ui.Orga2OrgaUnitPropertiesStep"
|
||||||
|
ordering="3"/>
|
||||||
|
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
<table name="inits" />
|
<table name="inits" />
|
||||||
<table name="acs_objects" />
|
<table name="acs_objects" />
|
||||||
<table name="cms_items" />
|
<table name="cms_items" />
|
||||||
|
<table name="ct_organizationalunits" />
|
||||||
<table name="ct_persons" />
|
<table name="ct_persons" />
|
||||||
<initializer class="com.arsdigita.cms.Initializer" />
|
<initializer class="com.arsdigita.cms.Initializer" />
|
||||||
</requires>
|
</requires>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,239 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.*;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.DataOperation;
|
||||||
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.persistence.Filter;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.persistence.Session;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.web.URL;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class Orga2OrgaUnit extends ACSObject {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(Orga2OrgaUnit.class);
|
||||||
|
|
||||||
|
public final static String TARGETITEM = "targetItem";
|
||||||
|
|
||||||
|
public final static String UNITOWNER = "unitOwner";
|
||||||
|
|
||||||
|
public final static String UNITORDER = "unitOrder";
|
||||||
|
|
||||||
|
public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Orga2OrgaUnit";
|
||||||
|
|
||||||
|
public Orga2OrgaUnit() {
|
||||||
|
super(BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Orga2OrgaUnit(BigDecimal id) {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Orga2OrgaUnit(OID id) {
|
||||||
|
super(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Orga2OrgaUnit(DataObject obj) {
|
||||||
|
super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Orga2OrgaUnit(String type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenericOrganization getUnitOwner() {
|
||||||
|
DataObject obj = (DataObject) get(UNITOWNER);
|
||||||
|
if (obj == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return (GenericOrganization) DomainObjectFactory.newInstance(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitOwner(GenericOrganization orga) {
|
||||||
|
Assert.exists(orga, GenericOrganization.class);
|
||||||
|
setAssociation(UNITOWNER, orga);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationalUnit getTargetItem() {
|
||||||
|
DataObject object = (DataObject) get(TARGETITEM);
|
||||||
|
return (OrganizationalUnit) DomainObjectFactory.newInstance(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargetItem(OrganizationalUnit unit) {
|
||||||
|
setAssociation(TARGETITEM, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrder() {
|
||||||
|
return (Integer) get(UNITORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(Integer order) {
|
||||||
|
Assert.exists(order);
|
||||||
|
set(UNITORDER, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getURI(PageState s) {
|
||||||
|
OrganizationalUnit unit = getTargetItem();
|
||||||
|
|
||||||
|
if(unit == null) {
|
||||||
|
logger.error(getOID() + "is a link between an organization and an organizational unit, but the associated organizational unit is null");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentSection section = unit.getContentSection();
|
||||||
|
ItemResolver resolver = section.getItemResolver();
|
||||||
|
String url = resolver.generateItemURL(s, unit, section, unit.getVersion());
|
||||||
|
|
||||||
|
return URL.there(s.getRequest(), url).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataCollection getReferingUnits(OrganizationalUnit unit) {
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection units = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
Filter filter = units.addInSubqueryFilter("id", "com.arsdigita.cms.contenttypes.getReferingUnits");
|
||||||
|
filter.set("itemID", unit.getID());
|
||||||
|
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataCollection getUnits(GenericOrganization orga) {
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection units = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
units.addEqualsFilter(UNITOWNER + ".id", orga.getID());
|
||||||
|
units.addOrder(UNITORDER);
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithNext() {
|
||||||
|
swapWithNext("com.arsdigita.cms.contenttypes.allUnitsOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrga2OrgaUnitWithNextInGroup");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithPrevious() {
|
||||||
|
swapWithPrevious("com.arsdigita.cms.contenttypes.allUnitsOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrga2OrgaUnitWithNextInGroup");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithNext(String queryName, String operationName) {
|
||||||
|
swapKeys(true, queryName, operationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithPrevious(String queryName, String operationName) {
|
||||||
|
swapKeys(false, queryName, operationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DataQuery getSwapQuery(String queryName) {
|
||||||
|
DataQuery query = SessionManager.getSession().retrieve(queryName);
|
||||||
|
query.setParameter("ownerID", getUnitOwner().getID());
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DataOperation getSwapOperation(String operationName) {
|
||||||
|
DataOperation operation = SessionManager.getSession().retrieveDataOperation(operationName);
|
||||||
|
operation.setParameter("ownerID", getUnitOwner().getID());
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void swapKeys(boolean swapNext, String queryName, String operationName) {
|
||||||
|
|
||||||
|
String methodName = null;
|
||||||
|
if (swapNext) {
|
||||||
|
methodName = "swapWithNext";
|
||||||
|
} else {
|
||||||
|
methodName = "swapWithPrevious";
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.isTrue(!isNew(), methodName + " cannot be called on an object that is new");
|
||||||
|
|
||||||
|
Integer currentKey = (Integer) get(UNITORDER);
|
||||||
|
|
||||||
|
if(currentKey == null) {
|
||||||
|
alphabetize();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.isTrue(currentKey != null, methodName + " cannot be " +
|
||||||
|
"called on an object that is not currently in the " +
|
||||||
|
"list");
|
||||||
|
|
||||||
|
int key = currentKey.intValue();
|
||||||
|
|
||||||
|
DataQuery query = getSwapQuery(queryName);
|
||||||
|
|
||||||
|
int otherKey;
|
||||||
|
if(swapNext) {
|
||||||
|
otherKey = key + 1;
|
||||||
|
query.addOrder("unitOrder ASC");
|
||||||
|
query.addFilter(query.getFilterFactory().greaterThan("unitOrder", currentKey, true));
|
||||||
|
} else {
|
||||||
|
otherKey = key - 1;
|
||||||
|
query.addOrder("unitOrder DESC");
|
||||||
|
query.addFilter(query.getFilterFactory().lessThan("unitOrder", currentKey, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(query.next()) {
|
||||||
|
otherKey = ((Integer) query.get("unitOrder")).intValue();
|
||||||
|
query.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
DataOperation operation = getSwapOperation(operationName);
|
||||||
|
operation.setParameter("unitOrder", new Integer(key));
|
||||||
|
operation.setParameter("nextUnitOrder", new Integer(otherKey));
|
||||||
|
operation.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void alphabetize() {
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection units = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
units.addEqualsFilter(UNITOWNER + ".id", getUnitOwner().getID());
|
||||||
|
int sortkey = 0;
|
||||||
|
while (units.next()) {
|
||||||
|
sortkey++;
|
||||||
|
Orga2OrgaUnit o2ou = new Orga2OrgaUnit(units.getDataObject());
|
||||||
|
o2ou.setOrder(sortkey);
|
||||||
|
o2ou.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int maxOrder() {
|
||||||
|
GenericOrganization unitOwner = getUnitOwner();
|
||||||
|
if (unitOwner == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int returnOrder = 0;
|
||||||
|
DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.cms.contenttypes.allUnitsOrderForOrganization");
|
||||||
|
query.setParameter("ownerID", getUnitOwner().getID());
|
||||||
|
query.addOrder("unitOrder DESC");
|
||||||
|
if(query.next()) {
|
||||||
|
Integer unitOrder = ((Integer) query.get("unitOrder"));
|
||||||
|
query.close();
|
||||||
|
if(unitOrder != null) {
|
||||||
|
returnOrder = unitOrder.intValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeSave() {
|
||||||
|
super.beforeSave();
|
||||||
|
if (getOrder() == null) {
|
||||||
|
setOrder(maxOrder() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormSection;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class Orga2OrgaUnitPropertiesStep extends ResettableContainer {
|
||||||
|
|
||||||
|
private AuthoringKitWizard m_parent;
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private BigDecimalParameter m_o2ouParam = new BigDecimalParameter(("orga2orgaunit"));
|
||||||
|
private Orga2OrgaUnitSelectionModel m_o2ouModel = new Orga2OrgaUnitSelectionModel(m_o2ouParam);
|
||||||
|
|
||||||
|
public Orga2OrgaUnitPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_parent = parent;
|
||||||
|
setOrga2OrgaUnitSelectionModel();
|
||||||
|
add(getDisplayComponent());
|
||||||
|
|
||||||
|
Form form = new Form("orga2OrgaUnitEditForm");
|
||||||
|
form.add(getEditSheet());
|
||||||
|
|
||||||
|
WorkflowLockedContainer edit = new WorkflowLockedContainer(itemModel);
|
||||||
|
edit.add(form);
|
||||||
|
add(edit);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOrga2OrgaUnitSelectionModel() {
|
||||||
|
setOrga2OrgaUnitSelectionModel(new Orga2OrgaUnitSelectionModel(m_o2ouParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOrga2OrgaUnitSelectionModel(Orga2OrgaUnitSelectionModel model) {
|
||||||
|
this.m_o2ouModel = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Orga2OrgaUnitSelectionModel getOrga2OrgaUnitSelectionModel() {
|
||||||
|
return this.m_o2ouModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BigDecimalParameter getO2OUParam() {
|
||||||
|
return this.m_o2ouParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getDisplayComponent() {
|
||||||
|
SimpleContainer container = new SimpleContainer();
|
||||||
|
container.add(new Orga2OrgaUnitTable(m_itemModel, m_o2ouModel));
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormSection getEditSheet() {
|
||||||
|
return new Orga2OrgaUnitPropertyForm(this.m_itemModel, this.m_o2ouModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(Page p) {
|
||||||
|
super.register(p);
|
||||||
|
p.addComponentStateParam(this, m_o2ouParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,174 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
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.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.event.FormValidationListener;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganization;
|
||||||
|
import com.arsdigita.cms.contenttypes.Orga2OrgaUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.OrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class Orga2OrgaUnitPropertyForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(Orga2OrgaUnitPropertyForm.class);
|
||||||
|
public final static String ID = "orga2orgaunit_edit";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private Orga2OrgaUnitSelectionModel m_o2ouModel;
|
||||||
|
private ItemSearchWidget m_itemSearch;
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
private final String ITEM_SEARCH = "orga2OrgaUnit";
|
||||||
|
|
||||||
|
public Orga2OrgaUnitPropertyForm(ItemSelectionModel itemModel, Orga2OrgaUnitSelectionModel o2ouModel) {
|
||||||
|
super(new ColumnPanel(2));
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_o2ouModel = o2ouModel;
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addValidationListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addWidgets() {
|
||||||
|
add(new Label("OrganizationalUnit"));
|
||||||
|
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.OrganizationalUnit"));
|
||||||
|
add(this.m_itemSearch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSaveCancelSection() {
|
||||||
|
this.m_saveCancelSection = new SaveCancelSection();
|
||||||
|
try {
|
||||||
|
this.m_saveCancelSection.getCancelButton().addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
Submit target = (Submit) e.getTarget();
|
||||||
|
if (m_o2ouModel.isSelected(e.getPageState())) {
|
||||||
|
target.setButtonLabel("Cancel");
|
||||||
|
} else {
|
||||||
|
target.setButtonLabel("Reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.m_saveCancelSection.getSaveButton().addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
Submit target = (Submit) e.getTarget();
|
||||||
|
if (m_o2ouModel.isSelected(e.getPageState())) {
|
||||||
|
target.setButtonLabel("Save");
|
||||||
|
} else {
|
||||||
|
target.setButtonLabel("Create");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new UncheckedWrapperException("this cannot happen", ex);
|
||||||
|
}
|
||||||
|
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
|
return this.m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Orga2OrgaUnitSelectionModel getO2OUSelectionModel() {
|
||||||
|
return this.m_o2ouModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected GenericOrganization getOrganization(PageState s) {
|
||||||
|
return (GenericOrganization) m_itemModel.getSelectedItem(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Orga2OrgaUnit createOrga2OrgaUnit(PageState s) {
|
||||||
|
GenericOrganization orga = this.getOrganization(s);
|
||||||
|
Assert.exists(orga);
|
||||||
|
Orga2OrgaUnit o2ou = new Orga2OrgaUnit();
|
||||||
|
o2ou.setUnitOwner(orga);
|
||||||
|
return o2ou;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOrga2OrgaUnitProperties(Orga2OrgaUnit o2ou, FormSectionEvent e) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
|
||||||
|
o2ou.setTargetItem((OrganizationalUnit) data.get(ITEM_SEARCH));
|
||||||
|
|
||||||
|
o2ou.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
|
||||||
|
Orga2OrgaUnit o2ou;
|
||||||
|
if (m_o2ouModel.isSelected(state)) {
|
||||||
|
o2ou = m_o2ouModel.getSelectedO2OU(state);
|
||||||
|
try {
|
||||||
|
data.put(ITEM_SEARCH, o2ou.getTargetItem());
|
||||||
|
} catch (IllegalStateException ex) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data.put(ITEM_SEARCH, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(FormSectionEvent e) throws FormProcessException {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
Orga2OrgaUnit o2ou;
|
||||||
|
|
||||||
|
if (this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||||
|
this.m_o2ouModel.clearSelection(state);
|
||||||
|
} else {
|
||||||
|
if (this.m_o2ouModel.isSelected(state)) {
|
||||||
|
o2ou = m_o2ouModel.getSelectedO2OU(state);
|
||||||
|
} else {
|
||||||
|
o2ou = createOrga2OrgaUnit(state);
|
||||||
|
}
|
||||||
|
setOrga2OrgaUnitProperties(o2ou, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_o2ouModel.clearSelection(state);
|
||||||
|
init(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||||
|
if (e.getFormData().get(ITEM_SEARCH) == null) {
|
||||||
|
throw new FormProcessException("OrganiztionalUnit selection is required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||||
|
if (this.m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) {
|
||||||
|
m_o2ouModel.clearSelection(e.getPageState());
|
||||||
|
init(e);
|
||||||
|
throw new FormProcessException("cancelled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.cms.contenttypes.Orga2OrgaUnit;
|
||||||
|
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class Orga2OrgaUnitSelectionModel extends ACSObjectSelectionModel {
|
||||||
|
|
||||||
|
public Orga2OrgaUnitSelectionModel(BigDecimalParameter param) {
|
||||||
|
super(Orga2OrgaUnit.class.getName(), Orga2OrgaUnit.BASE_DATA_OBJECT_TYPE, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Orga2OrgaUnitSelectionModel(String itemClass, String objectType, BigDecimalParameter param) {
|
||||||
|
super(itemClass, objectType, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Orga2OrgaUnit getSelectedO2OU(PageState s) {
|
||||||
|
return (Orga2OrgaUnit) getSelectedObject(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,191 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
import com.arsdigita.bebop.ExternalLink;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
|
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.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.contenttypes.Orga2OrgaUnit;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class Orga2OrgaUnitTable extends Table {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(Orga2OrgaUnitTable.class);
|
||||||
|
private Orga2OrgaUnitSelectionModel m_o2ouModel;
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private TableColumn m_orgaUnitCol;
|
||||||
|
private TableColumn m_moveUpCol;
|
||||||
|
private TableColumn m_moveDownCol;
|
||||||
|
private TableColumn m_editCol;
|
||||||
|
private TableColumn m_delCol;
|
||||||
|
private RequestLocal m_size;
|
||||||
|
private RequestLocal m_editor;
|
||||||
|
protected final static String EDIT_EVENT = "Edit";
|
||||||
|
protected final static String DELETE_EVENT = "Delete";
|
||||||
|
protected final static String UP_EVENT = "up";
|
||||||
|
protected final static String DOWN_EVENT = "down";
|
||||||
|
|
||||||
|
public Orga2OrgaUnitTable(ItemSelectionModel itemModel, Orga2OrgaUnitSelectionModel o2ouModel) {
|
||||||
|
super();
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_o2ouModel = o2ouModel;
|
||||||
|
addColumns();
|
||||||
|
|
||||||
|
m_size = new RequestLocal();
|
||||||
|
m_editor = new RequestLocal() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object initialValue(PageState s) {
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(s);
|
||||||
|
ContentItem item = m_itemModel.getSelectedItem(s);
|
||||||
|
Boolean val = new Boolean(sm.canAccess(s.getRequest(), SecurityManager.EDIT_ITEM, item));
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Label empty = new Label("There are no organizational units for this organization.");
|
||||||
|
setEmptyView(empty);
|
||||||
|
addTableActionListener(new Orga2OrgaUnitTableActionListener());
|
||||||
|
setRowSelectionModel(m_o2ouModel);
|
||||||
|
setDefaultCellRenderer(new Orga2OrgaUnitTableRenderer());
|
||||||
|
setModelBuilder(new Orga2OrgaUnitTableModelBuilder(itemModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addColumns() {
|
||||||
|
TableColumnModel model = getColumnModel();
|
||||||
|
int i = 0;
|
||||||
|
this.m_orgaUnitCol = new TableColumn(i, "Organizational Unit");
|
||||||
|
this.m_editCol = new TableColumn(++i, "Edit");
|
||||||
|
model.add(this.m_delCol);
|
||||||
|
model.add(this.m_moveUpCol);
|
||||||
|
model.add(this.m_moveDownCol);
|
||||||
|
setColumnModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Orga2OrgaUnitTableRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
|
public Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column) {
|
||||||
|
Orga2OrgaUnit o2ou = (Orga2OrgaUnit) value;
|
||||||
|
boolean isFirst = (row == 0);
|
||||||
|
if (m_size.get(state) == null) {
|
||||||
|
m_size.set(state, new Long(((Orga2OrgaUnitTableModelBuilder.Orga2OrgaUnitTableModel) table.getTableModel(state)).size()));
|
||||||
|
}
|
||||||
|
boolean isLast = (row == ((Long) m_size.get(state)).intValue() - 1);
|
||||||
|
|
||||||
|
String url = o2ou.getURI(state);
|
||||||
|
if (column == m_orgaUnitCol.getModelIndex()) {
|
||||||
|
ExternalLink extLink = new ExternalLink(o2ou.getTargetItem().getOrganizationalUnitName(), url);
|
||||||
|
return extLink;
|
||||||
|
} else if (column == m_editCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
if (isSelected) {
|
||||||
|
return new Label(EDIT_EVENT, Label.BOLD);
|
||||||
|
} else {
|
||||||
|
return new ControlLink(EDIT_EVENT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new Label(EDIT_EVENT);
|
||||||
|
}
|
||||||
|
} else if (column == m_delCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
return new ControlLink(DELETE_EVENT);
|
||||||
|
} else {
|
||||||
|
return new Label(DELETE_EVENT);
|
||||||
|
}
|
||||||
|
} else if (column == m_moveUpCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state)) && !isFirst) {
|
||||||
|
Label downLabel = new Label(UP_EVENT);
|
||||||
|
downLabel.setClassAttr("linkSort");
|
||||||
|
return new ControlLink(downLabel);
|
||||||
|
} else {
|
||||||
|
return new Label("");
|
||||||
|
}
|
||||||
|
} else if (column == m_moveDownCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state)) && !isLast) {
|
||||||
|
Label downLabel = new Label(DOWN_EVENT);
|
||||||
|
downLabel.setClassAttr("linkSort");
|
||||||
|
return new ControlLink(downLabel);
|
||||||
|
} else {
|
||||||
|
return new Label("");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new UncheckedWrapperException("column out of bounds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Orga2OrgaUnitTableActionListener implements TableActionListener {
|
||||||
|
|
||||||
|
private Orga2OrgaUnit getOrga2OrgaUnit(TableActionEvent e) {
|
||||||
|
Object o = e.getRowKey();
|
||||||
|
BigDecimal id;
|
||||||
|
if (o instanceof String) {
|
||||||
|
id = new BigDecimal((String) o);
|
||||||
|
} else {
|
||||||
|
id = (BigDecimal) e.getRowKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.exists(id);
|
||||||
|
Orga2OrgaUnit o2ou;
|
||||||
|
try {
|
||||||
|
o2ou = (Orga2OrgaUnit) DomainObjectFactory.newInstance(new OID(Orga2OrgaUnit.BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
} catch (DataObjectNotFoundException ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
return o2ou;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cellSelected(TableActionEvent e) {
|
||||||
|
int col = e.getColumn().intValue();
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
Orga2OrgaUnit o2ou = getOrga2OrgaUnit(e);
|
||||||
|
Assert.exists(o2ou);
|
||||||
|
|
||||||
|
if (col == m_editCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
m_o2ouModel.setSelectedObject(state, o2ou);
|
||||||
|
}
|
||||||
|
} else if (col == m_delCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
try {
|
||||||
|
m_o2ouModel.clearSelection(state);
|
||||||
|
o2ou.delete();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (col == m_moveUpCol.getModelIndex()) {
|
||||||
|
m_o2ouModel.clearSelection(state);
|
||||||
|
o2ou.swapWithPrevious();
|
||||||
|
} else if (col == m_moveDownCol.getModelIndex()) {
|
||||||
|
m_o2ouModel.clearSelection(state);
|
||||||
|
o2ou.swapWithNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected(TableActionEvent e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganization;
|
||||||
|
import com.arsdigita.cms.contenttypes.Orga2OrgaUnit;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class Orga2OrgaUnitTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(Orga2OrgaUnitTableModelBuilder.class);
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public Orga2OrgaUnitTableModelBuilder(ItemSelectionModel itemModel) {
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table t, PageState s) {
|
||||||
|
DataCollection units = getUnits(s);
|
||||||
|
|
||||||
|
if (units.isEmpty()) {
|
||||||
|
return Table.EMPTY_MODEL;
|
||||||
|
} else {
|
||||||
|
return new Orga2OrgaUnitTableModel(units);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataCollection getUnits(PageState s) {
|
||||||
|
Assert.isTrue(this.m_itemModel.isSelected(s), "item selected");
|
||||||
|
GenericOrganization orga = (GenericOrganization) this.m_itemModel.getSelectedItem(s);
|
||||||
|
return Orga2OrgaUnit.getUnits(orga);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Orga2OrgaUnitTableModel implements TableModel {
|
||||||
|
|
||||||
|
Orga2OrgaUnit m_o2ou;
|
||||||
|
DataCollection m_units;
|
||||||
|
|
||||||
|
public Orga2OrgaUnitTableModel(DataCollection units) {
|
||||||
|
m_units = units;
|
||||||
|
m_o2ou = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColumnCount() {
|
||||||
|
return (int) m_units.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean nextRow() {
|
||||||
|
if (m_units.next()) {
|
||||||
|
DataObject obj = m_units.getDataObject();
|
||||||
|
m_o2ou = (Orga2OrgaUnit) DomainObjectFactory.newInstance(obj);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
return m_o2ou;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_o2ou.getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long size() {
|
||||||
|
return m_units.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -186,7 +186,7 @@ public class OrganizationRoleTable extends Table {
|
||||||
try {
|
try {
|
||||||
role = (OrganizationRole)DomainObjectFactory.newInstance(new OID(OrganizationRole.BASE_DATA_OBJECT_TYPE, id));
|
role = (OrganizationRole)DomainObjectFactory.newInstance(new OID(OrganizationRole.BASE_DATA_OBJECT_TYPE, id));
|
||||||
} catch(DataObjectNotFoundException ex) {
|
} catch(DataObjectNotFoundException ex) {
|
||||||
throw new UncheckedWrapperException(e);
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
component="com.arsdigita.cms.contenttypes.ui.OrganizationalUnitPropertiesStep"
|
component="com.arsdigita.cms.contenttypes.ui.OrganizationalUnitPropertiesStep"
|
||||||
ordering="1"/>
|
ordering="1"/>
|
||||||
|
|
||||||
|
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||||
</ctd:authoring-kit>
|
</ctd:authoring-kit>
|
||||||
|
|
||||||
</ctd:content-type>
|
</ctd:content-type>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
<table name="inits" />
|
<table name="inits" />
|
||||||
<table name="acs_objects" />
|
<table name="acs_objects" />
|
||||||
<table name="cms_items" />
|
<table name="cms_items" />
|
||||||
<table name="ct_genericorganizations" />
|
|
||||||
<table name="ct_persons" />
|
<table name="ct_persons" />
|
||||||
<initializer class="com.arsdigita.cms.Initializer" />
|
<initializer class="com.arsdigita.cms.Initializer" />
|
||||||
</requires>
|
</requires>
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ import java.math.BigDecimal;
|
||||||
*/
|
*/
|
||||||
public class OrganizationalUnit extends ContentPage {
|
public class OrganizationalUnit extends ContentPage {
|
||||||
|
|
||||||
public final static String ORGANIZATIONALUNIT_NAME = "organizationalunitname";
|
public final static String ORGANIZATIONALUNIT_NAME = "organizationalunitName";
|
||||||
public final static String ORGANIZATIONAL_DESCRIPTION = "description";
|
public final static String ORGANIZATIONALUNIT_DESCRIPTION = "organizationalunitDescription";
|
||||||
|
|
||||||
public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationalUnit";
|
public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationalUnit";
|
||||||
|
|
||||||
|
|
@ -65,10 +65,10 @@ public class OrganizationalUnit extends ContentPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOrganizationalUnitDescription() {
|
public String getOrganizationalUnitDescription() {
|
||||||
return (String) get(ORGANIZATIONAL_DESCRIPTION);
|
return (String) get(ORGANIZATIONALUNIT_DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrganizationalUnitDescription(String description) {
|
public void setOrganizationalUnitDescription(String description) {
|
||||||
set(ORGANIZATIONAL_DESCRIPTION, description);
|
set(ORGANIZATIONALUNIT_DESCRIPTION, description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class OrganizationalUnitInitializer extends ContentTypeInitializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStylesheet() {
|
public String getStylesheet() {
|
||||||
return "static/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xml";
|
return "static/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xsl";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import org.apache.log4j.Logger;
|
||||||
public class OrganizationalUnitLoader extends AbstractContentTypeLoader {
|
public class OrganizationalUnitLoader extends AbstractContentTypeLoader {
|
||||||
|
|
||||||
private final static Logger logger = Logger.getLogger(OrganizationalUnitLoader.class);
|
private final static Logger logger = Logger.getLogger(OrganizationalUnitLoader.class);
|
||||||
private final static String[] TYPES = {"/WEB-INF/content-types/com/arsdigita/cms/contentypes/OrganizationalUnit.xml"};
|
private final static String[] TYPES = {"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xml"};
|
||||||
|
|
||||||
public String[] getTypes() {
|
public String[] getTypes() {
|
||||||
return TYPES;
|
return TYPES;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.OrganizationalUnit;
|
||||||
|
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.domain.DomainObject;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class OrganizationalUnitPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(OrganizationalUnitPropertiesStep.class);
|
||||||
|
public final static String EDIT_SHEET_NAME = "edit";
|
||||||
|
|
||||||
|
public OrganizationalUnitPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
|
super(itemModel, parent);
|
||||||
|
|
||||||
|
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||||
|
BasicPageForm editSheet;
|
||||||
|
|
||||||
|
editSheet = new OrganizationalUnitPropertyForm(itemModel, this);
|
||||||
|
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
setDisplayComponent(getOrganizationalUnitPropertySheet(itemModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component getOrganizationalUnitPropertySheet(ItemSelectionModel itemModel) {
|
||||||
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.organizatialunit.unitname"), OrganizationalUnit.ORGANIZATIONALUNIT_NAME);
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.organizatialunit.unitdescription"), OrganizationalUnit.ORGANIZATIONALUNIT_DESCRIPTION);
|
||||||
|
|
||||||
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
|
public String format(DomainObject obj, String attribute, PageState state) {
|
||||||
|
ContentPage page = (ContentPage) obj;
|
||||||
|
if (page.getLaunchDate() != null) {
|
||||||
|
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
|
||||||
|
} else {
|
||||||
|
return (String) GlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.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.TextArea;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.OrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class OrganizationalUnitPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(OrganizationalUnitPropertyForm.class);
|
||||||
|
private OrganizationalUnitPropertiesStep m_step;
|
||||||
|
public final static String ORGANIZATIONALUNIT_NAME = OrganizationalUnit.ORGANIZATIONALUNIT_NAME;
|
||||||
|
public final static String ORGANIZATIONALUNIT_DESCRIPTION = OrganizationalUnit.ORGANIZATIONALUNIT_DESCRIPTION;
|
||||||
|
public final static String ID = "OrganizationalUnit_edit";
|
||||||
|
|
||||||
|
public OrganizationalUnitPropertyForm(ItemSelectionModel itemModel) {
|
||||||
|
this(itemModel, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationalUnitPropertyForm(ItemSelectionModel itemModel, OrganizationalUnitPropertiesStep step) {
|
||||||
|
super(ID, itemModel);
|
||||||
|
this.m_step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addWidgets() {
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.organizationalunit.ui.unitname")));
|
||||||
|
ParameterModel orgaUnitNameParam = new StringParameter(ORGANIZATIONALUNIT_NAME);
|
||||||
|
TextField orgaUnitName = new TextField(orgaUnitNameParam);
|
||||||
|
orgaUnitName.addValidationListener(new NotNullValidationListener());
|
||||||
|
add(orgaUnitName);
|
||||||
|
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.organizationalunit.ui.description")));
|
||||||
|
TextArea description = new TextArea(ORGANIZATIONALUNIT_DESCRIPTION);
|
||||||
|
description.setRows(5);
|
||||||
|
description.setCols(30);
|
||||||
|
add(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
OrganizationalUnit orgaUnit = (OrganizationalUnit) super.initBasicWidgets(e);
|
||||||
|
|
||||||
|
data.put(ORGANIZATIONALUNIT_NAME, orgaUnit.getOrganizationalUnitName());
|
||||||
|
data.put(ORGANIZATIONALUNIT_DESCRIPTION, orgaUnit.getOrganizationalUnitDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
|
||||||
|
OrganizationalUnit orgaUnit = (OrganizationalUnit) super.processBasicWidgets(e);
|
||||||
|
|
||||||
|
if ((orgaUnit != null) && (getSaveCancelSection().getSaveButton().isSelected(e.getPageState()))) {
|
||||||
|
orgaUnit.setOrganizationalUnitName((String) data.get(ORGANIZATIONALUNIT_NAME));
|
||||||
|
orgaUnit.setOrganizationalUnitDescription((String) data.get(ORGANIZATIONALUNIT_DESCRIPTION));
|
||||||
|
|
||||||
|
orgaUnit.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.m_step != null) {
|
||||||
|
this.m_step.maybeForwardToNextStep(e.getPageState());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||||
|
if ((this.m_step != null) &&
|
||||||
|
(getSaveCancelSection().getCancelButton().isSelected(e.getPageState()))) {
|
||||||
|
this.m_step.cancelStreamlinedCreation(e.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue