Retrieves property definitions and property validation rules, and validates and sets their values.
List<PropertyDefinition2VO> getPropertyDefinitions() throws SUPAdminException; List<PropertyValidationRuleVO> getPropertyValidationRules() throws SUPAdminException;
If successful, returns an object of the specified type (can be null). If unsuccessful, returns SUPAdminException.
// Get property definitions
List<PropertyDefinition2VO> definitions = deviceUser
.getPropertyDefinitions();
// Get property validation rules
List<PropertyValidationRuleVO> validationRules = deviceUser
.getPropertyValidationRules();
// Bellow shows how to use PropertyDefinition2VO and
// PropertyValidationRuleVO
// Get the Property Definition for property ID 2.
PropertyDefinition2VO propMetadataWithIDTwo = null;
for (PropertyDefinition2VO propMetadata : definitions) {
if (propMetadata.getID() == 2) {
propMetadataWithIDTwo = propMetadata;
}
}
// Get the Property Validation Rule for propMetadataWithIDTwo.
PropertyValidationRuleVO validationRule = null;
for (PropertyValidationRuleVO rule : validationRules) {
if (rule.getValidationID() == propMetadataWithIDTwo
.getValidateRuleID()) {
validationRule = rule;
}
}
PropertyItemVO propertyItem = new PropertyItemVO();
propertyItem.setPropertyID(2);
int value = 5001;
// validate the property value
if (value < validationRule.getMinValue()
|| validationRule.getMaxValue() < value) {
throw new Exception("the value is not valid!");
}
// Now the value is valid, set the value.
propertyItem.setPropertyValue(value);