[Bedework-commit] r657 - in trunk/calendar3:
appcommon/src/org/bedework/appcommon
calCore/src/org/bedework/calcore/hibernate
calFacade/src/org/bedework/calfacade
calFacade/src/org/bedework/calfacade/util
calsvc/src/org/bedework/calsvc webclient/war/docs
svnadmin at bedework.org
svnadmin at bedework.org
Sun Jun 25 01:04:50 EDT 2006
Author: douglm
Date: 2006-06-25 01:04:42 -0400 (Sun, 25 Jun 2006)
New Revision: 657
Added:
trunk/calendar3/calFacade/src/org/bedework/calfacade/util/
trunk/calendar3/calFacade/src/org/bedework/calfacade/util/Granulator.java
Modified:
trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java
trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeViewDailyInfo.java
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java
trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
trunk/calendar3/webclient/war/docs/main.jsp
Log:
Remove unnecessary checks in jsp and split out some code into new class
Modified: trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java
===================================================================
--- trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java 2006-06-24 04:33:26 UTC (rev 656)
+++ trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java 2006-06-25 05:04:42 UTC (rev 657)
@@ -286,8 +286,10 @@
}
ArrayList al = new ArrayList();
-// Dur oneDay = new Dur(1, 0, 0, 0);
- long millis = System.currentTimeMillis();
+ long millis = 0;
+ if (debug) {
+ millis = System.currentTimeMillis();
+ }
//tzcache.setSysTimezones(cal.getTimezones());
BwDateTime startDt = CalFacadeUtil.getDateTime(date.getDateDigits(),
Modified: trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeViewDailyInfo.java
===================================================================
--- trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeViewDailyInfo.java 2006-06-24 04:33:26 UTC (rev 656)
+++ trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeViewDailyInfo.java 2006-06-25 05:04:42 UTC (rev 657)
@@ -548,7 +548,7 @@
}
/**
- * @return Collection
+ * @return Collection - never null.
* @throws Throwable
*/
public Collection getEventFormatters() throws Throwable {
@@ -564,7 +564,7 @@
Iterator it = events.iterator();
while (it.hasNext()) {
- eventFormatters.add(new EventFormatter(view.getSvcI(),
+ eventFormatters.add(new EventFormatter(view.getSvcI(),
(EventInfo)it.next(), view,
calInfo, view.getTimezones()));
}
Modified: trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
===================================================================
--- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java 2006-06-24 04:33:26 UTC (rev 656)
+++ trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java 2006-06-25 05:04:42 UTC (rev 657)
@@ -79,10 +79,7 @@
import org.bedework.calfacade.CalFacadeAccessException;
import org.bedework.calfacade.CalFacadeDefs;
import org.bedework.calfacade.CalFacadeException;
-import org.bedework.calfacade.CalFacadeUtil;
import org.bedework.calfacade.CoreEventInfo;
-import org.bedework.calfacade.CalFacadeUtil.EventPeriod;
-import org.bedework.calfacade.CalFacadeUtil.GetPeriodsPars;
import org.bedework.calfacade.base.BwShareableDbentity;
import org.bedework.calfacade.base.CalintfBase;
import org.bedework.calfacade.filter.BwFilter;
@@ -91,6 +88,9 @@
import org.bedework.calfacade.ifs.EventsI;
import org.bedework.calfacade.ifs.Groups;
import org.bedework.calfacade.svc.EventInfo;
+import org.bedework.calfacade.util.Granulator;
+import org.bedework.calfacade.util.Granulator.EventPeriod;
+import org.bedework.calfacade.util.Granulator.GetPeriodsPars;
import org.bedework.icalendar.IcalTranslator;
import java.sql.Timestamp;
@@ -1095,7 +1095,7 @@
}
limit--;
- Collection periodEvents = CalFacadeUtil.getPeriodsEvents(gpp);
+ Collection periodEvents = Granulator.getPeriodsEvents(gpp);
if (returnAll) {
fbc = new BwFreeBusyComponent();
Modified: trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java
===================================================================
--- trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java 2006-06-24 04:33:26 UTC (rev 656)
+++ trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java 2006-06-25 05:04:42 UTC (rev 657)
@@ -54,12 +54,9 @@
package org.bedework.calfacade;
import org.bedework.calfacade.ifs.CalTimezones;
-import org.bedework.calfacade.svc.EventInfo;
-import net.fortuna.ical4j.model.DateTime;
import net.fortuna.ical4j.model.Parameter;
import net.fortuna.ical4j.model.ParameterList;
-import net.fortuna.ical4j.model.Period;
import net.fortuna.ical4j.model.Property;
import net.fortuna.ical4j.model.property.DateProperty;
@@ -630,81 +627,6 @@
return tzid;
}
- /** This class defines the entities which occupy time and the period of
- * interest and can be passed repeatedly to getPeriodsEvents.
- *
- * <p>The end datetime will be updated ready for the next call. If endDt is
- * non-null on entry it will be used to set the startDt.
- */
- public static class GetPeriodsPars {
- /** Event Info or EventPeriod or Period objects to extract from */
- public Collection periods;
- /** Start of period - updated at each call from endDt */
- public BwDateTime startDt;
- /** Duration of period */
- public BwDuration dur;
- /** */
- public CalTimezones tzcache;
-
- /** On return has the end date of the period. */
- public BwDateTime endDt;
- }
-
- /** Select the events in the collection which fall within the period
- * defined by the start and duration.
- *
- * @param pars GetPeriodsPars object
- * @return Collection of EventInfo being one days events or empty for no events.
- * @throws CalFacadeException
- */
- public static Collection getPeriodsEvents(GetPeriodsPars pars) throws CalFacadeException {
- ArrayList al = new ArrayList();
- //long millis = System.currentTimeMillis();
-
- if (pars.endDt != null) {
- pars.startDt = pars.endDt.copy(pars.tzcache);
- }
- pars.endDt = pars.startDt.addDuration(pars.dur, pars.tzcache);
- String start = pars.startDt.getDate();
- String end = pars.endDt.getDate();
-
- //if (debug) {
- // debugMsg("Did UTC stuff in " + (System.currentTimeMillis() - millis));
- //}
-
- EntityRange er = new EntityRange();
- Iterator it = pars.periods.iterator();
- while (it.hasNext()) {
- er.setEntity(it.next());
-
- /* Period is within range if:
- ((evstart < end) and ((evend > start) or
- ((evstart = evend) and (evend >= start))))
- */
-
- int evstSt = er.start.compareTo(end);
-
- //debugMsg(" event " + evStart + " to " + evEnd);
-
- if (evstSt < 0) {
- int evendSt = er.end.compareTo(start);
-
- if ((evendSt > 0) ||
- (er.start.equals(er.end) && (evendSt >= 0))) {
- // Passed the tests.
- //if (debug) {
- // debugMsg("Event passed range " + start + "-" + end +
- // " with dates " + evStart + "-" + evEnd +
- // ": " + ev.getSummary());
- //}
- al.add(er.entity);
- }
- }
- }
-
- return al;
- }
-
/** Turn the int minutes into a 4 digit String hours and minutes value
*
* @param minutes int
@@ -725,133 +647,4 @@
return "0" + String.valueOf(val);
}
-
- private static class EntityRange {
- Object entity;
-
- String start;
- String end;
-
- void setEntity(Object o) throws CalFacadeException {
- entity = o;
-
- if (o instanceof EventInfo) {
- EventInfo ei = (EventInfo)o;
- BwEvent ev = ei.getEvent();
-
- start = ev.getDtstart().getDate();
- end = ev.getDtend().getDate();
-
- return;
- }
-
- if (o instanceof EventPeriod) {
- EventPeriod ep = (EventPeriod)o;
-
- start = String.valueOf(ep.getStart());
- end = String.valueOf(ep.getEnd());
-
- return;
- }
-
- if (o instanceof Period) {
- Period p = (Period)o;
-
- start = String.valueOf(p.getStart());
- end = String.valueOf(p.getEnd());
-
- return;
- }
-
- start = null;
- end = null;
- }
- }
-
- /**
- *
- */
- public static class EventPeriod implements Comparable {
- private DateTime start;
- private DateTime end;
- private int type; // from BwFreeBusyComponent
-
- /** Constructor
- *
- * @param start
- * @param end
- * @param type
- */
- public EventPeriod(DateTime start, DateTime end, int type) {
- this.start = start;
- this.end = end;
- this.type = type;
- }
-
- /**
- * @return DateTime
- */
- public DateTime getStart() {
- return start;
- }
-
- /**
- * @return DateTime
- */
- public DateTime getEnd() {
- return end;
- }
-
- /**
- * @return int
- */
- public int getType() {
- return type;
- }
-
- public int compareTo(Object o) {
- if (!(o instanceof EventPeriod)) {
- return -1;
- }
-
- EventPeriod that = (EventPeriod)o;
-
- /* Sort by type first */
- if (type < that.type) {
- return -1;
- }
-
- if (type > that.type) {
- return 1;
- }
-
- int res = start.compareTo(that.start);
- if (res != 0) {
- return res;
- }
-
- return end.compareTo(that.end);
- }
-
- public boolean equals(Object o) {
- return compareTo(o) == 0;
- }
-
- public int hashCode() {
- return 7 * (type + 1) * (start.hashCode() + 1) * (end.hashCode() + 1);
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer("EventPeriod{start=");
-
- sb.append(start);
- sb.append(", end=");
- sb.append(end);
- sb.append(", type=");
- sb.append(type);
- sb.append("}");
-
- return sb.toString();
- }
- }
}
Added: trunk/calendar3/calFacade/src/org/bedework/calfacade/util/Granulator.java
===================================================================
--- trunk/calendar3/calFacade/src/org/bedework/calfacade/util/Granulator.java (rev 0)
+++ trunk/calendar3/calFacade/src/org/bedework/calfacade/util/Granulator.java 2006-06-25 05:04:42 UTC (rev 657)
@@ -0,0 +1,276 @@
+/* **********************************************************************
+ Copyright 2005 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+ Redistribution and use of this distribution in source and binary forms,
+ with or without modification, are permitted provided that:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.calfacade.util;
+
+import org.bedework.calfacade.BwDateTime;
+import org.bedework.calfacade.BwDuration;
+import org.bedework.calfacade.BwEvent;
+import org.bedework.calfacade.CalFacadeException;
+import org.bedework.calfacade.ifs.CalTimezones;
+import org.bedework.calfacade.svc.EventInfo;
+
+import net.fortuna.ical4j.model.DateTime;
+import net.fortuna.ical4j.model.Period;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.log4j.Logger;
+
+/** Select periods in the Collection of periods which fall within a given
+ * time period. By incrementing that time period we can break up the given
+ * periods into time periods of a given granularity.
+ *
+ * <p>Don't make much sense? Try an example:
+ *
+ * <p>The given set of periods is a set of events for the week. The granularity
+ * is one day - each call gives events appearing in that day - possibly extending
+ * into previous and next days.
+ *
+ * <p>Another? The periods are a set of freebusy objects defining busy time for
+ * one day.
+ * The granularity is 30 minutes. The result is a free busy for a day divided
+ * into 30 minute periods.
+ *
+ * @author Mike Douglass douglm at rpi.edu
+ */
+public class Granulator {
+ private Granulator() {}
+
+ /** This class defines the entities which occupy time and the period of
+ * interest and can be passed repeatedly to getPeriodsEvents.
+ *
+ * <p>The end datetime will be updated ready for the next call. If endDt is
+ * non-null on entry it will be used to set the startDt.
+ */
+ public static class GetPeriodsPars {
+ boolean debug = false;
+
+ /** Event Info or EventPeriod or Period objects to extract from */
+ public Collection periods;
+ /** Start of period - updated at each call from endDt */
+ public BwDateTime startDt;
+ /** Duration of period or granularity */
+ public BwDuration dur;
+ /** */
+ public CalTimezones tzcache;
+
+ /** On return has the end date of the period. */
+ public BwDateTime endDt;
+ }
+
+ /** Select the events in the collection which fall within the period
+ * defined by the start and duration.
+ *
+ * @param pars GetPeriodsPars object
+ * @return Collection of EventInfo being one days events or empty for no events.
+ * @throws CalFacadeException
+ */
+ public static Collection getPeriodsEvents(GetPeriodsPars pars) throws CalFacadeException {
+ ArrayList al = new ArrayList();
+ long millis = 0;
+ if (pars.debug) {
+ millis = System.currentTimeMillis();
+ }
+
+ if (pars.endDt != null) {
+ pars.startDt = pars.endDt.copy(pars.tzcache);
+ }
+ pars.endDt = pars.startDt.addDuration(pars.dur, pars.tzcache);
+ String start = pars.startDt.getDate();
+ String end = pars.endDt.getDate();
+
+ if (pars.debug) {
+ debugMsg("Did UTC stuff in " + (System.currentTimeMillis() - millis));
+ }
+
+ EntityRange er = new EntityRange();
+ Iterator it = pars.periods.iterator();
+ while (it.hasNext()) {
+ er.setEntity(it.next());
+
+ /* Period is within range if:
+ ((evstart < end) and ((evend > start) or
+ ((evstart = evend) and (evend >= start))))
+ */
+
+ int evstSt = er.start.compareTo(end);
+
+ //debugMsg(" event " + evStart + " to " + evEnd);
+
+ if (evstSt < 0) {
+ int evendSt = er.end.compareTo(start);
+
+ if ((evendSt > 0) ||
+ (er.start.equals(er.end) && (evendSt >= 0))) {
+ // Passed the tests.
+ //if (debug) {
+ // debugMsg("Event passed range " + start + "-" + end +
+ // " with dates " + evStart + "-" + evEnd +
+ // ": " + ev.getSummary());
+ //}
+ al.add(er.entity);
+ }
+ }
+ }
+
+ return al;
+ }
+
+ private static class EntityRange {
+ Object entity;
+
+ String start;
+ String end;
+
+ void setEntity(Object o) throws CalFacadeException {
+ entity = o;
+
+ if (o instanceof EventInfo) {
+ EventInfo ei = (EventInfo)o;
+ BwEvent ev = ei.getEvent();
+
+ start = ev.getDtstart().getDate();
+ end = ev.getDtend().getDate();
+
+ return;
+ }
+
+ if (o instanceof EventPeriod) {
+ EventPeriod ep = (EventPeriod)o;
+
+ start = String.valueOf(ep.getStart());
+ end = String.valueOf(ep.getEnd());
+
+ return;
+ }
+
+ if (o instanceof Period) {
+ Period p = (Period)o;
+
+ start = String.valueOf(p.getStart());
+ end = String.valueOf(p.getEnd());
+
+ return;
+ }
+
+ start = null;
+ end = null;
+ }
+ }
+
+ /**
+ *
+ */
+ public static class EventPeriod implements Comparable {
+ private DateTime start;
+ private DateTime end;
+ private int type; // from BwFreeBusyComponent
+
+ /** Constructor
+ *
+ * @param start
+ * @param end
+ * @param type
+ */
+ public EventPeriod(DateTime start, DateTime end, int type) {
+ this.start = start;
+ this.end = end;
+ this.type = type;
+ }
+
+ /**
+ * @return DateTime
+ */
+ public DateTime getStart() {
+ return start;
+ }
+
+ /**
+ * @return DateTime
+ */
+ public DateTime getEnd() {
+ return end;
+ }
+
+ /**
+ * @return int
+ */
+ public int getType() {
+ return type;
+ }
+
+ public int compareTo(Object o) {
+ if (!(o instanceof EventPeriod)) {
+ return -1;
+ }
+
+ EventPeriod that = (EventPeriod)o;
+
+ /* Sort by type first */
+ if (type < that.type) {
+ return -1;
+ }
+
+ if (type > that.type) {
+ return 1;
+ }
+
+ int res = start.compareTo(that.start);
+ if (res != 0) {
+ return res;
+ }
+
+ return end.compareTo(that.end);
+ }
+
+ public boolean equals(Object o) {
+ return compareTo(o) == 0;
+ }
+
+ public int hashCode() {
+ return 7 * (type + 1) * (start.hashCode() + 1) * (end.hashCode() + 1);
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("EventPeriod{start=");
+
+ sb.append(start);
+ sb.append(", end=");
+ sb.append(end);
+ sb.append(", type=");
+ sb.append(type);
+ sb.append("}");
+
+ return sb.toString();
+ }
+ }
+
+ private static void debugMsg(String msg) {
+ Logger.getLogger(Granulator.class).debug(msg);
+ }
+}
Modified: trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
===================================================================
--- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java 2006-06-24 04:33:26 UTC (rev 656)
+++ trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java 2006-06-25 05:04:42 UTC (rev 657)
@@ -54,7 +54,6 @@
package org.bedework.calsvc;
import org.bedework.calenv.CalEnv;
-import org.bedework.calfacade.CalFacadeUtil.GetPeriodsPars;
import org.bedework.calfacade.base.BwOwnedDbentity;
import org.bedework.calfacade.base.BwShareableDbentity;
import org.bedework.calfacade.BwAlarm;
@@ -94,6 +93,8 @@
import org.bedework.calfacade.svc.EventInfo;
import org.bedework.calfacade.svc.UserAuth;
import org.bedework.calfacade.svc.wrappers.BwCalSuiteWrapper;
+import org.bedework.calfacade.util.Granulator;
+import org.bedework.calfacade.util.Granulator.GetPeriodsPars;
import org.bedework.calsvci.CalSvcI;
import org.bedework.calsvci.CalSvcIPars;
import org.bedework.icalendar.IcalCallback;
@@ -1202,7 +1203,7 @@
}
limit--;
- Collection periodEvents = CalFacadeUtil.getPeriodsEvents(gpp);
+ Collection periodEvents = Granulator.getPeriodsEvents(gpp);
if (returnAll) {
fbc = new BwFreeBusyComponent();
Modified: trunk/calendar3/webclient/war/docs/main.jsp
===================================================================
--- trunk/calendar3/webclient/war/docs/main.jsp 2006-06-24 04:33:26 UTC (rev 656)
+++ trunk/calendar3/webclient/war/docs/main.jsp 2006-06-25 05:04:42 UTC (rev 657)
@@ -48,18 +48,13 @@
<shortdate><bean:write name="dayInfo" property="dateShort"/></shortdate>
<%/* Do not produce events if we are in the year view */%>
<logic:equal name="calForm"
- property="curTimeView.showData"
- value="true">
- <logic:notEqual name="dayInfo" property="filler" value="true" >
- <logic:notEmpty name="dayInfo" property="eventFormatters" >
- <logic:iterate id="eventFmt" name="dayInfo"
- property="eventFormatters" >
- <bean:define id="eventFormatter" name="eventFmt"
- toScope="request" />
- <jsp:include page="/docs/event/emitEvent.jsp" />
- </logic:iterate>
- </logic:notEmpty>
- </logic:notEqual>
+ property="curTimeView.showData" value="true">
+ <logic:iterate id="eventFmt" name="dayInfo"
+ property="eventFormatters" >
+ <bean:define id="eventFormatter" name="eventFmt"
+ toScope="request" />
+ <jsp:include page="/docs/event/emitEvent.jsp" />
+ </logic:iterate>
</logic:equal>
</logic:equal>
</day>
More information about the Bedework-commit
mailing list