diff --git a/ccm-cms-types-genericorganization/pdl/com/arsdigita/content-types/OrganizationRole.pdl b/ccm-cms-types-genericorganization/pdl/com/arsdigita/content-types/OrganizationRole.pdl index 993294a85..de54872d7 100644 --- a/ccm-cms-types-genericorganization/pdl/com/arsdigita/content-types/OrganizationRole.pdl +++ b/ccm-cms-types-genericorganization/pdl/com/arsdigita/content-types/OrganizationRole.pdl @@ -47,20 +47,22 @@ query getRefferingRoles { data operation swapOrganizationRoleWithNextInGroup { do { - update organizationroles + 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 (select owner_id from ct_organizationroles where organizationrole_id=role_id) = :roleID - and 2 = (select count(*) from ct_organizationroles r where r.role_id=r.organizationrole_id - and (role_order = :roleOrder or role_order = :nextRoleOrder) - and owner_id = :ownerID) + 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; diff --git a/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/OrganizationRole.java b/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/OrganizationRole.java index 6fe84978a..f2d77acea 100644 --- a/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/OrganizationRole.java +++ b/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/OrganizationRole.java @@ -234,7 +234,7 @@ public class OrganizationRole extends ACSObject { * @throws java.lang.UnsupportedOperationException */ public void swapWithPrevious() throws UnsupportedOperationException { - swapWithNext("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup"); + swapWithPrevious("com.arsdigita.cms.contenttypes.allRoleOrderForOrganization", "com.arsdigita.cms.contenttypes.swapOrganizationRoleWithNextInGroup"); } /** @@ -289,6 +289,8 @@ public class OrganizationRole extends ACSObject { * @param operationName */ protected void swapKeys(boolean swapNext, String queryName, String operationName) { + logger.info("this is swapKeys()..."); + String methodName = null; if (swapNext) { methodName = "swapWithNext"; @@ -299,6 +301,7 @@ public class OrganizationRole extends ACSObject { 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(); @@ -310,11 +313,11 @@ public class OrganizationRole extends ACSObject { "list"); int key = currentKey.intValue(); + logger.info(String.format("key = %d", key)); DataQuery query = getSwapQuery(queryName); - int otherKey = key; - + int otherKey; // = key; if (swapNext) { otherKey = key + 1; query.addOrder("roleOrder ASC"); @@ -330,9 +333,13 @@ public class OrganizationRole extends ACSObject { 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(); } diff --git a/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/ui/OrganizationRoleTable.java b/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/ui/OrganizationRoleTable.java index d5c8b9982..12084ffca 100644 --- a/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/ui/OrganizationRoleTable.java +++ b/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/ui/OrganizationRoleTable.java @@ -36,6 +36,7 @@ public class OrganizationRoleTable extends Table { 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; @@ -97,17 +98,19 @@ public class OrganizationRoleTable extends Table { protected void addColumns() { TableColumnModel model = getColumnModel(); int i = 0; - m_roleNameCol = new TableColumn(i, "Role"); - m_editCol = new TableColumn(++i, "Edit"); - m_delCol = new TableColumn(++i, "Delete"); - m_moveUpCol = new TableColumn(++i, ""); - m_moveDownCol = new TableColumn(++i, ""); + this.m_roleNameCol = new TableColumn(i, "Role"); + this.m_personCol = new TableColumn(++i, "Person"); + this.m_editCol = new TableColumn(++i, "Edit"); + this.m_delCol = new TableColumn(++i, "Delete"); + this.m_moveUpCol = new TableColumn(++i, ""); + this.m_moveDownCol = new TableColumn(++i, ""); - model.add(m_roleNameCol); - model.add(m_editCol); - model.add(m_delCol); - model.add(m_moveUpCol); - model.add(m_moveDownCol); + 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); } @@ -125,6 +128,9 @@ public class OrganizationRoleTable extends Table { 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) { @@ -142,8 +148,8 @@ public class OrganizationRoleTable extends Table { return new Label(DELETE_EVENT); } } else if (column == m_moveUpCol.getModelIndex()) { - if (Boolean.TRUE.equals(m_editor.get(state)) && !isLast) { - Label downLabel = new Label(DOWN_EVENT); + if (Boolean.TRUE.equals(m_editor.get(state)) && !isFirst) { + Label downLabel = new Label(UP_EVENT); downLabel.setClassAttr("linkSort"); return new ControlLink(downLabel); } else { @@ -191,9 +197,10 @@ public class OrganizationRoleTable extends Table { OrganizationRole role = getOrganizationRole(e); Assert.exists(role); - if (col == m_roleNameCol.getModelIndex()) { + /*if (col == m_roleNameCol.getModelIndex()) { //Nothing to do... - } else if (col == m_editCol.getModelIndex()) { + } 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); diff --git a/ccm-cms-types-organizationalunit/application.xml b/ccm-cms-types-organizationalunit/application.xml new file mode 100644 index 000000000..23226cabb --- /dev/null +++ b/ccm-cms-types-organizationalunit/application.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + Content type for representing organizational units. + + diff --git a/ccm-cms-types-organizationalunit/pdl/com/arsdigita/content-types/OrganizationalUnit.pdl b/ccm-cms-types-organizationalunit/pdl/com/arsdigita/content-types/OrganizationalUnit.pdl new file mode 100644 index 000000000..361f3ec43 --- /dev/null +++ b/ccm-cms-types-organizationalunit/pdl/com/arsdigita/content-types/OrganizationalUnit.pdl @@ -0,0 +1,31 @@ +// +// 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 OrganizationalUnit extends ContentPage { + String[0..1] organizationalunitName = ct_organizationalunits.organizationalunit_name VARCHAR(512); + String[0..1] organizationalunitDescription = ct_organizationalunits.organizationalunit_description VARCHAR(2048); + + reference key (ct_organizationalunits.organizationalunit_id); +} \ No newline at end of file diff --git a/ccm-cms-types-organizationalunit/sql/ccm-cms-types-organizationalunit/postgres-create.sql b/ccm-cms-types-organizationalunit/sql/ccm-cms-types-organizationalunit/postgres-create.sql new file mode 100644 index 000000000..a733590e2 --- /dev/null +++ b/ccm-cms-types-organizationalunit/sql/ccm-cms-types-organizationalunit/postgres-create.sql @@ -0,0 +1,3 @@ +begin; +\i ddl/postgres/create.sql +end; \ No newline at end of file diff --git a/ccm-cms-types-organizationalunit/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xml b/ccm-cms-types-organizationalunit/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xml new file mode 100644 index 000000000..00498128e --- /dev/null +++ b/ccm-cms-types-organizationalunit/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + diff --git a/ccm-cms-types-organizationalunit/src/ccm-cms-types-organizationalunit.config b/ccm-cms-types-organizationalunit/src/ccm-cms-types-organizationalunit.config new file mode 100644 index 000000000..b6865e594 --- /dev/null +++ b/ccm-cms-types-organizationalunit/src/ccm-cms-types-organizationalunit.config @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ccm-cms-types-organizationalunit/src/ccm-cms-types-organizationalunit.load b/ccm-cms-types-organizationalunit/src/ccm-cms-types-organizationalunit.load new file mode 100644 index 000000000..ba5755a63 --- /dev/null +++ b/ccm-cms-types-organizationalunit/src/ccm-cms-types-organizationalunit.load @@ -0,0 +1,18 @@ + + + +
+
+
+
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnit.java b/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnit.java new file mode 100644 index 000000000..cbd534b15 --- /dev/null +++ b/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnit.java @@ -0,0 +1,74 @@ +/* + * 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; + +/** + * + * @author Jens Pelzetter + */ +public class OrganizationalUnit extends ContentPage { + + public final static String ORGANIZATIONALUNIT_NAME = "organizationalunitname"; + public final static String ORGANIZATIONAL_DESCRIPTION = "description"; + + public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.OrganizationalUnit"; + + public OrganizationalUnit() { + super(BASE_DATA_OBJECT_TYPE); + } + + public OrganizationalUnit(BigDecimal id) throws DataObjectNotFoundException { + this(new OID(BASE_DATA_OBJECT_TYPE, id)); + } + + public OrganizationalUnit(OID id) throws DataObjectNotFoundException { + super(id); + } + + public OrganizationalUnit(DataObject obj) { + super(obj); + } + + public OrganizationalUnit(String type) { + super(type); + } + + /* accessors ***************************************************/ + public String getOrganizationalUnitName() { + return (String)get(ORGANIZATIONALUNIT_NAME); + } + + public void setOrganizationalUnitName(String name) { + set(ORGANIZATIONALUNIT_NAME, name); + } + + public String getOrganizationalUnitDescription() { + return (String) get(ORGANIZATIONAL_DESCRIPTION); + } + + public void setOrganizationalUnitDescription(String description) { + set(ORGANIZATIONAL_DESCRIPTION, description); + } +} diff --git a/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnitInitializer.java b/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnitInitializer.java new file mode 100644 index 000000000..50c338d09 --- /dev/null +++ b/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnitInitializer.java @@ -0,0 +1,44 @@ +/* + * 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.LegacyInitEvent; +import org.apache.log4j.Logger; + +/** + * + * @author Jens Pelzetter + */ +public class OrganizationalUnitInitializer extends ContentTypeInitializer { + + private final static Logger logger = Logger.getLogger(OrganizationalUnitInitializer.class); + + public OrganizationalUnitInitializer() { + super("ccm-cms-types-organizationalunit.pdl.mf", OrganizationalUnit.BASE_DATA_OBJECT_TYPE); + } + + public String getStylesheet() { + return "static/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xml"; + } + + @Override + public void init(LegacyInitEvent evt) { + super.init(evt); + } +} diff --git a/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnitLoader.java b/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnitLoader.java new file mode 100644 index 000000000..2dcda83a7 --- /dev/null +++ b/ccm-cms-types-organizationalunit/src/com/arsdigita/cms/contenttypes/OrganizationalUnitLoader.java @@ -0,0 +1,21 @@ +package com.arsdigita.cms.contenttypes; + +import org.apache.log4j.Logger; + +/** + * + * @author Jens Pelzetter + */ +public class OrganizationalUnitLoader extends AbstractContentTypeLoader { + + private final static Logger logger = Logger.getLogger(OrganizationalUnitLoader.class); + private final static String[] TYPES = {"/WEB-INF/content-types/com/arsdigita/cms/contentypes/OrganizationalUnit.xml"}; + + public String[] getTypes() { + return TYPES; + } + + public OrganizationalUnitLoader() { + super(); + } +} diff --git a/ccm-cms-types-organizationalunit/web/static/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xsl b/ccm-cms-types-organizationalunit/web/static/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xsl new file mode 100644 index 000000000..2367238fd --- /dev/null +++ b/ccm-cms-types-organizationalunit/web/static/content-types/com/arsdigita/cms/contenttypes/OrganizationalUnit.xsl @@ -0,0 +1,33 @@ + +]> + + + + + +

+ + +

+ +
+ + + +

+ + +

+ +
+ + +
\ No newline at end of file