List of usage examples for org.springframework.batch.item.file.transform FieldSet getProperties
Properties getProperties();
From source file:fr.acxio.tools.agia.alfresco.AbstractFieldSetToNodeMapping.java
@Override public Object transformData(FieldSet sData) { return (sData != null) ? sData.getProperties() : null; }
From source file:de.langmi.spring.batch.examples.readers.file.csv.FieldSetSqlParameterSourceProvider.java
/** {@inheritDoc} */ @Override/*from ww w . ja v a2 s . c o m*/ public SqlParameterSource createSqlParameterSource(FieldSet item) { MapSqlParameterSource sps = new MapSqlParameterSource(); for (Entry<Object, Object> entry : item.getProperties().entrySet()) { sps.addValue(entry.getKey().toString(), entry.getValue()); } return sps; }
From source file:fr.acxio.tools.agia.ConfigurationTest.java
@Test public void testSimpleNodeFactory() throws Exception { StandardEvaluationContext aContext = new StandardEvaluationContext(); FieldSet aData = new DefaultFieldSet(new String[] { "V1", "V2", "V3" }, new String[] { "C1", "C2", "C3" }); aContext.setVariable("in", aData.getProperties()); NodeList aNodeList = defaultNodeFactory.getNodes(aContext); assertNotNull(aNodeList);//from w w w.ja v a2 s .com assertEquals(5, aNodeList.size()); }
From source file:de.langmi.spring.batch.templates.importfile.generic.FieldSetSqlParameterSourceProvider.java
@Override public SqlParameterSource createSqlParameterSource(FieldSet item) { // map FieldSet to MapSqlParameterSource MapSqlParameterSource sps = new MapSqlParameterSource(); for (Entry<Object, Object> entry : item.getProperties().entrySet()) { sps.addValue(entry.getKey().toString(), entry.getValue()); }/* w w w .j a v a 2s. c o m*/ return sps; }
From source file:fr.acxio.tools.agia.item.MultiLineItemReader.java
@Override public synchronized T read() { List<FieldSet> aTmpResult = new ArrayList<FieldSet>(); boolean aConditionResult = false; FieldSet line = readNextFieldSet(); while (!aConditionResult && (line != null)) { aTmpResult.add(line);/*from ww w . j a va 2 s. co m*/ if (nextItem != null) { updateContext(currentVariableName, (line.hasNames()) ? line.getProperties() : line.getValues(), getEvaluationContext()); updateContext(nextVariableName, (nextItem.hasNames()) ? nextItem.getProperties() : nextItem.getValues(), getEvaluationContext()); aConditionResult = getExpressionResolver().evaluate(newRecordCondition, getEvaluationContext(), Boolean.class); } if (!aConditionResult) { line = readNextFieldSet(); } } return (aTmpResult.isEmpty() ? null : mapFieldSets(aTmpResult)); }
From source file:de.langmi.spring.batch.examples.readers.file.tokenizers.DelimitedLineTokenizerTests.java
/** * Standard tokenizer test with white space values. * Shows the differences for readString and readRawString, first one * trims whitespace.//from w w w.j a v a2 s.com * * @throws Exception * @see http://forum.springsource.org/showthread.php?114765-Issue-FlatFileItemReader-automatically-Trimming-the-leading-and-trailing-spaces */ @Test public void testWithSpaces() throws Exception { // set names only, standard configuration tokenizer.setNames(new String[] { "id", "value1", "value2" }); // fire FieldSet fieldSet = tokenizer.tokenize("1, foo , bar"); // assertions assertNotNull(fieldSet); assertTrue("field count", fieldSet.getFieldCount() == 3); assertEquals("1", fieldSet.readString("id")); // readString trims assertEquals("foo", fieldSet.readString("value1")); assertEquals("bar", fieldSet.readString("value2")); // readRawString does not trim assertEquals(" foo ", fieldSet.readRawString("value1")); assertEquals(" bar", fieldSet.readRawString("value2")); // assertions with properties Properties props = fieldSet.getProperties(); // the used fieldSet impl. trims whitespace in its getProperties method // see http://forum.springsource.org/showthread.php?114765-Issue-FlatFileItemReader-automatically-Trimming-the-leading-and-trailing-spaces // for follow up problems e.g. with BeanWrapperFieldSetMapper assertEquals("foo", props.getProperty("value1")); assertEquals("bar", props.getProperty("value2")); }