Organizationen (speziell Projekte) können jetzt nach den Mitgliedern gefiltert werden (Ticket #1678).
git-svn-id: https://svn.libreccm.org/ccm/trunk@2157 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
c3ade037a9
commit
0dab49e03b
|
|
@ -27,6 +27,8 @@ import com.arsdigita.kernel.ACSObject;
|
||||||
object type GenericOrganizationalUnit extends ContentPage {
|
object type GenericOrganizationalUnit extends ContentPage {
|
||||||
String[0..1] addendum = cms_organizationalunits.addendum VARCHAR(512);
|
String[0..1] addendum = cms_organizationalunits.addendum VARCHAR(512);
|
||||||
|
|
||||||
|
String[0..1] personsStr = cms_organizationalunits.personsstr CLOB;
|
||||||
|
|
||||||
reference key (cms_organizationalunits.organizationalunit_id);
|
reference key (cms_organizationalunits.organizationalunit_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2013 Jens Pelzetter All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- This library is free software; you can redistribute it and/or
|
||||||
|
-- modify it under the terms of the GNU Lesser General Public License
|
||||||
|
-- as published by the Free Software Foundation; either version 2.1 of
|
||||||
|
-- the License, or (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This library is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
-- Lesser General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU Lesser General Public
|
||||||
|
-- License along with this library; if not, write to the Free Software
|
||||||
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
--
|
||||||
|
-- $Id$
|
||||||
|
|
||||||
|
-- adds to personsstr column (used for filtering organization by their members)
|
||||||
|
|
||||||
|
ALTER TABLE cms_organizationalunits ADD COLUMN personsstr TEXT;
|
||||||
|
|
@ -24,5 +24,6 @@
|
||||||
begin;
|
begin;
|
||||||
|
|
||||||
\i ../default/upgrade/6.6.7-6.6.8/rename_workspace_to_contentcenter.sql
|
\i ../default/upgrade/6.6.7-6.6.8/rename_workspace_to_contentcenter.sql
|
||||||
|
\i ../default/upgrade/6.6.7-6.6.8/add_personsstr_column.sql
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
|
@ -64,6 +64,9 @@
|
||||||
</version>
|
</version>
|
||||||
<version from="6.6.7" to="6.6.8">
|
<version from="6.6.7" to="6.6.8">
|
||||||
<!-- Rename com.arsdigita.cms.Workspace to com.arsdigita.cms.ContentCenter -->
|
<!-- Rename com.arsdigita.cms.Workspace to com.arsdigita.cms.ContentCenter -->
|
||||||
|
<!-- Add column to GenericOrganizationalUnit for filtering -->
|
||||||
<script sql="ccm-cms/upgrade/::database::-6.6.7-6.6.8.sql"/>
|
<script sql="ccm-cms/upgrade/::database::-6.6.7-6.6.8.sql"/>
|
||||||
|
<!-- Fill the personsstr column -->
|
||||||
|
<script class="com.arsdigita.cms.upgrade.PersonsStrColumn"/>
|
||||||
</version>
|
</version>
|
||||||
</upgrade>
|
</upgrade>
|
||||||
|
|
|
||||||
|
|
@ -705,5 +705,6 @@ public final class ContentSectionSetup {
|
||||||
m_cats.pop();
|
m_cats.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // END private class CategoryHandler
|
} // END private class CategoryHandler
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ public class GenericOrganizationalUnit extends ContentPage {
|
||||||
public final static String ADDENDUM = "addendum";
|
public final static String ADDENDUM = "addendum";
|
||||||
public final static String CONTACTS = "contacts";
|
public final static String CONTACTS = "contacts";
|
||||||
public final static String PERSONS = "persons";
|
public final static String PERSONS = "persons";
|
||||||
|
protected final static String PERSONS_STR = "personsStr";
|
||||||
public final static String SUPERIOR_ORGAUNITS = "superiorOrgaunits";
|
public final static String SUPERIOR_ORGAUNITS = "superiorOrgaunits";
|
||||||
public final static String SUBORDINATE_ORGAUNITS = "subordinateOrgaunits";
|
public final static String SUBORDINATE_ORGAUNITS = "subordinateOrgaunits";
|
||||||
public final static String BASE_DATA_OBJECT_TYPE =
|
public final static String BASE_DATA_OBJECT_TYPE =
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.arsdigita.cms.contenttypes;
|
||||||
import com.arsdigita.cms.ContentBundle;
|
import com.arsdigita.cms.ContentBundle;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.CustomCopy;
|
import com.arsdigita.cms.CustomCopy;
|
||||||
|
import com.arsdigita.cms.ItemCollection;
|
||||||
import com.arsdigita.cms.ItemCopier;
|
import com.arsdigita.cms.ItemCopier;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
|
@ -74,18 +75,45 @@ public class GenericOrganizationalUnitBundle extends ContentBundle {
|
||||||
link.set(GenericOrganizationalUnitPersonCollection.PERSON_ROLE, role);
|
link.set(GenericOrganizationalUnitPersonCollection.PERSON_ROLE, role);
|
||||||
link.set(GenericOrganizationalUnitPersonCollection.STATUS, status);
|
link.set(GenericOrganizationalUnitPersonCollection.STATUS, status);
|
||||||
link.save();
|
link.save();
|
||||||
|
|
||||||
|
updatePersonsStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePerson(final GenericPerson person) {
|
public void removePerson(final GenericPerson person) {
|
||||||
Assert.exists(person, GenericPerson.class);
|
Assert.exists(person, GenericPerson.class);
|
||||||
|
|
||||||
remove(PERSONS, person.getContentBundle());
|
remove(PERSONS, person.getContentBundle());
|
||||||
|
|
||||||
|
updatePersonsStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPersons() {
|
public boolean hasPersons() {
|
||||||
return !getPersons().isEmpty();
|
return !getPersons().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updatePersonsStr() {
|
||||||
|
final GenericOrganizationalUnitPersonCollection persons = getPersons();
|
||||||
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
while(persons.next()) {
|
||||||
|
if (builder.length() > 0) {
|
||||||
|
builder.append("; ");
|
||||||
|
}
|
||||||
|
builder.append(persons.getSurname());
|
||||||
|
builder.append(", ");
|
||||||
|
builder.append(persons.getGivenName());
|
||||||
|
}
|
||||||
|
|
||||||
|
final String personsStr = builder.toString();
|
||||||
|
|
||||||
|
final ItemCollection instances = getInstances();
|
||||||
|
|
||||||
|
GenericOrganizationalUnit orgaunit;
|
||||||
|
while(instances.next()) {
|
||||||
|
orgaunit = (GenericOrganizationalUnit) instances.getDomainObject();
|
||||||
|
orgaunit.set(GenericOrganizationalUnit.PERSONS_STR, personsStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public GenericOrganizationalUnitContactCollection getContacts() {
|
public GenericOrganizationalUnitContactCollection getContacts() {
|
||||||
return new GenericOrganizationalUnitContactCollection((DataCollection) get(
|
return new GenericOrganizationalUnitContactCollection((DataCollection) get(
|
||||||
CONTACTS));
|
CONTACTS));
|
||||||
|
|
|
||||||
|
|
@ -18,27 +18,20 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.upgrade;
|
package com.arsdigita.cms.upgrade;
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentSection;
|
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.ContentTypeCollection;
|
import com.arsdigita.cms.ContentTypeCollection;
|
||||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
|
||||||
import com.arsdigita.cms.ContentTypeWorkflowTemplate;
|
|
||||||
import com.arsdigita.cms.contenttypes.XMLContentTypeHandler;
|
import com.arsdigita.cms.contenttypes.XMLContentTypeHandler;
|
||||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.kernel.KernelExcursion;
|
import com.arsdigita.kernel.KernelExcursion;
|
||||||
import org.apache.commons.cli.CommandLine;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.arsdigita.util.cmd.Program;
|
|
||||||
import com.arsdigita.persistence.Session;
|
import com.arsdigita.persistence.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.persistence.TransactionContext;
|
import com.arsdigita.persistence.TransactionContext;
|
||||||
import com.arsdigita.workflow.simple.WorkflowTemplate;
|
import com.arsdigita.util.cmd.Program;
|
||||||
import com.arsdigita.xml.XML;
|
import com.arsdigita.xml.XML;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.arsdigita.cms.upgrade;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ItemCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitBundle;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.kernel.Kernel;
|
||||||
|
import com.arsdigita.kernel.KernelExcursion;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.Session;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.persistence.TransactionContext;
|
||||||
|
import com.arsdigita.util.cmd.Program;
|
||||||
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class PersonsStrColumn extends Program {
|
||||||
|
|
||||||
|
public PersonsStrColumn() {
|
||||||
|
super("PersonsStrColumn", "1.0.0", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void main(final String[] args) {
|
||||||
|
new PersonsStrColumn().run(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doRun(final CommandLine cmdLine) {
|
||||||
|
|
||||||
|
new KernelExcursion() {
|
||||||
|
@Override
|
||||||
|
protected void excurse() {
|
||||||
|
setEffectiveParty(Kernel.getSystemParty());
|
||||||
|
|
||||||
|
final Session session = SessionManager.getSession();
|
||||||
|
final TransactionContext transactionContext = session.getTransactionContext();
|
||||||
|
|
||||||
|
transactionContext.beginTxn();
|
||||||
|
|
||||||
|
final DataCollection orgaUnitBundles = session.retrieve(
|
||||||
|
GenericOrganizationalUnitBundle.BASE_DATA_OBJECT_TYPE);
|
||||||
|
while (orgaUnitBundles.next()) {
|
||||||
|
createPersonsStr(orgaUnitBundles.getDataObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionContext.commitTxn();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}.run();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createPersonsStr(final DataObject dobj) {
|
||||||
|
final GenericOrganizationalUnitBundle orgaunitBundle =
|
||||||
|
(GenericOrganizationalUnitBundle) DomainObjectFactory.newInstance(dobj);
|
||||||
|
final GenericOrganizationalUnitPersonCollection persons = orgaunitBundle.getPersons();
|
||||||
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
while (persons.next()) {
|
||||||
|
if (builder.length() > 0) {
|
||||||
|
builder.append("; ");
|
||||||
|
}
|
||||||
|
builder.append(persons.getSurname());
|
||||||
|
builder.append(", ");
|
||||||
|
builder.append(persons.getGivenName());
|
||||||
|
}
|
||||||
|
|
||||||
|
final String personsStr = builder.toString();
|
||||||
|
|
||||||
|
final ItemCollection instances = orgaunitBundle.getInstances();
|
||||||
|
|
||||||
|
GenericOrganizationalUnit instance;
|
||||||
|
while (instances.next()) {
|
||||||
|
instance = (GenericOrganizationalUnit) instances.getDomainObject();
|
||||||
|
instance.set("personsStr", personsStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue