Search in sources :

Example 1 with BwProperty

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

the class BwPreferences method setLongProp.

/**
 * @param val  long.
 */
private void setLongProp(final String name, final long val) {
    BwProperty prop = findProperty(name);
    if (prop == null) {
        prop = new BwProperty();
        prop.setName(name);
        prop.setValue(String.valueOf(val));
        addProperty(prop);
        return;
    }
    prop.setValue(String.valueOf(val));
}
Also used : BwProperty(org.bedework.calfacade.BwProperty)

Example 2 with BwProperty

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

the class BwPreferences method setDefaultCategoryUids.

/**
 * Supply the set of default category uids. Will replace the current set.
 *
 * @param val Set of category uids.
 */
public void setDefaultCategoryUids(final Set<String> val) {
    final Set<BwProperty> catuids = getProperties(propertyDefaultCategory);
    final boolean noprops = Util.isEmpty(catuids);
    if (Util.isEmpty(val)) {
        if (noprops) {
            return;
        }
        for (BwProperty p : catuids) {
            removeProperty(p);
        }
        return;
    }
    // Work out what we have to add/remove
    for (final String uid : val) {
        final BwProperty p = new BwProperty(propertyDefaultCategory, uid);
        if (noprops) {
            addProperty(p);
            continue;
        }
        if (!catuids.contains(p)) {
            // Not in properties
            addProperty(p);
        } else {
            catuids.remove(p);
        }
    }
    if (Util.isEmpty(catuids)) {
        return;
    }
    // If any left in catuids remove them from properties
    for (final BwProperty p : catuids) {
        removeProperty(p);
    }
}
Also used : ToString(org.bedework.util.misc.ToString) BwProperty(org.bedework.calfacade.BwProperty)

Example 3 with BwProperty

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

the class BwPreferences method setProp.

/**
 * @param val  String
 */
private void setProp(final String name, final String val) {
    BwProperty prop = findProperty(name);
    if (prop == null) {
        prop = new BwProperty();
        prop.setName(name);
        prop.setValue(val);
        addProperty(prop);
        return;
    }
    prop.setValue(val);
}
Also used : BwProperty(org.bedework.calfacade.BwProperty)

Example 4 with BwProperty

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

the class DocBuilder method indexProperties.

private void indexProperties(final Set<BwProperty> props) throws CalFacadeException {
    if (props == null) {
        return;
    }
    try {
        startArray(getJname(PropertyInfoIndex.COL_PROPERTIES));
        for (final BwProperty prop : props) {
            startObject();
            makeField(PropertyInfoIndex.NAME, prop.getName());
            makeField(PropertyInfoIndex.VALUE, prop.getValue());
            endObject();
        }
        endArray();
    } catch (final IndexException e) {
        throw new CalFacadeException(e);
    }
}
Also used : IndexException(org.bedework.util.indexing.IndexException) BwProperty(org.bedework.calfacade.BwProperty) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 5 with BwProperty

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

the class AbstractDirImpl method mergePreferences.

@Override
public boolean mergePreferences(final BwPreferences prefs, final BwPrincipalInfo pinfo) throws CalFacadeException {
    boolean changed = false;
    // PrincipalProperty kind = pinfo.findProperty("kind");
    /* ============ auto scheduling ================== */
    final BooleanPrincipalProperty pautoSched = (BooleanPrincipalProperty) pinfo.findProperty("auto-schedule");
    if ((pautoSched != null) && (pautoSched.getVal() != prefs.getScheduleAutoRespond())) {
        prefs.setScheduleAutoRespond(pautoSched.getVal());
        if (pautoSched.getVal()) {
            // Ensure we delete cancelled
            prefs.setScheduleAutoCancelAction(BwPreferences.scheduleAutoCancelDelete);
        }
        changed = true;
    }
    final IntPrincipalProperty pschedMaxInstances = (IntPrincipalProperty) pinfo.findProperty("max-instances");
    if (pschedMaxInstances != null) {
        int mi = pschedMaxInstances.getVal();
        String strMi = String.valueOf(mi);
        BwProperty pmi = prefs.findProperty(BwPreferences.propertyScheduleMaxinstances);
        if (pmi == null) {
            prefs.addProperty(new BwProperty(BwPreferences.propertyScheduleMaxinstances, strMi));
        } else if (!pmi.getValue().equals(strMi)) {
            pmi.setValue(strMi);
        }
        changed = true;
    }
    return changed;
}
Also used : BooleanPrincipalProperty(org.bedework.calfacade.BwPrincipalInfo.BooleanPrincipalProperty) IntPrincipalProperty(org.bedework.calfacade.BwPrincipalInfo.IntPrincipalProperty) BwProperty(org.bedework.calfacade.BwProperty)

Aggregations

BwProperty (org.bedework.calfacade.BwProperty)8 TreeSet (java.util.TreeSet)3 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)2 IndexException (org.bedework.util.indexing.IndexException)2 ToString (org.bedework.util.misc.ToString)2 Collection (java.util.Collection)1 Set (java.util.Set)1 BwLongString (org.bedework.calfacade.BwLongString)1 BooleanPrincipalProperty (org.bedework.calfacade.BwPrincipalInfo.BooleanPrincipalProperty)1 IntPrincipalProperty (org.bedework.calfacade.BwPrincipalInfo.IntPrincipalProperty)1 BwString (org.bedework.calfacade.BwString)1 NoDump (org.bedework.calfacade.annotations.NoDump)1 PropertiesEntity (org.bedework.calfacade.base.PropertiesEntity)1