Changeset 375
- Timestamp:
- 04/13/06 23:18:13
- Files:
-
- trunk/calendar3/appcommon/src/org/bedework/appcommon/FormattedFreeBusy.java (added)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwDateTime.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/BwPreferences.java (modified) (3 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (2 diffs)
- trunk/calendar3/webclient/src/org/bedework/webclient/BwActionForm.java (modified) (4 diffs)
- trunk/calendar3/webclient/src/org/bedework/webclient/BwFreeBusyAction.java (modified) (5 diffs)
- trunk/calendar3/webclient/war/docs/freeBusy.jsp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/calFacade/src/org/bedework/calfacade/BwDateTime.java
r366 r375 370 370 } 371 371 372 /** 373 * @param val 374 * @param timezones 375 * @throws CalFacadeException 376 */ 377 public void initFromDateTime(Date val, CalTimezones timezones) throws CalFacadeException { 378 boolean dateOnly = true; 379 String tzid = null; 380 381 if (val instanceof DateTime) { 382 DateTime dt = (DateTime)val; 383 384 dateOnly = false; 385 tzid = dt.getTimeZone().getID(); 386 } 387 388 init(dateOnly, val.toString(), tzid, timezones); 389 } 390 372 391 /** Set utc time 373 392 * trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java
r366 r375 690 690 return al; 691 691 } 692 693 /**Turn the int minutes into a 4 digit String hours and minutes value 694 * 695 * @param int minutes 696 * @return String time 697 */ 698 public static String getTimeFromMinutes(int minutes) { 699 return pad2(minutes / 60) + pad2(minutes % 60); 700 } 701 702 /** Return String value of par padded to 2 digits. 703 * @param val 704 * @return 705 */ 706 public static String pad2(int val) { 707 if (val > 9) { 708 return String.valueOf(val); 709 } 710 711 return "0" + String.valueOf(val); 712 } 692 713 } 693 714 trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/BwPreferences.java
r372 r375 32 32 import org.bedework.calfacade.BwCalendar; 33 33 import org.bedework.calfacade.CalFacadeException; 34 import org.bedework.calfacade.CalFacadeUtil; 34 35 35 36 import java.util.Collection; … … 344 345 } 345 346 346 /** Turn a String time value e.g. 1030 into a numeric minutes value and set 347 * the numeric value in the prefeences. 348 * 349 * <p>Ignores anything after the first four characters which must all be digits. 347 /** Set the workday start minutes from a String time value 350 348 * 351 349 * @param val String time value 352 350 */ 353 351 public void setWorkdayStart(String val) throws CalFacadeException{ 354 boolean badval = false; 355 int minutes = 0; 356 357 try { 358 int hours = Integer.parseInt(val.substring(0, 2)); 359 minutes = Integer.parseInt(val.substring(2, 4)); 360 if ((hours < 0) || (hours > 24)) { 361 badval = true; 362 } else if ((minutes < 0) || (minutes > 59)) { 363 badval = true; 364 } else { 365 minutes *= (hours * 60); 366 } 367 } catch (Throwable t) { 368 badval = true; 369 } 370 371 if (badval) { 372 throw new CalFacadeException("org.bedework.prefs.badvalue", val); 373 } 374 375 setWorkdayStart(minutes); 376 } 377 378 /** 379 * @return int work day start 380 * / 381 public int getWorkdayStart() { 382 return workdayStart; 383 }*/ 352 setWorkdayStart(makeMinutesFromTime(val)); 353 } 354 355 /** Get the workday start as a 4 digit String hours and minutes value 356 * 357 * @return String work day start time 358 */ 359 public String getWorkdayStartTime() { 360 return CalFacadeUtil.getTimeFromMinutes(getWorkdayStart()); 361 } 362 363 /** Set the workday end minutes from a String time value 364 * 365 * @param val String time value 366 */ 367 public void setWorkdayEnd(String val) throws CalFacadeException{ 368 setWorkdayEnd(makeMinutesFromTime(val)); 369 } 370 371 /** Get the workday end as a 4 digit String hours and minutes value 372 * 373 * @return String work day end time 374 */ 375 public String getWorkdayEndTime() { 376 return CalFacadeUtil.getTimeFromMinutes(getWorkdayEnd()); 377 } 384 378 385 379 /* ==================================================================== … … 448 442 return sb.toString(); 449 443 } 444 445 /* ==================================================================== 446 * private methods 447 * ==================================================================== */ 448 449 /** Turn a String time value e.g. 1030 into a numeric minutes value and set 450 * the numeric value in the prefeences. 451 * 452 * <p>Ignores anything after the first four characters which must all be digits. 453 * 454 * @param val String time value 455 */ 456 private int makeMinutesFromTime(String val) throws CalFacadeException{ 457 boolean badval = false; 458 int minutes = 0; 459 460 try { 461 int hours = Integer.parseInt(val.substring(0, 2)); 462 minutes = Integer.parseInt(val.substring(2, 4)); 463 if ((hours < 0) || (hours > 24)) { 464 badval = true; 465 } else if ((minutes < 0) || (minutes > 59)) { 466 badval = true; 467 } else { 468 minutes *= (hours * 60); 469 } 470 } catch (Throwable t) { 471 badval = true; 472 } 473 474 if (badval) { 475 throw new CalFacadeException("org.bedework.prefs.badvalue", val); 476 } 477 478 return minutes; 479 } 450 480 } trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r372 r375 1107 1107 fbc = new BwFreeBusyComponent(); 1108 1108 fb.addTime(fbc); 1109 fbc.addPeriod(new Period(new DateTime(gpp.startDt.getDtval()), 1110 new DateTime(gpp.endDt.getDtval()))); 1109 1110 DateTime psdt = new DateTime(gpp.startDt.getDtval()); 1111 DateTime pedt = new DateTime(gpp.endDt.getDtval()); 1112 1113 psdt.setUtc(true); 1114 pedt.setUtc(true); 1115 fbc.addPeriod(new Period(psdt, pedt)); 1111 1116 if (periodEvents.size() == 0) { 1112 1117 fbc.setType(BwFreeBusyComponent.typeFree); … … 1115 1120 // Some events fall in the period. Add an entry. 1116 1121 1117 fbc.addPeriod(new Period(new DateTime(gpp.startDt.getDtval()), 1118 new DateTime(gpp.endDt.getDtval()))); 1122 DateTime psdt = new DateTime(gpp.startDt.getDtval()); 1123 DateTime pedt = new DateTime(gpp.endDt.getDtval()); 1124 1125 psdt.setUtc(true); 1126 pedt.setUtc(true); 1127 fbc.addPeriod(new Period(psdt, pedt)); 1119 1128 } 1120 1129 } trunk/calendar3/webclient/src/org/bedework/webclient/BwActionForm.java
r251 r375 55 55 package org.bedework.webclient; 56 56 57 import java.util.ArrayList; 58 import java.util.Collection; 57 59 import java.util.Date; 58 60 import java.util.Locale; … … 62 64 import org.bedework.appcommon.MyCalendarVO; 63 65 import org.bedework.calfacade.BwCalendar; 64 import org.bedework.calfacade.BwFreeBusy;65 66 import org.bedework.webcommon.DurationBean; 66 67 import org.bedework.webcommon.BwActionFormBase; … … 130 131 private boolean alarmTriggerByDate; 131 132 132 private BwFreeBusyfreeBusy;133 private Collection freeBusy; 133 134 134 135 /* ==================================================================== … … 308 309 * @param val 309 310 */ 310 public void assignFreeBusy( BwFreeBusyval) {311 public void assignFreeBusy(Collection val) { 311 312 freeBusy = val; 312 313 } 313 314 314 315 /** 315 * @return free/busy 316 */ 317 public BwFreeBusy getFreeBusy() { 316 * @return Collection of formatted free/busy 317 */ 318 public Collection getFreeBusy() { 319 if (freeBusy == null) { 320 freeBusy = new ArrayList(); 321 } 318 322 return freeBusy; 319 323 } trunk/calendar3/webclient/src/org/bedework/webclient/BwFreeBusyAction.java
r369 r375 52 52 to the maximum extent the law permits. 53 53 */ 54 55 54 package org.bedework.webclient; 56 55 57 56 //import org.bedework.calfacade.BwDateTime; 57 import org.bedework.appcommon.FormattedFreeBusy; 58 58 import org.bedework.appcommon.MyCalendarVO; 59 59 import org.bedework.calfacade.BwDuration; … … 64 64 import org.bedework.calsvci.CalSvcI; 65 65 66 import java.util.ArrayList; 66 67 import java.util.Calendar; 68 import java.util.Collection; 67 69 import java.util.Date; 68 70 import javax.servlet.http.HttpServletRequest; … … 90 92 * <p>If no period is given return this week. If no interval and intunit is 91 93 * supplied default to 1 hour intervals during the workday. 94 * 95 * @author Mike Douglass douglm @ rpi.edu 92 96 */ 93 97 public class BwFreeBusyAction extends BwCalAbstractAction { … … 118 122 Calendar end = thisWeek.getNextWeek().getCalendar(); 119 123 //BwDateTime endDt = form.getEventEndDate().getDateTime(); 124 125 Calendar endDay = thisWeek.getTomorrow().getCalendar(); 120 126 121 127 int interval = getIntReqPar(request, "interval", 1); … … 148 154 CalTimezones tzs = svci.getTimezones(); 149 155 150 Date sdt = start.getTime(); 151 Date edt = end.getTime(); 156 Collection freeBusy = new ArrayList(); 157 /* Get the free busy in daily chunks and process for display 158 */ 159 while (start.before(end)) { 160 Date sdt = start.getTime(); 161 Date edt = endDay.getTime(); 152 162 153 if (debug) { 154 debugMsg("getFreeBusy for start = " + sdt + 155 " end = " + edt); 163 if (debug) { 164 debugMsg("getFreeBusy for start = " + sdt + 165 " end = " + edt); 166 } 167 BwFreeBusy fb = svci.getFreeBusy(null, user, 168 CalFacadeUtil.getDateTime(sdt, false, false, tzs), 169 CalFacadeUtil.getDateTime(edt, false, false, tzs), 170 dur, true); 171 172 FormattedFreeBusy ffb = new FormattedFreeBusy(fb); 173 freeBusy.add(ffb); 174 175 start.add(Calendar.DAY_OF_MONTH, 1); 176 endDay.add(Calendar.DAY_OF_MONTH, 1); 156 177 } 157 BwFreeBusy fb = svci.getFreeBusy(null, user,158 CalFacadeUtil.getDateTime(sdt, false, false, tzs),159 CalFacadeUtil.getDateTime(edt, false, false, tzs),160 dur, true);161 178 162 form.assignFreeBusy(f b);179 form.assignFreeBusy(freeBusy); 163 180 164 181 return "success"; trunk/calendar3/webclient/war/docs/freeBusy.jsp
r369 r375 12 12 <page>freeBusy</page> 13 13 14 <bean:define id="freeBusyObj"15 name="calForm"16 property="freeBusy"17 toScope="request"/>18 19 14 <freebusy> 20 <bw:emitText name="freeBusyObj" property="who.account" tagName="who" />21 < bw:emitText name="freeBusyObj" property="start.dtval" tagName="start" />22 <bw:emitText name="freeBusyObj" property="end.dtval" tagName="end" />23 <logic:iterate id="freeBusyComponent" name="freeBusyObj" property="times">24 < freeBusyComponent>25 <fbtype><bean:write name="freeBusyComponent" property="type" /></fbtype>26 <logic:iterate id="period" name="freeBusyComponent" property="periods">27 <period>28 <start><bean:write name="period" property="start" /></start>29 <end><bean:write name="period" property="end" /></end>30 </period>31 </logic:iterate>32 </freeBusyComponent>33 </logic:iterate>15 <logic:iterate id="freeBusyObj" name="calForm" property="freeBusy" > 16 <day> 17 <bw:emitText name="freeBusyObj" property="who.account" tagName="who" /> 18 <bw:emitText name="freeBusyObj" property="start.dtval" tagName="start" /> 19 <bw:emitText name="freeBusyObj" property="end.dtval" tagName="end" /> 20 <logic:iterate id="fbperiod" name="freeBusyObj" property="times" > 21 <period> 22 <fbtype><bean:write name="fbperiod" property="type" /></fbtype> 23 <start><bean:write name="fbperiod" property="startTime" /></start> 24 <length><bean:write name="fbperiod" property="minutesLength" /></length> 25 </period> 26 </logic:iterate> 27 </day> 28 </logic:iterate> 34 29 </freebusy> 35 30
