helper.populateInfo(helper.getHolder());
return forward();
}
public String save() {
Restriction restriction = getRestriction();
RestrictionHolder<Restriction> holder = new RestrictionHelper(entityDao).getHolder();
List<Restriction> myRestrictions = getMyRestrictions(restriction.getPattern(), holder);
Set<RestrictField> ignoreFields = getIgnoreFields(myRestrictions);
boolean isAdmin = isAdmin();
for (final RestrictField field : restriction.getPattern().getEntity().getFields()) {
String[] values = (String[]) getAll(field.getName());
if ((ignoreFields.contains(field) || isAdmin) && getBool("ignoreField" + field.getId())) {
restriction.setItem(field, "*");
} else {
if (null == values || values.length == 0) {
restriction.getItems().remove(field.getId());
} else {
String storedValue = null;
if (null != field.getKeyName()) {
final Set<String> keys = CollectUtils.newHashSet(values);
Collection<?> allValues = restrictionService.getFieldValues(field.getName());
allValues = CollectionUtils.select(allValues, new Predicate() {
public boolean evaluate(Object arg0) {
try {
String keyValue = String.valueOf(PropertyUtils.getProperty(arg0,
field.getKeyName()));
return keys.contains(keyValue);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
});
storedValue = idDataResolver.marshal(field, allValues);
} else {
storedValue = StrUtils.join(values);
}
restriction.setItem(field, storedValue);
}
}
}
if (restriction.getItems().isEmpty()) {
holder.getRestrictions().remove(restriction);
if (restriction.isPersisted()) entityDao.remove(restriction);
entityDao.saveOrUpdate(holder);
return redirect("info", "info.save.success");
} else {
if (!restriction.isPersisted()) {
holder.getRestrictions().add(restriction);
entityDao.saveOrUpdate(holder);
} else {
entityDao.saveOrUpdate(
(String) RestrictionHelper.restrictionTypeMap.get(get("restrictionType")),