ExtraXmlGenerator für SciMember, notwendig wegen neuer Assoziationsstruktur
git-svn-id: https://svn.libreccm.org/ccm/trunk@1497 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b122cb97d5
commit
b68d483a9d
|
|
@ -18,10 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ExtraXMLGenerator;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -53,4 +55,11 @@ public class SciMember extends GenericPerson {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ExtraXMLGenerator> getExtraXMLGenerators() {
|
||||||
|
final List<ExtraXMLGenerator> generators = super.getExtraListXMLGenerators();
|
||||||
|
generators.add(new SciMemberExtraXmlGenerator());
|
||||||
|
return generators;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ExtraXMLGenerator;
|
||||||
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.cms.dispatcher.XMLGenerator;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciMemberExtraXmlGenerator implements ExtraXMLGenerator {
|
||||||
|
|
||||||
|
public void generateXML(final ContentItem item,
|
||||||
|
final Element element,
|
||||||
|
final PageState state) {
|
||||||
|
if (!(item instanceof SciMember)) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"The SciMemberExtraXmlGenerator can only process "
|
||||||
|
+ "instances of SciMember");
|
||||||
|
}
|
||||||
|
|
||||||
|
final SciMember member = (SciMember) item;
|
||||||
|
final GenericPersonContactCollection contacts = member.getContacts();
|
||||||
|
|
||||||
|
final Element contactsElem = element.newChildElement("contacts");
|
||||||
|
while (contacts.next()) {
|
||||||
|
generateContactXml(contactsElem, contacts.getContact(), state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGlobalStateParams(final Page page) {
|
||||||
|
//Nothing for now
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateContactXml(final Element contactsElem,
|
||||||
|
final GenericContact contact,
|
||||||
|
final PageState state) {
|
||||||
|
final XmlGenerator generator = new XmlGenerator(contact);
|
||||||
|
generator.setItemElemName("contact", "");
|
||||||
|
generator.addItemAttribute("contactType", contact.getContactType());
|
||||||
|
generator.generateXML(state, contactsElem, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
|
private ContentItem item;
|
||||||
|
|
||||||
|
public XmlGenerator(final ContentItem item) {
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentItem getContentItem(final PageState state) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue