use of org.bedework.calfacade.BwRequestStatus in project bw-calendar-engine by Bedework.
the class BwObjectFilter method match.
/* ====================================================================
* matching methods
* ==================================================================== */
@Override
public boolean match(final Object o, final String userHref) throws WebdavException {
ObjectFilter of = getEntity();
Object ent = of.getEntity();
boolean not = of.getNot();
String val = null;
Integer ival = null;
if (ent instanceof BwCalendar) {
val = ((BwCalendar) ent).getPath();
} else if (ent instanceof String) {
val = (String) ent;
} else if (ent instanceof Integer) {
ival = (Integer) ent;
} else {
throw new WebdavException("Unmatchable filter");
}
BwEvent ev = null;
if (o instanceof BwEvent) {
ev = (BwEvent) o;
}
if (of instanceof EntityTypeFilter) {
if (ev == null) {
return false;
}
if (not) {
return ev.getEntityType() != ival;
}
return ev.getEntityType() == ival;
}
PropertyInfoIndex pii = of.getPropertyIndex();
BwIcalPropertyInfoEntry pi = BwIcalPropertyInfo.getPinfo(pii);
if (pi.getParam()) {
pii = of.getParentPropertyIndex();
}
switch(pii) {
case CLASS:
if (ev.getClassification() == null) {
return false;
}
return stringMatch(ev.getClassification(), val);
case CREATED:
return stringMatch(ev.getCreated(), val);
case DESCRIPTION:
for (BwLongString ls : ev.getDescriptions()) {
if (stringMatch(ls.getValue(), val)) {
return true;
}
}
return false;
case DTSTAMP:
return stringMatch(ev.getDtstamp(), val);
case DTEND:
/* Event only */
case DUE:
/* Todo only */
return matchDateTime(pi, ev.getDtend(), val);
case DTSTART:
return matchDateTime(pi, ev.getDtstart(), val);
case DURATION:
return stringMatch(ev.getDuration(), val);
case GEO:
if (ev.getGeo() == null) {
return false;
}
return stringMatch(ev.getGeo().toString(), val);
case LAST_MODIFIED:
return stringMatch(ev.getLastmod(), val);
case LOCATION:
if (ev.getLocation() == null) {
return false;
}
return stringMatch(ev.getLocation().getAddress().getValue(), val);
case ORGANIZER:
if (ev.getOrganizer() == null) {
return false;
}
return stringMatch(ev.getOrganizer().getOrganizerUri(), val);
case PRIORITY:
if (ev.getPriority() == null) {
return false;
}
return stringMatch(String.valueOf(ev.getPriority()), val);
case RECURRENCE_ID:
if (ev.getRecurrenceId() == null) {
return false;
}
return stringMatch(ev.getRecurrenceId(), val);
case SEQUENCE:
return stringMatch(String.valueOf(ev.getSequence()), val);
case STATUS:
if (ev.getStatus() == null) {
return false;
}
return stringMatch(ev.getStatus(), val);
case SUMMARY:
for (BwString s : ev.getSummaries()) {
if (stringMatch(s.getValue(), val)) {
return true;
}
}
return false;
case UID:
return stringMatch(ev.getUid(), val);
case URL:
if (ev.getLink() == null) {
return false;
}
return stringMatch(ev.getLink(), val);
case TRANSP:
try {
if (ev.getPeruserTransparency(userHref) == null) {
return false;
}
return stringMatch(ev.getPeruserTransparency(userHref), val);
} catch (Throwable t) {
throw new WebdavException(t);
}
case COMPLETED:
if (ev.getCompleted() == null) {
return false;
}
return stringMatch(ev.getCompleted(), val);
case PERCENT_COMPLETE:
if (ev.getPercentComplete() == null) {
return false;
}
return stringMatch(String.valueOf(ev.getPercentComplete()), val);
case ATTACH:
break;
case ATTENDEE:
break;
case CATEGORIES:
for (BwCategory cat : ev.getCategories()) {
if (stringMatch(cat.getWordVal(), val)) {
return true;
}
}
return false;
case COMMENT:
for (BwString s : ev.getComments()) {
if (stringMatch(s.getValue(), val)) {
return true;
}
}
return false;
case CONTACT:
for (BwContact c : ev.getContacts()) {
if (stringMatch(c.getCn().getValue(), val)) {
return true;
}
}
return false;
case EXDATE:
for (BwDateTime dt : ev.getExdates()) {
if (stringMatch(dt.getDtval(), val)) {
return true;
}
}
return false;
case EXRULE:
for (String s : ev.getExrules()) {
if (stringMatch(s, val)) {
return true;
}
}
return false;
case REQUEST_STATUS:
for (BwRequestStatus rs : ev.getRequestStatuses()) {
if (stringMatch(rs.getCode(), val)) {
return true;
}
}
return false;
case RELATED_TO:
if (ev.getRelatedTo() == null) {
return false;
}
return stringMatch(ev.getRelatedTo().getValue(), val);
case RESOURCES:
for (BwString s : ev.getResources()) {
if (stringMatch(s.getValue(), val)) {
return true;
}
}
return false;
case RDATE:
for (BwDateTime dt : ev.getRdates()) {
if (stringMatch(dt.getDtval(), val)) {
return true;
}
}
return false;
case RRULE:
for (String s : ev.getRrules()) {
if (stringMatch(s, val)) {
return true;
}
}
return false;
case FREEBUSY:
break;
case TZID:
break;
case TZNAME:
break;
case TZOFFSETFROM:
break;
case TZOFFSETTO:
break;
case TZURL:
break;
case ACTION:
break;
case REPEAT:
break;
case TRIGGER:
break;
case COLLECTION:
return stringMatch(ev.getColPath(), val);
case CREATOR:
return stringMatch(ev.getCreatorHref(), val);
case OWNER:
return stringMatch(ev.getOwnerHref(), val);
case ENTITY_TYPE:
break;
}
return false;
}
use of org.bedework.calfacade.BwRequestStatus in project bw-calendar-engine by Bedework.
the class BwStringRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
if (name.equals("bwstring")) {
// 3.5 onwards we wrapped with a tag. Do nothing
return;
}
BwString entity = (BwString) pop();
if (top() instanceof BwRequestStatus) {
BwRequestStatus rs = (BwRequestStatus) top();
rs.setDescription(entity);
return;
}
if (top() instanceof BwCategory) {
BwCategory cat = (BwCategory) top();
if (name.equals("keyword")) {
cat.setWord(entity);
} else if (name.equals("desc")) {
cat.setDescription(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwContact) {
BwContact ent = (BwContact) top();
if (name.equals("value")) {
ent.setCn(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwLocation) {
BwLocation loc = (BwLocation) top();
if (name.equals("addr")) {
loc.setAddress(entity);
} else if (name.equals("subaddr")) {
loc.setSubaddress(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwFilterDef) {
BwFilterDef f = (BwFilterDef) top();
if (name.equals("display-name")) {
f.addDisplayName(entity);
} else if (name.equals("subaddr")) {
f.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwAlarm) {
BwAlarm a = (BwAlarm) top();
if (name.equals("description")) {
a.addDescription(entity);
if (entity.getLang() != null) {
a.addXproperty(new BwXproperty(entity.getLang(), null, entity.getValue()));
} else {
a.addDescription(entity);
}
return;
}
if (name.equals("summary")) {
a.addSummary(entity);
} else {
unknownTag(name);
}
return;
}
EventInfo ei = (EventInfo) top();
BwEvent e = ei.getEvent();
if (e instanceof BwEventProxy) {
e = ((BwEventProxy) e).getRef();
}
if (name.equals("comment")) {
e.addComment(entity);
} else if (name.equals("description")) {
e.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
} else if (name.equals("resource")) {
e.addResource(entity);
} else if (name.equals("summary")) {
e.addSummary(entity);
} else {
unknownTag(name);
}
}
use of org.bedework.calfacade.BwRequestStatus in project bw-calendar-engine by Bedework.
the class InReply method getRstat.
private String getRstat(final BwEvent ev) {
String rstat = null;
for (final BwRequestStatus bwrstat : ev.getRequestStatuses()) {
if (rstat != null) {
rstat += ",";
rstat += bwrstat.getCode();
} else {
rstat = bwrstat.getCode();
}
}
if (rstat == null) {
rstat = IcalDefs.deliveryStatusSuccess;
}
return rstat;
}
use of org.bedework.calfacade.BwRequestStatus in project bw-calendar-engine by Bedework.
the class DocBuilder method indexReqStat.
private void indexReqStat(final Set<BwRequestStatus> val) throws CalFacadeException {
try {
if (Util.isEmpty(val)) {
return;
}
startArray(getJname(PropertyInfoIndex.REQUEST_STATUS));
for (final BwRequestStatus rs : val) {
value(rs.strVal());
}
endArray();
} catch (final IndexException e) {
throw new CalFacadeException(e);
}
}
use of org.bedework.calfacade.BwRequestStatus in project bw-calendar-engine by Bedework.
the class EventBwRequestStatusRule method end.
public void end(String ns, String name) throws Exception {
BwRequestStatus entity = (BwRequestStatus) pop();
EventInfo ei = (EventInfo) top();
BwEvent e = ei.getEvent();
if (e instanceof BwEventProxy) {
e = ((BwEventProxy) e).getRef();
}
e.addRequestStatus(entity);
}
Aggregations