@JsonIgnore public FieldRuleProperty getProperty(final String name) { return Iterables.tryFind(getProperties(), new Predicate<FieldRuleProperty>() { @Override public boolean apply(FieldRuleProperty fieldRuleProperty) { return fieldRuleProperty.getName().equalsIgnoreCase(name); } }).orNull(); }
/** * strip out everything that is not needed when saving */ @JsonIgnore public void simplifyForSerialization() { this.displayName = null; this.description = null; this.shortDescription = null; this.propertyValuesDisplayString = null; if (getProperties() != null) { for (FieldRuleProperty property : getProperties()) { property.simplifyForSerialization(); } } }
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); }
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); }
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); }
@JsonIgnore public void buildValueDisplayString() { StringBuffer sb = null; if (getProperties() != null) { for (FieldRuleProperty property : getProperties()) { if (!PolicyPropertyTypes.PROPERTY_TYPE.currentFeed.name().equalsIgnoreCase(property.getType())) { //get the values String value = property.getStringValue(); if (sb == null) { sb = new StringBuffer(); } else { sb.append(";"); } sb.append(property.getName() + ": " + value); } } } if (sb != null) { setPropertyValuesDisplayString(sb.toString()); } }
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; }
/** * 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); } }