public void setValue(List list) { String stringValue; if (list != null) { StringBuilder buffer = new StringBuilder(); for (Object element : list) { buffer.append(element).append('\n'); } stringValue = buffer.toString(); } else { stringValue = null; } this.prop.setStringValue(stringValue); }
@Override public void setValue(List list) { String stringValue; if (list != null && !list.isEmpty()) { StringBuilder buffer = new StringBuilder(list.get(0).toString()); for (int i = 1; i < list.size(); ++i) { String arg = list.get(i).toString(); // put options on new line, keep space delimited options on same line buffer.append(arg.startsWith("-") ? '\n' : ' ').append(arg); } stringValue = buffer.toString(); } else { stringValue = null; } // If the value is too long then don't store it, because it will likely invalidate the Map on the way back out. if (null != stringValue && stringValue.length() > PropertySimple.MAX_VALUE_LENGTH) { throw new IllegalArgumentException(stringValue); } this.prop.setStringValue(stringValue); }
/** * @param map * @throws IllegalArgumentException if the map values can not be translated to a storable string. Typically this * means max property length is exceeded. */ public void setValue(Map<String, String> map) { String stringValue; if (map != null) { StringBuilder buffer = new StringBuilder(); for (String key : map.keySet()) { String value = map.get(key); buffer.append(key).append('=').append(value).append('\n'); } stringValue = buffer.toString(); } else { stringValue = null; } // If the value is too long then don't store it, because it will likely invalidate the Map on the way back out. if (null != stringValue && stringValue.length() > PropertySimple.MAX_VALUE_LENGTH) { throw new IllegalArgumentException(stringValue); } this.prop.setStringValue(stringValue); }
private static void calculateGroupOpenPropertyMap(List<AbstractPropertyMap> sourceParentPropertyMaps, AbstractPropertyMap targetParentPropertyMap) { Map<String, Map<String, Integer>> memberNameValueFrequenciesMap = createMemberNameValueFrequenciesMap(sourceParentPropertyMaps); for (String memberName : memberNameValueFrequenciesMap.keySet()) { // Add each unique member to the target map, so the renderer will be able to display it on the main // config page. PropertySimple member = new PropertySimple(memberName, null); targetParentPropertyMap.put(member); // Also add it to each of the source config maps that don't already contain it, so that they can be // rendered as unset on the propSet page. for (AbstractPropertyMap map : sourceParentPropertyMaps) { if (map.get(memberName) == null) map.put(new PropertySimple(memberName, null)); } Map<String, Integer> valueFrequencies = memberNameValueFrequenciesMap.get(memberName); if (valueFrequencies.size() == 1 && valueFrequencies.values().iterator().next() == sourceParentPropertyMaps.size()) { // Set override to true so the renderers will know the prop is homogenous. member.setOverride(true); // And set the value, so it can be displayed on the main config page. member.setStringValue(valueFrequencies.keySet().iterator().next()); } } }
private static void validatePropertySimple(PropertyDefinition propertyDefinition, PropertySimple propertySimple, PropertySimple currentPropertySimple, List<String> errorMessages) { // make sure required properties have a value if (propertyDefinition.isRequired() && (propertySimple.getStringValue() == null)) { errorMessages.add("Required property '" + propertyDefinition.getName() + "' has a null value."); propertySimple.setStringValue(""); } // make sure readOnly properties are not being changed if (propertyDefinition.isReadOnly() && null != currentPropertySimple) { String currentValue = currentPropertySimple.getStringValue(); // if there is no current value allow an initial value to be set for the readOnly property. if (!(null == currentValue || currentValue.trim().isEmpty() || propertySimple.getStringValue().equals( currentValue))) { errorMessages.add("ReadOnly property '" + propertyDefinition.getName() + "' has a value [" + propertySimple.getStringValue() + "] different than the current value [" + currentValue + "]. It is not allowed to change."); } } }
private static void unmaskPropertySimple(PropertySimple propertySimple, AbstractPropertyMap unmaskedParentPropertyMap) { if (propertySimple.isMasked()) { PropertySimple unmaskedPropertySimple = unmaskedParentPropertyMap.getSimple(propertySimple.getName()); String unmaskedValue = (unmaskedPropertySimple != null) ? unmaskedPropertySimple.getStringValue() : null; propertySimple.setStringValue(unmaskedValue); } }
private void updateResourceFavorites(Set<Integer> favIds) { Configuration conf = caller.getUserConfiguration(); if (conf==null) { conf = new Configuration(); } StringBuilder builder = buildFavStringFromSet(favIds); PropertySimple prop = conf.getSimple(RESOURCE_HEALTH_RESOURCES); if (prop == null) { conf.put(new PropertySimple(RESOURCE_HEALTH_RESOURCES, builder.toString())); } else { prop.setStringValue(builder.toString()); } caller.setUserConfiguration(conf); subjectManager.updateSubject(caller, caller); }
/** * Set the value of a simple property to the specified value. If the property is not yet defined, it will be added. * * @param name the name of the simple property to be set * @param value the new value for the property * * @since 4.4 */ public void setSimpleValue(String name, String value) { PropertySimple property = getSimple(name); if (value == null) { if (property != null) { remove(name); } } else { if (property == null) { put(new PropertySimple(name, value)); } else { property.setStringValue(value); } } }
private void updateGroupFavorites(Set<Integer> favIds) { Configuration conf = caller.getUserConfiguration(); if (conf==null) { conf = new Configuration(); } StringBuilder builder = buildFavStringFromSet(favIds); PropertySimple prop = conf.getSimple(GROUP_HEALTH_GROUPS); if (prop == null) { conf.put(new PropertySimple(GROUP_HEALTH_GROUPS, builder.toString())); } else { prop.setStringValue(builder.toString()); } caller.setUserConfiguration(conf); subjectManager.updateSubject(caller, caller); }
private static void adaptPropertySimple(PropertySimple source, PropertySimple target, PropertyDefinitionSimple definition, Object parent, boolean adaptReadonlyProperties) { if (adaptReadonlyProperties || !definition.isReadOnly()) { if (target == null) { target = new PropertySimple(); target.setName(definition.getName()); add(parent, target); } target.setStringValue(source.getStringValue()); } }
@Override @Lock(LockType.WRITE) public void setUserProperty(int subjectId, String propertyName, String value) { load(subjectId); Configuration config = subjectPreferences.get(subjectId); if (config == null) { return; } PropertySimple prop = config.getSimple(propertyName); if (prop == null) { prop = new PropertySimple(propertyName, value); config.put(prop); // add new to collection mergeProperty(prop); } else if (prop.getStringValue() == null || !prop.getStringValue().equals(value)) { prop.setStringValue(value); mergeProperty(prop); } }
private static void mergeOpenPropertyMap(List<AbstractPropertyMap> memberParentPropertyMaps, AbstractPropertyMap groupParentPropertyMap) { for (String groupMemberPropertyName : groupParentPropertyMap.getMap().keySet()) { PropertySimple groupMemberProperty = groupParentPropertyMap.getSimple(groupMemberPropertyName); if (groupMemberProperty != null && groupMemberProperty.getOverride() != null && groupMemberProperty.getOverride()) { for (AbstractPropertyMap sourceParentPropertyMap : memberParentPropertyMaps) { PropertySimple sourcePropertySimple = sourceParentPropertyMap.getSimple(groupMemberPropertyName); if (sourcePropertySimple == null) { sourcePropertySimple = new PropertySimple(groupMemberPropertyName, groupMemberProperty .getStringValue()); sourceParentPropertyMap.put(sourcePropertySimple); } else { sourcePropertySimple.setStringValue(groupMemberProperty.getStringValue()); } } } } }
base.put(basePropertySimple); } else { basePropertySimple.setStringValue(changesPropertySimple.getStringValue());
if (value.equals("")) { propertySimple.setStringValue(null); } else if (value.length() > PropertySimple.MAX_VALUE_LENGTH) { propertySimple.setStringValue(value.substring(0, PropertySimple.MAX_VALUE_LENGTH));
PropertySimple exps = existConf.getSimple(name); if (ps.getStringValue() != null) { exps.setStringValue(ps.getStringValue());
pro.setStringValue(p); else if (pro.getStringValue() != null) pro.setStringValue(null); break;
sourceParentPropertyMap.put(sourcePropertySimple); } else { sourcePropertySimple.setStringValue(propertySimple.getStringValue());