Publizieren Assoiziation GenericContact <-> GenericOrganizatzationalUnit

git-svn-id: https://svn.libreccm.org/ccm/trunk@1565 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-04-02 07:07:01 +00:00
parent 355f54236f
commit 07dd42dc28
1 changed files with 37 additions and 7 deletions

View File

@ -34,27 +34,27 @@ public class GenericContactBundle
setContentType(primary.getContentType()); setContentType(primary.getContentType());
addInstance(primary); addInstance(primary);
super.setName(primary.getName()); super.setName(primary.getName());
} }
public GenericContactBundle(final OID oid) throws public GenericContactBundle(final OID oid) throws
DataObjectNotFoundException { DataObjectNotFoundException {
super(oid); super(oid);
} }
public GenericContactBundle(final BigDecimal id) throws public GenericContactBundle(final BigDecimal id) throws
DataObjectNotFoundException { DataObjectNotFoundException {
super(new OID(BASE_DATA_OBJECT_TYPE, id)); super(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
public GenericContactBundle(final DataObject dobj) { public GenericContactBundle(final DataObject dobj) {
super(dobj); super(dobj);
} }
public GenericContactBundle(final String type) { public GenericContactBundle(final String type) {
super(type); super(type);
} }
/** /**
* <p> Copy association properties. These are for example the associations * <p> Copy association properties. These are for example the associations
* between GenericPerson and GenericContact, or between * between GenericPerson and GenericContact, or between
@ -76,7 +76,6 @@ public class GenericContactBundle
(GenericContactBundle) source; (GenericContactBundle) source;
if (PERSON.equals(attribute)) { if (PERSON.equals(attribute)) {
final DataCollection persons = (DataCollection) contactBundle. final DataCollection persons = (DataCollection) contactBundle.
get(PERSON); get(PERSON);
@ -85,7 +84,16 @@ public class GenericContactBundle
} }
return true; return true;
} else { } else if ("organizationalunit".equals(attribute)) {
final DataCollection orgaunits = (DataCollection) contactBundle.
get("organizationalunit");
while (orgaunits.next()) {
createOrgaUnitAssoc(orgaunits);
}
return true;
} else {
return super.copyProperty(source, property, copier); return super.copyProperty(source, property, copier);
} }
} else { } else {
@ -114,6 +122,28 @@ public class GenericContactBundle
} }
} }
private void createOrgaUnitAssoc(final DataCollection orgaunits) {
final GenericOrganizationalUnitBundle draftOrga =
(GenericOrganizationalUnitBundle) DomainObjectFactory.
newInstance(orgaunits.getDataObject());
final GenericOrganizationalUnitBundle liveOrga =
(GenericOrganizationalUnitBundle) draftOrga.
getLiveVersion();
if (liveOrga != null) {
final DataObject link = add("organizationalunit", liveOrga);
link.set(GenericOrganizationalUnitContactCollection.CONTACT_TYPE,
orgaunits.get(
GenericOrganizationalUnitContactCollection.LINK_CONTACT_TYPE));
link.set(GenericOrganizationalUnitContactCollection.CONTACT_ORDER,
orgaunits.get(
GenericOrganizationalUnitContactCollection.LINK_CONTACT_ORDER));
link.save();
}
}
public GenericPerson getPerson() { public GenericPerson getPerson() {
DataCollection collection; DataCollection collection;