Überflüssige Pakete entfernt

git-svn-id: https://svn.libreccm.org/ccm/trunk@775 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2011-03-03 08:23:58 +00:00
parent d498fe2540
commit ac641409c0
40 changed files with 0 additions and 3843 deletions

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name="ccm-cms-relationattributeimporter"
prettyName="RelationAttribute Importer"
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:requires name="ccm-ldn-util" version="6.6.0" relation="ge"/>
</ccm:dependencies>
<ccm:contacts>
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
</ccm:contacts>
<ccm:description>
Tool to import RelationAttributes.
</ccm:description>
</ccm:application>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<registry>
<!-- nothing yet -->
</registry>

View File

@ -1,12 +0,0 @@
<load>
<requires>
<table name="cms_items"/>
<initializer class="com.arsdigita.london.util.Initializer"/>
</requires>
<provides>
<initializer class="com.arsdigita.cms.relationattributeimporter.Initializer"/>
</provides>
<scripts>
<data class="com.arsdigita.cms.relationattributeimporter.Loader"/>
</scripts>
</load>

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.relationattributeimporter;
import com.arsdigita.runtime.CompoundInitializer;
/**
* Initializer for the ccm-cms-relationattributeimporter application.
*
* @author Jens Pelzetter
*/
public class Initializer extends CompoundInitializer {
public Initializer() {
//Nothing yet.
}
}

View File

@ -1,36 +0,0 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.relationattributeimporter;
import com.arsdigita.loader.PackageLoader;
import com.arsdigita.runtime.ScriptContext;
/**
* Loader for the ccm-cms-relationattribute application.
*
* @author Jens Pelzetter
*/
public class Loader extends PackageLoader {
public void run(final ScriptContext ctx) {
//Nothing yet.
}
}

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.relationattributeimporter;
/**
* A bean used to keep the information of {@link RelationAttribute} while
* parsing the XML file.
*
* @author Jens Pelzetter
*/
public class RelAttrBean {
private String attribute;
private String key;
private String lang;
private String name;
private String description;
public RelAttrBean() {
}
public String getAttribute() {
return attribute;
}
public void setAttribute(String attribute) {
this.attribute = attribute;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -1,211 +0,0 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.relationattributeimporter;
import com.arsdigita.cms.RelationAttribute;
import com.arsdigita.cms.RelationAttributeInterface;
import com.arsdigita.london.util.Transaction;
import com.arsdigita.packaging.Program;
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.commons.cli.CommandLine;
import org.xml.sax.SAXException;
/**
* <p>
* A simple import tool for {@link RelationAttribute}s. This tool imports the
* relation attributes from a simple XML file or from parameters at the
* commandline. The XML file format:
* </p>
* <pre>
* &lt;?xml version="1.0"?&gt;
* &lt;relationAttributes&gt;
* &lt;relationAttribute&gt;
* &lt;attribute&gt;...&lt;/attribute&gt;
* &lt;key&gt;...&lt;/key&gt;
* &lt;lang&gt;...&lt;/lang&gt;
* &lt;name&gt;...&lt;/name&gt;
* &lt;description&gt;...&lt;/description&gt;
* &lt;/relationAttribute&gt;
* ...
* &lt;/relationAttributes&gt;
* </pre>
* <p>
* The tool can be invoked using the ccm-run command. One parameter, the file
* to import is needed. With tools-ng and ECDC, the line for calling the
* <code>RelationAttributeImporter</code> would like the following:
* </p>
* <p>
* With a XML file:
* </p>
* <pre>
* ant -Dccm.classname="com.arsdigita.cms.relationattributeimporter.RelationAttributeImporter" -Dccm.parameters="/path/to/relation/attribute/file.xml" ccm-run
* </pre>
* <p>
* With command line parameters:
* </p>
* <pre>
* ant -Dccm.classname="com.arsdigita.cms.relationattributeimporter.RelationAttributeImporter" -Dccm.parameters="attribute key lang name [description]" ccm-run
* </pre>
* <p>
* The description parameter is optional.
* </p>
* <p>
* You have to add the <code>RelationAttributeImporter</code> to add to your
* environment, of course.
* </p>
*
* @author Jens Pelzetter
* @see RelationAttribute
* @see RelationAttributeInterface
*/
public class RelationAttributeImporter extends Program {
public RelationAttributeImporter() {
super("Relation Attribute Importer",
"0.1.0",
"FILE | ATTRIBUTE KEY LANG NAME [DESCRIPTION]");
}
public RelationAttributeImporter(boolean startup) {
super("Relation Attribute Importer",
"0.1.0",
"FILE | ATTRIBUTE KEY LANG NAME [DESCRIPTION]", startup);
}
@Override
protected void doRun(CommandLine cmdLine) {
final String[] args;
File relAttrFile;
SAXParserFactory saxFactory;
SAXParser saxParser = null;
RelationAttributeParser parser;
args = cmdLine.getArgs();
if (args.length == 1) {
System.out.printf("Using file %s.", args[0]);
relAttrFile = new File(args[0]);
if (!relAttrFile.exists()) {
System.err.printf("ERROR: File %s does not exist.", args[0]);
System.exit(-1);
}
if (!relAttrFile.isFile()) {
System.err.printf("ERROR: Path %s does not point to a file.",
args[0]);
System.exit(-1);
}
saxFactory = SAXParserFactory.newInstance();
try {
saxParser = saxFactory.newSAXParser();
} catch (ParserConfigurationException ex) {
System.err.printf("Error creating SAXParser: %s",
ex.getMessage());
ex.printStackTrace();
System.exit(-1);
} catch (SAXException ex) {
System.err.printf("Error creating SAXParser: %s",
ex.getMessage());
ex.printStackTrace();
System.exit(-1);
}
parser = new RelationAttributeParser();
try {
saxParser.parse(relAttrFile, parser);
} catch (SAXException ex) {
System.err.printf("Error parsing file %s: %s",
args[0],
ex.getMessage());
ex.printStackTrace();
System.exit(-1);
} catch (IOException ex) {
System.err.printf("Error parsing file %s: %s",
args[0], ex.getMessage());
ex.printStackTrace();
System.exit(-1);
}
System.out.println(
"Parsed XML file successfully. Creating ACSObjects...");
for (int i = 0; i < parser.getRelAttrs().size(); i++) {
System.out.printf("%d of %d...", (i + 1), parser.getRelAttrs().
size());
createACSObject(parser.getRelAttrs().get(i));
}
} else if ((args.length == 4) || (args.length == 5)) {
RelAttrBean relAttr;
relAttr = new RelAttrBean();
relAttr.setAttribute(args[0]);
relAttr.setKey(args[1]);
relAttr.setLang(args[2]);
relAttr.setName(args[3]);
if (args.length == 5) {
relAttr.setDescription(args[4]);
}
createACSObject(relAttr);
} else {
help(System.err);
System.exit(-1);
}
}
/**
* The method creates the {@link RelationAttribute} object from the data
* retrieved from the XML file and stores the object in the database.
*
* @param relAttr
* @param index
*/
private void createACSObject(final RelAttrBean relAttr) {
/*System.out.printf("\tattribute = %s\n", relAttr.getAttribute());
System.out.printf("\tkey = %s\n", relAttr.getKey());
System.out.printf("\tlang = %s\n", relAttr.getLang());
System.out.printf("\tname = %s\n", relAttr.getName());
System.out.printf("\tdescription = %s\n", relAttr.getDescription());*/
Transaction transaction = new Transaction() {
@Override
public void doRun() {
RelationAttribute attr;
attr = new RelationAttribute();
attr.setAttribute(relAttr.getAttribute());
attr.setKey(relAttr.getKey());
attr.setLanguage(relAttr.getLang());
attr.setName(relAttr.getName());
attr.setDescription(relAttr.getDescription());
System.out.print("Saving...");
attr.save();
}
};
transaction.run();
System.out.println("Done\n");
}
public final static void main(String[] args) {
new RelationAttributeImporter().run(args);
}
}

View File

@ -1,176 +0,0 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.relationattributeimporter;
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
/**
* Parser for the XML file. This parser uses the SAX-Parser from the Java
* Standard API.
*
* @author Jens Pelzetter
*/
public class RelationAttributeParser extends DefaultHandler {
private RelAttrBean currentRelAttr;
/**
* A buffer
*/
private StringBuilder buffer;
private boolean relAttrOpen;
private boolean attrOpen;
private boolean keyOpen;
private boolean langOpen;
private boolean nameOpen;
private boolean descOpen;
private List<RelAttrBean> relAttrs;
public RelationAttributeParser() {
relAttrs = new ArrayList<RelAttrBean>();
relAttrOpen = false;
attrOpen = false;
keyOpen = false;
langOpen = false;
nameOpen = false;
descOpen = false;
}
@Override
public void startDocument() throws SAXException {
System.out.println("Relation attribute document begin...");
}
@Override
public void endDocument() throws SAXException {
System.out.println("Relation attribute document end.");
}
@Override
public void startElement(String uri,
String localName,
String qName,
Attributes attributes) throws SAXException {
System.out.printf("DEBUG: uri = %s\n", uri);
System.out.printf("DEBUG: localName = %s\n", localName);
System.out.printf("DEBUG: qName = %s\n", qName);
buffer = new StringBuilder();
if ("relationAttributes".equals(qName)) {
//Nothing to do
} else if ("relationAttribute".equals(qName)) {
relAttrOpen = true;
currentRelAttr = new RelAttrBean();
} else if ("attribute".equals(qName)) {
attrOpen = true;
} else if ("key".equals(qName)) {
keyOpen = true;
} else if ("lang".equals(qName)) {
langOpen = true;
} else if ("name".equals(qName)) {
nameOpen = true;
} else if ("description".equals(qName)) {
descOpen = true;
} else {
System.err.printf(
"Warning: Encountered unexpected element %s. Ignoring.\n",
qName);
}
}
@Override
public void endElement(String uri,
String localName,
String qName) throws SAXException {
if ("relationAttributes".equals(qName)) {
//Nothing to do
} else if ("relationAttribute".equals(qName)) {
relAttrs.add(currentRelAttr);
currentRelAttr = null;
relAttrOpen = false;
} else if ("attribute".equals(qName)) {
System.out.printf("buffer = %s\n", buffer.toString());
currentRelAttr.setAttribute(buffer.toString());
attrOpen = false;
} else if ("key".equals(qName)) {
currentRelAttr.setKey(buffer.toString());
keyOpen = false;
} else if ("lang".equals(qName)) {
currentRelAttr.setLang(buffer.toString());
langOpen = false;
} else if ("name".equals(qName)) {
currentRelAttr.setName(buffer.toString());
nameOpen = false;
} else if ("description".equals(qName)) {
currentRelAttr.setDescription(buffer.toString());
descOpen = false;
} else {
System.err.printf(
"Warning: Encountered unexpected element %s. Ignoring.\n",
qName);
}
}
@Override
public void characters(char[] ch,
int start,
int length) throws SAXException {
System.out.printf("Parsing characters %d to %d...\n", start, (start + length));
for (int i = start; i < (start + length); i++) {
char character;
character = ch[i];
buffer.append(character);
}
}
@Override
public void warning(SAXParseException ex) {
System.err.println(saxMsg(ex));
}
@Override
public void error(SAXParseException ex) {
System.err.println(saxMsg(ex));
}
@Override
public void fatalError(SAXParseException ex) {
System.err.println(saxMsg(ex));
}
protected List<RelAttrBean> getRelAttrs() {
return relAttrs;
}
private String saxMsg(SAXParseException ex) {
String msg;
msg = String.format(
"SAX parser reported an error at line %d, column %d: %s",
ex.getLineNumber(),
ex.getColumnNumber(),
ex.getMessage());
return msg;
}
}

View File

@ -1,25 +0,0 @@
<?xml version="1.0"?>
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name="ccm-cms-types-genericorganization"
prettyName="Red Hat 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:requires name="ccm-cms-types-organizationalunit" 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>
Generic organization type for OpenCCM
</ccm:description>
</ccm:application>

View File

@ -1,35 +0,0 @@
//
// Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//
model com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.DomainObject;
object type GenericOrganization extends ContentPage {
String[0..1] organizationname = ct_genericorganizations.organizationname VARCHAR(512);
String[0..1] organizationnameaddendum = ct_genericorganizations.organizationnameaddendum VARCHAR(512);
String[0..1] organizationdescription = ct_genericorganizations.organizationdescription VARCHAR(2000);
OrganizationRole[0..n] organizationroles = join ct_genericorganizations.organization_id to ct_organizationroles.owner_id;
Orga2OrgaUnit[0..n] subunits = join ct_genericorganizations.organization_id to ct_orga2orgaunits.owner_id;
reference key (ct_genericorganizations.organization_id);
}

View File

@ -1,69 +0,0 @@
//
// 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.owner_id 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;
}
}

View File

@ -1,76 +0,0 @@
//
// Copyright (C) 2009 Center for Social Policy Reseearch, 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;
import com.arsdigita.cms.contenttypes.GenericPerson;
object type OrganizationRole extends ACSObject {
String[1..1] roleName = ct_organizationroles.rolename VARCHAR(150);
GenericPerson[0..1] targetItem = join ct_organizationroles.target_item_id to cms_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 ct_organizationroles r where r.target_item_id = :itemID
} map {
id = r.role_id;
}
}
data operation swapOrganizationRoleWithNextInGroup {
do {
update ct_organizationroles
set role_order = CASE WHEN (role_order = :roleOrder) THEN
(:nextRoleOrder)
ELSE
(:roleOrder)
END
where (role_order = :roleOrder or role_order = :nextRoleOrder)
and owner_id = :ownerID
}
}
// and 2 = (select count(*) from ct_organizationroles r where r.role_id=r.role_id
// and (role_order = :roleOrder or role_order = :nextRoleOrder)
// and owner_id = :ownerID)
query allRoleOrderForOrganization {
Integer roleOrder;
do {
select r.role_order from ct_organizationroles r where r.owner_id = :ownerID
}
map {
roleOrder = r.role_order;
}
}

View File

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

View File

@ -1,45 +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="GenericOrganization"
description="A generic organization type"
objectType="com.arsdigita.cms.contenttypes.GenericOrganization"
classname="com.arsdigita.cms.contenttypes.GenericOrganization">
<ctd:authoring-kit
createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
<ctd:authoring-step
labelKey="genericorganization.authoring.basic_properties.title"
labelBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
descriptionKey="genericorganization.authoring.basic_properties.description"
descriptionBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
component="com.arsdigita.cms.contenttypes.ui.GenericOrganizationPropertiesStep"
ordering="1"/>
<ctd:authoring-step
labelKey="genericorganization.authoring.roles.title"
labelBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
descriptionKey="genericorganization.authoring.roles.description"
descriptionBundle="com.arsdigita.cms.contenttypes.GenericOrganizationResources"
component="com.arsdigita.cms.contenttypes.ui.OrganizationRolePropertiesStep"
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:authoring-kit>
</ctd:content-type>
</ctd:content-types>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.GenericOrganization"
extends="com.arsdigita.cms.ContentPage">
<xrd:associations rule="include">
<xrd:property name="/object/organizationroles"/>
<xrd:property name="/object/organizationroles/targetItem"/>
<xrd:property name="/object/subunits"/>
<xrd:property name="/object/subunits/targetItem"/>
<xrd:property name="/object/subunits/targetItem/memberships"/>
<xrd:property name="/object/subunits/targetItem/memberships/targetItem"/>
</xrd:associations>
</xrd:adapter>
</xrd:context>
</xrd:adapters>

