use of ietf.params.xml.ns.icalendar_2.ArrayOfComponents in project bw-calendar-engine by Bedework.
the class ToXEvent method processEventAlarm.
/**
* Process any alarms.
*
* @param ev
* @param comp
* @param pattern
* @param masterClass
* @throws CalFacadeException
*/
public static void processEventAlarm(final BwEvent ev, final BaseComponentType comp, final BaseComponentType pattern, final Class masterClass) throws CalFacadeException {
if (!emit(pattern, masterClass, ValarmType.class)) {
return;
}
Set<BwAlarm> als = ev.getAlarms();
if ((als == null) || als.isEmpty()) {
return;
}
if (!(comp instanceof VeventType) && !(comp instanceof VtodoType)) {
warn("Entity of class " + ev.getClass() + " has alarms but not allowed by entity of type " + comp.getClass());
}
ArrayOfComponents aoc = comp.getComponents();
if (aoc == null) {
aoc = new ArrayOfComponents();
comp.setComponents(aoc);
}
for (BwAlarm alarm : als) {
ValarmType va = Xalarms.toXAlarm(ev, alarm, pattern, masterClass);
aoc.getBaseComponent().add(of.createValarm(va));
}
}
use of ietf.params.xml.ns.icalendar_2.ArrayOfComponents in project bw-calendar-engine by Bedework.
the class IcalTranslator method toXMLIcalendar.
/**
* @param val
* @param methodType
* @param pattern
* @return XML IcalendarType
* @throws CalFacadeException
*/
public IcalendarType toXMLIcalendar(final EventInfo val, final int methodType, final IcalendarType pattern, final boolean wrapXprops) throws CalFacadeException {
IcalendarType ical = new IcalendarType();
VcalendarType vcal = new VcalendarType();
ical.getVcalendar().add(vcal);
vcal.setProperties(new ArrayOfProperties());
List<JAXBElement<? extends BasePropertyType>> pl = vcal.getProperties().getBasePropertyOrTzid();
ProdidPropType prod = new ProdidPropType();
prod.setText(prodId);
pl.add(Xutil.of.createProdid(prod));
VersionPropType vers = new VersionPropType();
vers.setText("2.0");
pl.add(Xutil.of.createVersion(vers));
if ((methodType > ScheduleMethods.methodTypeNone) && (methodType < ScheduleMethods.methodTypeUnknown)) {
MethodPropType m = new MethodPropType();
m.setText(ScheduleMethods.methods[methodType]);
pl.add(Xutil.of.createMethod(m));
}
ArrayOfComponents aoc = vcal.getComponents();
if (aoc == null) {
aoc = new ArrayOfComponents();
vcal.setComponents(aoc);
}
BwEvent ev = val.getEvent();
JAXBElement<? extends BaseComponentType> el = null;
VcalendarType vc = null;
if ((pattern != null) && !pattern.getVcalendar().isEmpty()) {
vc = pattern.getVcalendar().get(0);
}
BaseComponentType bc = matches(vc, ev.getEntityType());
if ((vc != null) && (bc == null)) {
return ical;
}
if (!ev.getSuppressed()) {
if (ev.getEntityType() == IcalDefs.entityTypeFreeAndBusy) {
el = ToXEvent.toComponent(ev, false, wrapXprops, bc);
} else {
el = ToXEvent.toComponent(ev, false, wrapXprops, bc);
}
if (el != null) {
aoc.getBaseComponent().add(el);
}
}
if (val.getNumOverrides() == 0) {
return ical;
}
for (EventInfo oei : val.getOverrides()) {
ev = oei.getEvent();
el = ToXEvent.toComponent(ev, true, wrapXprops, bc);
if (el != null) {
aoc.getBaseComponent().add(el);
}
}
if (val.getNumContainedItems() > 0) {
for (EventInfo aei : val.getContainedItems()) {
ev = aei.getEvent();
el = ToXEvent.toComponent(ev, true, wrapXprops, bc);
if (el != null) {
aoc.getBaseComponent().add(el);
}
}
}
return ical;
}
Aggregations