use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.
the class BwAlarm method getXicalProperties.
/**
* Find x-properties storing the value of the named ical property
*
* @param val - name to match
* @return list of matching properties - never null
* @throws CalFacadeException
*/
@NoProxy
@NoDump
public List<BwXproperty> getXicalProperties(final String val) throws CalFacadeException {
List<BwXproperty> res = new ArrayList<>();
List<BwXproperty> xs = getXproperties();
if (xs == null) {
return res;
}
for (BwXproperty x : xs) {
if (x.getName().equals(BwXproperty.bedeworkIcalProp)) {
List<Xpar> xpars = x.getParameters();
Xpar xp = xpars.get(0);
if (xp.getName().equals(val)) {
res.add(x);
}
}
}
return res;
}
use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.
the class BwEvent method getXicalProperties.
/**
* Find x-properties storing the value of the named ical property
*
* @param val - name to match
* @return list of matching properties - never null
* @throws CalFacadeException
*/
@NoProxy
@NoDump
public List<BwXproperty> getXicalProperties(final String val) throws CalFacadeException {
List<BwXproperty> res = new ArrayList<>();
List<BwXproperty> xs = getXproperties();
if (xs == null) {
return res;
}
for (BwXproperty x : xs) {
if (x.getName().equals(BwXproperty.bedeworkIcalProp)) {
List<Xpar> xpars = x.getParameters();
Xpar xp = xpars.get(0);
if (xp.getName().equals(val)) {
res.add(x);
}
}
}
return res;
}
use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.
the class Xutil method xpropertiesToXcal.
/**
* @param pl
* @param xprops
* @param pattern
* @param masterClass
* @param wrapXprops wrap x-properties in bedework object - allows
* us to push them through soap
* @throws Throwable
*/
@SuppressWarnings("deprecation")
public static void xpropertiesToXcal(final List<JAXBElement<? extends BasePropertyType>> pl, final List<BwXproperty> xprops, final BaseComponentType pattern, final Class masterClass, final boolean wrapXprops) throws Throwable {
for (final BwXproperty x : xprops) {
// Skip any timezone we saved in the event.
final String xname = x.getName();
final String val = x.getValue();
if (xname.startsWith(BwXproperty.bedeworkTimezonePrefix)) {
continue;
}
if (xname.equals(BwXproperty.bedeworkExsynchEndtzid)) {
if (!emit(pattern, masterClass, XBedeworkExsynchEndtzidPropType.class)) {
continue;
}
final XBedeworkExsynchEndtzidPropType p = new XBedeworkExsynchEndtzidPropType();
p.setText(val);
pl.add(of.createXBedeworkExsynchEndtzid(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkExsynchLastmod)) {
if (!emit(pattern, masterClass, XBedeworkExsynchLastmodPropType.class)) {
continue;
}
final XBedeworkExsynchLastmodPropType p = new XBedeworkExsynchLastmodPropType();
p.setText(val);
pl.add(of.createXBedeworkExsynchLastmod(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkExsynchOrganizer)) {
continue;
}
if (xname.equals(BwXproperty.bedeworkExsynchStarttzid)) {
if (!emit(pattern, masterClass, XBedeworkExsynchStarttzidPropType.class)) {
continue;
}
final XBedeworkExsynchStarttzidPropType p = new XBedeworkExsynchStarttzidPropType();
p.setText(val);
pl.add(of.createXBedeworkExsynchStarttzid(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegStart)) {
if (!emit(pattern, masterClass, XBedeworkRegistrationStartPropType.class)) {
continue;
}
final XBedeworkRegistrationStartPropType p = new XBedeworkRegistrationStartPropType();
String tzid = null;
for (final Xpar xp : x.getParameters()) {
if (xp.getName().equalsIgnoreCase("TZID")) {
tzid = xp.getValue();
break;
}
}
XcalUtil.initDt(p, val, tzid);
pl.add(of.createXBedeworkRegistrationStart(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegEnd)) {
if (!emit(pattern, masterClass, XBedeworkRegistrationEndPropType.class)) {
continue;
}
final XBedeworkRegistrationEndPropType p = new XBedeworkRegistrationEndPropType();
String tzid = null;
for (final Xpar xp : x.getParameters()) {
if (xp.getName().equalsIgnoreCase("TZID")) {
tzid = xp.getValue();
break;
}
}
XcalUtil.initDt(p, val, tzid);
pl.add(of.createXBedeworkRegistrationEnd(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegMaxTickets)) {
if (!emit(pattern, masterClass, XBedeworkMaxTicketsPropType.class)) {
continue;
}
final XBedeworkMaxTicketsPropType p = new XBedeworkMaxTicketsPropType();
p.setInteger(BigInteger.valueOf(Long.valueOf(val)));
pl.add(of.createXBedeworkMaxTickets(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegMaxTicketsPerUser)) {
if (!emit(pattern, masterClass, XBedeworkMaxTicketsPerUserPropType.class)) {
continue;
}
final XBedeworkMaxTicketsPerUserPropType p = new XBedeworkMaxTicketsPerUserPropType();
p.setInteger(BigInteger.valueOf(Long.valueOf(val)));
pl.add(of.createXBedeworkMaxTicketsPerUser(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegWaitListLimit)) {
if (!emit(pattern, masterClass, XBedeworkWaitListLimitPropType.class)) {
continue;
}
final XBedeworkWaitListLimitPropType p = new XBedeworkWaitListLimitPropType();
p.setText(val);
pl.add(of.createXBedeworkWaitListLimit(p));
continue;
}
if (xname.equals(BwXproperty.xBedeworkCategories)) {
if (!emit(pattern, masterClass, XBwCategoriesPropType.class)) {
continue;
}
final XBwCategoriesPropType p = new XBwCategoriesPropType();
p.getText().add(val);
pl.add(of.createXBedeworkCategories(p));
continue;
}
if (xname.equals(BwXproperty.xBedeworkContact)) {
if (!emit(pattern, masterClass, XBwContactPropType.class)) {
continue;
}
final XBwContactPropType p = new XBwContactPropType();
p.setText(val);
pl.add(of.createXBedeworkContact(p));
continue;
}
if (xname.equals(BwXproperty.xBedeworkLocation)) {
if (!emit(pattern, masterClass, XBwLocationPropType.class)) {
continue;
}
final XBwLocationPropType p = new XBwLocationPropType();
p.setText(val);
pl.add(of.createXBedeworkLocation(p));
continue;
}
if (!wrapXprops) {
if (getLog().isDebugEnabled()) {
warn("Not handing x-property " + xname);
}
continue;
}
final XBedeworkWrapperPropType wrapper = new XBedeworkWrapperPropType();
if (x.getParameters() != null) {
for (final Xpar xp : x.getParameters()) {
xparam(wrapper, xp);
}
}
final XBedeworkWrappedNameParamType wnp = new XBedeworkWrappedNameParamType();
wnp.setText(x.getName());
if (wrapper.getParameters() == null) {
wrapper.setParameters(new ArrayOfParameters());
}
wrapper.getParameters().getBaseParameter().add(of.createXBedeworkWrappedName(wnp));
wrapper.setText(val);
pl.add(of.createXBedeworkWrapper(wrapper));
}
}
use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.
the class IcalUtil method xpropertiesToIcal.
/**
* @param pl
* @param xprops
* @throws Throwable
*/
@SuppressWarnings("deprecation")
public static void xpropertiesToIcal(final PropertyList pl, final List<BwXproperty> xprops) throws Throwable {
for (BwXproperty x : xprops) {
String xname = x.getName();
if (xname.equals(BwXproperty.bedeworkIcalProp)) {
// Some get squirreled away in here -mostly for alarms
List<Xpar> params = x.getParameters();
String pname = params.get(0).getValue();
if (params.size() == 1) {
params = null;
} else {
params = new ArrayList<Xpar>(params);
params.remove(0);
}
// XXX Need to be able to do this in ical4j - create property by name
if (pname.equals("UID")) {
pl.add(new Uid(makeXparlist(params), x.getValue()));
}
}
if (x.getSkip()) {
continue;
}
// Skip any timezone we saved in the event.
if (xname.startsWith(BwXproperty.bedeworkTimezonePrefix)) {
continue;
}
addXproperty(pl, xname, x.getParameters(), x.getValue());
}
}
use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.
the class IcalUtil method makeXparlist.
/**
* @param pars
* @return par list - always non-null
* @throws Throwable
*/
public static ParameterList makeXparlist(final List<BwXproperty.Xpar> pars) throws Throwable {
ParameterList xparl = new ParameterList();
if (pars == null) {
return xparl;
}
for (BwXproperty.Xpar xpar : pars) {
String xval = xpar.getValue();
if ((xval.indexOf(":") >= 0) || (xval.indexOf(";") >= 0) || (xval.indexOf(",") >= 0)) {
xval = "\"" + xval + "\"";
}
xparl.add(ParameterFactoryImpl.getInstance().createParameter(xpar.getName().toUpperCase(), xval));
}
return xparl;
}
Aggregations