View File

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

View File

@ -1,17 +0,0 @@
<load>
<requires>
<table name="inits" />
<table name="acs_objects" />
<table name="cms_items" />
<table name="ct_organizationalunits" />
<initializer class="com.arsdigita.cms.Initializer" />
</requires>
<provides>
<table name="ct_genericorganizations" />
<initializer class="com.arsdigita.cms.contenttypes.GenericOrganizationInitializer"/>
</provides>
<scripts>
<schema directory="ccm-cms-types-genericorganization" />
<data class="com.arsdigita.cms.contenttypes.GenericOrganizationLoader" />
</scripts>
</load>

View File

@ -1,187 +0,0 @@
/*
* Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
/**
* This represents an organization. It is designed to be suitable
* for most organizations. Currently, it offers the following properties:
* - name of the organization
* - an addendum for the name
* - a short description of the organization.
*
* It is also possible to add roles to the organization, e.g. CEO, mayor or others.
* The following features are planned to implement in one of the next commits:
* - Adding OrganizationUnits
*
* The current version of this contenttype is modeled on base of the MultipartArticle
* contenttype.
*
* @author Jens Pelzetter
*/
public class GenericOrganization extends ContentPage {
/**
* The name of the organization (name can't be used as shorter name here
* because name is already used in one of parent classes, and is used for
* internal purposes also.
*/
public static final String ORGANIZATIONNAME = "organizationname";
/**
* Addendum for the name of the organization.
*/
public static final String ORGANIZATIONNAMEADDENDUM = "organizationnameaddendum";
/**
* A short description of the organization.
*/
public static final String ORGANIZATIONDESCRIPTION = "organizationdescription";
/**
* Roles associated with the organization.
*/
public static final String ROLES = "roles";
/**
* Type of this class (used for internal purposed).
*/
public static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericOrganization";
//private static final GenericOrganizationConfig s_config = new GenericOrganizationConfig();
private static final Logger s_log = Logger.getLogger(GenericOrganization.class);
/**
* Called when the class is loaded by the Java class loader.
*/
/*static {
s_config.load();
}*/
/**
* Returns a possibly existing configuration object for the class.
*
* @return config object
*/
/*public static final GenericOrganizationConfig getConfig() {
return s_config;
}*/
/**
* Default constructor. This creates a new (empty) organization
*/
public GenericOrganization() {
this(BASE_DATA_OBJECT_TYPE);
}
/**
* Trys to find an organization in the database by its id.
*
* @param id ID of the object to (re-)create
* @throws DataObjectNotFoundException if no object with the given id is found in the database.
*/
public GenericOrganization(BigDecimal id) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
/**
* Trys to find an organization in the database by its OID.
*
* @param id ID of the object to (re-)create
* @throws DataObjectNotFoundException if no object with the given OID is found in the database.
*/
public GenericOrganization(OID id) throws DataObjectNotFoundException {
super(id);
}
/**
* Create an new GenericOrganization object from a DataObject
*
* @param obj The data object
*/
public GenericOrganization(DataObject obj) {
super(obj);
}
/**
* Not sure for what this constructor is.
*
* @param type The type of the object to create (?)
*/
public GenericOrganization(String type) {
super(type);
}
/* accessors *************************************************/
/**
* Gets the name of the organization.
*
* @return The name of the organization.
*/
public String getOrganizationName() {
return (String) get(ORGANIZATIONNAME);
}
/**
* Sets the name of the organization.
*
* @param name The (new) name of the organization.
*/
public void setOrganizationName(String name) {
set(ORGANIZATIONNAME, name);
}
/**
*
* @return Addendum for the name of the organization.
*/
public String getOrganizationNameAddendum() {
return (String) get(ORGANIZATIONNAMEADDENDUM);
}
/**
* Sets the the addenum property of the organization.
*
* @param addendum The new value for the addendum property.
*/
public void setOrganizationNameAddendum(String addendum) {
set(ORGANIZATIONNAMEADDENDUM, addendum);
}
/**
*
* @return Description of the organization, if any.
*/
public String getOrganizationDescription() {
return (String) get(ORGANIZATIONDESCRIPTION);
}
/**
* Sets the description of the organization.
*
* @param description The (new) description.
*/
public void setOrganizationDescription(String description) {
set(ORGANIZATIONDESCRIPTION, description);
}
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.runtime.AbstractConfig;
/**
* Configuration for GenericOrganization. Not used yet.
*
* @author Jens Pelzetter
*/
public class GenericOrganizationConfig extends AbstractConfig {
}

View File

@ -1,29 +0,0 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.globalization.GlobalizedMessage;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class GenericOrganizationGlobalizationUtil {
final public static String BUNDLE_NAME =
"com.arsdigita.cms.contenttypes.GenericOrganizationResourceBundle";
/**
* This returns a globalized message using the type specific bundle,
* BUNDLE_NAME
*/
public static GlobalizedMessage globalize(String key) {
return new GlobalizedMessage(key, BUNDLE_NAME);
}
/**
* This returns a globalized message using the type specific bundle,
* BUNDLE_NAME
*/
public static GlobalizedMessage globalize(String key, Object[] args) {
return new GlobalizedMessage(key, BUNDLE_NAME, args);
}
}

View File

@ -1,82 +0,0 @@
/*
* Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes;
import org.apache.log4j.Logger;
import com.arsdigita.runtime.LegacyInitEvent;
/**
* Initializer of the GenericOrganization content type.
*
* @author Jens Pelzetter
*/
public class GenericOrganizationInitializer extends ContentTypeInitializer {
/*public final static String versionId =
"$Id: GenericOrganizationInitializer.java 1 2009-04-30 09:32:55Z jensp $" +
"$Author: jensp $" +
"$DateTime: 2009/04/30 11:33:39 $";*/
private static final Logger s_log = Logger.getLogger(GenericOrganizationInitializer.class);
/**
* Constructor. calls only the constructor of the parent class with name of
* the pdl.mf file of the content type an the BASIC_DATA_OBJECT_TYPE.
*/
public GenericOrganizationInitializer() {
super("ccm-cms-types-genericorganization.pdl.mf",
GenericOrganization.BASE_DATA_OBJECT_TYPE);
}
/**
*
* @return path of the traversal-adapter XML file.
*/
@Override
public String getTraversalXML() {
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/GenericOrganization.xml";
}
/**
*
* @return path of the XSL stylesheet file. The stylesheet is very generic, because this
* contenttype will be used with the new mandalay theme only.
*/
@Override
public String[] getStylesheets() {
return new String[] { "/static/content-types/com/arsdigita/cms/contenttypes/GenericOrganization.xsl" };
}
/**
* Calls the init method of the parent class.
*
* @param evt The init event. LegacyInitEvent is marked deprecated. What should be used insted?
*/
@Override
public void init(LegacyInitEvent evt) {
super.init(evt);
/* MetadataProviderRegistry.registerAdapter(OrganizationRole.BASE_DATA_OBJECT_TYPE,
new OrganizationRoleMetadataProvider());*/
/*URLService.registerFinder(OrganizationRole.BASE_DATA_OBJECT_TYPE,
new OrganizationRoleURLFinder());
ContentSection.registerExtraXMLGenerator(GenericOrganization.class.getName(),
new OrganizationRolesPanel());*/
}
}

View File

@ -1,76 +0,0 @@
/*
* Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes;
import org.apache.log4j.Logger;
/**
* Loader for the GenericOrganization content type.
*
* @author Jens Pelzetter
*/
public class GenericOrganizationLoader extends AbstractContentTypeLoader {
private static final Logger s_log = Logger.getLogger(GenericOrganizationLoader.class);
private static final String[] TYPES = {
"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/GenericOrganization.xml"
};
//private ResourceParameter m_template;
/**
* Returns the value of the type string.
*
* @return The type string.
*/
public String[] getTypes() {
return TYPES;
}
/**
* Constructor.
*/
//public GenericOrganizationLoader() {
// super();
/*m_template = new ResourceParameter("com.arsdigita.cms.contenttypes.genericorganization.template",
Parameter.REQUIRED,
"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/genericorganization-item.jsp");
register(m_template);*/
//}
/**
*
* @param section
* @param type
* @param ld
* @param wf
*/
/*@Override
protected void prepareSection(final ContentSection section,
final ContentType type,
final LifecycleDefinition ld,
final WorkflowTemplate wf) {
super.prepareSection(section, type, ld, wf);
setDefaultTemplate("GenericOrganization-genericorganization-item",
"genericorganization-item",
(InputStream) get(m_template),
section,
type,
ld,
wf);
}*/
}

View File

@ -1,22 +0,0 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.CMSGlobalized;
import com.arsdigita.globalization.ChainedResourceBundle;
import java.util.PropertyResourceBundle;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class GenericOrganizationResourceBundle extends ChainedResourceBundle implements CMSGlobalized {
public final static String GENERIC_ORGANIZATION_BUNDLE_NAME =
"com.arsdigita.cms.contenttypes.GenericOrganizationResources";
public GenericOrganizationResourceBundle() {
super();
addBundle((PropertyResourceBundle)getBundle(GENERIC_ORGANIZATION_BUNDLE_NAME));
addBundle((PropertyResourceBundle)getBundle(BUNDLE_NAME));
}
}

View File

@ -1,15 +0,0 @@
cms.contenttypes.ui.genericorganization.delete=Delete
cms.contenttypes.ui.genericorganization.description=Description
cms.contenttypes.ui.genericorganization.edit=Edit
cms.contenttypes.ui.genericorganization.noorganizationalunitassociated=There are no organizational units for this organization.
cms.contenttypes.ui.genericorganization.noRolesForThisOrga=There are no roles for this organization.
cms.contenttypes.ui.genericorganization.organizationalunit=Organizational Unit
cms.contenttypes.ui.genericorganization.organizationname=Name of Organization
cms.contenttypes.ui.genericorganization.organizationnameaddendum=Addendum
cms.contenttypes.ui.genericorganization.person=Person
cms.contenttypes.ui.genericorganization.role=Role
cms.contenttypes.ui.genericorganization.rolename=Name of role
genericorganization.authoring.basic_properties.title=Basic properties
genericorganization.authoring.roles.title=Roles
genericorganization.authoring.units.title=Organizational Units

View File

@ -1,15 +0,0 @@
cms.contenttypes.ui.genericorganization.delete=L\u00F6schen
cms.contenttypes.ui.genericorganization.description=Beschreibung
cms.contenttypes.ui.genericorganization.edit=Bearbeiten
cms.contenttypes.ui.genericorganization.noorganizationalunitassociated=F\u00FCr diese Organisation sind keine Organisationseiheiten definiert.
cms.contenttypes.ui.genericorganization.noRolesForThisOrga=F\u00FCr diese Organisation sind keine Rollen definiert.
cms.contenttypes.ui.genericorganization.organizationalunit=Organisationseinheit
cms.contenttypes.ui.genericorganization.organizationname=Name der Organisation
cms.contenttypes.ui.genericorganization.organizationnameaddendum=Namenszusatz
cms.contenttypes.ui.genericorganization.person=Person
cms.contenttypes.ui.genericorganization.role=Rolle
cms.contenttypes.ui.genericorganization.rolename=Bezeichnung der Rolle
genericorganization.authoring.basic_properties.title=Basiseigenschaften
genericorganization.authoring.roles.title=Rollen
genericorganization.authoring.units.title=Organisationseinheiten

View File

@ -1,363 +0,0 @@
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;
/**
* This class represents all relationship between an organization and an
* organizational unit.
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class Orga2OrgaUnit extends ACSObject {
private final static Logger logger = Logger.getLogger(Orga2OrgaUnit.class);
/**
* Id for the targetItem property.
*/
public final static String TARGETITEM = "targetItem";
/**
* Id for the unitOwner property.
*/
public final static String UNITOWNER = "unitOwner";
/**
* Id for the unitOrder property.
*/
public final static String UNITORDER = "unitOrder";
/**
* Object type
*/
public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Orga2OrgaUnit";
/**
* Constrcutor without parameters for creating an new Orga2OrgaUnit relation.
*/
public Orga2OrgaUnit() {
super(BASE_DATA_OBJECT_TYPE);
}
/**
* Tries to find the Orga2OrgaUnit relation with the given {@code id} in the database.
*
* @param id Of an existing organization to organizational unit relation.
*/
public Orga2OrgaUnit(BigDecimal id) {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
/**
* Tries to find the Orga2OrgaUnit relation with the {@code id} in the database.
*
* @param id OID Of an existing organization to organizational unit relation.
*/
public Orga2OrgaUnit(OID id) {
super(id);
}
/**
* Creates an new instance of this class from {@code obj}
*
* @param obj
*/
public Orga2OrgaUnit(DataObject obj) {
super(obj);
}
/**
*
* @param type Type of the object to create.
*/
public Orga2OrgaUnit(String type) {
super(type);
}
/**
*
* @return The GenericOrganization which is part of the relation.
*/
public GenericOrganization getUnitOwner() {
DataObject obj = (DataObject) get(UNITOWNER);
if (obj == null) {
return null;
} else {
return (GenericOrganization) DomainObjectFactory.newInstance(obj);
}
}
/**
* Sets the owing organization.
*
* @param orga The owning organization.
*/
public void setUnitOwner(GenericOrganization orga) {
Assert.exists(orga, GenericOrganization.class);
logger.debug(String.format("Setting unit owner to %s", orga.getOrganizationName()));
setAssociation(UNITOWNER, orga);
}
/**
*
* @return The OrganizationalUnit which is part of the relation.
*/
public OrganizationalUnit getTargetItem() {
DataObject object = (DataObject) get(TARGETITEM);
return (OrganizationalUnit) DomainObjectFactory.newInstance(object);
}
/**
* Sets the OrganizationalUnit
*
* @param unit
*/
public void setTargetItem(OrganizationalUnit unit) {
setAssociation(TARGETITEM, unit);
}
/**
*
* @return The order of the the relations.
*/
public Integer getOrder() {
return (Integer) get(UNITORDER);
}
/**
* Sets the order.
*
* @param order
*/
public void setOrder(Integer order) {
Assert.exists(order);
set(UNITORDER, order);
}
/**
*
* @param s Current PageState.
* @return The URI of the targetItem.
*/
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();
}
/**
*
* @param unit
* @return All Orga2OrgaUnit relations for a specific OrganizationalUnit
*/
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;
}
/**
*
* @param orga
* @return All units associated with an GenericOrganization.
*/
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;
}
/**
* Swaps an Orga2OrgaUnit relation with the next one in the list.
*/
public void swapWithNext() {
swapWithNext("com.arsdigita.cms.contenttypes.allUnitsOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrga2OrgaUnitWithNextInGroup");
}
/**
* Swaps an Orga2OrgaUnit relation with the previous one in the list.
*/
public void swapWithPrevious() {
swapWithPrevious("com.arsdigita.cms.contenttypes.allUnitsOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrga2OrgaUnitWithNextInGroup");
}
/**
* Swaps an Orga2OrgaUnit relation with the next one in the list.
*
* @param queryName Query to use.
* @param operationName Operation to use.
*/
public void swapWithNext(String queryName, String operationName) {
swapKeys(true, queryName, operationName);
}
/**
* Swaps an Orga2OrgaUnit relation with the previous one in the list.
*
* @param queryName Query to use.
* @param operationName Operation to use.
*/
public void swapWithPrevious(String queryName, String operationName) {
swapKeys(false, queryName, operationName);
}
/**
*
* @param queryName Name of the SwapQuery.
* @return The query named with @queryName
*/
protected DataQuery getSwapQuery(String queryName) {
DataQuery query = SessionManager.getSession().retrieveQuery(queryName);
query.setParameter("ownerID", getUnitOwner().getID());
return query;
}
/**
*
* @param operationName Name of the operation.
* @return Returns the DataOperation for swapping.
*/
protected DataOperation getSwapOperation(String operationName) {
DataOperation operation = SessionManager.getSession().retrieveDataOperation(operationName);
operation.setParameter("ownerID", getUnitOwner().getID());
return operation;
}
/**
* The method which does the real swapping.
*
* @param swapNext If true, swap with next, if false, swap with previous
* @param queryName Name of the DataQuery to use.
* @param operationName Name of the DataOperation to use.
*/
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();
}
/**
* Don't kwow what this is for, but it is needed for the swapping
*/
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();
}
}
/**
*
* @return Maximum order index.
*/
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;
}
/**
* Invoked before saving to the database.
*/
@Override
public void beforeSave() {
super.beforeSave();
if (getOrder() == null) {
setOrder(maxOrder() + 1);
}
}
}

View File

@ -1,397 +0,0 @@
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;
/**
* This class represents an role in a organization. Examples for roles
* are CEO, chairmen, mayor, speaker etc.
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class OrganizationRole extends ACSObject {
private static final Logger logger = Logger.getLogger(OrganizationRole.class);
/**
* PDL identifier of the name property of the role
*/
public static final String ROLENAME = "roleName";
/**
* PDL identifier for the targetItem - the person assoicated with the role.
*/
public static final String TARGETITEM = "targetItem";
/**
* PDL for identifier for the organization associated with this role.
*/
public static final String ROLEOWNER = "roleOwner";
/**
* PDL id for the property for ordering the roles of an organization.
*/
public static final String ORDER = "roleOrder";
/**
* Type of this object.
*/
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationRole";
/**
* Empty construtor creating a new role
*/
public OrganizationRole() {
this(BASE_DATA_OBJECT_TYPE);
}
/**
* Tries to get the role with @id from the database.
*
* @param id
* @throws com.arsdigita.domain.DataObjectNotFoundException
*/
public OrganizationRole(BigDecimal id) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
/**
* Tries to get the role with @id from the database.
*
* @param id
* @throws com.arsdigita.domain.DataObjectNotFoundException
*/
public OrganizationRole(OID id) throws DataObjectNotFoundException {
super(id);
}
/**
* Tries to find obj in the database.
*
* @param obj
*/
public OrganizationRole(DataObject obj) {
super(obj);
}
/**
* Creates a new role.
*
* @param type
*/
public OrganizationRole(String type) {
super(type);
}
/**
*
* @return The name of the role.
*/
public String getRolename() {
return (String) get(ROLENAME);
}
/**
* Sets the name of the role
*
* @param rolename
*/
public void setRolename(String rolename) {
set(ROLENAME, rolename);
}
/**
*
* @return The owning organization.
*/
public GenericOrganization getRoleOwner() {
DataObject obj = (DataObject) get(ROLEOWNER);
if (obj == null) {
return null;
} else {
return (GenericOrganization) DomainObjectFactory.newInstance(obj);
}
}
/**
* Sets the owing organization.
*
* @param orga
*/
public void setRoleOwner(GenericOrganization orga) {
Assert.exists(orga, GenericOrganization.class);
logger.debug(String.format("Setting role owner to %s", orga.getOrganizationName()));
setAssociation(ROLEOWNER, orga);
}
/**
*
* @return The person associated with the role.
*/
public com.arsdigita.cms.contenttypes.GenericPerson getTargetItem() {
DataObject object = (DataObject) get(TARGETITEM);
return (com.arsdigita.cms.contenttypes.GenericPerson) DomainObjectFactory.newInstance(object);
}
/**
* Sets the person associated with the role
*
* @param item
*/
public void setTargetItem(com.arsdigita.cms.contenttypes.GenericPerson item) {
setAssociation(TARGETITEM, item);
}
/**
*
* @return The order of the role.
*/
public Integer getOrder() {
return (Integer) get(ORDER);
}
/**
* Sets the order of the role
*
* @param order
*/
public void setOrder(Integer order) {
Assert.exists(order);
set(ORDER, order);
}
/*
*
* @param s Current PageState
* @return The URI of the target item.
*/
public String getURI(PageState s) {
com.arsdigita.cms.contenttypes.GenericPerson 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();
}
/**
*
* @param person
* @return All roles a person is associated with.
*/
public static DataCollection getReferingRoles(com.arsdigita.cms.contenttypes.GenericPerson 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;
}
/**
*
* @param orga
* @return all roles an organization is associated with.
*/
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;
}
/**
* Swaps an role with the next in the order.
*
* @throws java.lang.UnsupportedOperationException
*/
public void swapWithNext() throws UnsupportedOperationException {
swapWithNext("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup");
}
/**
* Swaps a role with the previous in the order.
*
* @throws java.lang.UnsupportedOperationException
*/
public void swapWithPrevious() throws UnsupportedOperationException {
swapWithPrevious("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup");
}
/**
* Swaps an role with the next in the order.
*
* @param queryName
* @param operationName
*/
public void swapWithNext(String queryName, String operationName) {
swapKeys(true, queryName, operationName);
}
/**
* Swaps a role with the previous in the order.
*
* @param queryName
* @param operationName
*/
public void swapWithPrevious(String queryName, String operationName) {
swapKeys(false, queryName, operationName);
}
/**
* Returns the query for swaping roles definied in the PDL.
*
* @param queryName
* @return
*/
protected DataQuery getSwapQuery(String queryName) {
DataQuery query = SessionManager.getSession().retrieveQuery(queryName);
query.setParameter("ownerID", getRoleOwner().getID());
return query;
}
/**
* Gets the PDL operation for swaping.
*
* @param operationName
* @return
*/
protected DataOperation getSwapOperation(String operationName) {
DataOperation operation = SessionManager.getSession().retrieveDataOperation(operationName);
operation.setParameter("ownerID", getRoleOwner().getID());
return operation;
}
/**
* Swaps the keys of two roles.
*
* @param swapNext
* @param queryName
* @param operationName
*/
protected void swapKeys(boolean swapNext, String queryName, String operationName) {
logger.info("this is swapKeys()...");
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);
logger.info(String.format("currentKey = %s", currentKey.intValue()));
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();
logger.info(String.format("key = %d", key));
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();
}
logger.info(String.format("otherKey = %s", otherKey));
DataOperation operation = getSwapOperation(operationName);
//operation.setParameter("roleID", this.get(ID));
operation.setParameter("roleOrder", new Integer(key));
operation.setParameter("nextRoleOrder", new Integer(otherKey));
logger.info(String.format("swapoperation = %s", operation.toString()));
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();
}
}
/**
*
* @return
*/
public int maxOrder() {
GenericOrganization roleOwner = getRoleOwner();
if (roleOwner == null) {
return 0;
}
int returnOrder = 0;
DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization");
query.setParameter("ownerID", getRoleOwner().getID());
query.addOrder("roleOrder DESC");
if (query.next()) {
Integer roleOrder = ((Integer) query.get("roleOrder"));
query.close();
if (roleOrder != null) {
returnOrder = roleOrder.intValue();
}
}
return returnOrder;
}
/**
* Called before the object is saved to the database.
*/
@Override
public void beforeSave() {
super.beforeSave();
if (getOrder() == null) {
setOrder(maxOrder() + 1);
}
}
}

View File

@ -1,86 +0,0 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganization;
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 com.arsdigita.cms.contenttypes.GenericOrganizationGlobalizationUtil;
import com.arsdigita.bebop.Component;
import com.arsdigita.cms.util.GlobalizationUtil;
import java.text.DateFormat;
import org.apache.log4j.Logger;
/**
* AuthoringStep for the basic properties of an organization (name, name addendum and
* a short description).
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class GenericOrganizationPropertiesStep extends SimpleEditStep {
private static final Logger logger = Logger.getLogger(GenericOrganizationPropertiesStep.class);
/**
* Name of the this edit sheet (Don't know if this this really needed.
* It has the same value in almost all PropertiesStep classes)
*/
public static final String EDIT_SHEET_NAME = "edit";
/**
* Constructor for the PropertiesStep.
*
* @param itemModel
* @param parent
*/
public GenericOrganizationPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
super(itemModel, parent);
setDefaultEditKey(EDIT_SHEET_NAME);
BasicPageForm editSheet;
editSheet = new GenericOrganizationPropertyForm(itemModel, this);
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getGenericOrganizationPropertySheet(itemModel));
}
/**
* Creates and returns the sheet for editing the basic properties
* of an organization. (@see GenericOrganizationPropertyForm).
*
* @param itemModel
* @return The sheet for editing the properties of the organization.
*/
public static Component getGenericOrganizationPropertySheet(ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.organizationname"), GenericOrganization.ORGANIZATIONNAME);
sheet.add(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.organizationnameaddendum"), GenericOrganization.ORGANIZATIONNAMEADDENDUM);
sheet.add(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.description"), GenericOrganization.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;
}
}

View File

@ -1,132 +0,0 @@
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.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 com.arsdigita.cms.contenttypes.GenericOrganizationGlobalizationUtil;
import org.apache.log4j.Logger;
/**
* Form for editing the basic properties of an organization.
*
* @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 ORGANIZATIONDESCRIPTION = GenericOrganization.ORGANIZATIONDESCRIPTION;
/**
* ID of the form
*/
public static final String ID = "GenericOrganization_edit";
/**
* Constrctor taking an ItemSelectionModel
*
* @param itemModel
*/
public GenericOrganizationPropertyForm(ItemSelectionModel itemModel) {
this(itemModel, null);
}
/**
* Constrctor taking an ItemSelectionModel and an instance of GenericOrganizationPropertiesStep.
*
* @param itemModel
* @param step
*/
public GenericOrganizationPropertyForm(ItemSelectionModel itemModel, GenericOrganizationPropertiesStep step) {
super(ID, itemModel);
m_step = step;
addSubmissionListener(this);
}
@Override
public void addWidgets() {
super.addWidgets();
add(new Label(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.organizationname")));
ParameterModel organizationNameParam = new StringParameter(ORGANIZATIONAME);
TextField organizationName = new TextField(organizationNameParam);
organizationName.addValidationListener(new NotNullValidationListener());
add(organizationName);
add(new Label(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.organizationnameaddendum")));
TextField organizationNameAddendum = new TextField(ORGANIZATIONNAMEADDENDUM);
add(organizationNameAddendum);
add(new Label(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganzation.description")));
TextArea description = new TextArea(ORGANIZATIONDESCRIPTION);
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(ORGANIZATIONDESCRIPTION, 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(ORGANIZATIONDESCRIPTION));
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());
}
}
}

View File

@ -1,102 +0,0 @@
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;
/**
* PropertiesStep for adding organizational units to an organization.
*
* @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);
/**
* Creates a new instance of the PropertiesStep.
*
* @param itemModel ItemSelectionModel to use
* @param parent Parent component.
*/
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);
}
/**
* Sets the custom SelectionModel to use.
*/
protected void setOrga2OrgaUnitSelectionModel() {
setOrga2OrgaUnitSelectionModel(new Orga2OrgaUnitSelectionModel(m_o2ouParam));
}
/**
* Sets the custom SelectionModel to use.
*
* @param model The {@see Orga2OrgaUnitSelectionModel} instance to use.
*/
protected void setOrga2OrgaUnitSelectionModel(Orga2OrgaUnitSelectionModel model) {
this.m_o2ouModel = model;
}
/**
* Gets the {@see Orga2OrgaUnitSelectionModel} used.
* @return The Orga2OrgaUnitSelectionModel used.
*/
protected Orga2OrgaUnitSelectionModel getOrga2OrgaUnitSelectionModel() {
return this.m_o2ouModel;
}
/**
*
* @return
*/
protected BigDecimalParameter getO2OUParam() {
return this.m_o2ouParam;
}
/**
* Returns the displaying component.
*
* @return The displying Component.
*/
public Component getDisplayComponent() {
SimpleContainer container = new SimpleContainer();
container.add(new Orga2OrgaUnitTable(m_itemModel, m_o2ouModel));
return container;
}
/**
* Returns the edit sheet used.
*
* @return The edit sheet used.
*/
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);
}
}

View File

@ -1,220 +0,0 @@
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.GenericOrganizationGlobalizationUtil;
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;
/**
* The form for adding, editing and removing associations between an organization
* and an organizational unit.
*
* @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);
/**
* ID String.
*/
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";
/**
* Creates the new form using the ItemSelectionModel and Orga2OrgaUnitSelectionModel proviveded.
*
* @param itemModel
* @param o2ouModel
*/
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);
}
/**
* Creates the widgets for the form.
*/
protected void addWidgets() {
add(new Label(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.organizationalunit")));
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.OrganizationalUnit"));
add(this.m_itemSearch);
}
/**
* Creates the section with the save and the cancel button.
*/
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);
}
/**
* Returns the SavaCancelSection of the form.
*
* @return The SavaCancelSection of the form.
*/
public SaveCancelSection getSaveCancelSection() {
return this.m_saveCancelSection;
}
/**
* Returns the Orga2OrgaUnitSelectionModel used.
*
* @return The Orga2OrgaUnitSelectionModel used.
*/
protected Orga2OrgaUnitSelectionModel getO2OUSelectionModel() {
return this.m_o2ouModel;
}
/**
* Returns the Organization of the assocication displayed by the form.
*
* @param s
* @return The Organization of the assocication displayed by the form.
*/
protected GenericOrganization getOrganization(PageState s) {
return (GenericOrganization) m_itemModel.getSelectedItem(s);
}
/**
* Creates a new Orga2OrgaUnit assoication form the values of the form.
*
* @param s
* @return
*/
protected Orga2OrgaUnit createOrga2OrgaUnit(PageState s) {
GenericOrganization orga = this.getOrganization(s);
Assert.exists(orga);
Orga2OrgaUnit o2ou = new Orga2OrgaUnit();
o2ou.setUnitOwner(orga);
return o2ou;
}
/**
* Sets the properties of an Orga2OrgaUnit instance.
*
* @param o2ou
* @param e
*/
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");
}
}
}

View File

