Aktueller Stand GenericOrganization mit Verküpfung zu Person. Funktioniert noch nicht 100%
git-svn-id: https://svn.libreccm.org/ccm/trunk@192 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b59b330028
commit
d44f00ff43
|
|
@ -8,6 +8,8 @@
|
||||||
<ccm:dependencies>
|
<ccm:dependencies>
|
||||||
<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-article" version="6.6.0" requires="ge"/>
|
||||||
</ccm:dependencies>
|
</ccm:dependencies>
|
||||||
<ccm:directories>
|
<ccm:directories>
|
||||||
<ccm:directory name="pdl"/>
|
<ccm:directory name="pdl"/>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
//
|
||||||
|
// 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 OrganizationRole extends ACSObject {
|
||||||
|
String[1..1] roleName = ct_organizationroles.rolename VARCHAR(150);
|
||||||
|
Person[0..1] targetItem = join ct_organizationroles.target_item_id to ct_persons.person_id;
|
||||||
|
|
||||||
|
Integer[0..1] roleOrder = ct_organizationroles.role_order INTEGER;
|
||||||
|
|
||||||
|
reference key(ct_organizationroles.role_id);
|
||||||
|
aggressive load (roleOwner.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
association {
|
||||||
|
composite GenericOrganization[0..1] roleOwner = join ct_organizationroles.owner_id to ct_genericorganizations.organization_id;
|
||||||
|
composite OrganizationRole[0..n] roles = join ct_genericorganizations.organization_id to ct_organizationroles.owner_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
query getRefferingRoles {
|
||||||
|
BigDecimal id;
|
||||||
|
|
||||||
|
do {
|
||||||
|
select r.role_id from organizationroles r where r.target_item_id = :itemID
|
||||||
|
} map {
|
||||||
|
id = r.role_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data operation swapOrganizationRoleWithNextInGroup {
|
||||||
|
do {
|
||||||
|
update organizationroles
|
||||||
|
set role_order = CASE WHEN (role_order = :roleOrder) THEN
|
||||||
|
(:nextRoleOrder)
|
||||||
|
ELSE
|
||||||
|
(:roleOrder)
|
||||||
|
END
|
||||||
|
where (role_order = :roleOrder or role_order = :nextRoleOrder)
|
||||||
|
and (select owner_id from ct_organizationroles where organizationrole_id=role_id) = :roleID
|
||||||
|
and 2 = (select count(*) from ct_organizationroles r where r.role_id=r.organizationrole_id
|
||||||
|
and (role_order = :roleOrder or role_order = :nextRoleOrder)
|
||||||
|
and owner_id = :ownerID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query allRoleOrderForOrganization {
|
||||||
|
Integer linkOrder;
|
||||||
|
|
||||||
|
do {
|
||||||
|
select r.role_order from ct_organizationroles r where r.owner_id = :ownerID
|
||||||
|
}
|
||||||
|
map {
|
||||||
|
linkOrder = r.linkOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
component="com.arsdigita.cms.contenttypes.ui.GenericOrganizationPropertiesStep"
|
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.OrganizationRolePropertiesStep"
|
||||||
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>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<registry>
|
<registry>
|
||||||
<config class="com.arsdigita.cms.contenttypes.GenericOrganizationConfig"
|
|
||||||
storage="ccm-cms-types-event/genericorganization.properties"/>
|
|
||||||
</registry>
|
</registry>
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
<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>
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,7 @@ import com.arsdigita.cms.ContentPage;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.util.Assert;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -70,24 +67,24 @@ public class GenericOrganization extends ContentPage {
|
||||||
* Type of this class (used for internal purposed).
|
* Type of this class (used for internal purposed).
|
||||||
*/
|
*/
|
||||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericOrganization";
|
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericOrganization";
|
||||||
private static final GenericOrganizationConfig s_config = new GenericOrganizationConfig();
|
//private static final GenericOrganizationConfig s_config = new GenericOrganizationConfig();
|
||||||
private static final Logger s_log = Logger.getLogger(GenericOrganization.class);
|
private static final Logger s_log = Logger.getLogger(GenericOrganization.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the class is loaded by the Java class loader.
|
* Called when the class is loaded by the Java class loader.
|
||||||
*/
|
*/
|
||||||
static {
|
/*static {
|
||||||
s_config.load();
|
s_config.load();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a possibly existing configuration object for the class.
|
* Returns a possibly existing configuration object for the class.
|
||||||
*
|
*
|
||||||
* @return config object
|
* @return config object
|
||||||
*/
|
*/
|
||||||
public static final GenericOrganizationConfig getConfig() {
|
/*public static final GenericOrganizationConfig getConfig() {
|
||||||
return s_config;
|
return s_config;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. This creates a new (empty) organization
|
* Default constructor. This creates a new (empty) organization
|
||||||
|
|
@ -188,32 +185,4 @@ public class GenericOrganization extends ContentPage {
|
||||||
public void setOrganizationDescription(String description) {
|
public void setOrganizationDescription(String description) {
|
||||||
set(DESCRIPTION, description);
|
set(DESCRIPTION, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return All roles associated with this organization.
|
|
||||||
*/
|
|
||||||
public OrganizationRoleCollection getOrganizationRoles() {
|
|
||||||
return new OrganizationRoleCollection((DataCollection) get(ROLES));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a role to a organization.
|
|
||||||
*
|
|
||||||
* @param organizationRole The role to add.
|
|
||||||
*/
|
|
||||||
public void addOrganizationRole(OrganizationRole organizationRole) {
|
|
||||||
Assert.exists(organizationRole, OrganizationRole.class);
|
|
||||||
add(ROLES, organizationRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a role from a organization.
|
|
||||||
*
|
|
||||||
* @param organizationRole The role to remove.
|
|
||||||
*/
|
|
||||||
public void removeOrganizationRole(OrganizationRole organizationRole) {
|
|
||||||
Assert.exists(organizationRole, OrganizationRole.class);
|
|
||||||
remove(ROLES, organizationRole);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,246 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
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 OrganizationRole extends ACSObject {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(OrganizationRole.class);
|
||||||
|
public static final String ROLENAME = "roleName";
|
||||||
|
public static final String TARGETITEM = "targetItem";
|
||||||
|
public static final String ROLEOWNER = "roleOwner";
|
||||||
|
public static final String ORDER = "roleOrder";
|
||||||
|
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationRole";
|
||||||
|
|
||||||
|
public OrganizationRole() {
|
||||||
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationRole(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationRole(OID id) throws DataObjectNotFoundException {
|
||||||
|
super(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationRole(DataObject obj) {
|
||||||
|
super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationRole(String type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRolename() {
|
||||||
|
return (String) get(ROLENAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRolename(String rolename) {
|
||||||
|
set(ROLENAME, rolename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenericOrganization getRoleOwner() {
|
||||||
|
DataObject obj = (DataObject) get(ROLEOWNER);
|
||||||
|
if (obj == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return (GenericOrganization) DomainObjectFactory.newInstance(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleOwner(GenericOrganization orga) {
|
||||||
|
Assert.exists(orga, GenericOrganization.class);
|
||||||
|
logger.debug(String.format("Setting role owner to %s", orga.getOrganizationName()));
|
||||||
|
setAssociation(ROLEOWNER, orga);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Person getTargetItem() {
|
||||||
|
DataObject object = (DataObject) get(TARGETITEM);
|
||||||
|
return (Person) DomainObjectFactory.newInstance(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargetItem(Person item) {
|
||||||
|
setAssociation(TARGETITEM, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrder() {
|
||||||
|
return (Integer) get(ORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(Integer order) {
|
||||||
|
Assert.exists(order);
|
||||||
|
set(ORDER, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getURI(PageState s) {
|
||||||
|
Person item = getTargetItem();
|
||||||
|
|
||||||
|
if (item == null) {
|
||||||
|
logger.error(getOID() + " is a link between an organization and a person, but the associated person is null");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentSection section = item.getContentSection();
|
||||||
|
ItemResolver resolver = section.getItemResolver();
|
||||||
|
String url = resolver.generateItemURL(s, item, section, item.getVersion());
|
||||||
|
|
||||||
|
return URL.there(s.getRequest(), url).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataCollection getReferingRoles(Person person) {
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection roles = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
Filter filter = roles.addInSubqueryFilter("id", "com.arsdigita.cms.contenttypes.getRefferingRoles");
|
||||||
|
filter.set("itemID", person.getID());
|
||||||
|
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataCollection getRoles(GenericOrganization orga) {
|
||||||
|
logger.debug("Getting roles for an organization...");
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection roles = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
roles.addEqualsFilter(ROLEOWNER + ".id", orga.getID());
|
||||||
|
roles.addOrder(ORDER);
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithNext() throws UnsupportedOperationException {
|
||||||
|
swapWithNext("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithPrevious() throws UnsupportedOperationException {
|
||||||
|
swapWithNext("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup");
|
||||||
|
}
|
||||||
|
|
||||||
|
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().retrieveQuery(queryName);
|
||||||
|
query.setParameter("ownerID", getRoleOwner().getID());
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DataOperation getSwapOperation(String operationName) {
|
||||||
|
DataOperation operation = SessionManager.getSession().retrieveDataOperation(operationName);
|
||||||
|
operation.setParameter("ownerID", getRoleOwner().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(ORDER);
|
||||||
|
|
||||||
|
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 = key;
|
||||||
|
|
||||||
|
if (swapNext) {
|
||||||
|
otherKey = key + 1;
|
||||||
|
query.addOrder("roleOrder ASC");
|
||||||
|
query.addFilter(query.getFilterFactory().greaterThan("roleOrder", currentKey, true));
|
||||||
|
} else {
|
||||||
|
otherKey = key - 1;
|
||||||
|
query.addOrder("roleOrder DESC");
|
||||||
|
query.addFilter(query.getFilterFactory().lessThan("roleOrder", currentKey, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.next()) {
|
||||||
|
otherKey = ((Integer) query.get("roleOrder")).intValue();
|
||||||
|
query.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
DataOperation operation = getSwapOperation(operationName);
|
||||||
|
operation.setParameter("linkOrder", new Integer(key));
|
||||||
|
operation.setParameter("nextLinkOrder", new Integer(otherKey));
|
||||||
|
operation.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void alphabetize() {
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection roles = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
roles.addEqualsFilter(ROLEOWNER + ".id", getRoleOwner().getID());
|
||||||
|
roles.addOrder(ROLENAME);
|
||||||
|
int sortkey = 0;
|
||||||
|
while (roles.next()) {
|
||||||
|
sortkey++;
|
||||||
|
OrganizationRole role = new OrganizationRole(roles.getDataObject());
|
||||||
|
role.setOrder(sortkey);
|
||||||
|
role.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int maxOrder() {
|
||||||
|
GenericOrganization roleOwner = getRoleOwner();
|
||||||
|
if (roleOwner == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int returnOrder = 0;
|
||||||
|
DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.cms.contenttypes.allRoleOrderForItem");
|
||||||
|
query.setParameter("ownerID", getRoleOwner().getID());
|
||||||
|
query.addOrder("linkOrder DESC");
|
||||||
|
if (query.next()) {
|
||||||
|
Integer roleOrder = ((Integer) query.get("roleOrder"));
|
||||||
|
query.close();
|
||||||
|
if (roleOrder != null) {
|
||||||
|
returnOrder = roleOrder.intValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeSave() {
|
||||||
|
super.beforeSave();
|
||||||
|
if (getOrder() == null) {
|
||||||
|
setOrder(maxOrder() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,51 +1,56 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentPage;
|
import com.arsdigita.cms.ContentPage;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.OrganizationRole;
|
import com.arsdigita.cms.contenttypes.GenericOrganization;
|
||||||
import com.arsdigita.domain.DomainObject;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
import com.arsdigita.ui.util.GlobalizationUtil;
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
public class OrganizationRolePropertiesStep extends SimpleEditStep {
|
public class GenericOrganizationPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(GenericOrganizationPropertiesStep.class);
|
||||||
|
|
||||||
public static final String EDIT_SHEET_NAME = "edit";
|
public static final String EDIT_SHEET_NAME = "edit";
|
||||||
|
|
||||||
public OrganizationRolePropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
public GenericOrganizationPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
super(itemModel, parent);
|
super(itemModel, parent);
|
||||||
|
|
||||||
setDefaultEditKey(EDIT_SHEET_NAME);
|
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||||
BasicPageForm editSheet;
|
BasicPageForm editSheet;
|
||||||
|
|
||||||
editSheet = new OrganizationRolePropertyForm(itemModel, this);
|
editSheet = new GenericOrganizationPropertyForm(itemModel, this);
|
||||||
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton());
|
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
setDisplayComponent(getOrganizationRolePropertySheet(itemModel));
|
setDisplayComponent(getGenericOrganizationPropertySheet(itemModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component getOrganizationRolePropertySheet(ItemSelectionModel itemModel) {
|
public static Component getGenericOrganizationPropertySheet(ItemSelectionModel itemModel) {
|
||||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.organizationrole.rolename"), OrganizationRole.ROLENAME);
|
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);
|
||||||
|
|
||||||
if(!ContentSection.getConfig().getHideLaunchDate()) {
|
if(!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() {
|
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;
|
public String format(DomainObject obj, String attribute, PageState state) {
|
||||||
|
ContentPage page = (ContentPage)obj;
|
||||||
if(page.getLaunchDate() != null) {
|
if(page.getLaunchDate() != null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
|
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
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.bebop.Label;
|
||||||
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class GenericOrganizationPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(GenericOrganizationPropertyForm.class);
|
||||||
|
|
||||||
|
private GenericOrganizationPropertiesStep m_step;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Organizationname.
|
||||||
|
*/
|
||||||
|
public static final String ORGANIZATIONAME = GenericOrganization.ORGANIZATIONNAME;
|
||||||
|
/**
|
||||||
|
* Addedum
|
||||||
|
*/
|
||||||
|
public static final String ORGANIZATIONNAMEADDENDUM = GenericOrganization.ORGANIZATIONNAMEADDENDUM;
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*/
|
||||||
|
public static final String DESCRIPTION = GenericOrganization.DESCRIPTION;
|
||||||
|
|
||||||
|
public static final String ID = "GenericOrganization_edit";
|
||||||
|
|
||||||
|
public GenericOrganizationPropertyForm(ItemSelectionModel itemModel) {
|
||||||
|
this(itemModel, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenericOrganizationPropertyForm(ItemSelectionModel itemModel, GenericOrganizationPropertiesStep step) {
|
||||||
|
super(ID, itemModel);
|
||||||
|
m_step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addWidgets() {
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.genericorganization.ui.organizationname")));
|
||||||
|
ParameterModel organizationNameParam = new StringParameter(ORGANIZATIONAME);
|
||||||
|
TextField organizationName = new TextField(organizationNameParam);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
GenericOrganization orga = (GenericOrganization)super.initBasicWidgets(e);
|
||||||
|
|
||||||
|
data.put(ORGANIZATIONAME, orga.getOrganizationName());
|
||||||
|
data.put(ORGANIZATIONNAMEADDENDUM, orga.getOrganizationNameAddendum());
|
||||||
|
data.put(DESCRIPTION, orga.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(FormSectionEvent e) throws FormProcessException {
|
||||||
|
logger.error("proccessing...");
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
|
||||||
|
GenericOrganization orga = (GenericOrganization)super.processBasicWidgets(e);
|
||||||
|
|
||||||
|
if((orga != null)
|
||||||
|
&& (getSaveCancelSection().getSaveButton().isSelected(e.getPageState()))) {
|
||||||
|
orga.setOrganizationName((String)data.get(ORGANIZATIONAME));
|
||||||
|
orga.setOrganizationNameAddendum((String)data.get(ORGANIZATIONNAMEADDENDUM));
|
||||||
|
orga.setDescription((String)data.get(DESCRIPTION));
|
||||||
|
|
||||||
|
logger.error("Saving new values of orga");
|
||||||
|
orga.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_step != null) {
|
||||||
|
m_step.maybeForwardToNextStep(e.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||||
|
logger.error("submitted");
|
||||||
|
if((m_step != null) &&
|
||||||
|
(getSaveCancelSection().getCancelButton().isSelected(e.getPageState()))) {
|
||||||
|
m_step.cancelStreamlinedCreation(e.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class OrganizationRolePropertiesStep extends ResettableContainer {
|
||||||
|
|
||||||
|
private AuthoringKitWizard m_parent;
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private BigDecimalParameter m_roleParam = new BigDecimalParameter("organizationrole");
|
||||||
|
private OrganizationRoleSelectionModel m_roleModel = new OrganizationRoleSelectionModel(m_roleParam);
|
||||||
|
|
||||||
|
public OrganizationRolePropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_parent = parent;
|
||||||
|
setOrganizationRoleSelectionModel();
|
||||||
|
add(getDisplayComponent());
|
||||||
|
|
||||||
|
Form form = new Form("organizationRoleEditForm");
|
||||||
|
form.add(getEditSheet());
|
||||||
|
|
||||||
|
WorkflowLockedContainer edit = new WorkflowLockedContainer(itemModel);
|
||||||
|
edit.add(form);
|
||||||
|
add(edit);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOrganizationRoleSelectionModel() {
|
||||||
|
setOrganizationRoleSelectionModel(new OrganizationRoleSelectionModel(m_roleParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOrganizationRoleSelectionModel(OrganizationRoleSelectionModel model) {
|
||||||
|
m_roleModel = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected OrganizationRoleSelectionModel getOrganizationRoleSelectionModel() {
|
||||||
|
return m_roleModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BigDecimalParameter getRoleParam() {
|
||||||
|
return this.m_roleParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getDisplayComponent() {
|
||||||
|
SimpleContainer container = new SimpleContainer();
|
||||||
|
container.add(new OrganizationRoleTable(m_itemModel, m_roleModel));
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FormSection getEditSheet() {
|
||||||
|
return new OrganizationRolePropertyForm(this.m_itemModel, this.m_roleModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(Page p) {
|
||||||
|
super.register(p);
|
||||||
|
p.addComponentStateParam(this, m_roleParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,198 @@
|
||||||
|
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.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.Article;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganization;
|
||||||
|
import com.arsdigita.cms.contenttypes.OrganizationRole;
|
||||||
|
import com.arsdigita.cms.contenttypes.Person;
|
||||||
|
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 OrganizationRolePropertyForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
public final static Logger logger = Logger.getLogger(OrganizationRolePropertyForm.class);
|
||||||
|
public final static String ID = "organizationrole_edit";
|
||||||
|
//public final static String SSL_PROTOCOL = "https://";
|
||||||
|
//public final static String HTTP_PROTOCOL = "http://";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private OrganizationRoleSelectionModel m_roleModel;
|
||||||
|
private TextField m_rolename;
|
||||||
|
private ItemSearchWidget m_itemSearch;
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
private final String ITEM_SEARCH = "organizationRole";
|
||||||
|
|
||||||
|
public OrganizationRolePropertyForm(ItemSelectionModel itemModel, OrganizationRoleSelectionModel roleModel) {
|
||||||
|
super(new ColumnPanel(2));
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_roleModel = roleModel;
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addValidationListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addWidgets() {
|
||||||
|
this.m_rolename = new TextField("rolename");
|
||||||
|
this.m_rolename.addValidationListener(new NotNullValidationListener());
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.rolename")));
|
||||||
|
add(this.m_rolename);
|
||||||
|
|
||||||
|
add(new Label("Person"));
|
||||||
|
//logger.error(String.format("Person.CONTENT_TYPE = %s", Person.CONTENT_TYPE));
|
||||||
|
//logger.error(String.format("Article.CONTENT_TYPE = %s", Article.CONTENT_TYPE));
|
||||||
|
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.Person"));
|
||||||
|
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_roleModel.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_roleModel.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 OrganizationRoleSelectionModel getRoleSelectionModel() {
|
||||||
|
return this.m_roleModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*protected Person getPerson(PageState s) {
|
||||||
|
return (Person) m_itemModel.getSelectedObject(s);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
protected GenericOrganization getOrganization(PageState s) {
|
||||||
|
return (GenericOrganization)m_itemModel.getSelectedObject(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected OrganizationRole createOrganizationRole(PageState s) {
|
||||||
|
//Person person = this.getPerson(s);
|
||||||
|
//Assert.exists(person);
|
||||||
|
GenericOrganization orga = this.getOrganization(s);
|
||||||
|
Assert.exists(orga);
|
||||||
|
OrganizationRole role = new OrganizationRole();
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOrganizationRoleProperties(OrganizationRole role, FormSectionEvent e) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
|
||||||
|
role.setRolename((String)m_rolename.getValue(state));
|
||||||
|
role.setTargetItem((Person)data.get(ITEM_SEARCH));
|
||||||
|
|
||||||
|
role.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
|
||||||
|
OrganizationRole role;
|
||||||
|
if (m_roleModel.isSelected(state)) {
|
||||||
|
role = m_roleModel.getSelectedRole(state);
|
||||||
|
try {
|
||||||
|
m_rolename.setValue(state, role.getRolename());
|
||||||
|
data.put(ITEM_SEARCH, role.getTargetItem());
|
||||||
|
} catch (IllegalStateException ex) {
|
||||||
|
logger.error(ex.getMessage());
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_rolename.setValue(state, null);
|
||||||
|
data.put(ITEM_SEARCH, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(FormSectionEvent e) throws FormProcessException {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
OrganizationRole role;
|
||||||
|
|
||||||
|
if (this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||||
|
m_roleModel.clearSelection(state);
|
||||||
|
} else {
|
||||||
|
if (m_roleModel.isSelected(state)) {
|
||||||
|
role = m_roleModel.getSelectedRole(state);
|
||||||
|
} else {
|
||||||
|
role = createOrganizationRole(state);
|
||||||
|
}
|
||||||
|
setOrganizationRoleProperties(role, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_roleModel.clearSelection(state);
|
||||||
|
init(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||||
|
if (e.getFormData().get(ITEM_SEARCH) == null) {
|
||||||
|
throw new FormProcessException("Person selection is required.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||||
|
if (this.m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) {
|
||||||
|
logger.debug("Cancel in submission listener");
|
||||||
|
m_roleModel.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.kernel.ui.ACSObjectSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.OrganizationRole;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class OrganizationRoleSelectionModel extends ACSObjectSelectionModel {
|
||||||
|
|
||||||
|
public OrganizationRoleSelectionModel(BigDecimalParameter param) {
|
||||||
|
super(OrganizationRole.class.getName(), OrganizationRole.BASE_DATA_OBJECT_TYPE, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationRoleSelectionModel(String itemClass, String objectType, BigDecimalParameter parameter) {
|
||||||
|
super(itemClass, objectType, parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationRole getSelectedRole(PageState state) {
|
||||||
|
return (OrganizationRole) getSelectedObject(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
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.Link;
|
||||||
|
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.OrganizationRole;
|
||||||
|
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 OrganizationRoleTable extends Table {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(OrganizationRoleTable.class);
|
||||||
|
private OrganizationRoleSelectionModel m_roleModel;
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private TableColumn m_roleNameCol;
|
||||||
|
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 OrganizationRoleTable(ItemSelectionModel itemModel, OrganizationRoleSelectionModel roleModel) {
|
||||||
|
super();
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_roleModel = roleModel;
|
||||||
|
addColumns();
|
||||||
|
|
||||||
|
m_size = new RequestLocal();
|
||||||
|
m_editor = new RequestLocal() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object initialValue(PageState state) {
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = m_itemModel.getSelectedItem(state);
|
||||||
|
Boolean val = new Boolean(sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM, item));
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Label empty = new Label("There are no roles for this organization.");
|
||||||
|
setEmptyView(empty);
|
||||||
|
addTableActionListener(new OrganizationRoleTableActionListener());
|
||||||
|
setRowSelectionModel(m_roleModel);
|
||||||
|
setDefaultCellRenderer(new OrganizationRoleTableRenderer());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addColumns() {
|
||||||
|
TableColumnModel model = getColumnModel();
|
||||||
|
int i = 0;
|
||||||
|
m_roleNameCol = new TableColumn(i, "Role");
|
||||||
|
m_editCol = new TableColumn(++i, "Edit");
|
||||||
|
m_delCol = new TableColumn(++i, "Delete");
|
||||||
|
m_moveUpCol = new TableColumn(++i, "");
|
||||||
|
m_moveDownCol = new TableColumn(++i, "");
|
||||||
|
|
||||||
|
model.add(m_roleNameCol);
|
||||||
|
model.add(m_editCol);
|
||||||
|
model.add(m_delCol);
|
||||||
|
model.add(m_moveUpCol);
|
||||||
|
model.add(m_moveDownCol);
|
||||||
|
setColumnModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class OrganizationRoleTableRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
|
public Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column) {
|
||||||
|
OrganizationRole role = (OrganizationRole) value;
|
||||||
|
boolean isFirst = (row == 0);
|
||||||
|
if (m_size.get(state) == null) {
|
||||||
|
m_size.set(state, new Long(((OrganizationRoleTableModelBuilder.OrganizationRoleTableModel) table.getTableModel(state)).size()));
|
||||||
|
}
|
||||||
|
boolean isLast = (row == ((Long) m_size.get(state)).intValue() - 1);
|
||||||
|
|
||||||
|
String url = role.getURI(state);
|
||||||
|
if (column == m_roleNameCol.getModelIndex()) {
|
||||||
|
ExternalLink extLink = new ExternalLink(role.getRolename(), 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)) && !isLast) {
|
||||||
|
Label downLabel = new Label(DOWN_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 OrganizationRoleTableActionListener implements TableActionListener {
|
||||||
|
|
||||||
|
private OrganizationRole getOrganizationRole(TableActionEvent e) {
|
||||||
|
Object o = e.getRowKey();
|
||||||
|
BigDecimal id;
|
||||||
|
if(o instanceof String) {
|
||||||
|
logger.debug("row key is a string: " + o);
|
||||||
|
id = new BigDecimal((String)o);
|
||||||
|
} else {
|
||||||
|
id = (BigDecimal)e.getRowKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.exists(id);
|
||||||
|
OrganizationRole role;
|
||||||
|
try {
|
||||||
|
role = (OrganizationRole)DomainObjectFactory.newInstance(new OID(OrganizationRole.BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
} catch(DataObjectNotFoundException ex) {
|
||||||
|
throw new UncheckedWrapperException(e);
|
||||||
|
}
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cellSelected(TableActionEvent e) {
|
||||||
|
int col = e.getColumn().intValue();
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
OrganizationRole role = getOrganizationRole(e);
|
||||||
|
Assert.exists(role);
|
||||||
|
|
||||||
|
if (col == m_roleNameCol.getModelIndex()) {
|
||||||
|
//Nothing to do...
|
||||||
|
} else if (col == m_editCol.getModelIndex()) {
|
||||||
|
if(Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
logger.debug("setting organizationRoleModel to: " + role.getRolename());
|
||||||
|
m_roleModel.setSelectedObject(state, role);
|
||||||
|
}
|
||||||
|
} else if(col == m_delCol.getModelIndex()) {
|
||||||
|
if(Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
try {
|
||||||
|
logger.debug("About to delete");
|
||||||
|
m_roleModel.clearSelection(state);
|
||||||
|
role.delete();;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(col == m_moveUpCol.getModelIndex()) {
|
||||||
|
m_roleModel.clearSelection(state);
|
||||||
|
role.swapWithPrevious();
|
||||||
|
} else if(col == m_moveDownCol.getModelIndex()) {
|
||||||
|
m_roleModel.clearSelection(state);
|
||||||
|
role.swapWithNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected(TableActionEvent e) {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
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.OrganizationRole;
|
||||||
|
import com.arsdigita.cms.contenttypes.Person;
|
||||||
|
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 OrganizationRoleTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(OrganizationRoleTableModelBuilder.class);
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public OrganizationRoleTableModelBuilder(ItemSelectionModel itemModel) {
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table t, PageState s) {
|
||||||
|
logger.debug("OrganizationRoleTableModelBuilder.makemodel()");
|
||||||
|
|
||||||
|
DataCollection roles = getRoles(s);
|
||||||
|
|
||||||
|
if(roles.isEmpty()) {
|
||||||
|
return Table.EMPTY_MODEL;
|
||||||
|
} else {
|
||||||
|
return new OrganizationRoleTableModel(roles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataCollection getRoles(PageState s) {
|
||||||
|
Assert.isTrue(this.m_itemModel.isSelected(s), "item selected");
|
||||||
|
GenericOrganization orga = (GenericOrganization) m_itemModel.getSelectedItem(s);
|
||||||
|
return OrganizationRole.getRoles(orga);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class OrganizationRoleTableModel implements TableModel {
|
||||||
|
|
||||||
|
OrganizationRole m_role;
|
||||||
|
DataCollection m_roles;
|
||||||
|
|
||||||
|
public OrganizationRoleTableModel(DataCollection roles) {
|
||||||
|
m_roles = roles;
|
||||||
|
m_role = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColumnCount() {
|
||||||
|
return (int)m_roles.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean nextRow() {
|
||||||
|
if (m_roles.next()) {
|
||||||
|
DataObject obj = m_roles.getDataObject();
|
||||||
|
m_role = (OrganizationRole)DomainObjectFactory.newInstance(obj);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
return m_role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_role.getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long size() {
|
||||||
|
return m_roles.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
<?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>
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
begin;
|
|
||||||
\i ddl/postgres/create.sql
|
|
||||||
end;
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
<?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>
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<registry>
|
|
||||||
</registry>
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<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>
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
package com.arsdigita.cms.contenttypes;
|
|
||||||
|
|
||||||
import com.arsdigita.domain.DomainCollection;
|
|
||||||
import com.arsdigita.domain.DomainObject;
|
|
||||||
import com.arsdigita.persistence.DataCollection;
|
|
||||||
import com.arsdigita.persistence.Filter;
|
|
||||||
import com.arsdigita.persistence.PersistenceException;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
|
||||||
*/
|
|
||||||
public class OrganizationRoleCollection extends DomainCollection {
|
|
||||||
|
|
||||||
public OrganizationRoleCollection(DataCollection dataCollection) {
|
|
||||||
super(dataCollection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addOrder(String order) {
|
|
||||||
m_dataCollection.addOrder(order);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainObject getDomainObject() {
|
|
||||||
return new OrganizationRole(m_dataCollection.getDataObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganizationRole getOrganizationRole() {
|
|
||||||
return (OrganizationRole) getDomainObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Filter addFilter(String conditions) {
|
|
||||||
return m_dataCollection.addFilter(conditions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearFilter() {
|
|
||||||
m_dataCollection.clearFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearOrder() throws PersistenceException {
|
|
||||||
m_dataCollection.clearOrder();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
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"};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
<!DOCTYPE stylesheet [
|
|
||||||
<!ENTITY nbsp " " ><!-- 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>
|
|
||||||
|
|
@ -137,6 +137,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isVisible(PageState ps) {
|
public boolean isVisible(PageState ps) {
|
||||||
return ((m_search.isSelected(ps) ||
|
return ((m_search.isSelected(ps) ||
|
||||||
hasQuery(ps)) &&
|
hasQuery(ps)) &&
|
||||||
|
|
@ -151,6 +152,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
super("<hr/>", false);
|
super("<hr/>", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isVisible(PageState ps) {
|
public boolean isVisible(PageState ps) {
|
||||||
return ((m_search.isSelected(ps) ||
|
return ((m_search.isSelected(ps) ||
|
||||||
m_searchComponent.hasQuery(ps)) &&
|
m_searchComponent.hasQuery(ps)) &&
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.util;
|
package com.arsdigita.util;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -67,6 +68,10 @@ public class UncheckedWrapperException extends RuntimeException {
|
||||||
this(msg, null);
|
this(msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UncheckedWrapperException(TableActionEvent e) {
|
||||||
|
throw new UnsupportedOperationException("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor which takes a root cause
|
* Constructor which takes a root cause
|
||||||
* that this exception will be wrapping.
|
* that this exception will be wrapping.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue