private static boolean isOptional(PropertyDefinitionSimple propertyDefinitionSimple) { return propertyDefinitionSimple == null || !propertyDefinitionSimple.isRequired(); }
private static PropertyDefinitionSimple createExcludePattern(boolean readOnly) { String name = PROP_PATTERN; String description = "Pathname pattern that must match for the items in the directory path to be excluded."; boolean required = false; PropertySimpleType type = PropertySimpleType.STRING; PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type); pd.setDisplayName("Pattern"); pd.setReadOnly(readOnly); pd.setSummary(true); pd.setOrder(1); pd.setAllowCustomEnumeratedValue(false); return pd; }
private static PropertyDefinitionSimple createDescription(ConfigurationDefinition configDef) { String name = PROP_DESCRIPTION; String description = "A description of the drift detection definition or template"; boolean required = false; PropertySimpleType type = PropertySimpleType.STRING; PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type); pd.setDisplayName("Drift Definition Description"); pd.setSummary(true); pd.setOrder(1); pd.setAllowCustomEnumeratedValue(false); pd.setConfigurationDefinition(configDef); return pd; }
private static PropertyDefinitionSimple createAttached(ConfigurationDefinition configDef, boolean readOnly) { String name = PROP_ATTACHED; String description = "A flag that indicates whether or not the definition is attached to the template from " + "which it is created. When a template is updated, the changes will be propagated to any attached " + "definitions. Furthermore, if you pin an existing template to a snapshot, then attached definitions will " + "become pinned as well. Finally, if you delete a template, attached definitions will also be deleted."; boolean required = true; PropertySimpleType type = PropertySimpleType.BOOLEAN; PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type); pd.setDisplayName("Attached to Template"); pd.setDefaultValue("true"); pd.setOrder(3); pd.setReadOnly(readOnly); pd.setConfigurationDefinition(configDef); return pd; }
PropertyDefinitionSimple newPDS = (PropertyDefinitionSimple) newProperty; existingPDS.setType(newPDS.getType()); List<PropertyDefinitionEnumeration> existingOptions = existingPDS.getEnumeratedValues(); List<PropertyDefinitionEnumeration> newOptions = newPDS.getEnumeratedValues(); existingPDS.removeEnumeratedValues(pde); existingPDS.addEnumeratedValues(pde); entityManager.persist(pde); Set<Constraint> exCon = existingPDS.getConstraints(); if (exCon.size() > 0) { for (Constraint con : exCon) { existingPDS.getConstraints().clear(); // clear out existing for (Constraint con : newPDS.getConstraints()) { existingPDS.addConstraints(con); existingPDS.setDefaultValue(newPDS.getDefaultValue()); existingPDS.setOptionsSource(newPDS.getOptionsSource()); } else {
/** * Copies the parameters of an OperationDefinition into to an object that can be * returned to a REST-client, so that this knows which fields are to be filled in, * of which type they are and which ones are required * @param def OperationsDefinition to "copy" * @param definitionRest The definition to fill in */ private void copyParamsForDefinition(OperationDefinition def, OperationDefinitionRest definitionRest) { ConfigurationDefinition cd = def.getParametersConfigurationDefinition(); if (cd==null) { return; } for (Map.Entry<String,PropertyDefinition> entry : cd.getPropertyDefinitions().entrySet()) { PropertyDefinition pd = entry.getValue(); if (pd instanceof PropertyDefinitionSimple) { PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd; SimplePropDef prop = new SimplePropDef(); prop.setName(pds.getName()); prop.setRequired(pds.isRequired()); prop.setType(pds.getType()); prop.setDefaultValue(pds.getDefaultValue()); definitionRest.addParam(prop); } log.debug("copyParams: " + pd.getName() + " not yet supported"); } }
if (propertyDefinition.getType().equals(PropertySimpleType.LONG)) { Long num = Long.parseLong(property.getStringValue()); } else { if (property.getStringValue() == null && propertyDefinition.isRequired()) { o = getObjectWithType(propertyDefinition, propertyDefinition.getDefaultValue()); } else { o = getObjectWithType(propertyDefinition, property.getStringValue());
private static PropertyDefinitionSimple createEnabled(ConfigurationDefinition configDef) { String name = PROP_ENABLED; String description = "Enables or disables the drift definition"; boolean required = true; PropertySimpleType type = PropertySimpleType.BOOLEAN; PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type); pd.setDisplayName("Enabled"); pd.setReadOnly(false); pd.setSummary(true); pd.setOrder(2); pd.setAllowCustomEnumeratedValue(false); pd.setConfigurationDefinition(configDef); pd.setDefaultValue(String.valueOf(DEFAULT_ENABLED)); return pd; }
PropertySimple loadHandlePropertySimple(PropertyDefinitionSimple propDef, Object valueObject) { PropertySimple propertySimple; String name = propDef.getName(); if (valueObject != null) { // Property is non-null -> return it. if (valueObject instanceof Map) { // If this is a map and no single type, get the EXPRESSION_VALUE Object o = ((Map) valueObject).get("EXPRESSION_VALUE"); propertySimple = new PropertySimple(name, o); } else { propertySimple = new PropertySimple(name, valueObject); } } else { // property is null? Check if it is required if (propDef.isRequired()) { String defaultValue = ((PropertyDefinitionSimple) propDef).getDefaultValue(); propertySimple = new PropertySimple(name, defaultValue); } else { // Not required and null -> return null propertySimple = new PropertySimple(name, null); } } return propertySimple; }
public boolean shouldBeObfuscated() { return getType() == PropertySimpleType.PASSWORD; }
@Override public String toString() { return "SimpleProperty[" + getName() + "] (Type: " + getType() + ")" + ((getPropertyGroupDefinition() != null) ? ("(Group: " + getPropertyGroupDefinition().getName() + ")") : ""); } }
private void createWriteAttributePropertySimple(CompositeOperation cop, PropertySimple property, PropertyDefinitionSimple propertyDefinition, Address address) { if (property.getName().endsWith(":ignore")) // Caller takes care return; if (propertyDefinition.isReadOnly() && !createChildRequested) return; //If the property value is null and the property is optional, //then send default value or null to the server if (property.getStringValue() == null && !propertyDefinition.isRequired()) { String name = property.getName(); if (name.indexOf(':') != -1) { name = name.substring(0, name.indexOf(":")); } Operation writeAttribute = new WriteAttribute(address, name, null); cop.addStep(writeAttribute); return; } SimpleEntry<String, Object> entry = this.preparePropertySimple(property, propertyDefinition); Operation writeAttribute = new WriteAttribute(address, entry.getKey(), entry.getValue()); cop.addStep(writeAttribute); }
.deCamelCase(simpleProperty.getName()); PropertyDefinitionSimple property = new PropertyDefinitionSimple(simpleProperty.getName(), description, simpleProperty.isRequired(), translatePropertyType(simpleProperty.getType())); property.setReadOnly(simpleProperty.isReadOnly()); property.setSummary(simpleProperty.isSummary()); property.setActivationPolicy(translateActivationPolicy(simpleProperty.getActivationPolicy())); property.setConstraints(translateContraints(simpleProperty.getConstraint())); property.setDisplayName(displayName); property.setDefaultValue(simpleProperty.getDefaultValue()); property.setUnits(MetricsMetadataParser.getMeasurementUnits(simpleProperty.getUnits(), null)); throw new IllegalArgumentException("Expression must be less than 400 chars long"); optionsSource.setExpression(expression); property.setOptionsSource(optionsSource);
PropertySimpleType type = PropertySimpleType.STRING; PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type); pd.setDisplayName("Drift Handling Mode"); pd.setReadOnly(false); pd.setSummary(true); pd.setOrder(4); pd.setConfigurationDefinition(configDef); pdEnums.add(normalEnum); pdEnums.add(plannedEnum); pd.setEnumeratedValues(pdEnums, false); pd.setDefaultValue(DEFAULT_DRIFT_HANDLING_MODE.name());
public static UIInput createInput(PropertyDefinitionSimple propertyDefinitionSimple) { UIInput input; PropertySimpleType type = (propertyDefinitionSimple != null) ? propertyDefinitionSimple.getType() : PropertySimpleType.STRING; switch (type) { input.getAttributes().put("label", propertyDefinitionSimple.getDisplayName()); input.getAttributes().put("ondblclick", "//" + propertyDefinitionSimple.getName());
PropertySimple propertySimple = this.propertyMap.getSimple(propertyDefinitionSimple.getName()); ValueExpression propertyValueExpression = createPropertyValueExpression(propertySimple.getName(), this.valueExpressionFormat); if (!propertyDefinitionSimple.isRequired()) PropertyRenderingUtility.addUnsetControl(parent, propertyDefinitionSimple.isRequired(), propertyDefinitionSimple.isReadOnly(), propertySimple, this.config.getListIndex(), input, this.isGroup, this.config.isReadOnly(), this.config.isFullyEditable()); FacesComponentUtility.addVerbatimText(parent, "</td>");
if (!propDef.isRequired() && property.getStringValue()==null) { return; if (propDef.isRequired() && property.getStringValue()==null) { messages.add(prefix + "required but was 'null'"); return; switch (propDef.getType()) { case DOUBLE: try {
private List<Validator> createSubValidators() { List<Validator> subValidators = new ArrayList<Validator>(); subValidators.add(new LengthValidator(PropertySimple.MAX_VALUE_LENGTH)); if (this.propertyDefinition != null) { switch (this.propertyDefinition.getType()) { case INTEGER: { subValidators.add(new LongRangeValidator(Integer.MAX_VALUE, Integer.MIN_VALUE)); break; } case LONG: { subValidators.add(new LongRangeValidator(Long.MAX_VALUE, Long.MIN_VALUE)); break; } case FLOAT: { subValidators.add(new DoubleRangeValidator(Float.MAX_VALUE, Float.MIN_VALUE)); break; } case DOUBLE: { subValidators.add(new DoubleRangeValidator(Double.MAX_VALUE, Double.MIN_VALUE)); break; // There is no need for type-based validators for booleans or enums, because the UI input controls // (e.g. radio buttons or pulldown menus) prevent invalid values from being entered. } } for (Constraint constraint : this.propertyDefinition.getConstraints()) { subValidators.add(createValidator(constraint)); } } return subValidators; }
PropertyDefinitionSimple def = configurationDefinition.getPropertyDefinitionSimple(property .getName()); if (!(ignoreReadOnly && def.isReadOnly())) { switch (def.getType()) { case INTEGER: { attribute.setValue(property.getIntegerValue());