@ -1,43 +0,0 @@
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;
/**
* The custom SelectionModel used by the {@see Orga2OrgaUnitPropertiesStep} and
* {@see Orga2OrgaUnitPropertyForm}.
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class Orga2OrgaUnitSelectionModel extends ACSObjectSelectionModel {
/**
* Creates an new instance.
*
* @param param The parameter to use.
*/
public Orga2OrgaUnitSelectionModel(BigDecimalParameter param) {
super(Orga2OrgaUnit.class.getName(), Orga2OrgaUnit.BASE_DATA_OBJECT_TYPE, param);
}
/**
*
* @param itemClass
* @param objectType
* @param param
*/
public Orga2OrgaUnitSelectionModel(String itemClass, String objectType, BigDecimalParameter param) {
super(itemClass, objectType, param);
}
/**
*
* @param s
* @return
*/
public Orga2OrgaUnit getSelectedO2OU(PageState s) {
return (Orga2OrgaUnit) getSelectedObject(s);
}
}

View File

@ -1,221 +0,0 @@
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.GenericOrganizationGlobalizationUtil;
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;
/**
* The table used by {@see Orga2OrgaUnitPropertyForm} for displying the existing
* associations between an organization and an organizational unit.
*
* @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;
/**
* ID String for the "edit" event.
*/
protected final static String EDIT_EVENT = "Edit";
/**
* ID for the "delete" event.
*/
protected final static String DELETE_EVENT = "Delete";
/**
* ID fpr the "up" event.
*/
protected final static String UP_EVENT = "up";
/**
* ID for the "down" event.
*/
protected final static String DOWN_EVENT = "down";
/**
* Creates an new table.
*
* @param itemModel
* @param o2ouModel
*/
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(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.noorganizationalunitassociated"));
setEmptyView(empty);
addTableActionListener(new Orga2OrgaUnitTableActionListener());
setRowSelectionModel(m_o2ouModel);
setDefaultCellRenderer(new Orga2OrgaUnitTableRenderer());
setModelBuilder(new Orga2OrgaUnitTableModelBuilder(itemModel));
}
/**
* Adds the columns of the table.
*/
public void addColumns() {
TableColumnModel model = getColumnModel();
int i = 0;
this.m_orgaUnitCol = new TableColumn(i, GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.organizationalunit").localize());
this.m_editCol = new TableColumn(++i, GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.edit").localize());
this.m_delCol = new TableColumn(++i, GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.delete").localize());
this.m_moveUpCol = new TableColumn(++i, "");
this.m_moveDownCol = new TableColumn(++i, "");
model.add(this.m_orgaUnitCol);
model.add(this.m_editCol);
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) {
}
}
}

View File

@ -1,107 +0,0 @@
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;
/**
* ModelBuilder for the TableModel of the {@see Orga2OrgaUnitTable}.
*
* @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;
/**
* Creates an new TableModelBuilder.
*
* @param 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);
}
}
/**
* Gets all organizational units associated with the selected organization.
*
* @param s
* @return All organizational units associated with the selected organization.
*/
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);
}
/**
* The table model for the the {@see Orga2OrgaUnitTable}.
*/
public static class Orga2OrgaUnitTableModel implements TableModel {
Orga2OrgaUnit m_o2ou;
DataCollection m_units;
/**
* Creates a new TableModel
*
* @param units The associations between an organization and some organizational units to display.
*/
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();
}
/**
* Returns the number of associations displayed.
*
* @return The number of associations displayed.
*/
public long size() {
return m_units.size();
}
}
}

View File

@ -1,102 +0,0 @@
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;
/**
* Authoring step for adding roles (e.g. chairmen) to an organization.
*
* @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);
/**
* Constructor for creating an new instance of this authoring step.
*
* @param itemModel
* @param parent
*/
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);
}
/**
* Creates an new instance of OrganizationRoleSelectionModel and calls
* setOrganizationRole(OrganizationRoleSelectionModel model) with the new
* instance.
*/
protected void setOrganizationRoleSelectionModel() {
setOrganizationRoleSelectionModel(new OrganizationRoleSelectionModel(m_roleParam));
}
/**
* Sets the OrganizationRoleSelectionModel.
*
* @param model
*/
protected void setOrganizationRoleSelectionModel(OrganizationRoleSelectionModel model) {
m_roleModel = model;
}
/**
* @return The OrganizationRoleSelectionModel instance of this authoring step.
*/
protected OrganizationRoleSelectionModel getOrganizationRoleSelectionModel() {
return m_roleModel;
}
/**
*
* @return The value of the m_roleParam property.
*/
protected BigDecimalParameter getRoleParam() {
return this.m_roleParam;
}
/**
*
* @return The component displaying the authoring step
*/
public Component getDisplayComponent() {
SimpleContainer container = new SimpleContainer();
container.add(new OrganizationRoleTable(m_itemModel, m_roleModel));
return container;
}
/**
*
* @return The form for editing the roles of the organization
*/
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);
}
}

View File

