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.Web;
|
||||
// Quasimodo: End
|
||||
import java.text.DateFormat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -83,7 +85,7 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
* same category.
|
||||
* This flag toggles the generation of nav:item xml elements.
|
||||
*/
|
||||
public void setNavItems (boolean navItems){
|
||||
public void setNavItems(boolean navItems) {
|
||||
m_navItems = navItems;
|
||||
}
|
||||
|
||||
|
|
@ -97,8 +99,8 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
m_wrapAttributes = wrapAttributes;
|
||||
}
|
||||
|
||||
public List getAttributes () {
|
||||
return m_attributes;
|
||||
public List getAttributes() {
|
||||
return m_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -111,7 +113,7 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
// Quasimodo: Begin
|
||||
// If objects is empty, do not insert objectList-element but do insert noContent-element
|
||||
// and return immediately
|
||||
if(objects.isEmpty()) {
|
||||
if (objects.isEmpty()) {
|
||||
return Navigation.newElement("noContent");
|
||||
}
|
||||
// Quasimodo: End
|
||||
|
|
@ -120,14 +122,14 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
|
||||
//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
|
||||
if (! m_navItems) {
|
||||
Element paginator = Navigation.newElement("paginator");
|
||||
content.addContent(paginator);
|
||||
return content;
|
||||
if (!m_navItems) {
|
||||
Element paginator = Navigation.newElement("paginator");
|
||||
content.addContent(paginator);
|
||||
return content;
|
||||
}
|
||||
|
||||
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) {
|
||||
pageNumber = 1;
|
||||
|
|
@ -137,12 +139,12 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
pageNumber = (pageCount == 0 ? 1 : pageCount);
|
||||
}
|
||||
|
||||
long begin = ((pageNumber-1) * m_pageSize);
|
||||
int count = (int)Math.min(m_pageSize, (objectCount - begin));
|
||||
long begin = ((pageNumber - 1) * m_pageSize);
|
||||
int count = (int) Math.min(m_pageSize, (objectCount - begin));
|
||||
long end = begin + count;
|
||||
|
||||
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");
|
||||
|
|
@ -157,7 +159,7 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
if (url.getParameterMap() != null) {
|
||||
Iterator current = url.getParameterMap().keySet().iterator();
|
||||
while (current.hasNext()) {
|
||||
String key = (String)current.next();
|
||||
String key = (String) current.next();
|
||||
if (key.equals(pageParam)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -172,7 +174,7 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
paginator.addAttribute("pageNumber", new Long(pageNumber).toString());
|
||||
paginator.addAttribute("pageCount", new Long(pageCount).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("objectCount", new Long(objectCount).toString());
|
||||
|
||||
|
|
@ -191,15 +193,15 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
|
||||
Iterator attributes = m_attributes.iterator();
|
||||
while (attributes.hasNext()) {
|
||||
String name = (String)attributes.next();
|
||||
String name = (String) attributes.next();
|
||||
String[] paths = StringUtils.split(name, '.');
|
||||
outputValue( item, dobj, name, paths, 0 );
|
||||
outputValue(item, dobj, name, paths, 0);
|
||||
}
|
||||
|
||||
Iterator properties = m_properties.iterator();
|
||||
while( properties.hasNext() ) {
|
||||
while (properties.hasNext()) {
|
||||
DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.next();
|
||||
property.render( objects, item );
|
||||
property.render(objects, item);
|
||||
}
|
||||
|
||||
Element path = Navigation.newElement("path");
|
||||
|
|
@ -216,74 +218,89 @@ public class DataCollectionRenderer extends LockableImpl {
|
|||
}
|
||||
|
||||
protected String getStableURL(DataObject dobj, ACSObject obj) {
|
||||
OID oid = new OID((String)dobj.get(ACSObject.OBJECT_TYPE),
|
||||
dobj.get(ACSObject.ID));
|
||||
OID oid = new OID((String) dobj.get(ACSObject.OBJECT_TYPE),
|
||||
dobj.get(ACSObject.ID));
|
||||
return Navigation.redirectURL(oid);
|
||||
}
|
||||
|
||||
private void outputValue( final Element item, final Object value,
|
||||
final String name,
|
||||
final String[] paths, final int depth ) {
|
||||
if( null == value ) return;
|
||||
private void outputValue(final Element item, final Object value,
|
||||
final String name,
|
||||
final String[] paths, final int depth) {
|
||||
if (null == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( value instanceof DataAssociation ) {
|
||||
if (value instanceof DataAssociation) {
|
||||
DataAssociation assoc = (DataAssociation) value;
|
||||
DataAssociationCursor cursor = assoc.cursor();
|
||||
|
||||
while( cursor.next() ) {
|
||||
outputValue( item, cursor.getDataObject(), name, paths, depth );
|
||||
while (cursor.next()) {
|
||||
outputValue(item, cursor.getDataObject(), name, paths, depth);
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
else if( value instanceof DataObject ) {
|
||||
} else if (value instanceof DataObject) {
|
||||
try {
|
||||
Object newValue = ((DataObject) value).get( paths[depth] );
|
||||
outputValue( item, newValue, name, paths, depth + 1 );
|
||||
} catch( PersistenceException ex ) {
|
||||
valuePersistenceError( ex, paths, depth );
|
||||
Object newValue = ((DataObject) value).get(paths[depth]);
|
||||
outputValue(item, newValue, name, paths, depth + 1);
|
||||
} catch (PersistenceException ex) {
|
||||
valuePersistenceError(ex, paths, depth);
|
||||
}
|
||||
}
|
||||
|
||||
else if( depth == paths.length ) {
|
||||
} else if (depth == paths.length) {
|
||||
Element attribute = Navigation.newElement("attribute");
|
||||
attribute.addAttribute("name", name);
|
||||
attribute.setText(value.toString());
|
||||
|
||||
// Special handling of Date - see ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java
|
||||
if (value instanceof Date) {
|
||||
Date date = (Date) value;
|
||||
Calendar calDate = Calendar.getInstance();
|
||||
calDate.setTime(date);
|
||||
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("hour", Integer.toString(calDate.get(Calendar.HOUR_OF_DAY)));
|
||||
attribute.addAttribute("minute", Integer.toString(calDate.get(Calendar.MINUTE)));
|
||||
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);
|
||||
} else {
|
||||
valuePersistenceError(null, paths, depth);
|
||||
}
|
||||
|
||||
else valuePersistenceError( null, paths, depth );
|
||||
}
|
||||
|
||||
private void valuePersistenceError( PersistenceException ex,
|
||||
String[] paths, int depth ) {
|
||||
StringBuffer msg = new StringBuffer();
|
||||
msg.append( "Attribute " );
|
||||
for( int i=0; i <= depth; i++ ) {
|
||||
msg.append( paths[i] );
|
||||
if( i != depth ) msg.append( '.' );
|
||||
msg.append("Attribute ");
|
||||
for (int i = 0; i <= depth; i++) {
|
||||
msg.append(paths[i]);
|
||||
if (i != depth) {
|
||||
msg.append('.');
|
||||
}
|
||||
}
|
||||
msg.append( " doesn't exist" );
|
||||
msg.append(" doesn't exist");
|
||||
|
||||
if( null == ex ) s_log.warn( msg.toString() );
|
||||
else s_log.warn( msg.toString(), ex );
|
||||
if (null == ex) {
|
||||
s_log.warn(msg.toString());
|
||||
} else {
|
||||
s_log.warn(msg.toString(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateItemXML(Element item,
|
||||
DataObject dobj,
|
||||
ACSObject obj,
|
||||
int index) {
|
||||
DataObject dobj,
|
||||
ACSObject obj,
|
||||
int index) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue