]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/ExecutionParameterPostProcessor.java
Local variables management
[gpl/argeo-slc.git] / sandbox / argeo.slc.executionflow / src / main / java / org / argeo / slc / executionflow / ExecutionParameterPostProcessor.java
index adeddaafb9231198ea541024b6ebf4a6a6b0c788..e7a6a0de7cded641aa18d8e8cabd2710a8e29413 100644 (file)
@@ -28,27 +28,30 @@ public class ExecutionParameterPostProcessor extends
        public PropertyValues postProcessPropertyValues(PropertyValues pvs,
                        PropertyDescriptor[] pds, Object bean, String beanName)
                        throws BeansException {
-               ExecutionFlow currentFlow = ExecutionContext.getCurrentFlow();
-               if (currentFlow == null)
+               if (!ExecutionContext.isExecuting())
                        return pvs;
 
+//             ExecutionFlow currentFlow = ExecutionContext.getCurrentFlow();
+//
+//             Properties props = new Properties();
+//             Map<String, Object> attributes = currentFlow.getAttributes();
+//             Map<String, ExecutionSpecAttribute> specAttributes = currentFlow
+//                             .getExecutionSpec().getAttributes();
+//
+//             for (String key : specAttributes.keySet()) {
+//                     ExecutionSpecAttribute obj = specAttributes.get(key);
+//                     if (!(obj instanceof RefSpecAttribute)) {
+//                             if (!attributes.containsKey(key))
+//                                     throw new SlcException("Specified attribute " + key
+//                                                     + " is not set in " + currentFlow);
+//
+//                             props.setProperty(key, attributes.get(key).toString());
+//                             // if (log.isTraceEnabled())
+//                             // log.trace("Use attribute " + key);
+//                     }
+//             }
+
                Properties props = new Properties();
-               Map<String, Object> attributes = currentFlow.getAttributes();
-               Map<String, ExecutionSpecAttribute> specAttributes = currentFlow
-                               .getExecutionSpec().getAttributes();
-
-               for (String key : specAttributes.keySet()) {
-                       ExecutionSpecAttribute obj = specAttributes.get(key);
-                       if (!(obj instanceof RefSpecAttribute)) {
-                               if (!attributes.containsKey(key))
-                                       throw new SlcException("Specified attribute " + key
-                                                       + " is not set in " + currentFlow);
-
-                               props.setProperty(key, attributes.get(key).toString());
-//                             if (log.isTraceEnabled())
-//                                     log.trace("Use attribute " + key);
-                       }
-               }
                CustomPpc ppc = new CustomPpc(props);
 
                for (PropertyValue pv : pvs.getPropertyValues()) {
@@ -59,14 +62,14 @@ public class ExecutionParameterPostProcessor extends
                                tsv.setValue(convertedValue);
                                if (log.isTraceEnabled()) {
                                        if (!originalValue.equals(convertedValue))
-                                               log.trace("Converted " + beanName + "[" + pv.getName()
-                                                               + "]: " + originalValue + " to "
-                                                               + convertedValue);
+                                               log.trace("Converted field '" + pv.getName() + "': '"
+                                                               + originalValue + "' to '" + convertedValue
+                                                               + "' in bean " + beanName);
                                }
                        } else {
-//                             if (log.isTraceEnabled())
-//                                     log.trace(beanName + "[" + pv.getName() + "]: "
-//                                                     + pv.getValue().getClass());
+                               // if (log.isTraceEnabled())
+                               // log.trace(beanName + "[" + pv.getName() + "]: "
+                               // + pv.getValue().getClass());
                        }
                }
 
@@ -97,8 +100,21 @@ public class ExecutionParameterPostProcessor extends
                }
 
                public String process(String strVal) {
-                       String value = parseStringValue(strVal, this.props, new HashSet<String>());
+                       String value = parseStringValue(strVal, this.props,
+                                       new HashSet<String>());
                        return (value.equals(nullValue) ? null : value);
                }
+
+               @Override
+               protected String resolvePlaceholder(String placeholder, Properties props) {
+                       if (ExecutionContext.isExecuting())
+                               return ExecutionContext.getVariable(placeholder).toString();
+                       else if (SimpleExecutionSpec.isInFlowInitialization())
+                               return SimpleExecutionSpec.getInitializingFlowParameter(
+                                               placeholder).toString();
+                       else
+                               return super.resolvePlaceholder(placeholder, props);
+               }
+
        }
 }