AbstractPropertyMap defaultConfigurationParentMap) throws InvalidPluginDescriptorException {
String description = parseMultiValue(simpleProperty.getDescription(), simpleProperty.getLongDescription());
String displayName = (simpleProperty.getDisplayName() != null) ? simpleProperty.getDisplayName() : StringUtils
.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));
String initialValue = simpleProperty.getInitialValue();
if ((defaultConfigurationParentMap != null) && (initialValue != null)) {
defaultConfigurationParentMap.put(new PropertySimple(simpleProperty.getName(), initialValue));
}
// Load the enumeration of options
if (simpleProperty.getPropertyOptions() != null) {
parsePropertyOptions(property, simpleProperty.getPropertyOptions());
}
if (simpleProperty.getOptionSource() != null) {
PropertyOptionsSource optionsSource = new PropertyOptionsSource();
OptionSource source = simpleProperty.getOptionSource();
optionsSource.setTarget(source.getTarget().toString());
optionsSource.setLinkToTarget(source.isLinkToTarget());
if (source.getFilter() != null && source.getFilter().length() > 40) {
throw new IllegalArgumentException("Filter expression must be less than 40 chars long");
}
optionsSource.setFilter(source.getFilter());
ExpressionScope expressionScope = source.getExpressionScope();
if (expressionScope != null) {
optionsSource.setExpressionScope(PropertyOptionsSource.ExpressionScope.fromValue(expressionScope
.value()));
}
String expression = source.getExpression();
if (expression == null || expression.isEmpty())
throw new IllegalArgumentException("Expression must not be empty");
if (expression.length() > 400)
throw new IllegalArgumentException("Expression must be less than 400 chars long");
optionsSource.setExpression(expression);
property.setOptionsSource(optionsSource);
}
return property;
}