Assoziation zwischen GenericOrganizationalUnit und GenericContact ist jetzt sprachunabhängig (Ticket 1109)
git-svn-id: https://svn.libreccm.org/ccm/trunk@1488 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
bf08544698
commit
5fb8456648
|
|
@ -37,15 +37,15 @@ object type GenericOrganizationalUnitBundle extends ContentBundle {
|
|||
// Link for contact points.
|
||||
association {
|
||||
|
||||
GenericOrganizationalUnit[0..n] organizationalunit = join cms_contacts.contact_id
|
||||
to cms_organizationalunits_contact_map.contact_id,
|
||||
join cms_organizationalunits_contact_map.organizationalunit_id
|
||||
to cms_organizationalunits.organizationalunit_id;
|
||||
GenericOrganizationalUnitBundle[0..n] organizationalunit = join cms_contact_bundles.bundle_id
|
||||
to cms_organizationalunits_contact_map.contact_id,
|
||||
join cms_organizationalunits_contact_map.organizationalunit_id
|
||||
to cms_orgaunit_bundles.bundle_id;
|
||||
|
||||
GenericContact[0..n] contacts = join cms_organizationalunits.organizationalunit_id
|
||||
to cms_organizationalunits_contact_map.organizationalunit_id,
|
||||
join cms_organizationalunits_contact_map.contact_id
|
||||
to cms_contacts.contact_id;
|
||||
GenericContactBundle[0..n] contacts = join cms_orgaunit_bundles.bundle_id
|
||||
to cms_organizationalunits_contact_map.organizationalunit_id,
|
||||
join cms_organizationalunits_contact_map.contact_id
|
||||
to cms_contact_bundles.bundle_id;
|
||||
|
||||
// Some link attributes.
|
||||
String[0..1] contact_type = cms_organizationalunits_contact_map.contact_type VARCHAR(100);
|
||||
|
|
|
|||
|
|
@ -90,13 +90,15 @@ public class GenericOrganizationalUnit extends ContentPage {
|
|||
}
|
||||
|
||||
public GenericOrganizationalUnitContactCollection getContacts() {
|
||||
return new GenericOrganizationalUnitContactCollection((DataCollection) get(
|
||||
CONTACTS));
|
||||
//return new GenericOrganizationalUnitContactCollection((DataCollection) get(
|
||||
// CONTACTS));
|
||||
final DataCollection dataColl = (DataCollection) getContentBundle().get(CONTACTS);
|
||||
return new GenericOrganizationalUnitContactCollection(dataColl);
|
||||
}
|
||||
|
||||
public void addContact(final GenericContact contact,
|
||||
final String contactType) {
|
||||
Assert.exists(contact, GenericContact.class);
|
||||
/*Assert.exists(contact, GenericContact.class);
|
||||
|
||||
logger.debug(String.format("Adding contact of type \"%s\"...",
|
||||
contactType));
|
||||
|
|
@ -106,20 +108,23 @@ public class GenericOrganizationalUnit extends ContentPage {
|
|||
contactType);
|
||||
link.set(GenericOrganizationalUnitContactCollection.CONTACT_ORDER,
|
||||
Integer.valueOf((int) getContacts().size()));
|
||||
link.save();
|
||||
link.save();*/
|
||||
getGenericOrganizationalUnitBundle().addContact(contact, contactType);
|
||||
}
|
||||
|
||||
public void removeContact(final GenericContact contact) {
|
||||
Assert.exists(contact, GenericContact.class);
|
||||
remove(CONTACTS, contact);
|
||||
//Assert.exists(contact, GenericContact.class);
|
||||
//remove(CONTACTS, contact);
|
||||
getGenericOrganizationalUnitBundle().removeContact(contact);
|
||||
}
|
||||
|
||||
public boolean hasContacts() {
|
||||
return !this.getContacts().isEmpty();
|
||||
//return !this.getContacts().isEmpty();
|
||||
return getGenericOrganizationalUnitBundle().hasContacts();
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitPersonCollection getPersons() {
|
||||
DataCollection dataColl = (DataCollection) getContentBundle().get(PERSONS);
|
||||
final DataCollection dataColl = (DataCollection) getContentBundle().get(PERSONS);
|
||||
logger.debug(String.format(
|
||||
"GenericOrganizationalUnitPersonCollection size = %d", dataColl.
|
||||
size()));
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ import java.math.BigDecimal;
|
|||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
* @version $Id: GenericOrganizationalUnitBundle.java 1480 2012-01-30 13:52:00Z
|
||||
* jensp $
|
||||
*/
|
||||
public class GenericOrganizationalUnitBundle extends ContentBundle {
|
||||
|
||||
|
|
@ -20,6 +21,7 @@ public class GenericOrganizationalUnitBundle extends ContentBundle {
|
|||
"com.arsdigita.cms.contenttypes.GenericOrganizationalUnitBundle";
|
||||
public static final String PERSONS = "persons";
|
||||
public static final String ORGAUNITS = "organizationalunits";
|
||||
public final static String CONTACTS = "contacts";
|
||||
|
||||
public GenericOrganizationalUnitBundle(final ContentItem primary) {
|
||||
super(BASE_DATA_OBJECT_TYPE);
|
||||
|
|
@ -62,7 +64,7 @@ public class GenericOrganizationalUnitBundle extends ContentBundle {
|
|||
Assert.exists(person, GenericPerson.class);
|
||||
|
||||
final DataObject link = add(PERSONS, person.getGenericPersonBundle());
|
||||
|
||||
|
||||
link.set(GenericOrganizationalUnitPersonCollection.PERSON_ROLE, role);
|
||||
link.set(GenericOrganizationalUnitPersonCollection.STATUS, status);
|
||||
link.save();
|
||||
|
|
@ -77,4 +79,31 @@ public class GenericOrganizationalUnitBundle extends ContentBundle {
|
|||
public boolean hasPersons() {
|
||||
return !getPersons().isEmpty();
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitContactCollection getContacts() {
|
||||
return new GenericOrganizationalUnitContactCollection((DataCollection) get(
|
||||
CONTACTS));
|
||||
}
|
||||
|
||||
public void addContact(final GenericContact contact,
|
||||
final String contactType) {
|
||||
Assert.exists(contact, GenericContact.class);
|
||||
|
||||
final DataObject link = add(CONTACTS, contact.getContentBundle());
|
||||
|
||||
link.set(GenericOrganizationalUnitContactCollection.CONTACT_TYPE,
|
||||
contactType);
|
||||
link.set(GenericOrganizationalUnitContactCollection.CONTACT_ORDER,
|
||||
Integer.valueOf((int) getContacts().size()));
|
||||
link.save();
|
||||
}
|
||||
|
||||
public void removeContact(final GenericContact contact) {
|
||||
Assert.exists(contact, GenericContact.class);
|
||||
remove(CONTACTS, contact.getContentBundle());
|
||||
}
|
||||
|
||||
public boolean hasContacts() {
|
||||
return !this.getContacts().isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,14 @@
|
|||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.globalization.Globalization;
|
||||
import com.arsdigita.globalization.GlobalizationHelper;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import java.util.Locale;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -72,9 +76,8 @@ public class GenericOrganizationalUnitContactCollection extends DomainCollection
|
|||
* Swaps the item {@code contact} with the next one in the collection.
|
||||
*
|
||||
* @param contact The item to swap with the next one.
|
||||
* @throws IllegalArgumentException Thrown if the item provided is
|
||||
* not part of this collection, or if the item is the last one in the
|
||||
* collection.
|
||||
* @throws IllegalArgumentException Thrown if the item provided is not part
|
||||
* of this collection, or if the item is the last one in the collection.
|
||||
*/
|
||||
public void swapWithNext(GenericContact contact) {
|
||||
int currentPos = 0;
|
||||
|
|
@ -127,9 +130,8 @@ public class GenericOrganizationalUnitContactCollection extends DomainCollection
|
|||
* Swaps the item {@code contact} with the previous one in the collection.
|
||||
*
|
||||
* @param contact The item to swap with the previous one.
|
||||
* @throws IllegalArgumentException Thrown if the item provided is
|
||||
* not part of this collection, or if the item is the first one in the
|
||||
* collection.
|
||||
* @throws IllegalArgumentException Thrown if the item provided is not part
|
||||
* of this collection, or if the item is the first one in the collection.
|
||||
*/
|
||||
public void swapWithPrevious(GenericContact contact) {
|
||||
int previousPos = 0;
|
||||
|
|
@ -186,14 +188,26 @@ public class GenericOrganizationalUnitContactCollection extends DomainCollection
|
|||
* @return The current contact.
|
||||
*/
|
||||
public GenericContact getContact() {
|
||||
return new GenericContact(m_dataCollection.getDataObject());
|
||||
/*
|
||||
* return new GenericContact(m_dataCollection.getDataObject());
|
||||
*/
|
||||
final ContentBundle bundle = (ContentBundle) DomainObjectFactory.
|
||||
newInstance(m_dataCollection.getDataObject());
|
||||
return (GenericContact) bundle.getInstance(GlobalizationHelper.
|
||||
getNegotiatedLocale().getLanguage());
|
||||
}
|
||||
|
||||
public GenericContact getContact(final String language) {
|
||||
final ContentBundle bundle = (ContentBundle) DomainObjectFactory.
|
||||
newInstance(m_dataCollection.getDataObject());
|
||||
return (GenericContact) bundle.getInstance(language);
|
||||
}
|
||||
|
||||
public GenericPerson getPerson() {
|
||||
DataCollection collection;
|
||||
|
||||
collection = (DataCollection) m_dataCollection.getDataObject().get(
|
||||
GenericContact.PERSON);
|
||||
GenericContact.PERSON);
|
||||
|
||||
if (collection.size() == 0) {
|
||||
return null;
|
||||
|
|
@ -206,21 +220,23 @@ public class GenericOrganizationalUnitContactCollection extends DomainCollection
|
|||
// Close Collection to prevent an open ResultSet
|
||||
collection.close();
|
||||
|
||||
return (GenericPerson) DomainObjectFactory.newInstance(dobj);
|
||||
//return (GenericPerson) DomainObjectFactory.newInstance(dobj);
|
||||
final GenericPersonBundle bundle = (GenericPersonBundle) DomainObjectFactory.newInstance(dobj);
|
||||
return (GenericPerson) bundle.getPrimaryInstance();
|
||||
}
|
||||
}
|
||||
|
||||
public GenericAddress getAddress() {
|
||||
return (GenericAddress) DomainObjectFactory.newInstance((DataObject) m_dataCollection.
|
||||
/*return (GenericAddress) DomainObjectFactory.newInstance((DataObject) m_dataCollection.
|
||||
getDataObject().get(
|
||||
GenericContact.ADDRESS));
|
||||
GenericContact.ADDRESS));*/
|
||||
return getContact().getAddress();
|
||||
}
|
||||
|
||||
public GenericContactEntryCollection getContactEntries() {
|
||||
return new GenericContactEntryCollection((DataCollection) m_dataCollection.
|
||||
/*return new GenericContactEntryCollection((DataCollection) m_dataCollection.
|
||||
getDataObject().get(
|
||||
GenericContact.CONTACT_ENTRIES));
|
||||
GenericContact.CONTACT_ENTRIES));*/
|
||||
return getContact().getContactEntries();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue