Moving to XML
|
Let's see that again (i) the source
public class DayView extends DocumentGeneratorImpl
{
/** generate a document containing all the details of this session
* in this context */
public Document generate( ServiceContext context)
throws DataStoreException, SQLException
{
DocumentImpl doc = new DocumentImpl();
String day = context.getValueAsString( "day");
uk.co.weft.dbutil.Calendar when = new uk.co.weft.dbutil.Calendar();
if ( day == null) // default to today
day = new java.sql.Date( when.getTime().getTime()).toString();
else
when.setTime( java.sql.Date.valueOf( day));
doc.appendChild( new ElementImpl( doc, "eventsdiary"));
Element content = doc.getDocumentElement();
content.setAttribute( "date", when.toString());
String q = "select EVENT.Actor, EVENT.Event, " +
"CATEGORY.Description as Type, " +
"LOCATION.Description as Location, " +
"EVENT.EventDate, EVENT.StartTime, EVENT.EndTime, " +
"LOCATION.Description as Location, " +
"EVENT.Description " +
"from EVENT, CATEGORY, LOCATION " +
"where EVENT.EventDate = '" + day + "'" +
"and EVENT.Location = LOCATION.Location " +
"and EVENT.Category = CATEGORY.Category " +
"order by EventDate, StartTime";
Connection c = context.getConnection();
Statement s = c.createStatement();
ResultSet r = s.executeQuery( q);
Contexts events = new Contexts( r);
Enumeration e = events.elements();
while ( e.hasMoreElements())
content.appendChild( new
EventElement( doc, ( Context) e.nextElement()));
s.close();
context.releaseConnection( c);
return doc;
}
}
An older version of this course
is available here