@Override public boolean suits(TablePropertyDefinitionWrapper wrapper) { // The tablePropertyDefinition suits if the match expression is not empty // return wrapper.getDefinition().getExpression() != null; } });
private void applyDomain(TablePropertyDefinition propDef, IDomainAdaptor gatheredDomain) { String propName = propDef.getName(); String key = propName + ADispatcherTableColumn.LOCAL_PARAM_SUFFIX; if (gatheredDomain != null && !propertiesDomains.containsKey(key)) { if (propDef.getExpression() != null) { propertiesDomains.put(propDef.getExpression().getMatchExpression().getContextAttribute(), gatheredDomain); propertiesDomains.put(propName, gatheredDomain); propertiesDomains.put(key, gatheredDomain); } } }
public String getCodeExpression() { MatchingExpression matchExpression = getProperty().getExpression(); String result = getMatchByDefaultCodeExpression(matchExpression); // array values can have only "contains" operation // StringBuilder codeExpression = new StringBuilder(); if (matchExpression != null) { codeExpression.append("contains("); codeExpression.append(getLocalParameterName()); codeExpression.append(","); codeExpression.append(matchExpression.getMatchExpression().getContextAttribute()); codeExpression.append(")"); result += codeExpression.toString(); } else { String message = String.format("Can`t create expression for \"%s\" property validation.", getProperty().getName()); throw new OpenlNotCheckedException(message); } return result; }
private static TablePropertyDefinition getTablePropertyDefinition(Attribute attribute) { List<TablePropertyDefinition> dimensionalTableProperties = TablePropertyDefinitionUtils.getDimensionalTableProperties(); Class<? extends Constraint> constraintClass = getConstraintClass(attribute); for (TablePropertyDefinition property : dimensionalTableProperties) { String contextAttribute = property.getExpression().getMatchExpression().getContextAttribute(); if (contextAttribute.equals(attribute.getName())) { Constraints constraints = property.getConstraints(); if (constraints.size() == 1) { Constraint constraint = constraints.get(0); if (constraintClass == null || constraintClass.isAssignableFrom(constraint.getClass())) { return property; } } } } return null; }
private void init() { MatchingExpression expression = tablePropertyDefinition.getExpression(); if (expression != null) { operationName = expression.getMatchExpression().getOperationName(); propertyVar = tablePropertyDefinition.getName(); contextVar = expression.getMatchExpression().getContextAttribute(); } }
public String getCodeExpression() { String result = StringUtils.EMPTY; String propertyName = getProperty().getName(); MatchingExpression matchExpression = getProperty().getExpression(); if (matchExpression != null) { String parameterName = propertyName + ADispatcherTableColumn.LOCAL_PARAM_SUFFIX; result = getMatchByDefaultCodeExpression(matchExpression) + matchExpression.getMatchExpression().getCodeExpression(parameterName); } else { String message = String.format("Can`t create expression for \"%s\" property validation.", propertyName); throw new OpenlNotCheckedException(message); } return result; }
private Object convertAttribute(String attributeName, Object attributeValue) { List<TablePropertyDefinition> dimensionalTableProperties = TablePropertyDefinitionUtils.getDimensionalTableProperties(); for (TablePropertyDefinition property : dimensionalTableProperties) { String contextAttribute = property.getExpression().getMatchExpression().getContextAttribute(); if (contextAttribute.equals(attributeName)) { IOpenClass type = property.getType(); if (type.isArray()) { type = type.getComponentClass(); } IString2DataConvertor converter = String2DataConvertorFactory.getConvertor(type.getInstanceClass()); String argument = HelperFunctions.convertArgument(String.class, attributeValue); return converter.parse(argument, property.getFormat()); } } // Couldn't find property and converter for it return attributeValue; } }