GenericAddress
Bei der Ausgabe von GenericAddress und abgeleiteten CTs wird nun neben dem ISO-Country-Code auch das Land in übersetzter Form ausgegeben. git-svn-id: https://svn.libreccm.org/ccm/trunk@623 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
d02a207bba
commit
7bf1e264fa
|
|
@ -23,7 +23,7 @@
|
||||||
<xrd:property name="/object/type/displayName"/>
|
<xrd:property name="/object/type/displayName"/>
|
||||||
<xrd:property name="/object/type/associatedObjectType"/>
|
<xrd:property name="/object/type/associatedObjectType"/>
|
||||||
<xrd:property name="/object/type/className"/>
|
<xrd:property name="/object/type/className"/>
|
||||||
<xrd:property name="/object/type/isInternal"/>
|
<xrd:property name="/object/type/mode"/>
|
||||||
<xrd:property name="/object/type/itemFormID"/>
|
<xrd:property name="/object/type/itemFormID"/>
|
||||||
</xrd:attributes>
|
</xrd:attributes>
|
||||||
<xrd:associations rule="include">
|
<xrd:associations rule="include">
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms;
|
package com.arsdigita.cms;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericAddress;
|
||||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
import com.arsdigita.domain.DomainObject;
|
import com.arsdigita.domain.DomainObject;
|
||||||
import com.arsdigita.domain.DomainObjectTraversalAdapter;
|
import com.arsdigita.domain.DomainObjectTraversalAdapter;
|
||||||
import com.arsdigita.domain.DomainObjectXMLRenderer;
|
import com.arsdigita.domain.DomainObjectXMLRenderer;
|
||||||
|
import com.arsdigita.persistence.metadata.Property;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -22,14 +24,12 @@ import com.arsdigita.xml.Element;
|
||||||
*
|
*
|
||||||
* @author quasi
|
* @author quasi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ContentItemXMLRenderer extends DomainObjectXMLRenderer {
|
public class ContentItemXMLRenderer extends DomainObjectXMLRenderer {
|
||||||
|
|
||||||
public ContentItemXMLRenderer(Element root) {
|
public ContentItemXMLRenderer(Element root) {
|
||||||
super(root);
|
super(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This method will be called by DomainObjectTraversal.walk()
|
// This method will be called by DomainObjectTraversal.walk()
|
||||||
// It's purpose is to test for ContentBundle objects and if found, replace
|
// It's purpose is to test for ContentBundle objects and if found, replace
|
||||||
// that object with the negotiated version of the content item.
|
// that object with the negotiated version of the content item.
|
||||||
|
|
@ -50,4 +50,24 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer {
|
||||||
|
|
||||||
super.walk(adapter, nObj, path, context, linkObject);
|
super.walk(adapter, nObj, path, context, linkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleAttribute(DomainObject obj,
|
||||||
|
String path,
|
||||||
|
Property property) {
|
||||||
|
|
||||||
|
String name = property.getName();
|
||||||
|
|
||||||
|
if (obj instanceof GenericAddress) {
|
||||||
|
if (name.equals("isoCountryCode")) {
|
||||||
|
super.handleAttribute(obj, path, property);
|
||||||
|
|
||||||
|
Element element = newElement(m_element, "country");
|
||||||
|
element.setText(GenericAddress.getCountryNameFromIsoCode(((GenericAddress) obj).getIsoCountryCode()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.handleAttribute(obj, path, property);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,7 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
if (!item.getClass().getName().equals(className)) {
|
if (!item.getClass().getName().equals(className)) {
|
||||||
s_log.info("Specializing item");
|
s_log.info("Specializing item");
|
||||||
try {
|
try {
|
||||||
item = (ContentItem) DomainObjectFactory.newInstance(new OID(item.
|
item = (ContentItem) DomainObjectFactory.newInstance(new OID(item. getObjectType().getQualifiedName(), item.getID()));
|
||||||
getObjectType().getQualifiedName(),
|
|
||||||
item.
|
|
||||||
getID()));
|
|
||||||
} catch (DataObjectNotFoundException ex) {
|
} catch (DataObjectNotFoundException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
(String) GlobalizationUtil.globalize(
|
(String) GlobalizationUtil.globalize(
|
||||||
|
|
@ -133,8 +130,7 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
XMLGenerator xitem = (XMLGenerator) item;
|
XMLGenerator xitem = (XMLGenerator) item;
|
||||||
xitem.generateXML(state, parent, useContext);
|
xitem.generateXML(state, parent, useContext);
|
||||||
|
|
||||||
} else if (className.equals(
|
} else if (className.equals("com.arsdigita.cms.UserDefinedContentItem")) {
|
||||||
"com.arsdigita.cms.UserDefinedContentItem")) {
|
|
||||||
s_log.info("Item is a user defined content item");
|
s_log.info("Item is a user defined content item");
|
||||||
UserDefinedContentItem UDItem = (UserDefinedContentItem) item;
|
UserDefinedContentItem UDItem = (UserDefinedContentItem) item;
|
||||||
generateUDItemXML(UDItem, state, parent, useContext);
|
generateUDItemXML(UDItem, state, parent, useContext);
|
||||||
|
|
@ -145,8 +141,7 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
// This is the preferred method
|
// This is the preferred method
|
||||||
Element content = startElement(useContext);
|
Element content = startElement(useContext);
|
||||||
|
|
||||||
ContentItemXMLRenderer renderer =
|
ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(content);
|
||||||
new ContentItemXMLRenderer(content);
|
|
||||||
|
|
||||||
renderer.setWrapAttributes(true);
|
renderer.setWrapAttributes(true);
|
||||||
renderer.setWrapRoot(false);
|
renderer.setWrapRoot(false);
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,19 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger
|
private static final Logger s_log = Logger.getLogger(DomainObjectXMLRenderer.class);
|
||||||
(DomainObjectXMLRenderer.class);
|
|
||||||
|
|
||||||
private static Map s_formatters = new HashMap();
|
private static Map s_formatters = new HashMap();
|
||||||
|
private Stack m_elements = new Stack();
|
||||||
|
protected Element m_element;
|
||||||
|
private boolean m_wrapRoot = false;
|
||||||
|
private boolean m_wrapObjects = false;
|
||||||
|
private boolean m_wrapAttributes = false;
|
||||||
|
private boolean m_revisitFullObject = false;
|
||||||
|
private Map m_objectElements;
|
||||||
|
private String m_namespaceURI;
|
||||||
|
private String m_namespacePrefix;
|
||||||
|
private DomainObjectXMLFormatter m_formatter;
|
||||||
|
private String m_context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a traversal formatter for an object type in a given
|
* Registers a traversal formatter for an object type in a given
|
||||||
|
|
@ -88,9 +97,9 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
DomainObjectXMLFormatter formatter,
|
DomainObjectXMLFormatter formatter,
|
||||||
String context) {
|
String context) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug( "Registering formatter " +
|
s_log.debug("Registering formatter "
|
||||||
formatter.getClass().getName() + " for type " + type +
|
+ formatter.getClass().getName() + " for type " + type
|
||||||
" in context " + context );
|
+ " in context " + context);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerFormatter(MetadataRoot.getMetadataRoot().getObjectType(type),
|
registerFormatter(MetadataRoot.getMetadataRoot().getObjectType(type),
|
||||||
|
|
@ -121,8 +130,7 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
public static DomainObjectXMLFormatter getFormatter(
|
public static DomainObjectXMLFormatter getFormatter(
|
||||||
ObjectType type,
|
ObjectType type,
|
||||||
String context) {
|
String context) {
|
||||||
return (DomainObjectXMLFormatter)s_formatters
|
return (DomainObjectXMLFormatter) s_formatters.get(new AdapterKey(type, context));
|
||||||
.get(new AdapterKey(type, context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -147,22 +155,6 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
return formatter;
|
return formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stack m_elements = new Stack();
|
|
||||||
private Element m_element;
|
|
||||||
|
|
||||||
private boolean m_wrapRoot = false;
|
|
||||||
private boolean m_wrapObjects = false;
|
|
||||||
private boolean m_wrapAttributes = false;
|
|
||||||
private boolean m_revisitFullObject = false;
|
|
||||||
|
|
||||||
private Map m_objectElements;
|
|
||||||
|
|
||||||
private String m_namespaceURI;
|
|
||||||
private String m_namespacePrefix;
|
|
||||||
|
|
||||||
private DomainObjectXMLFormatter m_formatter;
|
|
||||||
private String m_context;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new DomainObject XML renderer
|
* Creates a new DomainObject XML renderer
|
||||||
* that outputs XML into the element passed into
|
* that outputs XML into the element passed into
|
||||||
|
|
@ -223,8 +215,8 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
String context,
|
String context,
|
||||||
DomainObjectTraversalAdapter adapter) {
|
DomainObjectTraversalAdapter adapter) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Traversing " + obj + " for context " + context + " " +
|
s_log.debug("Traversing " + obj + " for context " + context + " "
|
||||||
"using adapter " + adapter);
|
+ "using adapter " + adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_formatter = findFormatter(obj.getObjectType(), context);
|
m_formatter = findFormatter(obj.getObjectType(), context);
|
||||||
|
|
@ -237,7 +229,6 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
super.walk(obj, context, adapter);
|
super.walk(obj, context, adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines XML output for root object.
|
* Determines XML output for root object.
|
||||||
* If set to true a separate element will
|
* If set to true a separate element will
|
||||||
|
|
@ -281,7 +272,6 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
m_revisitFullObject = value;
|
m_revisitFullObject = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isWrappingAttributes() {
|
public boolean isWrappingAttributes() {
|
||||||
return m_wrapAttributes;
|
return m_wrapAttributes;
|
||||||
}
|
}
|
||||||
|
|
@ -396,7 +386,6 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void beginAssociation(DomainObject obj,
|
protected void beginAssociation(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
|
|
@ -429,18 +418,18 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
|
|
||||||
protected Element newElement(Element parent,
|
protected Element newElement(Element parent,
|
||||||
String name) {
|
String name) {
|
||||||
return m_namespaceURI == null ?
|
return m_namespaceURI == null
|
||||||
parent.newChildElement(name) :
|
? parent.newChildElement(name)
|
||||||
parent.newChildElement(m_namespacePrefix + ":" + name,
|
: parent.newChildElement(m_namespacePrefix + ":" + name,
|
||||||
m_namespaceURI);
|
m_namespaceURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element newElement(Element parent,
|
protected Element newElement(Element parent,
|
||||||
String name,
|
String name,
|
||||||
Element copy) {
|
Element copy) {
|
||||||
return m_namespaceURI == null ?
|
return m_namespaceURI == null
|
||||||
parent.newChildElement(name, copy) :
|
? parent.newChildElement(name, copy)
|
||||||
parent.newChildElement(m_namespacePrefix + ":" + name,
|
: parent.newChildElement(m_namespacePrefix + ":" + name,
|
||||||
m_namespaceURI,
|
m_namespaceURI,
|
||||||
copy);
|
copy);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue