Fix von Sören, damit die Datumsangaben in den Object Lists korrekt an die gewählte Sprache angepasst werden. Zusaetzlich muss das theme angepasst werden!
git-svn-id: https://svn.libreccm.org/ccm/trunk@545 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
e855c3e199
commit
ec4bc5fa78
|
|
@ -36,12 +36,14 @@ import com.arsdigita.web.URL;
|
||||||
import com.arsdigita.web.ParameterMap;
|
import com.arsdigita.web.ParameterMap;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
// Quasimodo: End
|
// Quasimodo: End
|
||||||
|
import java.text.DateFormat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -83,7 +85,7 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
* same category.
|
* same category.
|
||||||
* This flag toggles the generation of nav:item xml elements.
|
* This flag toggles the generation of nav:item xml elements.
|
||||||
*/
|
*/
|
||||||
public void setNavItems (boolean navItems){
|
public void setNavItems(boolean navItems) {
|
||||||
m_navItems = navItems;
|
m_navItems = navItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,8 +99,8 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
m_wrapAttributes = wrapAttributes;
|
m_wrapAttributes = wrapAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getAttributes () {
|
public List getAttributes() {
|
||||||
return m_attributes;
|
return m_attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -111,23 +113,23 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
// Quasimodo: Begin
|
// Quasimodo: Begin
|
||||||
// If objects is empty, do not insert objectList-element but do insert noContent-element
|
// If objects is empty, do not insert objectList-element but do insert noContent-element
|
||||||
// and return immediately
|
// and return immediately
|
||||||
if(objects.isEmpty()) {
|
if (objects.isEmpty()) {
|
||||||
return Navigation.newElement("noContent");
|
return Navigation.newElement("noContent");
|
||||||
}
|
}
|
||||||
// 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) {
|
||||||
Element paginator = Navigation.newElement("paginator");
|
Element paginator = Navigation.newElement("paginator");
|
||||||
content.addContent(paginator);
|
content.addContent(paginator);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
long objectCount = objects.size();
|
long objectCount = objects.size();
|
||||||
int pageCount = (int)Math.ceil((double)objectCount / (double)m_pageSize);
|
int pageCount = (int) Math.ceil((double) objectCount / (double) m_pageSize);
|
||||||
|
|
||||||
if (pageNumber < 1) {
|
if (pageNumber < 1) {
|
||||||
pageNumber = 1;
|
pageNumber = 1;
|
||||||
|
|
@ -137,12 +139,12 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
pageNumber = (pageCount == 0 ? 1 : pageCount);
|
pageNumber = (pageCount == 0 ? 1 : pageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
long begin = ((pageNumber-1) * m_pageSize);
|
long begin = ((pageNumber - 1) * m_pageSize);
|
||||||
int count = (int)Math.min(m_pageSize, (objectCount - begin));
|
int count = (int) Math.min(m_pageSize, (objectCount - begin));
|
||||||
long end = begin + count;
|
long end = begin + count;
|
||||||
|
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
objects.setRange(new Integer((int)begin+1), new Integer((int)end+1));
|
objects.setRange(new Integer((int) begin + 1), new Integer((int) end + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
Element paginator = Navigation.newElement("paginator");
|
Element paginator = Navigation.newElement("paginator");
|
||||||
|
|
@ -150,29 +152,29 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
// Quasimodo: Begin
|
// Quasimodo: Begin
|
||||||
// Copied from com.arsdigita.search.ui.ResultPane
|
// Copied from com.arsdigita.search.ui.ResultPane
|
||||||
String pageParam = "pageNumber";
|
String pageParam = "pageNumber";
|
||||||
|
|
||||||
URL url = Web.getContext().getRequestURL();
|
URL url = Web.getContext().getRequestURL();
|
||||||
ParameterMap map = new ParameterMap();
|
ParameterMap map = new ParameterMap();
|
||||||
|
|
||||||
if (url.getParameterMap() != null) {
|
if (url.getParameterMap() != null) {
|
||||||
Iterator current = url.getParameterMap().keySet().iterator();
|
Iterator current = url.getParameterMap().keySet().iterator();
|
||||||
while (current.hasNext()) {
|
while (current.hasNext()) {
|
||||||
String key = (String)current.next();
|
String key = (String) current.next();
|
||||||
if (key.equals(pageParam)) {
|
if (key.equals(pageParam)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
map.setParameterValues(key, url.getParameterValues(key));
|
map.setParameterValues(key, url.getParameterValues(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paginator.addAttribute("pageParam", pageParam);
|
paginator.addAttribute("pageParam", pageParam);
|
||||||
paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map).toString());
|
paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map).toString());
|
||||||
// Quasimodo: End
|
// Quasimodo: End
|
||||||
|
|
||||||
paginator.addAttribute("pageNumber", new Long(pageNumber).toString());
|
paginator.addAttribute("pageNumber", new Long(pageNumber).toString());
|
||||||
paginator.addAttribute("pageCount", new Long(pageCount).toString());
|
paginator.addAttribute("pageCount", new Long(pageCount).toString());
|
||||||
paginator.addAttribute("pageSize", new Long(m_pageSize).toString());
|
paginator.addAttribute("pageSize", new Long(m_pageSize).toString());
|
||||||
paginator.addAttribute("objectBegin", new Long(begin+1).toString());
|
paginator.addAttribute("objectBegin", new Long(begin + 1).toString());
|
||||||
paginator.addAttribute("objectEnd", new Long(end).toString());
|
paginator.addAttribute("objectEnd", new Long(end).toString());
|
||||||
paginator.addAttribute("objectCount", new Long(objectCount).toString());
|
paginator.addAttribute("objectCount", new Long(objectCount).toString());
|
||||||
|
|
||||||
|
|
@ -191,15 +193,15 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
|
|
||||||
Iterator attributes = m_attributes.iterator();
|
Iterator attributes = m_attributes.iterator();
|
||||||
while (attributes.hasNext()) {
|
while (attributes.hasNext()) {
|
||||||
String name = (String)attributes.next();
|
String name = (String) attributes.next();
|
||||||
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("path");
|
||||||
|
|
@ -216,74 +218,89 @@ public class DataCollectionRenderer extends LockableImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getStableURL(DataObject dobj, ACSObject obj) {
|
protected String getStableURL(DataObject dobj, ACSObject obj) {
|
||||||
OID oid = new OID((String)dobj.get(ACSObject.OBJECT_TYPE),
|
OID oid = new OID((String) dobj.get(ACSObject.OBJECT_TYPE),
|
||||||
dobj.get(ACSObject.ID));
|
dobj.get(ACSObject.ID));
|
||||||
return Navigation.redirectURL(oid);
|
return Navigation.redirectURL(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void outputValue( final Element item, final Object value,
|
private void outputValue(final Element item, final Object value,
|
||||||
final String name,
|
final String name,
|
||||||
final String[] paths, final int depth ) {
|
final String[] paths, final int depth) {
|
||||||
if( null == value ) return;
|
if (null == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( value instanceof DataAssociation ) {
|
if (value instanceof DataAssociation) {
|
||||||
DataAssociation assoc = (DataAssociation) value;
|
DataAssociation assoc = (DataAssociation) value;
|
||||||
DataAssociationCursor cursor = assoc.cursor();
|
DataAssociationCursor cursor = assoc.cursor();
|
||||||
|
|
||||||
while( cursor.next() ) {
|
while (cursor.next()) {
|
||||||
outputValue( item, cursor.getDataObject(), name, paths, depth );
|
outputValue(item, cursor.getDataObject(), name, paths, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
} else if (value instanceof DataObject) {
|
||||||
|
|
||||||
else if( value instanceof DataObject ) {
|
|
||||||
try {
|
try {
|
||||||
Object newValue = ((DataObject) value).get( paths[depth] );
|
Object newValue = ((DataObject) value).get(paths[depth]);
|
||||||
outputValue( item, newValue, name, paths, depth + 1 );
|
outputValue(item, newValue, name, paths, depth + 1);
|
||||||
} catch( PersistenceException ex ) {
|
} catch (PersistenceException ex) {
|
||||||
valuePersistenceError( ex, paths, depth );
|
valuePersistenceError(ex, paths, depth);
|
||||||
}
|
}
|
||||||
}
|
} else if (depth == paths.length) {
|
||||||
|
|
||||||
else if( depth == paths.length ) {
|
|
||||||
Element attribute = Navigation.newElement("attribute");
|
Element attribute = Navigation.newElement("attribute");
|
||||||
attribute.addAttribute("name", name);
|
attribute.addAttribute("name", name);
|
||||||
attribute.setText(value.toString());
|
attribute.setText(value.toString());
|
||||||
|
|
||||||
|
// Special handling of Date - see ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
Date date = (Date) value;
|
Date date = (Date) value;
|
||||||
Calendar calDate = Calendar.getInstance();
|
Calendar calDate = Calendar.getInstance();
|
||||||
calDate.setTime(date);
|
calDate.setTime(date);
|
||||||
attribute.addAttribute("year", Integer.toString(calDate.get(Calendar.YEAR)));
|
attribute.addAttribute("year", Integer.toString(calDate.get(Calendar.YEAR)));
|
||||||
attribute.addAttribute("month", Integer.toString(calDate.get(Calendar.MONTH)+1));
|
attribute.addAttribute("month", Integer.toString(calDate.get(Calendar.MONTH) + 1));
|
||||||
attribute.addAttribute("day", Integer.toString(calDate.get(Calendar.DAY_OF_MONTH)));
|
attribute.addAttribute("day", Integer.toString(calDate.get(Calendar.DAY_OF_MONTH)));
|
||||||
attribute.addAttribute("hour", Integer.toString(calDate.get(Calendar.HOUR_OF_DAY)));
|
attribute.addAttribute("hour", Integer.toString(calDate.get(Calendar.HOUR_OF_DAY)));
|
||||||
attribute.addAttribute("minute", Integer.toString(calDate.get(Calendar.MINUTE)));
|
attribute.addAttribute("minute", Integer.toString(calDate.get(Calendar.MINUTE)));
|
||||||
attribute.addAttribute("second", Integer.toString(calDate.get(Calendar.SECOND)));
|
attribute.addAttribute("second", Integer.toString(calDate.get(Calendar.SECOND)));
|
||||||
|
|
||||||
|
// Quasimodo: BEGIN
|
||||||
|
// Add attributes for date and time
|
||||||
|
Locale negLocale = com.arsdigita.dispatcher.DispatcherHelper.getNegotiatedLocale();
|
||||||
|
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM, negLocale);
|
||||||
|
DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT, negLocale);
|
||||||
|
attribute.addAttribute("date", dateFormatter.format(date));
|
||||||
|
attribute.addAttribute("time", timeFormatter.format(date));
|
||||||
|
// Quasimodo: END
|
||||||
|
|
||||||
}
|
}
|
||||||
item.addContent(attribute);
|
item.addContent(attribute);
|
||||||
|
} else {
|
||||||
|
valuePersistenceError(null, paths, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
else valuePersistenceError( null, paths, depth );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void valuePersistenceError( PersistenceException ex,
|
private void valuePersistenceError( PersistenceException ex,
|
||||||
String[] paths, int depth ) {
|
String[] paths, int depth ) {
|
||||||
StringBuffer msg = new StringBuffer();
|
StringBuffer msg = new StringBuffer();
|
||||||
msg.append( "Attribute " );
|
msg.append("Attribute ");
|
||||||
for( int i=0; i <= depth; i++ ) {
|
for (int i = 0; i <= depth; i++) {
|
||||||
msg.append( paths[i] );
|
msg.append(paths[i]);
|
||||||
if( i != depth ) msg.append( '.' );
|
if (i != depth) {
|
||||||
|
msg.append('.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msg.append( " doesn't exist" );
|
msg.append(" doesn't exist");
|
||||||
|
|
||||||
if( null == ex ) s_log.warn( msg.toString() );
|
if (null == ex) {
|
||||||
else s_log.warn( msg.toString(), ex );
|
s_log.warn(msg.toString());
|
||||||
|
} else {
|
||||||
|
s_log.warn(msg.toString(), ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateItemXML(Element item,
|
protected void generateItemXML(Element item,
|
||||||
DataObject dobj,
|
DataObject dobj,
|
||||||
ACSObject obj,
|
ACSObject obj,
|
||||||
int index) {
|
int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue