@Test public void testPopulatePropertyExpressionsFromGraph_RefreshGraphs() { Map<String, String> expressionGraph = new HashMap<String, String>(); expressionGraph.put("property1", "@{expr1}"); expressionGraph.put("property2", "@{expr2}"); expressionGraph.put("property3['key1']", "@{key1expr}"); expressionGraph.put("property4.property1", "@{nexpr1}"); expressionGraph.put("property4.property4.property3['key2']", "@{nkey2expr}"); MockConfigurable configurable = new MockConfigurable(); MockConfigurable configurable2 = new MockConfigurable(); MockConfigurable configurable3 = new MockConfigurable(); configurable2.setProperty4(configurable3); configurable.setProperty4(configurable2); configurable.setExpressionGraph(expressionGraph); ViewLifecycle.getExpressionEvaluator().populatePropertyExpressionsFromGraph(configurable, true); }
public static void populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable) { if (expressionConfigurable == null || expressionConfigurable.getExpressionGraph() == null) { return; } Map<String, Map<String, String>> refreshExpressionGraphs = new HashMap<String, Map<String, String>>(); Map<String, String> expressionGraph = expressionConfigurable.getExpressionGraph(); for (Map.Entry<String, String> expressionEntry : expressionGraph.entrySet()) { String propertyName = expressionEntry.getKey(); String expression = expressionEntry.getValue(); UifDictionaryBean configurableWithExpression = expressionConfigurable; String adjustedPropertyName = propertyName; if (StringUtils.contains(propertyName, ".")) { String configurablePath = StringUtils.substringBeforeLast(propertyName, "."); adjustedPropertyName = StringUtils.substringAfterLast(propertyName, "."); Object nestedObject = ObjectPropertyUtils.getPropertyValue(expressionConfigurable, configurablePath); if (nestedObject == null && expressionConfigurable instanceof LifecycleElement && ((LifecycleElement) expressionConfigurable).skipLifecycle()) { continue; } if ((nestedObject == null) || !(nestedObject instanceof UifDictionaryBean)) { throw new RiceRuntimeException("Object for which expression is configured on is null or does not " + "implement UifDictionaryBean: '" + configurablePath + "' on class " + expressionConfigurable.getClass().getName() + " while evaluating " + "expression for " + propertyName); } configurableWithExpression = (UifDictionaryBean) nestedObject; } configurableWithExpression.getPropertyExpressions().put(adjustedPropertyName, expression); } }
ExpressionUtils { public static void populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable) { if (expressionConfigurable == null || expressionConfigurable.getExpressionGraph() == null) { return; } Map<String, Map<String, String>> refreshExpressionGraphs = new HashMap<String, Map<String, String>>(); Map<String, String> expressionGraph = expressionConfigurable.getExpressionGraph(); for (Map.Entry<String, String> expressionEntry : expressionGraph.entrySet()) { String propertyName = expressionEntry.getKey(); String expression = expressionEntry.getValue(); UifDictionaryBean configurableWithExpression = expressionConfigurable; String adjustedPropertyName = propertyName; if (StringUtils.contains(propertyName, ".")) { String configurablePath = StringUtils.substringBeforeLast(propertyName, "."); adjustedPropertyName = StringUtils.substringAfterLast(propertyName, "."); Object nestedObject = ObjectPropertyUtils.getPropertyValue(expressionConfigurable, configurablePath); if (nestedObject == null && expressionConfigurable instanceof LifecycleElement && ((LifecycleElement) expressionConfigurable).skipLifecycle()) { continue; } if ((nestedObject == null) || !(nestedObject instanceof UifDictionaryBean)) { throw new RiceRuntimeException("Object for which expression is configured on is null or does not " + "implement UifDictionaryBean: '" + configurablePath + "' on class " + expressionConfigurable.getClass().getName() + " while evaluating " + "expression for " + propertyName); } configurableWithExpression = (UifDictionaryBean) nestedObject; } configurableWithExpression.getPropertyExpressions().put(adjustedPropertyName, expression); } } }
ExpressionUtils { public static void populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable) { if (expressionConfigurable == null || expressionConfigurable.getExpressionGraph() == null) { return; } Map<String, Map<String, String>> refreshExpressionGraphs = new HashMap<String, Map<String, String>>(); Map<String, String> expressionGraph = expressionConfigurable.getExpressionGraph(); for (Map.Entry<String, String> expressionEntry : expressionGraph.entrySet()) { String propertyName = expressionEntry.getKey(); String expression = expressionEntry.getValue(); UifDictionaryBean configurableWithExpression = expressionConfigurable; String adjustedPropertyName = propertyName; if (StringUtils.contains(propertyName, ".")) { String configurablePath = StringUtils.substringBeforeLast(propertyName, "."); adjustedPropertyName = StringUtils.substringAfterLast(propertyName, "."); Object nestedObject = ObjectPropertyUtils.getPropertyValue(expressionConfigurable, configurablePath); if (nestedObject == null && expressionConfigurable instanceof LifecycleElement && ((LifecycleElement) expressionConfigurable).skipLifecycle()) { continue; } if ((nestedObject == null) || !(nestedObject instanceof UifDictionaryBean)) { throw new RiceRuntimeException("Object for which expression is configured on is null or does not " + "implement UifDictionaryBean: '" + configurablePath + "' on class " + expressionConfigurable.getClass().getName() + " while evaluating " + "expression for " + propertyName); } configurableWithExpression = (UifDictionaryBean) nestedObject; } configurableWithExpression.getPropertyExpressions().put(adjustedPropertyName, expression); } }  }
ExpressionUtils { public static void populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable) { if (expressionConfigurable == null || expressionConfigurable.getExpressionGraph() == null) { return; } Map<String, Map<String, String>> refreshExpressionGraphs = new HashMap<String, Map<String, String>>(); Map<String, String> expressionGraph = expressionConfigurable.getExpressionGraph(); for (Map.Entry<String, String> expressionEntry : expressionGraph.entrySet()) { String propertyName = expressionEntry.getKey(); String expression = expressionEntry.getValue(); UifDictionaryBean configurableWithExpression = expressionConfigurable; String adjustedPropertyName = propertyName; if (StringUtils.contains(propertyName, ".")) { String configurablePath = StringUtils.substringBeforeLast(propertyName, "."); adjustedPropertyName = StringUtils.substringAfterLast(propertyName, "."); Object nestedObject = ObjectPropertyUtils.getPropertyValue(expressionConfigurable, configurablePath); if (nestedObject == null && expressionConfigurable instanceof LifecycleElement && ((LifecycleElement) expressionConfigurable).skipLifecycle()) { continue; } if ((nestedObject == null) || !(nestedObject instanceof UifDictionaryBean)) { throw new RiceRuntimeException("Object for which expression is configured on is null or does not " + "implement UifDictionaryBean: '" + configurablePath + "' on class " + expressionConfigurable.getClass().getName() + " while evaluating " + "expression for " + propertyName); } configurableWithExpression = (UifDictionaryBean) nestedObject; } configurableWithExpression.getPropertyExpressions().put(adjustedPropertyName, expression); } }  static void populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable); static String parseExpression(String exp, List<String> controlNames); static void evaluateCurrentStack(String stack, List<String> controlNames); }
ExpressionUtils { public static void populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable) { if (expressionConfigurable == null || expressionConfigurable.getExpressionGraph() == null) { return; } Map<String, Map<String, String>> refreshExpressionGraphs = new HashMap<String, Map<String, String>>(); Map<String, String> expressionGraph = expressionConfigurable.getExpressionGraph(); for (Map.Entry<String, String> expressionEntry : expressionGraph.entrySet()) { String propertyName = expressionEntry.getKey(); String expression = expressionEntry.getValue(); UifDictionaryBean configurableWithExpression = expressionConfigurable; String adjustedPropertyName = propertyName; if (StringUtils.contains(propertyName, ".")) { String configurablePath = StringUtils.substringBeforeLast(propertyName, "."); adjustedPropertyName = StringUtils.substringAfterLast(propertyName, "."); Object nestedObject = ObjectPropertyUtils.getPropertyValue(expressionConfigurable, configurablePath); if (nestedObject == null && expressionConfigurable instanceof LifecycleElement && ((LifecycleElement) expressionConfigurable).skipLifecycle()) { continue; } if ((nestedObject == null) || !(nestedObject instanceof UifDictionaryBean)) { throw new RiceRuntimeException("Object for which expression is configured on is null or does not " + "implement UifDictionaryBean: '" + configurablePath + "' on class " + expressionConfigurable.getClass().getName() + " while evaluating " + "expression for " + propertyName); } configurableWithExpression = (UifDictionaryBean) nestedObject; } configurableWithExpression.getPropertyExpressions().put(adjustedPropertyName, expression); } }  static void populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable); static String parseExpression(String exp, List<String> controlNames); static void evaluateCurrentStack(String stack, List<String> controlNames);  }