protected String getAugeasPathRelativeToParent(PropertyDefinition propDef, AugeasNode parentNode, Augeas augeas) { return propDef.getName(); }
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."); } } }
propertyDefinition.setOrder(0); int order = propertyDefinition.getOrder(); int size = map.size(); propertyDefinition.setOrder(size); if (p.getOrder() >= order) { p.setOrder(p.getOrder() + 1); map.put(propertyDefinition.getName(), propertyDefinition); propertyDefinition.setParentPropertyMapDefinition(this);
public void put(PropertyDefinition propertyDefinition) { if (this.propertyDefinitions == null) { this.propertyDefinitions = new LinkedHashMap<String, PropertyDefinition>(); } this.propertyDefinitions.put(propertyDefinition.getName(), propertyDefinition); propertyDefinition.setConfigurationDefinition(this); }
existingProperty.setDescription(newProperty.getDescription()); existingProperty.setDisplayName(newProperty.getDisplayName()); existingProperty.setActivationPolicy(newProperty.getActivationPolicy()); existingProperty.setVersion(newProperty.getVersion()); existingProperty.setRequired(newProperty.isRequired()); existingProperty.setReadOnly(newProperty.isReadOnly()); existingProperty.setSummary(newProperty.isSummary()); existingProperty.setPropertyGroupDefinition(newProperty.getPropertyGroupDefinition()); PropertyDefinition doomed = existingPropDefs.get(doomedKey); existingPropDefs.remove(doomedKey); entityManager.remove(entityManager.getReference(PropertyDefinition.class, doomed.getId())); PropertyDefinition newPropDef = newPropDefs.get(key); if (null == existingPropDef) { newPropDef.setOrder(order++); newPropDef.setParentPropertyMapDefinition((PropertyDefinitionMap) existingProperty); entityManager.persist(newPropDef); existingPropDefs.put(key, newPropDef); } else { existingPropDef.setOrder(order++); updatePropertyDefinition(existingPropDef, newPropDef);
private boolean isInvalidRequiredProperty(PropertyDefinition propertyDefinition) { boolean isInvalidRequiredProperty = false; if ((propertyDefinition instanceof PropertyDefinitionSimple) && propertyDefinition.isRequired()) { PropertySimple propertySimple = this.propertyMap.getSimple(propertyDefinition.getName()); String errorMessage = propertySimple.getErrorMessage(); if ((null == propertySimple.getStringValue()) || "".equals(propertySimple.getStringValue()) || ((null != errorMessage) && (!"".equals(errorMessage.trim())))) { // Required properties with no value, or an invalid value (assumed if we see an error message) should never // be set to read-only, otherwise the user will have no way to give the property a value and thereby // get things to a valid state. isInvalidRequiredProperty = true; } } return isInvalidRequiredProperty; }
/** * Simple map property parsing. * * @param property raw map property * @param propertyDefinition property definition * @return parsed map, can be empty if no members were set. */ protected Map<String, Object> prepareSimplePropertyMap(PropertyMap property, PropertyDefinitionMap propertyDefinition) { Map<String, PropertyDefinition> memberDefinitions = propertyDefinition.getMap(); Map<String, Object> results = new HashMap<String, Object>(); for (String name : memberDefinitions.keySet()) { PropertyDefinition memberDefinition = memberDefinitions.get(name); if (memberDefinition.isReadOnly()) continue; if (memberDefinition instanceof PropertyDefinitionSimple) { PropertyDefinitionSimple pds = (PropertyDefinitionSimple) memberDefinition; PropertySimple ps = (PropertySimple) property.get(name); if ((ps == null || ps.getStringValue() == null) && !pds.isRequired()) continue; if (ps != null) results.put(name, ps.getStringValue()); } else { log.error(" *** not yet supported *** : " + memberDefinition.getName()); } } return results; }
if (propertyDef.isRequired()) { Property templateProperty = templateConfiguration.get(propertyDef.getName()); if (templateProperty == null) { throw new IllegalArgumentException("The property [" + propertyDef.getName() + "] marked as required in the configuration definition of [" + propertyDef.getConfigurationDefinition().getName() + "] has no attribute 'default'"); } else { if (propertyDef.isRequired()) { String propertyValue = pluginConfiguration.getSimpleValue(propertyDef.getName(), null); if (propertyValue == null) { Property templateProperty = templateConfiguration.get(propertyDef.getName()); pluginConfiguration.put(templateProperty.deepCopy(false)); modified = true;
private void ensureDisplayNameIsSet(RecipeParseResults recipeParseResults) { if (recipeParseResults != null && recipeParseResults.getConfigurationDefinition() != null) { ConfigurationDefinition configDef = recipeParseResults.getConfigurationDefinition(); for (PropertyDefinition propDef : configDef.getPropertyDefinitions().values()) { if (propDef instanceof PropertyDefinitionSimple) { if (propDef.getDisplayName() == null) { propDef.setDisplayName(propDef.getName()); } } } } return; } }
if (existingPropertyDefinitions != null) { for (PropertyDefinition newProperty : newPropertyDefinitions) { PropertyDefinition existingProp = existingDefinition.get(newProperty.getName()); if (existingProp != null) { log.debug("Updating nonGrouped property [" + existingProp + "]"); existingDefinition.getPropertyDefinitions().remove(def.getName()); def.setPropertyGroupDefinition(null); entityManager.remove(def); PropertyDefinition existingProperty = existingDefinition.getPropertyDefinitions().get(nDef.getName()); if (existingProperty != null) { log.debug("Updating property [" + nDef + "] in group [" + group + "]"); for (PropertyDefinition def : defs) { entityManager.persist(def); def.setPropertyGroupDefinition(group); def.setConfigurationDefinition(existingDefinition); if (!exPDefs.containsKey(def.getName())) { updateReport.addNewPropertyDefinition(def); exPDefs.put(def.getName(), def);
public static void addPropertyDisplayName(UIComponent parent, PropertyDefinition propertyDefinition, Property property, boolean configReadOnly) { String displayName = (propertyDefinition != null) ? propertyDefinition.getDisplayName() : property.getName(); FacesComponentUtility.addOutputText(parent, null, displayName, CssStyleClasses.PROPERTY_DISPLAY_NAME_TEXT); if (!configReadOnly && propertyDefinition != null && propertyDefinition.isRequired() && (propertyDefinition instanceof PropertyDefinitionSimple || propertyDefinition instanceof PropertyDefinitionDynamic) ) { // Print a required marker next to required simples. // Ignore the required field for maps and lists, as it is has no significance for them. FacesComponentUtility.addOutputText(parent, null, " * ", CssStyleClasses.REQUIRED_MARKER_TEXT); } }
private boolean isReadOnly(PropertyDefinition propertyDefinition) { // A fully editable config overrides any other means of setting read only. return (!this.config.isFullyEditable() && (this.config.isReadOnly() || (propertyDefinition.isReadOnly() && !isInvalidRequiredProperty(propertyDefinition)))); }
/** * Retrieve property definitions for properties that are not in a group. The list is sorted by property definition * order index, then by name. * * <p/>DO NOT use this for updating the collection, as the updates will not be persisted! * * <p/> * * @return the set of properties that are not in a group * * @see #getPropertyDefinitions() */ @NotNull public List<PropertyDefinition> getNonGroupedProperties() { List<PropertyDefinition> propertyDefinitions = new ArrayList<PropertyDefinition>(); for (PropertyDefinition propertyDefinition : this.propertyDefinitions.values()) { if (propertyDefinition.getPropertyGroupDefinition() == null) { propertyDefinitions.add(propertyDefinition); } } Collections.sort(propertyDefinitions, new PropertyDefinitionComparator()); return propertyDefinitions; }
private static PropertyDefinition parseProperty(ConfigurationProperty uncastedProperty, int orderIndex, AbstractPropertyMap defaultConfigurationParentMap) throws InvalidPluginDescriptorException { PropertyDefinition property = null; if (uncastedProperty instanceof SimpleProperty) { property = parseSimpleProperty((SimpleProperty) uncastedProperty, defaultConfigurationParentMap); } else if (uncastedProperty instanceof ListProperty) { property = parseListProperty((ListProperty) uncastedProperty); } else if (uncastedProperty instanceof MapProperty) { property = parseMapProperty((MapProperty) uncastedProperty, defaultConfigurationParentMap); } else if (uncastedProperty instanceof DynamicProperty) { property = parseDynamicProperty((DynamicProperty) uncastedProperty); } if (property != null) { property.setOrder(orderIndex); } return property; }
public static void addPropertyDescription(UIComponent parent, PropertyDefinition propertyDefinition) { // <span class="description">DESCRIPTION</span> FacesComponentUtility.addOutputText(parent, null, propertyDefinition.getDescription(), CssStyleClasses.DESCRIPTION); }
Property property) { String name = propertyDefinition.getName(); if (propertyDefinition.isRequired() && property ==null) { messages.add("Required property [" + name + "] not found"); return; if (!propertyDefinition.isRequired() && property==null) { return;
if (propDef.isReadOnly()) return; String propDefName = propDef.getName(); if (propDef instanceof PropertyDefinitionList && propDefName.startsWith("*")) { propDef = ((PropertyDefinitionList) propDef).getMemberDefinition();
/** * Goes through the properties of this definition and builds a list of the groups that contain its properties. The * list is sorted by group order index, then by name. * * <p/>NOTE: updates of the result List will not be reflected in the database! * * @return all groups holding properties in this definition */ @NotNull public List<PropertyGroupDefinition> getGroupDefinitions() { Set<PropertyGroupDefinition> groupSet = new HashSet<PropertyGroupDefinition>(); for (PropertyDefinition propertyDefinition : getPropertyDefinitions().values()) { if (propertyDefinition.getPropertyGroupDefinition() != null) { groupSet.add(propertyDefinition.getPropertyGroupDefinition()); } } List<PropertyGroupDefinition> groups = new ArrayList<PropertyGroupDefinition>(groupSet.size()); for (PropertyGroupDefinition group : groupSet) { groups.add(group); } Collections.sort(groups, new GroupComparator()); return groups; }