Search in sources :

Example 16 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class BwCalendar method getVpollSupportedComponents.

/**
 * @return the supported vpoll components
 */
@NoDump
public List<String> getVpollSupportedComponents() {
    if (vpollSupportedComponents == null) {
        vpollSupportedComponents = new ArrayList<String>();
        if ((getCalType() != calTypePoll) && (getCalType() != calTypeInbox) && (getCalType() != calTypeOutbox)) {
            return vpollSupportedComponents;
        }
        String slist = getQproperty(CaldavTags.vpollSupportedComponentSet);
        if (slist == null) {
            vpollSupportedComponents.add("VEVENT");
        // vpollSupportedComponents.add("VTODO");
        // vpollSupportedComponents.add("VAVAILABILITY");
        } else {
            String[] ss = slist.split(",");
            for (String s : ss) {
                vpollSupportedComponents.add(s);
            }
        }
    }
    return vpollSupportedComponents;
}
Also used : ToString(org.bedework.util.misc.ToString) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 17 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class BwLocation method getRestoreCallback.

@NoDump
public static FromXmlCallback getRestoreCallback() {
    if (fromXmlCb == null) {
        fromXmlCb = new FromXmlCallback();
        fromXmlCb.addSkips("byteSize", "id", "seq");
        fromXmlCb.addMapField("public", "publick");
    }
    return fromXmlCb;
}
Also used : FromXmlCallback(org.bedework.util.xml.FromXmlCallback) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 18 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class BwPreferences method getProps.

/**
 * @return String values.
 */
@NoDump
private Set<String> getProps(final String name) {
    final Set<BwProperty> props = getProperties(name);
    final Set<String> vals = new TreeSet<>();
    if (props == null) {
        return vals;
    }
    for (final BwProperty p : props) {
        vals.add(p.getValue());
    }
    return vals;
}
Also used : TreeSet(java.util.TreeSet) ToString(org.bedework.util.misc.ToString) BwProperty(org.bedework.calfacade.BwProperty) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 19 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class DumpEntity method dump.

/* ====================================================================
   *                   Private Vcard methods
   * ==================================================================== */
/**
 * Dump this entity as a vcard.
 *
 * @param vc
 * @param dtype
 * @throws CalFacadeException
 */
@NoWrap
private void dump(final VCard vc, final DumpType dtype) throws CalFacadeException {
    if (!hasDumpValue()) {
        return;
    }
    NoDump ndCl = getClass().getAnnotation(NoDump.class);
    Dump dCl = getClass().getAnnotation(Dump.class);
    /* If dumpKeyFields is true we are dumping a field which is referred to by
     * a key field - for example, a principal is addressed by the principal
     * href.
     */
    boolean dumpKeyFields = dtype == DumpType.reference;
    ArrayList<String> noDumpMethods = null;
    ArrayList<String> firstMethods = null;
    try {
        if (ndCl != null) {
            if (ndCl.value().length == 0) {
                return;
            }
            noDumpMethods = new ArrayList<String>();
            for (String m : ndCl.value()) {
                noDumpMethods.add(m);
            }
        }
        if (!dumpKeyFields && (dCl != null) && (dCl.firstFields().length != 0)) {
            firstMethods = new ArrayList<String>();
            for (String f : dCl.firstFields()) {
                firstMethods.add(methodName(f));
            }
        }
        QName qn = null;
    /*
      if (dtype != DumpType.compound) {
        qn = startElement(xml, getClass(), dCl);
      }

      Collection<ComparableMethod> ms = findGetters(dCl, dtype);

      if (firstMethods != null) {
        doFirstMethods:
        for (String methodName: firstMethods) {
          for (ComparableMethod cm: ms) {
            Method m = cm.m;

            if (methodName.equals(m.getName())) {
              Dump d = m.getAnnotation(Dump.class);

              dumpValue(xml, m, d, m.invoke(this, (Object[])null), fromCollection);

              continue doFirstMethods;
            }
          }

          error("Listed first field has no corresponding getter: " + methodName);
        }
      }

      for (ComparableMethod cm: ms) {
        Method m = cm.m;

        if ((noDumpMethods != null) &&
            noDumpMethods.contains(fieldName(m.getName()))) {
          continue;
        }

        if ((firstMethods != null) &&
            firstMethods.contains(m.getName())) {
          continue;
        }

        Dump d = m.getAnnotation(Dump.class);

        dumpValue(xml, m, d, m.invoke(this, (Object[])null), fromCollection);
      }

      if (qn != null) {
        closeElement(xml, qn);
      }
      */
    // } catch (CalFacadeException cfe) {
    // throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : NoDump(org.bedework.calfacade.annotations.NoDump) NoDump(org.bedework.calfacade.annotations.NoDump) Dump(org.bedework.calfacade.annotations.Dump) QName(javax.xml.namespace.QName) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) NoWrap(org.bedework.calfacade.annotations.NoWrap)

Example 20 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class DumpEntity method dump.

/* ====================================================================
   *                   Private XML methods
   * ==================================================================== */
/**
 * Dump this entity as xml.
 *
 * @param xml
 * @param dtype
 * @param fromCollection  true if the value is a member of a collection
 * @throws CalFacadeException
 */
@NoWrap
private void dump(final XmlEmit xml, final DumpType dtype, final boolean fromCollection) throws CalFacadeException {
    if (!hasDumpValue()) {
        return;
    }
    NoDump ndCl = getClass().getAnnotation(NoDump.class);
    Dump dCl = getClass().getAnnotation(Dump.class);
    boolean dumpKeyFields = dtype == DumpType.reference;
    ArrayList<String> noDumpMethods = null;
    ArrayList<String> firstMethods = null;
    try {
        if (ndCl != null) {
            if (ndCl.value().length == 0) {
                return;
            }
            noDumpMethods = new ArrayList<String>();
            for (String m : ndCl.value()) {
                noDumpMethods.add(m);
            }
        }
        if (!dumpKeyFields && (dCl != null) && (dCl.firstFields().length != 0)) {
            firstMethods = new ArrayList<String>();
            for (String f : dCl.firstFields()) {
                firstMethods.add(methodName(f));
            }
        }
        QName qn = null;
        if (fromCollection || (dtype != DumpType.compound)) {
            qn = startElement(xml, getClass(), dCl);
        }
        Collection<ComparableMethod> ms = findGetters(dCl, dtype);
        if (firstMethods != null) {
            doFirstMethods: for (String methodName : firstMethods) {
                for (ComparableMethod cm : ms) {
                    Method m = cm.m;
                    if (methodName.equals(m.getName())) {
                        Dump d = m.getAnnotation(Dump.class);
                        dumpValue(xml, m, d, m.invoke(this, (Object[]) null), fromCollection);
                        continue doFirstMethods;
                    }
                }
                error("Listed first field has no corresponding getter: " + methodName);
            }
        }
        for (ComparableMethod cm : ms) {
            Method m = cm.m;
            if ((noDumpMethods != null) && noDumpMethods.contains(fieldName(m.getName()))) {
                continue;
            }
            if ((firstMethods != null) && firstMethods.contains(m.getName())) {
                continue;
            }
            Dump d = m.getAnnotation(Dump.class);
            dumpValue(xml, m, d, m.invoke(this, (Object[]) null), fromCollection);
        }
        if (qn != null) {
            closeElement(xml, qn);
        }
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : NoDump(org.bedework.calfacade.annotations.NoDump) NoDump(org.bedework.calfacade.annotations.NoDump) Dump(org.bedework.calfacade.annotations.Dump) QName(javax.xml.namespace.QName) Method(java.lang.reflect.Method) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) NoWrap(org.bedework.calfacade.annotations.NoWrap)

Aggregations

NoDump (org.bedework.calfacade.annotations.NoDump)21 ToString (org.bedework.util.misc.ToString)8 FromXmlCallback (org.bedework.util.xml.FromXmlCallback)7 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)5 TreeSet (java.util.TreeSet)4 ArrayList (java.util.ArrayList)3 NoProxy (org.bedework.calfacade.annotations.ical.NoProxy)3 Method (java.lang.reflect.Method)2 QName (javax.xml.namespace.QName)2 Dur (net.fortuna.ical4j.model.Dur)2 Xpar (org.bedework.calfacade.BwXproperty.Xpar)2 Dump (org.bedework.calfacade.annotations.Dump)2 NoWrap (org.bedework.calfacade.annotations.NoWrap)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Blob (java.sql.Blob)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 DateTime (net.fortuna.ical4j.model.DateTime)1 Period (net.fortuna.ical4j.model.Period)1