📄 reservationhelper.java
字号:
package org.rapla.entities.domain;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.rapla.facade.PeriodModel;
public class ReservationHelper
{
static public void makeRepeatingForPeriod(PeriodModel model, Appointment appointment, RepeatingType repeatingType, int repeatings) {
appointment.setRepeatingEnabled(true);
Repeating repeating = appointment.getRepeating();
repeating.setType( repeatingType );
Period period = model.getNearestPeriodForStartDate( appointment.getStart());
if ( period != null && repeatings <=1) {
repeating.setEnd(period.getEnd());
} else {
repeating.setNumber( repeatings );
}
}
/** find the first visible reservation*/
static public Date findFirst( List reservationList) {
Date firstStart = null;
Iterator it = reservationList.iterator();
while (it.hasNext()) {
Appointment[] appointments = ((Reservation) it.next()).getAppointments();
for (int i=0;i<appointments.length;i++) {
Date start = appointments[i].getStart();
Repeating r = appointments[i].getRepeating();
if (firstStart == null) {
firstStart = start;
continue;
}
if (!start.before(firstStart))
continue;
if ( r== null || !r.isException(start.getTime()))
{
firstStart = start;
}
else
{
AppointmentBlockArray blocks = new AppointmentBlockArray();
appointments[i].createBlocks( start, firstStart, blocks );
for (int j=0;j<blocks.size();j++) {
if (blocks.getStartAt(j)<firstStart.getTime()) {
firstStart = new Date(blocks.getStartAt(j));
continue;
}
}
}
}
}
return firstStart;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -