/** * Transform a domain policy rule to a user interface object * * @param policyRule the domain object * @return the user interface object */ @Override public U toUIModel(P policyRule) { Annotation annotation = policyRule.getClass().getAnnotation(getAnnotationClass()); List<FieldRuleProperty> properties = getUiProperties(policyRule); U rule = buildUiModel((A) annotation, policyRule, properties); return rule; }
private List<LabelValue> convertToLabelValue(PropertyLabelValue[] propertyLabelValues) { List<LabelValue> labelValues = null; if (propertyLabelValues != null) { for (PropertyLabelValue propertyLabelValue : propertyLabelValues) { if (labelValues == null) { labelValues = new ArrayList<>(); } LabelValue labelValue = convertToLabelValue((propertyLabelValue)); if (labelValue != null) { labelValues.add(labelValue); } } } return labelValues; }
public List<FieldRuleProperty> findPropertiesForRulesMatchingDefaultValue(List<? extends BaseUiPolicyRule> rules, final String value) { List<FieldRuleProperty> properties = new ArrayList<>(); for (BaseUiPolicyRule rule : rules) { properties.addAll(rule.getProperties()); } return findPropertiesMatchingDefaultValue(properties, value); }
/** * Trasform a user interface object back to the domain policy class * * @param rule the ui object * @return the domain policy transformed */ @Override public P fromUiModel(U rule) throws PolicyTransformException { try { P domainPolicy = createClass(rule); if (hasConstructor(domainPolicy.getClass())) { for (FieldRuleProperty property : rule.getProperties()) { String field = property.getObjectProperty(); String value = property.getStringValue(); Field f = FieldUtils.getField(domainPolicy.getClass(), field, true); Object objectValue = convertStringToObject(value, f.getType()); f.set(domainPolicy, objectValue); } } afterFromUiModel(domainPolicy, rule); return domainPolicy; } catch (Exception e) { throw new PolicyTransformException(e); } }
Map<String, Integer> groupOrder = new HashMap<>(); Map<String, List<FieldRuleProperty>> groupedProperties = new HashMap<>(); if (hasConstructor(policy.getClass())) { .patternInvalidMessage(prop.patternInvalidMessage()) .hidden(prop.hidden()) .addSelectableValues(convertToLabelValue(prop.selectableValues())) .addSelectableValues(convertToLabelValue(prop.labelValues())) .addAdditionalProperties(convertToLabelValue(prop.additionalProperties())).build(); properties.add(rule); if (!group.equals("")) {
/** * Find all the user interface properies for a given render type */ public List<FieldRuleProperty> findPropertiesMatchingRenderType(List<FieldRuleProperty> properties, final String type) { if (StringUtils.isNotBlank(type)) { return findPropertiesMatchingRenderTypes(properties, new String[]{type}); } return null; }
public List<FieldRuleProperty> findPropertiesForRulesetMatchingRenderType(List<? extends BaseUiPolicyRule> rules, final String type) { List<FieldRuleProperty> properties = new ArrayList<>(); for (BaseUiPolicyRule rule : rules) { properties.addAll(rule.getProperties()); } return findPropertiesMatchingRenderType(properties, type); }
paramValue = getPropertyValue(rule, domainPolicyClass, (PolicyPropertyRef) a);
private Object getPropertyValue(BaseUiPolicyRule rule, Class<P> domainPolicyClass, PolicyPropertyRef reference) { for (FieldRuleProperty property : rule.getProperties()) { String name = property.getName(); if (name.equalsIgnoreCase(reference.name())) { String field = property.getObjectProperty(); String value = property.getStringValue(); Field f = FieldUtils.getField(domainPolicyClass, field, true); Object objectValue = convertStringToObject(value, f.getType()); return objectValue; } } return null; }
List<FieldRuleProperty> properties = new ArrayList<>(); Map<String, List<FieldRuleProperty>> groupedProperties = new HashMap<>(); if (hasConstructor(policyClass)) { Map<String, Integer> groupOrder = new HashMap<>(); for (AnnotatedFieldProperty<PolicyProperty> annotatedFieldProperty : list) { .pattern(prop.pattern()) .patternInvalidMessage(prop.patternInvalidMessage()) .addSelectableValues(convertToLabelValue(prop.selectableValues())) .addSelectableValues(convertToLabelValue(prop.labelValues())) .addAdditionalProperties(convertToLabelValue(prop.additionalProperties())).build(); properties.add(rule); if (!group.equals("")) {
public List<FieldRuleProperty> findPropertiesMatchingDefaultValue(List<FieldRuleProperty> properties, final String value) { if (StringUtils.isNotBlank(value)) { return findPropertiesMatchingRenderTypes(properties, new String[]{value}); } return null; }
public List<FieldRuleProperty> findPropertiesForRulesetMatchingRenderTypes(List<? extends BaseUiPolicyRule> rules, final String[] types) { List<FieldRuleProperty> properties = new ArrayList<>(); for (BaseUiPolicyRule rule : rules) { properties.addAll(rule.getProperties()); } return findPropertiesMatchingRenderTypes(properties, types); }