public void testWidgetProcessor() { PathProcessor processor = new PathProcessor(); StaticXmlWidget springInput = new FormInputTag(); StaticSpringMetawidget metawidget = new StaticSpringMetawidget(); Map<String, String> attributes = CollectionUtils.newHashMap(); // Null value attributes.put(NAME, "bar"); springInput = processor.processWidget(springInput, PROPERTY, attributes, metawidget); assertEquals("<form:input path=\"bar\"/>", springInput.toString()); // Non-null value, no dot separator metawidget.setValue("foo"); springInput = processor.processWidget(springInput, PROPERTY, attributes, metawidget); assertEquals("<form:input path=\"bar\"/>", springInput.toString()); // Non-null value, dot separator metawidget.setValue("org.foo"); springInput = processor.processWidget(springInput, PROPERTY, attributes, metawidget); assertEquals("<form:input path=\"foo.bar\"/>", springInput.toString()); }
public List<JobParameter> getJobParameter( String jobName, String jobInstance, List<String> inputPaths) throws Exception { List<JobParameter> jobParams = new ArrayList<JobParameter>(); System.out.println( "Configuring job parameters job name :" + jobName + (null != inputPaths ? (" intput paths: " + inputPaths) : "")); JobConfig jobConfig = Configurator.instance().findJobConfig(jobName); if (null != jobConfig) { String className = jobConfig.getClassName(); Class<?> cls = Class.forName(className); List<String> args = new ArrayList<String>(); Tool job = (Tool) cls.newInstance(); List<String> distFiles = jobConfig.getFiles(); if (null != distFiles && !distFiles.isEmpty()) { String fileSt = buildComaSepString(distFiles); args.add("-files"); args.add(fileSt); } List<String> libJars = jobConfig.getLibjars(); if (null != libJars && !libJars.isEmpty()) { String libJarSt = buildComaSepString(libJars); args.add("-libjars"); args.add(libJarSt); } List<String> params = jobConfig.getUserParams(); if (null != params && !params.isEmpty()) { for (String param : params) { args.add("-D"); args.add(param); } } args.add("-D"); args.add("job.name=" + jobConfig.getName()); args.add("-D"); args.add("job.instance=" + jobInstance); List<String> allInputPaths = new ArrayList<String>(); List<String> confInputPaths = jobConfig.getInputPaths(); // input and output paths String outputPath = jobConfig.getOutputPath(); if (null != confInputPaths && !confInputPaths.isEmpty()) { String inpProcClass = jobConfig.getInputProcessorClass(); if (null != inpProcClass) { // process input and output paths Class<?> pathCls = Class.forName(inpProcClass); PathProcessor pathProc = (PathProcessor) pathCls.newInstance(); pathProc.initialize(jobConfig.getInputProcessorArgMap()); List<String> processedPaths = new ArrayList<String>(); for (String inpPath : confInputPaths) { processedPaths.add(pathProc.processInputPath(inpPath)); } allInputPaths.addAll(processedPaths); outputPath = pathProc.processOutputPath(outputPath); } else { allInputPaths.addAll(confInputPaths); } } // dependent job output paths if (null != inputPaths && !inputPaths.isEmpty()) { allInputPaths.addAll(inputPaths); } String inputPathSt = buildComaSepString(allInputPaths); args.add(inputPathSt); args.add(outputPath); String[] argArr = {}; argArr = args.toArray(argArr); JobParameter jobParam = new JobParameter(jobName, jobInstance, job, argArr); jobParams.add(jobParam); } else { throw new Exception("Invalid job name " + jobName); } return jobParams; }