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));
}
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);
}
}
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);
}
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);
}
}
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;
}
Aggregations