@ -1,244 +0,0 @@
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.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganization;
import com.arsdigita.cms.contenttypes.GenericOrganizationGlobalizationUtil;
import com.arsdigita.cms.contenttypes.OrganizationRole;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Logger;
/**
* Form for editing a role.
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class OrganizationRolePropertyForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
/**
* Logger for this class.
*/
public final static Logger logger = Logger.getLogger(OrganizationRolePropertyForm.class);
/**
* ID of the form
*/
public final static String ID = "organizationrole_edit";
//public final static String 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";
/**
* Creates an new instance of the form.
*
* @param itemModel
* @param roleModel
*/
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);
}
/**
* Adds the widgets to the form. For choosing the associated person,
* an ItemSearchWidget is used.
*/
protected void addWidgets() {
this.m_rolename = new TextField("rolename");
this.m_rolename.addValidationListener(new NotNullValidationListener());
add(new Label(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.rolename")));
add(this.m_rolename);
add(new Label(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.person")));
/* Create the ItemSearchWidget. The ContentType.findByAssociatedObjecType
* gets the ContentType of com.arsdigita.cms.contenttypes.GenericPerson and passes
* it to the constructor of the ItemSearchWidget. The ItemSearchWidget will only
* display object of type GenericPerson or derivated types.
*/
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.GenericPerson"));
add(this.m_itemSearch);
}
/**
* Adds the Save and Cancel buttons.
*/
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);
}
/**
*
* @return The section with the Save and Cancel buttons.
*/
public SaveCancelSection getSaveCancelSection() {
return this.m_saveCancelSection;
}
/**
*
* @return The RoleSelectionModel of the form.
*/
protected OrganizationRoleSelectionModel getRoleSelectionModel() {
return this.m_roleModel;
}
/*protected GenericPerson getPerson(PageState s) {
return (GenericPerson) m_itemModel.getSelectedObject(s);
}*/
/**
*
* @param s
* @return * The organization which roles are edited.
*/
protected GenericOrganization getOrganization(PageState s) {
return (GenericOrganization) m_itemModel.getSelectedObject(s);
}
/**
* Creates a new OrganizationRole.
*
* @param s
* @return Newly created OrganizationRole.
*/
protected OrganizationRole createOrganizationRole(PageState s) {
//GenericPerson person = this.getPerson(s);
//Assert.exists(person);
GenericOrganization orga = this.getOrganization(s);
Assert.exists(orga);
OrganizationRole role = new OrganizationRole();
role.setRoleOwner(orga);
return role;
}
/**
* Sets the properties of an instance of OrganizationRole.
*
* @param role
* @param e
*/
protected void setOrganizationRoleProperties(OrganizationRole role, FormSectionEvent e) {
PageState state = e.getPageState();
FormData data = e.getFormData();
role.setRolename((String) m_rolename.getValue(state));
role.setTargetItem((com.arsdigita.cms.contenttypes.GenericPerson) 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");
}
}
}

View File

@ -1,43 +0,0 @@
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;
/**
* SelectionModel for OrganizationRole.
*
* @author Jens Pelzetter <jens@jp-digital.de>
*/
public class OrganizationRoleSelectionModel extends ACSObjectSelectionModel {
/**
* Constructor taking a parameter.
*
* @param param
*/
public OrganizationRoleSelectionModel(BigDecimalParameter param) {
super(OrganizationRole.class.getName(), OrganizationRole.BASE_DATA_OBJECT_TYPE, param);
}
/**
* Constructor taking an itemClass, an objectType and a parameter.
*
* @param itemClass
* @param objectType
* @param parameter
*/
public OrganizationRoleSelectionModel(String itemClass, String objectType, BigDecimalParameter parameter) {
super(itemClass, objectType, parameter);
}
/**
*
* @param state
* @return The selected role.
*/
public OrganizationRole getSelectedRole(PageState state) {
return (OrganizationRole) getSelectedObject(state);
}
}

View File

@ -1,233 +0,0 @@
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.GenericOrganizationGlobalizationUtil;
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;
/**
* Table for displaying the existings roles associated with an organization.
*
* @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_personCol;
private TableColumn m_moveUpCol;
private TableColumn m_moveDownCol;
private TableColumn m_editCol;
private TableColumn m_delCol;
private RequestLocal m_size;
private RequestLocal m_editor;
/**
* Identifier for an Edit event.
*/
protected final static String EDIT_EVENT = "Edit";
/**
* ID for an Delete event.
*/
protected final static String DELETE_EVENT = "Delete";
/**
* ID for an Up event.
*/
protected final static String UP_EVENT = "up";
/**
* ID for an down event.
*/
protected final static String DOWN_EVENT = "down";
/**
* Constructor. Creates a new table a sets the column headers.
*
* @param itemModel
* @param roleModel
*/
public OrganizationRoleTable(ItemSelectionModel itemModel, OrganizationRoleSelectionModel roleModel) {
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(GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.noRolesForThisOrga"));
setEmptyView(empty);
addTableActionListener(new OrganizationRoleTableActionListener());
setRowSelectionModel(m_roleModel);
setDefaultCellRenderer(new OrganizationRoleTableRenderer());
setModelBuilder(new OrganizationRoleTableModelBuilder(itemModel));
}
/**
* Called by the constructor to add the columns of the table.
*/
protected void addColumns() {
TableColumnModel model = getColumnModel();
int i = 0;
this.m_roleNameCol = new TableColumn(i, GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.role").localize());
this.m_personCol = new TableColumn(++i, GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.person").localize());
this.m_editCol = new TableColumn(++i, GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.edit").localize());
this.m_delCol = new TableColumn(++i, GenericOrganizationGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganization.delete").localize());
this.m_moveUpCol = new TableColumn(++i, "");
this.m_moveDownCol = new TableColumn(++i, "");
model.add(this.m_roleNameCol);
model.add(this.m_personCol);
model.add(this.m_editCol);
model.add(this.m_delCol);
model.add(this.m_moveUpCol);
model.add(this.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_personCol.getModelIndex()) {
ExternalLink extLink = new ExternalLink(role.getTargetItem().getTitle(), 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 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(ex);
}
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
}
}
}

View File

@ -1,107 +0,0 @@
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.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;
/**
* TableModelBuilder for the OrganizationRoleTable.
*
* @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;
/**
* Constructor to create a new instance. Needs an ItemSelectionModel instance.
*
* @param 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);
}
}
/**
*
* @param s
* @return
*/
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);
}
/**
* TableModel for the OrganizationRoleTable.
*/
public static class OrganizationRoleTableModel implements TableModel {
OrganizationRole m_role;
DataCollection m_roles;
/**
*
* @param 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();
}
/**
*
* @return Number of roles in the table.
*/
public long size() {
return m_roles.size();
}
}
}

View File

@ -1,118 +0,0 @@
<!DOCTYPE stylesheet [
<!ENTITY nbsp "&#160;" ><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
]>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cms="http://www.arsdigita.com/cms/1.0"
version="1.0">
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.GenericOrganization']"
mode="cms:CT_graphics"
name="cms:CT_graphics_com_arsdigita_cms_contenttypes_GenericOrganization">
<h2>
<xsl:value-of select="./organizationname"/>
<span class="organizationnameaddendum">
&nbsp;<xsl:value-of select="./organizationnameaddendum"/>
</span>
</h2>
<p>
<xsl:value-of select="./pageDescription"/>
</p>
<dl>
<xsl:for-each select="organizationroles">
<dt>
<xsl:value-of select="./roleName"/>
</dt>
<dd>
<a>
<xsl:attribute name="href">
<xsl:text>/redirect?oid=</xsl:text>
<xsl:value-of select="./targetItem/@oid"/>
</xsl:attribute>
<xsl:value-of select="./targetItem/titlePre"/>&nbsp;<xsl:value-of select="./targetItem/givenname"/>&nbsp;<xsl:value-of select="./targetItem/surname"/>&nbsp;<xsl:value-of select="./targetItem/titlePost"/>
</a>
</dd>
</xsl:for-each>
</dl>
<ul>
<xsl:for-each select="subunits">
<li>
<a>
<xsl:attribute name="href">
<xsl:text>/redirect?oid=</xsl:text>
<xsl:value-of select="./targetItem/@oid"/>
</xsl:attribute>
<xsl:value-of select="./targetItem/organizationalunitName"/>
</a>
</li>
</xsl:for-each>
</ul>
<ul>
<xsl:for-each select="./subunits/targetItem/memberships/targetItem">
<xsl:sort select="surname" order="ascending" data-type="text" case-order="upper-first" />
<xsl:sort select="givenname" order="ascending" data-type="text" case-order="upper-first" />
<li>
<a>
<xsl:attribute name="href">
<xsl:text>/redirect?oid=</xsl:text>
<xsl:value-of select="./@oid" />
</xsl:attribute>
<xsl:value-of select="./titlePre"/>&nbsp;<xsl:value-of select="./givenname"/>&nbsp;<xsl:value-of select="./surname"/>&nbsp;<xsl:value-of select="./titlePost"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.GenericOrganization']"
mode="cms:CT_text"
name="cms:CT_text_com_arsdigita_cms_contenttypes_GenericOrganization">
<h2>
<xsl:value-of select="./organizationname"/>
<span class="organizationnameaddendum">
&nbsp;<xsl:value-of select="./organizationnameaddendum"/>
</span>
</h2>
<p>
<xsl:value-of select="./pageDescription"/>
</p>
<dl>
<xsl:for-each select="organizationroles">
<dt>
<xsl:value-of select="./roleName"/>
</dt>
<dd>
<a>
<xsl:attribute name="href">
<xsl:text>/redirect?oid=</xsl:text>
<xsl:value-of select="./targetItem/@oid"/>
</xsl:attribute>
<xsl:value-of select="./targetItem/titlePre"/>&nbsp;<xsl:value-of select="./targetItem/givenname"/>&nbsp;<xsl:value-of select="./targetItem/surname"/>&nbsp;<xsl:value-of select="./targetItem/titlePost"/>
</a>
</dd>
</xsl:for-each>
</dl>
<ul>
<xsl:for-each select="subunits">
<li>
<a>
<xsl:attribute name="href">
<xsl:text>/redirect?oid=</xsl:text>
<xsl:value-of select="./targetItem/@oid"/>
</xsl:attribute>
<xsl:value-of select="./targetItem/organizationalunitName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>