- RIS-Exporter optimiert
- Formatierungen git-svn-id: https://svn.libreccm.org/ccm/trunk@1677 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
697835822b
commit
986acd393e
|
|
@ -48,7 +48,8 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer {
|
||||||
final String path,
|
final String path,
|
||||||
final String context,
|
final String context,
|
||||||
final DomainObject linkObject) {
|
final DomainObject linkObject) {
|
||||||
|
final long start = System.nanoTime();
|
||||||
|
|
||||||
DomainObject nObj = obj;
|
DomainObject nObj = obj;
|
||||||
|
|
||||||
if (nObj instanceof ContentBundle) {
|
if (nObj instanceof ContentBundle) {
|
||||||
|
|
@ -58,6 +59,8 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
super.walk(adapter, nObj, path, context, linkObject);
|
super.walk(adapter, nObj, path, context, linkObject);
|
||||||
|
|
||||||
|
System.out.printf("Walked object in %d ms\n", (System.nanoTime() - start) / 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -13,31 +13,31 @@ import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class GenericPersonExtraXmlGenerator implements ExtraXMLGenerator {
|
public class GenericPersonExtraXmlGenerator implements ExtraXMLGenerator {
|
||||||
|
|
||||||
public void generateXML(final ContentItem item,
|
public void generateXML(final ContentItem item,
|
||||||
final Element element,
|
final Element element,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
if (!(item instanceof GenericPerson)) {
|
if (!(item instanceof GenericPerson)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The GenericPersonExtraXmlGenerator can only process "
|
"The GenericPersonExtraXmlGenerator can only process "
|
||||||
+ "instances of GenericPerson");
|
+ "instances of GenericPerson");
|
||||||
}
|
}
|
||||||
|
|
||||||
final GenericPerson person = (GenericPerson) item;
|
final GenericPerson person = (GenericPerson) item;
|
||||||
final GenericPersonContactCollection contacts = person.getContacts();
|
final GenericPersonContactCollection contacts = person.getContacts();
|
||||||
|
|
||||||
final Element contactsElem = element.newChildElement("contacts");
|
final Element contactsElem = element.newChildElement("contacts");
|
||||||
while (contacts.next()) {
|
while (contacts.next()) {
|
||||||
|
final GenericContact contact = contacts.getContact(GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
||||||
generateContactXml(
|
generateContactXml(
|
||||||
contactsElem,
|
contactsElem,
|
||||||
contacts.getContact(GlobalizationHelper.getNegotiatedLocale().
|
contact,
|
||||||
getLanguage()),
|
state);
|
||||||
state);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateContactXml(final Element contactsElem,
|
private void generateContactXml(final Element contactsElem,
|
||||||
|
|
@ -52,7 +52,7 @@ public class GenericPersonExtraXmlGenerator implements ExtraXMLGenerator {
|
||||||
public void addGlobalStateParams(final Page page) {
|
public void addGlobalStateParams(final Page page) {
|
||||||
//Nothing
|
//Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setListMode(final boolean listMode) {
|
public void setListMode(final boolean listMode) {
|
||||||
//nothing
|
//nothing
|
||||||
|
|
|
||||||
|
|
@ -133,13 +133,15 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
* @param useContext The use context
|
* @param useContext The use context
|
||||||
*/
|
*/
|
||||||
public void generateXML(PageState state, Element parent, String useContext) {
|
public void generateXML(PageState state, Element parent, String useContext) {
|
||||||
|
final long start = System.nanoTime();
|
||||||
ContentSection section = CMS.getContext().getContentSection();
|
|
||||||
|
//ContentSection section = CMS.getContext().getContentSection();
|
||||||
ContentItem item = getContentItem(state);
|
ContentItem item = getContentItem(state);
|
||||||
|
|
||||||
|
System.out.printf("After getting contentitem: %d ms\n", (System.nanoTime() - start) / 1000000);
|
||||||
|
|
||||||
s_log.info("Generate XML for item " + item.getOID());
|
s_log.info("Generate XML for item " + item.getOID());
|
||||||
|
|
||||||
|
|
||||||
Party currentParty = Kernel.getContext().getParty();
|
Party currentParty = Kernel.getContext().getParty();
|
||||||
if (currentParty == null) {
|
if (currentParty == null) {
|
||||||
currentParty = Kernel.getPublicUser();
|
currentParty = Kernel.getPublicUser();
|
||||||
|
|
@ -164,6 +166,8 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
}
|
}
|
||||||
String className = item.getDefaultDomainClass();
|
String className = item.getDefaultDomainClass();
|
||||||
|
|
||||||
|
System.out.printf("After creating permission attributes: %d ms\n", (System.nanoTime() - start) / 1000000);
|
||||||
|
|
||||||
// Ensure correct subtype of ContentItem is instantiated
|
// Ensure correct subtype of ContentItem is instantiated
|
||||||
if (!item.getClass().getName().equals(className)) {
|
if (!item.getClass().getName().equals(className)) {
|
||||||
s_log.info("Specializing item");
|
s_log.info("Specializing item");
|
||||||
|
|
@ -178,6 +182,8 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.printf("After checking type: %d ms\n", (System.nanoTime() - start) / 1000000);
|
||||||
|
|
||||||
// Implementing XMLGenerator directly is now deprecated
|
// Implementing XMLGenerator directly is now deprecated
|
||||||
if (item instanceof XMLGenerator) {
|
if (item instanceof XMLGenerator) {
|
||||||
|
|
@ -205,6 +211,8 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
renderer.setRevisitFullObject(true);
|
renderer.setRevisitFullObject(true);
|
||||||
|
|
||||||
renderer.walk(item, ADAPTER_CONTEXT);
|
renderer.walk(item, ADAPTER_CONTEXT);
|
||||||
|
|
||||||
|
System.out.printf("After getting rendering standard item xml: %d ms\n", (System.nanoTime() - start) / 1000000);
|
||||||
|
|
||||||
//parent.addContent(content);
|
//parent.addContent(content);
|
||||||
|
|
||||||
|
|
@ -222,6 +230,8 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
generator.generateXML(item, content, state);
|
generator.generateXML(item, content, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.printf("After rendering extra xml: %d ms\n", (System.nanoTime() - start) / 1000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,33 +40,23 @@ import java.util.HashSet;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This class provides a general purpose framework for iterating
|
* <p>This class provides a general purpose framework for iterating over a domain object's properties, processing
|
||||||
* over a domain object's properties, processing attributes and
|
* attributes and traversing associations as required.</p>
|
||||||
* traversing associations as required.</p>
|
|
||||||
*
|
*
|
||||||
* <p>Subclasses should implement the startXXX and endXXX methods to
|
* <p>Subclasses should implement the startXXX and endXXX methods to provide whatever processing logic they require upon
|
||||||
* provide whatever processing logic they require upon encountering
|
* encountering attributes, roles, associations and objects.</p>
|
||||||
* attributes, roles, associations and objects.</p>
|
|
||||||
*
|
*
|
||||||
* <p>The {@link com.arsdigita.domain.DomainObjectTraversalAdapter}
|
* <p>The {@link com.arsdigita.domain.DomainObjectTraversalAdapter} provides a means to control which properties are
|
||||||
* provides a means to control which properties are processed and,
|
* processed and, most importantly, which associations are traversed. When registering an adapter, a 'use context' is
|
||||||
* most importantly, which associations are traversed. When
|
* supplied allowing different adapters to be used according to the requirements of any implementing subclass. It is
|
||||||
* registering an adapter, a 'use context' is supplied allowing
|
* recommended that the use context be based on the fully qualified name of the class using DomainObjectTraversal, e.g.,
|
||||||
* different adapters to be used according to the requirements of any
|
|
||||||
* implementing subclass. It is recommended that the use context be
|
|
||||||
* based on the fully qualified name of the class using
|
|
||||||
* DomainObjectTraversal, e.g.,
|
|
||||||
* com.arsdigita.cms.ui.DomainObjectRenderer.</p>
|
* com.arsdigita.cms.ui.DomainObjectRenderer.</p>
|
||||||
*
|
*
|
||||||
* <p>The path argument provided to the adapter and the startXXX ad
|
* <p>The path argument provided to the adapter and the startXXX ad endXXX methods indicates which associations are
|
||||||
* endXXX methods indicates which associations are currently being
|
* currently being traversed. The first element in the path is always '/object'. If it then starts to traverse the
|
||||||
* traversed. The first element in the path is always '/object'. If it
|
* 'rootCategory' association, the path will become '/object/rootCategory'. For self-recursive associations, rather than
|
||||||
* then starts to traverse the 'rootCategory' association, the path
|
* building up a long repeating string, the path will be shortened by adding a '+' for each element that is repeated.
|
||||||
* will become '/object/rootCategory'. For self-recursive
|
* For example, '/object/container+' indicates that the container association has been followed two or more times.</p>
|
||||||
* associations, rather than building up a long repeating string, the
|
|
||||||
* path will be shortened by adding a '+' for each element that is
|
|
||||||
* repeated. For example, '/object/container+' indicates that the
|
|
||||||
* container association has been followed two or more times.</p>
|
|
||||||
*/
|
*/
|
||||||
public abstract class DomainObjectTraversal {
|
public abstract class DomainObjectTraversal {
|
||||||
|
|
||||||
|
|
@ -77,39 +67,37 @@ public abstract class DomainObjectTraversal {
|
||||||
public final static String LINK_NAME = "link";
|
public final static String LINK_NAME = "link";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a traversal adapter for an object type in a given
|
* Registers a traversal adapter for an object type in a given context.
|
||||||
* context.
|
|
||||||
*
|
*
|
||||||
* @param type the object type whose items will be traversed
|
* @param type the object type whose items will be traversed
|
||||||
* @param adapter the adapter for controlling object traversal
|
* @param adapter the adapter for controlling object traversal
|
||||||
* @param context the context in which the adapter should be used
|
* @param context the context in which the adapter should be used
|
||||||
*/
|
*/
|
||||||
public static void registerAdapter(final ObjectType type,
|
public static void registerAdapter(final ObjectType type,
|
||||||
final DomainObjectTraversalAdapter adapter,
|
final DomainObjectTraversalAdapter adapter,
|
||||||
final String context) {
|
final String context) {
|
||||||
Assert.exists(adapter,
|
Assert.exists(adapter,
|
||||||
"The DomainObjectTraversalAdapter is null for context '"
|
"The DomainObjectTraversalAdapter is null for context '"
|
||||||
+ context + "' and object type '" + type);
|
+ context + "' and object type '" + type);
|
||||||
Assert.exists(type, "The ObjectType for context '" + context
|
Assert.exists(type, "The ObjectType for context '" + context
|
||||||
+ "' and adapter '" + adapter + "' is null");
|
+ "' and adapter '" + adapter + "' is null");
|
||||||
Assert.exists(context, String.class);
|
Assert.exists(context, String.class);
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Registering adapter " + adapter.getClass()
|
s_log.debug("Registering adapter " + adapter.getClass()
|
||||||
+ " for object type " + type.getQualifiedName()
|
+ " for object type " + type.getQualifiedName()
|
||||||
+ " in context " + context);
|
+ " in context " + context);
|
||||||
}
|
}
|
||||||
s_adapters.put(new AdapterKey(type, context), adapter);
|
s_adapters.put(new AdapterKey(type, context), adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters a traversal adapter for an object type in a
|
* Unregisters a traversal adapter for an object type in a given context
|
||||||
* given context
|
|
||||||
*
|
*
|
||||||
* @param type the object type whose items will be traversed
|
* @param type the object type whose items will be traversed
|
||||||
* @param context the context in which the adapter should be used
|
* @param context the context in which the adapter should be used
|
||||||
*/
|
*/
|
||||||
public static void unregisterAdapter(final ObjectType type,
|
public static void unregisterAdapter(final ObjectType type,
|
||||||
final String context) {
|
final String context) {
|
||||||
Assert.exists(type, ObjectType.class);
|
Assert.exists(type, ObjectType.class);
|
||||||
Assert.exists(context, String.class);
|
Assert.exists(context, String.class);
|
||||||
|
|
||||||
|
|
@ -121,37 +109,34 @@ public abstract class DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a traversal adapter for an object type in a given
|
* Registers a traversal adapter for an object type in a given context.
|
||||||
* context.
|
|
||||||
*
|
*
|
||||||
* @param type the object type whose items will be traversed
|
* @param type the object type whose items will be traversed
|
||||||
* @param adapter the adapter for controlling object traversal
|
* @param adapter the adapter for controlling object traversal
|
||||||
* @param context the context in which the adapter should be used
|
* @param context the context in which the adapter should be used
|
||||||
*/
|
*/
|
||||||
public static void registerAdapter(final String type,
|
public static void registerAdapter(final String type,
|
||||||
final DomainObjectTraversalAdapter adapter,
|
final DomainObjectTraversalAdapter adapter,
|
||||||
final String context) {
|
final String context) {
|
||||||
registerAdapter(SessionManager.getMetadataRoot().getObjectType(type),
|
registerAdapter(SessionManager.getMetadataRoot().getObjectType(type),
|
||||||
adapter,
|
adapter,
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters a traversal adapter for an object type in a
|
* Unregisters a traversal adapter for an object type in a given context
|
||||||
* given context
|
|
||||||
*
|
*
|
||||||
* @param type the object type whose items will be traversed
|
* @param type the object type whose items will be traversed
|
||||||
* @param context the context in which the adapter should be used
|
* @param context the context in which the adapter should be used
|
||||||
*/
|
*/
|
||||||
public static void unregisterAdapter(final String type,
|
public static void unregisterAdapter(final String type,
|
||||||
final String context) {
|
final String context) {
|
||||||
unregisterAdapter(SessionManager.getMetadataRoot().getObjectType(type),
|
unregisterAdapter(SessionManager.getMetadataRoot().getObjectType(type),
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the traversal adapter for an object type in a given
|
* Retrieves the traversal adapter for an object type in a given context.
|
||||||
* context.
|
|
||||||
*
|
*
|
||||||
* @param type the object type to lookup
|
* @param type the object type to lookup
|
||||||
* @param context the adapter context
|
* @param context the adapter context
|
||||||
|
|
@ -163,7 +148,7 @@ public abstract class DomainObjectTraversal {
|
||||||
Assert.exists(context, String.class);
|
Assert.exists(context, String.class);
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("lookupAdapter for type " + type.getQualifiedName()
|
s_log.debug("lookupAdapter for type " + type.getQualifiedName()
|
||||||
+ " in context " + context);
|
+ " in context " + context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,21 +157,20 @@ public abstract class DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the closest matching traversal adapter for an object type
|
* Retrieves the closest matching traversal adapter for an object type in a given context. The algorithm looks for
|
||||||
* in a given context. The algorithm looks for an exact match, then
|
* an exact match, then considers the supertype, and the supertype's supertype. If no match could be found at all,
|
||||||
* considers the supertype, and the supertype's supertype. If no match
|
* returns null
|
||||||
* could be found at all, returns null
|
|
||||||
*
|
*
|
||||||
* @param type the object type to search for
|
* @param type the object type to search for
|
||||||
* @param context the adapter context
|
* @param context the adapter context
|
||||||
*/
|
*/
|
||||||
public static DomainObjectTraversalAdapter findAdapter(ObjectType type,
|
public static DomainObjectTraversalAdapter findAdapter(ObjectType type,
|
||||||
final String context) {
|
final String context) {
|
||||||
Assert.exists(type, ObjectType.class);
|
Assert.exists(type, ObjectType.class);
|
||||||
Assert.exists(context, String.class);
|
Assert.exists(context, String.class);
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("findAdapter for type " + type.getQualifiedName()
|
s_log.debug("findAdapter for type " + type.getQualifiedName()
|
||||||
+ " in context " + context);
|
+ " in context " + context);
|
||||||
|
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("Adapters contain:\n");
|
buf.append("Adapters contain:\n");
|
||||||
|
|
@ -212,19 +196,18 @@ public abstract class DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Walks over properties of a domain object, invoking
|
* Walks over properties of a domain object, invoking methods to handle associations, roles and attributes.
|
||||||
* methods to handle associations, roles and attributes.
|
|
||||||
*
|
*
|
||||||
* @param obj the domain object to traverse
|
* @param obj the domain object to traverse
|
||||||
* @param context the context for the traversal adapter
|
* @param context the context for the traversal adapter
|
||||||
*/
|
*/
|
||||||
public void walk(final DomainObject obj,
|
public void walk(final DomainObject obj,
|
||||||
final String context) {
|
final String context) {
|
||||||
final DomainObjectTraversalAdapter adapter = findAdapter(obj.getObjectType(),
|
final DomainObjectTraversalAdapter adapter = findAdapter(obj.getObjectType(),
|
||||||
context);
|
context);
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
final String errorMsg = "No adapter for object " + obj.getOID()
|
final String errorMsg = "No adapter for object " + obj.getOID()
|
||||||
+ " in context " + context;
|
+ " in context " + context;
|
||||||
s_log.error(errorMsg);
|
s_log.error(errorMsg);
|
||||||
throw new IllegalArgumentException(errorMsg);
|
throw new IllegalArgumentException(errorMsg);
|
||||||
}
|
}
|
||||||
|
|
@ -232,8 +215,8 @@ public abstract class DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void walk(final DomainObject obj,
|
protected void walk(final DomainObject obj,
|
||||||
final String context,
|
final String context,
|
||||||
final DomainObjectTraversalAdapter adapter) {
|
final DomainObjectTraversalAdapter adapter) {
|
||||||
Assert.exists(adapter, DomainObjectTraversalAdapter.class);
|
Assert.exists(adapter, DomainObjectTraversalAdapter.class);
|
||||||
walk(adapter, obj, "/object", context, null);
|
walk(adapter, obj, "/object", context, null);
|
||||||
}
|
}
|
||||||
|
|
@ -245,12 +228,12 @@ public abstract class DomainObjectTraversal {
|
||||||
// content item during XML generation, I have to test for ContentBundle and
|
// content item during XML generation, I have to test for ContentBundle and
|
||||||
// negotiate the language version. This is not possible in com.arsdigita.ccm.
|
// negotiate the language version. This is not possible in com.arsdigita.ccm.
|
||||||
protected void walk(final DomainObjectTraversalAdapter adapter,
|
protected void walk(final DomainObjectTraversalAdapter adapter,
|
||||||
final DomainObject obj,
|
final DomainObject obj,
|
||||||
final String path,
|
final String path,
|
||||||
final String context,
|
final String context,
|
||||||
final DomainObject linkObject) {
|
final DomainObject linkObject) {
|
||||||
s_log.debug(String.format("Walking with path %s and context %s...", path,
|
s_log.debug(String.format("Walking with path %s and context %s...", path,
|
||||||
context));
|
context));
|
||||||
OID oid = obj.getOID();
|
OID oid = obj.getOID();
|
||||||
OID linkOid = null;
|
OID linkOid = null;
|
||||||
if (linkObject != null) {
|
if (linkObject != null) {
|
||||||
|
|
@ -271,10 +254,10 @@ public abstract class DomainObjectTraversal {
|
||||||
if (linkObject != null) {
|
if (linkObject != null) {
|
||||||
beginLink(linkObject, path);
|
beginLink(linkObject, path);
|
||||||
walk(adapter,
|
walk(adapter,
|
||||||
linkObject,
|
linkObject,
|
||||||
appendToPath(path, LINK_NAME),
|
appendToPath(path, LINK_NAME),
|
||||||
context,
|
context,
|
||||||
null);
|
null);
|
||||||
endLink(linkObject, path);
|
endLink(linkObject, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,12 +269,13 @@ public abstract class DomainObjectTraversal {
|
||||||
String propName = prop.getName();
|
String propName = prop.getName();
|
||||||
|
|
||||||
if (!adapter.processProperty(obj,
|
if (!adapter.processProperty(obj,
|
||||||
appendToPath(path, prop.getName()),
|
appendToPath(path, prop.getName()),
|
||||||
prop,
|
prop,
|
||||||
context)) {
|
context)) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Not processing " + appendToPath(path, prop.getName()) + " in object " + oid + " and context "
|
s_log.debug("Not processing " + appendToPath(path, prop.getName()) + " in object " + oid
|
||||||
+ context + " with adapter " + adapter.getClass().
|
+ " and context "
|
||||||
|
+ context + " with adapter " + adapter.getClass().
|
||||||
getName());
|
getName());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -300,7 +284,7 @@ public abstract class DomainObjectTraversal {
|
||||||
if (propValue == null) {
|
if (propValue == null) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Object " + oid.toString() + " doesn't "
|
s_log.debug("Object " + oid.toString() + " doesn't "
|
||||||
+ "contain property " + propName);
|
+ "contain property " + propName);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -317,10 +301,10 @@ public abstract class DomainObjectTraversal {
|
||||||
beginRole(obj, path, prop);
|
beginRole(obj, path, prop);
|
||||||
|
|
||||||
walk(adapter,
|
walk(adapter,
|
||||||
DomainObjectFactory.newInstance((DataObject) propValue),
|
DomainObjectFactory.newInstance((DataObject) propValue),
|
||||||
appendToPath(path, propName),
|
appendToPath(path, propName),
|
||||||
context,
|
context,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
endRole(obj, path, prop);
|
endRole(obj, path, prop);
|
||||||
} else if (propValue instanceof DataAssociation) {
|
} else if (propValue instanceof DataAssociation) {
|
||||||
|
|
@ -332,11 +316,11 @@ public abstract class DomainObjectTraversal {
|
||||||
if (prop.getName().equals("fileAttachments") && !Domain.getConfig().queryBlobContentForFileAttachments()) {
|
if (prop.getName().equals("fileAttachments") && !Domain.getConfig().queryBlobContentForFileAttachments()) {
|
||||||
// make true a config
|
// make true a config
|
||||||
DataQuery fileAttachmentsQuery =
|
DataQuery fileAttachmentsQuery =
|
||||||
SessionManager.getSession().retrieveQuery(
|
SessionManager.getSession().retrieveQuery(
|
||||||
"com.arsdigita.cms.contentassets.fileAttachmentsQuery");
|
"com.arsdigita.cms.contentassets.fileAttachmentsQuery");
|
||||||
|
|
||||||
fileAttachmentsQuery.setParameter("item_id",
|
fileAttachmentsQuery.setParameter("item_id",
|
||||||
obj.getOID().get("id"));
|
obj.getOID().get("id"));
|
||||||
|
|
||||||
DataCollection files = new DataQueryDataCollectionAdapter(
|
DataCollection files = new DataQueryDataCollectionAdapter(
|
||||||
fileAttachmentsQuery, "file");
|
fileAttachmentsQuery, "file");
|
||||||
|
|
@ -344,47 +328,34 @@ public abstract class DomainObjectTraversal {
|
||||||
while (files.next()) {
|
while (files.next()) {
|
||||||
DataObject file = files.getDataObject();
|
DataObject file = files.getDataObject();
|
||||||
walk(adapter,
|
walk(adapter,
|
||||||
DomainObjectFactory.newInstance(file),
|
DomainObjectFactory.newInstance(file),
|
||||||
appendToPath(path, propName),
|
appendToPath(path, propName),
|
||||||
context,
|
context,
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//2010-11-08: Moved to seperate Methods to allow simple
|
//2010-11-08: Moved to seperate Methods to allow simple
|
||||||
//extending of the handling of data assocications
|
//extending of the handling of data assocications
|
||||||
/*if (s_log.isDebugEnabled()) {
|
/*
|
||||||
s_log.debug(prop.getName() + " is a DataAssociation");
|
* if (s_log.isDebugEnabled()) { s_log.debug(prop.getName() + " is a DataAssociation"); }
|
||||||
}
|
* beginAssociation(obj, path, prop);
|
||||||
beginAssociation(obj, path, prop);
|
*
|
||||||
|
* DataAssociationCursor daCursor = ((DataAssociation) propValue). getDataAssociationCursor();
|
||||||
DataAssociationCursor daCursor =
|
*
|
||||||
((DataAssociation) propValue).
|
* while (daCursor.next()) { s_log.debug("Processing data assoication cursor..."); DataObject link =
|
||||||
getDataAssociationCursor();
|
* daCursor.getLink(); DomainObject linkObj = null; if (link != null) { linkObj = new
|
||||||
|
* LinkDomainObject(link); } walk(adapter, DomainObjectFactory.newInstance(daCursor.
|
||||||
while (daCursor.next()) {
|
* getDataObject()), appendToPath(path, propName), context, linkObj); } endAssociation(obj, path, prop);
|
||||||
s_log.debug("Processing data assoication cursor...");
|
*/
|
||||||
DataObject link = daCursor.getLink();
|
|
||||||
DomainObject linkObj = null;
|
|
||||||
if (link != null) {
|
|
||||||
linkObj = new LinkDomainObject(link);
|
|
||||||
}
|
|
||||||
walk(adapter,
|
|
||||||
DomainObjectFactory.newInstance(daCursor.
|
|
||||||
getDataObject()),
|
|
||||||
appendToPath(path, propName),
|
|
||||||
context,
|
|
||||||
linkObj);
|
|
||||||
}
|
|
||||||
endAssociation(obj, path, prop);*/
|
|
||||||
|
|
||||||
walkDataAssociations(adapter,
|
walkDataAssociations(adapter,
|
||||||
obj,
|
obj,
|
||||||
path,
|
path,
|
||||||
context,
|
context,
|
||||||
prop,
|
prop,
|
||||||
propName,
|
propName,
|
||||||
propValue);
|
propValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unknown property value type - do nothing
|
// Unknown property value type - do nothing
|
||||||
|
|
@ -396,129 +367,120 @@ public abstract class DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void walkDataAssociations(DomainObjectTraversalAdapter adapter,
|
protected void walkDataAssociations(DomainObjectTraversalAdapter adapter,
|
||||||
DomainObject obj,
|
DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
String context,
|
String context,
|
||||||
Property prop,
|
Property prop,
|
||||||
String propName,
|
String propName,
|
||||||
Object propValue) {
|
Object propValue) {
|
||||||
s_log.debug(String.format("%s is a DataAssociation", prop.getName()));
|
s_log.debug(String.format("%s is a DataAssociation", prop.getName()));
|
||||||
|
|
||||||
beginAssociation(obj, path, prop);
|
beginAssociation(obj, path, prop);
|
||||||
|
|
||||||
DataAssociationCursor daCursor =
|
DataAssociationCursor daCursor =
|
||||||
((DataAssociation) propValue).getDataAssociationCursor();
|
((DataAssociation) propValue).getDataAssociationCursor();
|
||||||
|
|
||||||
while (daCursor.next()) {
|
while (daCursor.next()) {
|
||||||
walkDataAssociation(adapter,
|
walkDataAssociation(adapter,
|
||||||
obj,
|
obj,
|
||||||
path,
|
path,
|
||||||
context,
|
context,
|
||||||
propName,
|
propName,
|
||||||
daCursor);
|
daCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
endAssociation(obj, path, prop);
|
endAssociation(obj, path, prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void walkDataAssociation(DomainObjectTraversalAdapter adapter,
|
protected void walkDataAssociation(DomainObjectTraversalAdapter adapter,
|
||||||
DomainObject obj,
|
DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
String context,
|
String context,
|
||||||
String propName,
|
String propName,
|
||||||
DataAssociationCursor daCursor) {
|
DataAssociationCursor daCursor) {
|
||||||
s_log.debug(String.format("Processing data assoication cursor for object '%s'...",
|
s_log.debug(String.format("Processing data assoication cursor for object '%s'...",
|
||||||
obj.getOID().toString()));
|
obj.getOID().toString()));
|
||||||
DataObject link = daCursor.getLink();
|
DataObject link = daCursor.getLink();
|
||||||
DomainObject linkObj = null;
|
DomainObject linkObj = null;
|
||||||
if (link != null) {
|
if (link != null) {
|
||||||
linkObj = new LinkDomainObject(link);
|
linkObj = new LinkDomainObject(link);
|
||||||
}
|
}
|
||||||
walk(adapter,
|
walk(adapter,
|
||||||
DomainObjectFactory.newInstance(daCursor.getDataObject()),
|
DomainObjectFactory.newInstance(daCursor.getDataObject()),
|
||||||
appendToPath(path, propName),
|
appendToPath(path, propName),
|
||||||
context,
|
context,
|
||||||
linkObj);
|
linkObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the processing of an object
|
* Method called when the processing of an object starts
|
||||||
* starts
|
|
||||||
*/
|
*/
|
||||||
protected abstract void beginObject(DomainObject obj,
|
protected abstract void beginObject(DomainObject obj,
|
||||||
String path);
|
String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the procesing of an object
|
* Method called when the procesing of an object completes
|
||||||
* completes
|
|
||||||
*/
|
*/
|
||||||
protected abstract void endObject(DomainObject obj,
|
protected abstract void endObject(DomainObject obj,
|
||||||
String path);
|
String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the processing of a Link Object
|
* Method called when the processing of a Link Object starts
|
||||||
* starts
|
|
||||||
*/
|
*/
|
||||||
protected void beginLink(DomainObject obj, String path) {
|
protected void beginLink(DomainObject obj, String path) {
|
||||||
s_log.debug(String.format("Starting link with path = %s", path));
|
s_log.debug(String.format("Starting link with path = %s", path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the procesing of a Link Object
|
* Method called when the procesing of a Link Object completes
|
||||||
* completes
|
|
||||||
*/
|
*/
|
||||||
protected void endLink(DomainObject obj, String path) {
|
protected void endLink(DomainObject obj, String path) {
|
||||||
s_log.debug(String.format("Finished link with path = %s", path));
|
s_log.debug(String.format("Finished link with path = %s", path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when a previously visited object
|
* Method called when a previously visited object is encountered for a second time.
|
||||||
* is encountered for a second time.
|
|
||||||
*/
|
*/
|
||||||
protected abstract void revisitObject(DomainObject obj,
|
protected abstract void revisitObject(DomainObject obj,
|
||||||
String path);
|
String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when an attribute is encountered
|
* Method called when an attribute is encountered
|
||||||
*/
|
*/
|
||||||
protected abstract void handleAttribute(DomainObject obj,
|
protected abstract void handleAttribute(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property);
|
Property property);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the processing of a role
|
* Method called when the processing of a role starts
|
||||||
* starts
|
|
||||||
*/
|
*/
|
||||||
protected abstract void beginRole(DomainObject obj,
|
protected abstract void beginRole(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property);
|
Property property);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the procesing of a role
|
* Method called when the procesing of a role completes
|
||||||
* completes
|
|
||||||
*/
|
*/
|
||||||
protected abstract void endRole(DomainObject obj,
|
protected abstract void endRole(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property);
|
Property property);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the processing of an association
|
* Method called when the processing of an association starts
|
||||||
* starts
|
|
||||||
*/
|
*/
|
||||||
protected abstract void beginAssociation(DomainObject obj,
|
protected abstract void beginAssociation(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property);
|
Property property);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the procesing of an association
|
* Method called when the procesing of an association completes
|
||||||
* completes
|
|
||||||
*/
|
*/
|
||||||
protected abstract void endAssociation(DomainObject obj,
|
protected abstract void endAssociation(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property);
|
Property property);
|
||||||
|
|
||||||
protected String appendToPath(String path,
|
protected String appendToPath(String path,
|
||||||
String name) {
|
String name) {
|
||||||
if (path.endsWith("/" + name)) {
|
if (path.endsWith("/" + name)) {
|
||||||
path = path + "+";
|
path = path + "+";
|
||||||
} else if (!path.endsWith("/" + name + "+")) {
|
} else if (!path.endsWith("/" + name + "+")) {
|
||||||
|
|
@ -556,7 +518,7 @@ public abstract class DomainObjectTraversal {
|
||||||
private final String m_context;
|
private final String m_context;
|
||||||
|
|
||||||
public AdapterKey(ObjectType type,
|
public AdapterKey(ObjectType type,
|
||||||
String context) {
|
String context) {
|
||||||
Assert.exists(type, ObjectType.class);
|
Assert.exists(type, ObjectType.class);
|
||||||
Assert.exists(context, String.class);
|
Assert.exists(context, String.class);
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
|
@ -585,8 +547,7 @@ public abstract class DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is simply a subclass since DomainObject is abstract
|
* this is simply a subclass since DomainObject is abstract but we don't have any other domain object to use.
|
||||||
* but we don't have any other domain object to use.
|
|
||||||
*/
|
*/
|
||||||
protected class LinkDomainObject extends DomainObject {
|
protected class LinkDomainObject extends DomainObject {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,8 @@ import java.util.Locale;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of DomainObjectTraversal that generates an XML
|
* An implementation of DomainObjectTraversal that generates an XML tree representing the DomainObject. The output
|
||||||
* tree representing the DomainObject. The output format of the XML
|
* format of the XML can be controlled using the various setWrapXXX methods detailed below.
|
||||||
* can be controlled using the various setWrapXXX methods detailed
|
|
||||||
* below.
|
|
||||||
*
|
*
|
||||||
* @version $Id: DomainObjectXMLRenderer.java 2141 2011-01-16 12:17:15Z pboy $
|
* @version $Id: DomainObjectXMLRenderer.java 2141 2011-01-16 12:17:15Z pboy $
|
||||||
*/
|
*/
|
||||||
|
|
@ -61,69 +59,64 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
private String m_context;
|
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 context.
|
||||||
* context.
|
|
||||||
*
|
*
|
||||||
* @param type the object type whose items will be traversed
|
* @param type the object type whose items will be traversed
|
||||||
* @param formatter the formatter for controlling object traversal
|
* @param formatter the formatter for controlling object traversal
|
||||||
* @param context the context in which the formatter should be used
|
* @param context the context in which the formatter should be used
|
||||||
*/
|
*/
|
||||||
public static void registerFormatter(ObjectType type,
|
public static void registerFormatter(ObjectType type,
|
||||||
DomainObjectXMLFormatter formatter,
|
DomainObjectXMLFormatter formatter,
|
||||||
String context) {
|
String context) {
|
||||||
s_formatters.put(new AdapterKey(type, context), formatter);
|
s_formatters.put(new AdapterKey(type, context), formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisteres a traversal formatter for an object type in a
|
* Unregisteres a traversal formatter for an object type in a given context
|
||||||
* given context
|
|
||||||
*
|
*
|
||||||
* @param type the object type whose items will be traversed
|
* @param type the object type whose items will be traversed
|
||||||
* @param context the context in which the formatter should be used
|
* @param context the context in which the formatter should be used
|
||||||
*/
|
*/
|
||||||
public static void unregisterFormatter(ObjectType type,
|
public static void unregisterFormatter(ObjectType type,
|
||||||
String context) {
|
String context) {
|
||||||
s_formatters.remove(new AdapterKey(type, context));
|
s_formatters.remove(new AdapterKey(type, context));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a traversal formatter for an object type in a given
|
* Registers a traversal formatter for an object type in a given context.
|
||||||
* context.
|
|
||||||
*
|
*
|
||||||
* @param type the object type whose items will be traversed
|
* @param type the object type whose items will be traversed
|
||||||
* @param formatter the formatter for controlling object traversal
|
* @param formatter the formatter for controlling object traversal
|
||||||
* @param context the context in which the formatter should be used
|
* @param context the context in which the formatter should be used
|
||||||
*/
|
*/
|
||||||
public static void registerFormatter(String type,
|
public static void registerFormatter(String type,
|
||||||
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),
|
||||||
formatter,
|
formatter,
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisteres a traversal formatter for an object type in a
|
* Unregisteres a traversal formatter for an object type in a given context
|
||||||
* given context
|
|
||||||
*
|
*
|
||||||
* @param type the object type whose items will be traversed
|
* @param type the object type whose items will be traversed
|
||||||
* @param context the context in which the formatter should be used
|
* @param context the context in which the formatter should be used
|
||||||
*/
|
*/
|
||||||
public static void unregisterFormatter(String type,
|
public static void unregisterFormatter(String type,
|
||||||
String context) {
|
String context) {
|
||||||
unregisterFormatter(MetadataRoot.getMetadataRoot().getObjectType(type),
|
unregisterFormatter(MetadataRoot.getMetadataRoot().getObjectType(type),
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the traversal formatter for an object type in a given
|
* Retrieves the traversal formatter for an object type in a given context.
|
||||||
* context.
|
|
||||||
*
|
*
|
||||||
* @param type the object type to lookup
|
* @param type the object type to lookup
|
||||||
* @param context the formatter context
|
* @param context the formatter context
|
||||||
|
|
@ -135,16 +128,15 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the closest matching traversal formatter for an object type
|
* Retrieves the closest matching traversal formatter for an object type in a given context. The algorithm looks for
|
||||||
* in a given context. The algorithm looks for an exact match, then
|
* an exact match, then considers the supertype, and the supertype's supertype. If no match could be found at all,
|
||||||
* considers the supertype, and the supertype's supertype. If no match
|
* returns null
|
||||||
* could be found at all, returns null
|
|
||||||
*
|
*
|
||||||
* @param type the object type to search for
|
* @param type the object type to search for
|
||||||
* @param context the formatter context
|
* @param context the formatter context
|
||||||
*/
|
*/
|
||||||
public static DomainObjectXMLFormatter findFormatter(ObjectType type,
|
public static DomainObjectXMLFormatter findFormatter(ObjectType type,
|
||||||
String context) {
|
String context) {
|
||||||
DomainObjectXMLFormatter formatter = null;
|
DomainObjectXMLFormatter formatter = null;
|
||||||
while (formatter == null && type != null) {
|
while (formatter == null && type != null) {
|
||||||
formatter = getFormatter(type, context);
|
formatter = getFormatter(type, context);
|
||||||
|
|
@ -157,9 +149,7 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new DomainObject XML renderer
|
* Creates a new DomainObject XML renderer that outputs XML into the element passed into the constructor.
|
||||||
* that outputs XML into the element passed into
|
|
||||||
* the constructor.
|
|
||||||
*
|
*
|
||||||
* @param root the XML element in which to output children
|
* @param root the XML element in which to output children
|
||||||
*/
|
*/
|
||||||
|
|
@ -169,20 +159,20 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNamespace(String prefix,
|
public void setNamespace(String prefix,
|
||||||
String uri) {
|
String uri) {
|
||||||
m_namespacePrefix = prefix;
|
m_namespacePrefix = prefix;
|
||||||
m_namespaceURI = uri;
|
m_namespaceURI = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object format(DomainObject obj,
|
protected Object format(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property prop,
|
Property prop,
|
||||||
Object value) {
|
Object value) {
|
||||||
if (m_formatter != null) {
|
if (m_formatter != null) {
|
||||||
String propertyPath = appendToPath(path, prop.getName());
|
String propertyPath = appendToPath(path, prop.getName());
|
||||||
Object rendered = m_formatter.format(obj,
|
Object rendered = m_formatter.format(obj,
|
||||||
propertyPath,
|
propertyPath,
|
||||||
prop, value);
|
prop, value);
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("FORMAT " + obj + " m_formatter=" + m_formatter + " rendered=" + rendered);
|
s_log.debug("FORMAT " + obj + " m_formatter=" + m_formatter + " rendered=" + rendered);
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +188,8 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
rendered = null;
|
rendered = null;
|
||||||
}
|
}
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("FALLBACK supertype " + objectType + " formatter=" + formatter + " rendered=" + rendered);
|
s_log.debug("FALLBACK supertype " + objectType + " formatter=" + formatter + " rendered="
|
||||||
|
+ rendered);
|
||||||
}
|
}
|
||||||
objectType = objectType.getSupertype();
|
objectType = objectType.getSupertype();
|
||||||
}
|
}
|
||||||
|
|
@ -213,11 +204,11 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void walk(DomainObject obj,
|
protected void walk(DomainObject obj,
|
||||||
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);
|
||||||
|
|
@ -231,43 +222,33 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines XML output for root object.
|
* Determines XML output for root object. If set to true a separate element will be output for the root object, if
|
||||||
* If set to true a separate element will
|
* false, then the element passed into the constructor will be used.
|
||||||
* be output for the root object, if false,
|
|
||||||
* then the element passed into the constructor
|
|
||||||
* will be used.
|
|
||||||
*/
|
*/
|
||||||
public void setWrapRoot(boolean value) {
|
public void setWrapRoot(boolean value) {
|
||||||
m_wrapRoot = value;
|
m_wrapRoot = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines XML output used for objects.
|
* Determines XML output used for objects. If set to true, then a wrapper XML element will be generated for the
|
||||||
* If set to true, then a wrapper XML element
|
* association, and then individual elements generated for each object. If false then no wrapper XML element will be
|
||||||
* will be generated for the association,
|
* produced.
|
||||||
* and then individual elements generated for
|
|
||||||
* each object. If false then no wrapper
|
|
||||||
* XML element will be produced.
|
|
||||||
*/
|
*/
|
||||||
public void setWrapObjects(boolean value) {
|
public void setWrapObjects(boolean value) {
|
||||||
m_wrapObjects = value;
|
m_wrapObjects = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines XML output used for scalar
|
* Determines XML output used for scalar attributes. If set to true, then each attribute is output as a separate
|
||||||
* attributes. If set to true, then each
|
* element, otherwise, attributes are output as simple attributes.
|
||||||
* attribute is output as a separate element,
|
|
||||||
* otherwise, attributes are output as simple
|
|
||||||
* attributes.
|
|
||||||
*/
|
*/
|
||||||
public void setWrapAttributes(boolean value) {
|
public void setWrapAttributes(boolean value) {
|
||||||
m_wrapAttributes = value;
|
m_wrapAttributes = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines XML output used for objects.
|
* Determines XML output used for objects. If set to true, then repeated objects will generate full xml. If false
|
||||||
* If set to true, then repeated objects will generate full xml.
|
* then only the OID will be printed.
|
||||||
* If false then only the OID will be printed.
|
|
||||||
*/
|
*/
|
||||||
public void setRevisitFullObject(boolean value) {
|
public void setRevisitFullObject(boolean value) {
|
||||||
m_revisitFullObject = value;
|
m_revisitFullObject = value;
|
||||||
|
|
@ -286,7 +267,7 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void beginObject(DomainObject obj,
|
protected void beginObject(DomainObject obj,
|
||||||
String path) {
|
String path) {
|
||||||
if (m_wrapRoot || !path.equals("/object")) {
|
if (m_wrapRoot || !path.equals("/object")) {
|
||||||
String name = m_wrapObjects ? "object" : nameFromPath(path);
|
String name = m_wrapObjects ? "object" : nameFromPath(path);
|
||||||
Element element = newElement(m_element, name);
|
Element element = newElement(m_element, name);
|
||||||
|
|
@ -301,14 +282,14 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void endObject(DomainObject obj,
|
protected void endObject(DomainObject obj,
|
||||||
String path) {
|
String path) {
|
||||||
if (m_wrapRoot || !path.equals("/object")) {
|
if (m_wrapRoot || !path.equals("/object")) {
|
||||||
m_element = (Element) m_elements.pop();
|
m_element = (Element) m_elements.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void revisitObject(DomainObject obj,
|
protected void revisitObject(DomainObject obj,
|
||||||
String path) {
|
String path) {
|
||||||
Element priorElement = null;
|
Element priorElement = null;
|
||||||
if (m_revisitFullObject) {
|
if (m_revisitFullObject) {
|
||||||
priorElement = (Element) m_objectElements.get(obj.getOID());
|
priorElement = (Element) m_objectElements.get(obj.getOID());
|
||||||
|
|
@ -324,8 +305,8 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleAttribute(DomainObject obj,
|
protected void handleAttribute(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
String name = property.getName();
|
String name = property.getName();
|
||||||
Object value = obj.get(name);
|
Object value = obj.get(name);
|
||||||
|
|
||||||
|
|
@ -346,7 +327,7 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
Date date = (Date) value;
|
Date date = (Date) value;
|
||||||
Calendar calDate = Calendar.getInstance();
|
Calendar calDate = Calendar.getInstance();
|
||||||
calDate.setTime(date);
|
calDate.setTime(date);
|
||||||
|
|
||||||
// locale-independent date output
|
// locale-independent date output
|
||||||
element.addAttribute("year", Integer.toString(calDate.get(Calendar.YEAR)));
|
element.addAttribute("year", Integer.toString(calDate.get(Calendar.YEAR)));
|
||||||
element.addAttribute("month", Integer.toString(calDate.get(Calendar.MONTH) + 1));
|
element.addAttribute("month", Integer.toString(calDate.get(Calendar.MONTH) + 1));
|
||||||
|
|
@ -364,21 +345,22 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
element.addAttribute("date", dateFormatter.format(date));
|
element.addAttribute("date", dateFormatter.format(date));
|
||||||
element.addAttribute("longDate", longDateFormatter.format(date));
|
element.addAttribute("longDate", longDateFormatter.format(date));
|
||||||
element.addAttribute("time", timeFormatter.format(date));
|
element.addAttribute("time", timeFormatter.format(date));
|
||||||
element.addAttribute("monthName", calDate.getDisplayName(Calendar.MONTH, Calendar.LONG, negLocale));
|
element.addAttribute("monthName", calDate.getDisplayName(Calendar.MONTH, Calendar.LONG,
|
||||||
|
negLocale));
|
||||||
// Quasimodo: END
|
// Quasimodo: END
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_element.addAttribute(property.getName(),
|
m_element.addAttribute(property.getName(),
|
||||||
(String) format(obj, path, property, value));
|
(String) format(obj, path, property, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void beginRole(DomainObject obj,
|
protected void beginRole(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
Element element = newElement(m_element, property.getName());
|
Element element = newElement(m_element, property.getName());
|
||||||
m_elements.push(m_element);
|
m_elements.push(m_element);
|
||||||
|
|
@ -387,16 +369,16 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void endRole(DomainObject obj,
|
protected void endRole(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
m_element = (Element) m_elements.pop();
|
m_element = (Element) m_elements.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void beginAssociation(DomainObject obj,
|
protected void beginAssociation(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
Element element = newElement(m_element, property.getName());
|
Element element = newElement(m_element, property.getName());
|
||||||
m_elements.push(m_element);
|
m_elements.push(m_element);
|
||||||
|
|
@ -405,8 +387,8 @@ public class DomainObjectXMLRenderer extends DomainObjectTraversal {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void endAssociation(DomainObject obj,
|
protected void endAssociation(DomainObject obj,
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
m_element = (Element) m_elements.pop();
|
m_element = (Element) m_elements.pop();
|
||||||
}
|
}
|
||||||
|
|
@ -425,20 +407,20 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
// Quasimodo: End
|
// Quasimodo: End
|
||||||
|
|
||||||
Element content = Navigation.newElement("objectList");
|
Element content = Navigation.newElement("objectList");
|
||||||
|
|
||||||
//Return the empty nav:item & nav:paginator tags.
|
//Return the empty nav:item & nav:paginator tags.
|
||||||
// Quasimodo: Why should I??? There is no need for a paginator if there aren't any elements
|
// Quasimodo: Why should I??? There is no need for a paginator if there aren't any elements
|
||||||
if (!m_navItems) {
|
if (!m_navItems) {
|
||||||
|
|
@ -203,9 +203,9 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
paginator.addAttribute("objectCount", new Long(objectCount).toString());
|
paginator.addAttribute("objectCount", new Long(objectCount).toString());
|
||||||
|
|
||||||
content.addContent(paginator);
|
content.addContent(paginator);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (objects.next()) {
|
while (objects.next()) {
|
||||||
DataObject dobj = objects.getDataObject();
|
DataObject dobj = objects.getDataObject();
|
||||||
ACSObject object = null;
|
ACSObject object = null;
|
||||||
if (m_specializeObjects) {
|
if (m_specializeObjects) {
|
||||||
|
|
@ -214,11 +214,10 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
s_log.error(String.format("Failed to specialize object with with id %s. Skiping object.", dobj.getOID().toString()));
|
s_log.error(String.format("Failed to specialize object with with id %s. Skiping object.", dobj.getOID().toString()));
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
s_log.error("Specializing successful.");
|
s_log.debug("Specializing successful.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Element item = Navigation.newElement(content, "item");
|
||||||
Element item = Navigation.newElement("item");
|
|
||||||
|
|
||||||
Iterator attributes = m_attributes.iterator();
|
Iterator attributes = m_attributes.iterator();
|
||||||
while (attributes.hasNext()) {
|
while (attributes.hasNext()) {
|
||||||
|
|
@ -226,23 +225,23 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
String[] paths = StringUtils.split(name, '.');
|
String[] paths = StringUtils.split(name, '.');
|
||||||
outputValue(item, dobj, name, paths, 0);
|
outputValue(item, dobj, name, paths, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator properties = m_properties.iterator();
|
Iterator properties = m_properties.iterator();
|
||||||
while (properties.hasNext()) {
|
while (properties.hasNext()) {
|
||||||
DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.next();
|
DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.next();
|
||||||
property.render(objects, item);
|
property.render(objects, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element path = Navigation.newElement("path");
|
Element path = Navigation.newElement(item, "path");
|
||||||
path.setText(getStableURL(dobj, object));
|
path.setText(getStableURL(dobj, object));
|
||||||
item.addContent(path);
|
//item.addContent(path);
|
||||||
|
|
||||||
generateItemXML(item, dobj, object, index);
|
generateItemXML(item, dobj, object, index);
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
content.addContent(item);
|
//content.addContent(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,11 @@ public class Navigation extends Application {
|
||||||
NavigationConstants.NAV_NS);
|
NavigationConstants.NAV_NS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Element newElement(final Element parent, final String name) {
|
||||||
|
return parent.newChildElement(String.format("%s:%s", NavigationConstants.NAV_PREFIX, name),
|
||||||
|
NavigationConstants.NAV_NS);
|
||||||
|
}
|
||||||
|
|
||||||
public static String redirectURL(OID oid) {
|
public static String redirectURL(OID oid) {
|
||||||
ParameterMap map = new ParameterMap();
|
ParameterMap map = new ParameterMap();
|
||||||
map.setParameter( NavigationConstants.OID, oid.toString() );
|
map.setParameter( NavigationConstants.OID, oid.toString() );
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class CMSDataCollectionRenderer extends DataCollectionRenderer {
|
||||||
DataObject dobj,
|
DataObject dobj,
|
||||||
ACSObject obj,
|
ACSObject obj,
|
||||||
int index) {
|
int index) {
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(item);
|
ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(item);
|
||||||
renderer.setRevisitFullObject(false);
|
renderer.setRevisitFullObject(false);
|
||||||
renderer.setWrapAttributes(true);
|
renderer.setWrapAttributes(true);
|
||||||
|
|
@ -74,7 +74,7 @@ public class CMSDataCollectionRenderer extends DataCollectionRenderer {
|
||||||
* possible to set the adapter context used from a JSP template,
|
* possible to set the adapter context used from a JSP template,
|
||||||
* using DataCollectionRenderer#setSpecializeObjectsContext(String).
|
* using DataCollectionRenderer#setSpecializeObjectsContext(String).
|
||||||
*/
|
*/
|
||||||
renderer.walk(obj, getSpecializeObjectsContext());
|
renderer.walk(obj, getSpecializeObjectsContext());
|
||||||
|
|
||||||
if ((obj instanceof ContentItem) && useExtraXml) {
|
if ((obj instanceof ContentItem) && useExtraXml) {
|
||||||
final ContentItem contentItem = (ContentItem) obj;
|
final ContentItem contentItem = (ContentItem) obj;
|
||||||
|
|
@ -84,7 +84,7 @@ public class CMSDataCollectionRenderer extends DataCollectionRenderer {
|
||||||
generator.generateXML(contentItem, item, null);
|
generator.generateXML(contentItem, item, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,10 @@
|
||||||
*
|
*
|
||||||
* Autor: Sören Bernstein
|
* Autor: Sören Bernstein
|
||||||
*
|
*
|
||||||
* Diese Klasse realisiert eine ObjectList für Navigation,
|
* Diese Klasse realisiert eine ObjectList für Navigation, der man Filterbefehle für die SQL-Abfrage mitgeben kann. Auf
|
||||||
* der man Filterbefehle für die SQL-Abfrage mitgeben kann.
|
* diese Weise lassen sich Objekte listen, die bestimmte Kriterien erfüllen.
|
||||||
* Auf diese Weise lassen sich Objekte listen, die bestimmte
|
|
||||||
* Kriterien erfüllen.
|
|
||||||
*
|
*
|
||||||
* Angelegt wurde Sie für die Auflistung der aktuellen News
|
* Angelegt wurde Sie für die Auflistung der aktuellen News und Veranstalungen auf einer Navigationsseite.
|
||||||
* und Veranstalungen auf einer Navigationsseite.
|
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.navigation.ui.object;
|
package com.arsdigita.navigation.ui.object;
|
||||||
|
|
||||||
|
|
@ -50,9 +47,9 @@ public class ComplexObjectList extends AbstractObjectList {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hinzufügen eines SQL-Filter zur Abfrage
|
* Hinzufügen eines SQL-Filter zur Abfrage Verarbeitet einen boolschen Filter, der SQL-konform Formatiert ist. Siehe
|
||||||
* Verarbeitet einen boolschen Filter, der SQL-konform Formatiert ist.
|
* PostgreSQL-Handbuch zur where-Klausel
|
||||||
* Siehe PostgreSQL-Handbuch zur where-Klausel
|
*
|
||||||
* @param sqlfilter
|
* @param sqlfilter
|
||||||
*/
|
*/
|
||||||
public void setSQLFilter(String sqlfilter) {
|
public void setSQLFilter(String sqlfilter) {
|
||||||
|
|
@ -75,8 +72,8 @@ public class ComplexObjectList extends AbstractObjectList {
|
||||||
m_customAttributes.put(attribute, value);
|
m_customAttributes.put(attribute, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Diese Methode überschreibt die Methode aus der Eltern-Klasse, um
|
/*
|
||||||
* die SQL-Filter berücksichtigen zu können
|
* Diese Methode überschreibt die Methode aus der Eltern-Klasse, um die SQL-Filter berücksichtigen zu können
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected DataCollection getObjects(HttpServletRequest request,
|
protected DataCollection getObjects(HttpServletRequest request,
|
||||||
|
|
@ -109,7 +106,9 @@ public class ComplexObjectList extends AbstractObjectList {
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Diese Methode wird vom Servlet aufgerufen */
|
/*
|
||||||
|
* Diese Methode wird vom Servlet aufgerufen
|
||||||
|
*/
|
||||||
public Element generateXML(HttpServletRequest request,
|
public Element generateXML(HttpServletRequest request,
|
||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
Element content = Navigation.newElement("complexObjectList");
|
Element content = Navigation.newElement("complexObjectList");
|
||||||
|
|
@ -121,9 +120,9 @@ public class ComplexObjectList extends AbstractObjectList {
|
||||||
for (Map.Entry<String, String> attribute : m_customAttributes.entrySet()) {
|
for (Map.Entry<String, String> attribute : m_customAttributes.entrySet()) {
|
||||||
content.addAttribute(attribute.getKey(), attribute.getValue());
|
content.addAttribute(attribute.getKey(), attribute.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
content.addContent(generateObjectListXML(request, response));
|
content.addContent(generateObjectListXML(request, response));
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,7 @@ import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
|
||||||
import com.arsdigita.cms.contenttypes.SeriesCollection;
|
import com.arsdigita.cms.contenttypes.SeriesCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract base implementation of the {@link RisConverter} interface
|
* An abstract base implementation of the {@link RisConverter} interface providing common functionality.
|
||||||
* providing common functionality.
|
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
*/
|
*/
|
||||||
|
|
@ -66,16 +65,18 @@ public abstract class AbstractRisConverter implements RisConverter {
|
||||||
|
|
||||||
protected void convertYear(final Publication publication) {
|
protected void convertYear(final Publication publication) {
|
||||||
getRisBuilder().addField(RisFields.PY,
|
getRisBuilder().addField(RisFields.PY,
|
||||||
String.format("%d///", publication.
|
String.format("%d///", publication.getYearOfPublication()));
|
||||||
getYearOfPublication()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void convertPublisher(final PublicationWithPublisher publication) {
|
protected void convertPublisher(final PublicationWithPublisher publication) {
|
||||||
|
convertPublisher(publication, RisFields.CY);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void convertPublisher(final PublicationWithPublisher publication, final RisFields placeField) {
|
||||||
if (publication.getPublisher() != null) {
|
if (publication.getPublisher() != null) {
|
||||||
if ((publication.getPublisher().getPlace() != null)
|
if ((publication.getPublisher().getPlace() != null)
|
||||||
&& !(publication.getPublisher().getPlace().isEmpty())) {
|
&& !(publication.getPublisher().getPlace().isEmpty())) {
|
||||||
getRisBuilder().addField(RisFields.CY,
|
getRisBuilder().addField(placeField, publication.getPublisher().getPlace());
|
||||||
publication.getPublisher().getPlace());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getRisBuilder().addField(RisFields.PB,
|
getRisBuilder().addField(RisFields.PB,
|
||||||
|
|
|
||||||
|
|
@ -56,18 +56,18 @@ public class ArticleInCollectedVolumeConverter extends AbstractRisConverter {
|
||||||
convertYear(publication);
|
convertYear(publication);
|
||||||
|
|
||||||
if (article.getCollectedVolume() != null) {
|
if (article.getCollectedVolume() != null) {
|
||||||
getRisBuilder().addField(RisFields.BT,
|
getRisBuilder().addField(RisFields.T2,
|
||||||
article.getCollectedVolume().getTitle());
|
article.getCollectedVolume().getTitle());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (article.getPagesFrom() != null) {
|
if (article.getPagesFrom() != null) {
|
||||||
getRisBuilder().addField(RisFields.SP,
|
getRisBuilder().addField(RisFields.SP,
|
||||||
article.getPagesFrom().toString());
|
String.format("%d - %d", article.getPagesFrom(), article.getPagesTo()));
|
||||||
if (article.getPagesTo() != null) {
|
/*if (article.getPagesTo() != null) {
|
||||||
getRisBuilder().addField(RisFields.EP,
|
getRisBuilder().addField(RisFields.EP,
|
||||||
article.getPagesTo().toString());
|
article.getPagesTo().toString());
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return getRisBuilder().toRis();
|
return getRisBuilder().toRis();
|
||||||
|
|
|
||||||
|
|
@ -50,16 +50,20 @@ public class ArticleInJournalConverter extends AbstractRisConverter {
|
||||||
|
|
||||||
article = (ArticleInJournal) publication;
|
article = (ArticleInJournal) publication;
|
||||||
|
|
||||||
getRisBuilder().setType(RisTypes.MGZN);
|
getRisBuilder().setType(RisTypes.JOUR);
|
||||||
convertAuthors(publication);
|
convertAuthors(publication);
|
||||||
convertTitle(publication);
|
convertTitle(publication);
|
||||||
convertYear(publication);
|
convertYear(publication);
|
||||||
|
|
||||||
if (article.getJournal() != null) {
|
if (article.getJournal() != null) {
|
||||||
getRisBuilder().addField(RisFields.JF,
|
getRisBuilder().addField(RisFields.T2,
|
||||||
article.getJournal().getTitle());
|
article.getJournal().getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (article.getIssue() != null) {
|
||||||
|
getRisBuilder().addField(RisFields.M1, article.getIssue());
|
||||||
|
}
|
||||||
|
|
||||||
if (article.getVolume() != null) {
|
if (article.getVolume() != null) {
|
||||||
getRisBuilder().addField(RisFields.VL,
|
getRisBuilder().addField(RisFields.VL,
|
||||||
article.getVolume().toString());
|
article.getVolume().toString());
|
||||||
|
|
@ -67,11 +71,17 @@ public class ArticleInJournalConverter extends AbstractRisConverter {
|
||||||
|
|
||||||
if (article.getPagesFrom() != null) {
|
if (article.getPagesFrom() != null) {
|
||||||
getRisBuilder().addField(RisFields.SP,
|
getRisBuilder().addField(RisFields.SP,
|
||||||
article.getPagesFrom().toString());
|
String.format("%d - %d", article.getPagesFrom(), article.getPagesTo()));
|
||||||
getRisBuilder().addField(RisFields.EP,
|
/*
|
||||||
|
* getRisBuilder().addField(RisFields.EP,
|
||||||
article.getPagesTo().toString());
|
article.getPagesTo().toString());
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (article.getReviewed()) {
|
||||||
|
getRisBuilder().addField(RisFields.RI, "");
|
||||||
|
}
|
||||||
|
|
||||||
return getRisBuilder().toRis();
|
return getRisBuilder().toRis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class CollectedVolumeConverter extends AbstractRisConverter {
|
||||||
|
|
||||||
collectedVolume = (CollectedVolume) publication;
|
collectedVolume = (CollectedVolume) publication;
|
||||||
|
|
||||||
getRisBuilder().setType(RisTypes.BOOK);
|
getRisBuilder().setType(RisTypes.EDBOOK);
|
||||||
convertAuthors(publication);
|
convertAuthors(publication);
|
||||||
|
|
||||||
convertTitle(publication);
|
convertTitle(publication);
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,22 @@ public class GreyLiteratureConverter extends AbstractRisConverter {
|
||||||
|
|
||||||
greyLiterature = (GreyLiterature) publication;
|
greyLiterature = (GreyLiterature) publication;
|
||||||
|
|
||||||
getRisBuilder().setType(RisTypes.GEN);
|
getRisBuilder().setType(RisTypes.UNPB);
|
||||||
convertAuthors(publication);
|
convertAuthors(publication);
|
||||||
convertTitle(publication);
|
convertTitle(publication);
|
||||||
convertYear(publication);
|
convertYear(publication);
|
||||||
|
|
||||||
|
if (greyLiterature.getPlace() != null) {
|
||||||
|
getRisBuilder().addField(RisFields.CY, greyLiterature.getPlace());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (greyLiterature.getNumber() != null) {
|
||||||
|
getRisBuilder().addField(RisFields.M1, greyLiterature.getNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (greyLiterature.getOrganization() != null) {
|
||||||
|
getRisBuilder().addField(RisFields.PB, greyLiterature.getOrganization().getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
return getRisBuilder().toRis();
|
return getRisBuilder().toRis();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,31 +51,30 @@ public class InProceedingsConverter extends AbstractRisConverter {
|
||||||
|
|
||||||
inProceedings = (InProceedings) publication;
|
inProceedings = (InProceedings) publication;
|
||||||
|
|
||||||
getRisBuilder().setType(RisTypes.GEN);
|
getRisBuilder().setType(RisTypes.CPAPER);
|
||||||
convertAuthors(publication);
|
convertAuthors(publication);
|
||||||
convertTitle(publication);
|
convertTitle(publication);
|
||||||
convertYear(publication);
|
convertYear(publication);
|
||||||
|
|
||||||
|
if (inProceedings.getProceedings() != null) {
|
||||||
|
final Proceedings proceedings = inProceedings.getProceedings();
|
||||||
|
if (proceedings.getPlaceOfConference() != null) {
|
||||||
|
getRisBuilder().addField(RisFields.CY, proceedings.getPlaceOfConference());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (inProceedings.getPagesFrom() != null) {
|
if (inProceedings.getPagesFrom() != null) {
|
||||||
getRisBuilder().addField(RisFields.SP,
|
getRisBuilder().addField(RisFields.SP,
|
||||||
inProceedings.getPagesFrom().toString());
|
String.format("%d - %d",
|
||||||
getRisBuilder().addField(RisFields.EP,
|
inProceedings.getPagesFrom(),
|
||||||
inProceedings.getPagesTo().toString());
|
inProceedings.getPagesTo()));
|
||||||
|
/*getRisBuilder().addField(RisFields.EP,
|
||||||
|
inProceedings.getPagesTo().toString());*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inProceedings.getProceedings() != null) {
|
|
||||||
Proceedings proceedings;
|
|
||||||
|
|
||||||
proceedings = inProceedings.getProceedings();
|
|
||||||
|
|
||||||
getRisBuilder().addField(RisFields.BT,
|
|
||||||
proceedings.getTitle());
|
|
||||||
|
|
||||||
convertVolume(proceedings);
|
|
||||||
convertSeries(proceedings);
|
|
||||||
convertPublisher(proceedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
return getRisBuilder().toString();
|
return getRisBuilder().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,18 @@ public class InternetArticleConverter extends AbstractRisConverter {
|
||||||
|
|
||||||
article = (InternetArticle) publication;
|
article = (InternetArticle) publication;
|
||||||
|
|
||||||
getRisBuilder().setType(RisTypes.GEN);
|
getRisBuilder().setType(RisTypes.EJOUR);
|
||||||
convertAuthors(publication);
|
convertAuthors(publication);
|
||||||
convertTitle(publication);
|
convertTitle(publication);
|
||||||
convertYear(publication);
|
convertYear(publication);
|
||||||
|
|
||||||
|
if (article.getReviewed()) {
|
||||||
|
getRisBuilder().addField(RisFields.RI, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (article.getUrl() != null) {
|
||||||
|
getRisBuilder().addField(RisFields.UR, article.getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
return getRisBuilder().toRis();
|
return getRisBuilder().toRis();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,17 @@ public class ProceedingsConverter extends AbstractRisConverter {
|
||||||
|
|
||||||
convertVolume(proceedings);
|
convertVolume(proceedings);
|
||||||
convertSeries(publication);
|
convertSeries(publication);
|
||||||
convertPublisher(proceedings);
|
convertPublisher(proceedings, RisFields.C1);
|
||||||
|
|
||||||
|
if (proceedings.getPlaceOfConference() != null) {
|
||||||
|
getRisBuilder().addField(RisFields.CY, proceedings.getPlaceOfConference());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proceedings.getNameOfConference() != null) {
|
||||||
|
getRisBuilder().addField(RisFields.T2, proceedings.getNameOfConference());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return getRisBuilder().toRis();
|
return getRisBuilder().toRis();
|
||||||
|
|
|
||||||
|
|
@ -331,5 +331,16 @@ public enum RisFields {
|
||||||
* Edition. Not found in the specification, but used but by some other
|
* Edition. Not found in the specification, but used but by some other
|
||||||
* exports.
|
* exports.
|
||||||
*/
|
*/
|
||||||
ET
|
ET,
|
||||||
|
/**
|
||||||
|
* Reviewed item
|
||||||
|
*/
|
||||||
|
RI,
|
||||||
|
/**
|
||||||
|
* DA
|
||||||
|
*/
|
||||||
|
DA,
|
||||||
|
C1,
|
||||||
|
C2,
|
||||||
|
C3
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,10 @@ public enum RisTypes {
|
||||||
* Conference proceedings
|
* Conference proceedings
|
||||||
*/
|
*/
|
||||||
CONF,
|
CONF,
|
||||||
|
/**
|
||||||
|
* Conference Paper
|
||||||
|
*/
|
||||||
|
CPAPER,
|
||||||
/**
|
/**
|
||||||
* Catalog
|
* Catalog
|
||||||
*/
|
*/
|
||||||
|
|
@ -70,10 +74,18 @@ public enum RisTypes {
|
||||||
* Data file
|
* Data file
|
||||||
*/
|
*/
|
||||||
DATA,
|
DATA,
|
||||||
|
/**
|
||||||
|
* Edited book
|
||||||
|
*/
|
||||||
|
EDBOOK,
|
||||||
/**
|
/**
|
||||||
* Electronic citation
|
* Electronic citation
|
||||||
*/
|
*/
|
||||||
ELEC,
|
ELEC,
|
||||||
|
/**
|
||||||
|
* Eletronic Article
|
||||||
|
*/
|
||||||
|
EJOUR,
|
||||||
/**
|
/**
|
||||||
* Generic
|
* Generic
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue