org.springframework.batch.item.file.transform.FieldSet Java Examples

The following examples show how to use org.springframework.batch.item.file.transform.FieldSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordFieldSetMapper.java    From tutorials with MIT License 6 votes vote down vote up
public Transaction mapFieldSet(FieldSet fieldSet) throws BindException {

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyy");

        Transaction transaction = new Transaction();
        // you can either use the indices or custom names
        // I personally prefer the custom names easy for debugging and
        // validating the pipelines
        transaction.setUsername(fieldSet.readString("username"));
        transaction.setUserId(fieldSet.readInt("userid"));
        transaction.setAmount(fieldSet.readDouble(3));

        // Converting the date
        String dateString = fieldSet.readString(2);
        transaction.setTransactionDate(LocalDate.parse(dateString, formatter).atStartOfDay());

        return transaction;

    }
 
Example #2
Source File: VoltageFieldSetMapper.java    From batch-processing-large-datasets-spring with MIT License 5 votes vote down vote up
@Override
public Voltage mapFieldSet(FieldSet fieldSet) {
    final Voltage voltage = new Voltage();

    voltage.setVolt(fieldSet.readBigDecimal("volt"));
    voltage.setTime(fieldSet.readDouble("time"));
    return voltage;

}
 
Example #3
Source File: ProductFieldSetMapper.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ProductImportItem mapFieldSet(FieldSet fs) throws BindException {
	if (fs == null) {
		return null;
	}
	Product product = new Product();
	product.setIdentifier(fs.readString("IDENTIFIER"));
	product.setIdentifierType(fs.readString("IDENTIFIER_TYPE"));
	product.setCopyrightStatus(fs.readString("COPYRIGHT_STATUS"));
	product.setPublisher(fs.readString("PUBLISHER"));
	product.setTitle(fs.readString("TITLE"));
	product.setSubTitle(fs.readString("SUBTITLE"));
	product.setAlternativeTitle(fs.readString("ALTERNATIVE_TITLE"));
	product.setPrimaryCreators(fs.readString("PRIMARY_CREATORS"));
	product.setSecondaryCreators(fs.readString("SECONDARY_CREATORS"));
	product.setEdition(fs.readString("EDITION"));
	product.setPrimaryLanguages(fs.readString("PRIMARY_LANGUAGES"));
	product.setSecondaryLanguages(fs.readString("SECONDARY_LANGUAGES"));
	product.setSubjectArea(fs.readString("SUBJECT_AREA"));
	product.setPublicationDate(getDateTime(fs.readString("PUBLICATION_DATE")));
	product.setEmbargoDate(getDateTime(fs.readString("EMBARGO_DATE")));
	product.setLicenceFeeInDollars(fs.readBigDecimal("LICENCE_FEE_IN_DOLLARS"));
	product.setShortDescription(fs.readString("SHORT_DESCRIPTION"));
	product.setLongDescription(fs.readString("LONG_DESCRIPTION"));
	product.setParentIsbn(fs.readString("PARENT_ISBN"));
	product.setAlternateIsbn(fs.readString("ALTERNATE_ISBN"));
	product.setAudience(fs.readString("AUDIENCE"));
	product.setOneUpFilename(fs.readString("ONE_UP_PDF_FILENAME"));
	product.setTwoUpFilename(fs.readString("TWO_UP_PDF_FILENAME"));
	product.setA5Filename(fs.readString("A5_PDF_FILENAME"));
	product.setJacketImageFilename(fs.readString("JACKET_IMAGE_NAME"));
	product.setDisallowedCountries(fs.readString("TERRITORY"));
	product.setTags(fs.readString("TAGS"));
	product.setUrl(fs.readString("URL"));
	product.setUrlCallToAction(fs.readString("URL_CALL_TO_ACTION"));
	product.setSupportsAds(StringUtils.equals(fs.readString("SUPPORTS_ADS"), "1") ? true : false);
	product.setSamplePageRange(fs.readString("SAMPLE_PAGE_RANGE"));
	product.setLicenceStatement(fs.readString("LICENCE_STATEMENT"));
	return ProductImportItem.newInstance(product, fs.toString());
}
 
Example #4
Source File: BookRecordFieldSetMapper.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public BookRecord mapFieldSet(FieldSet fieldSet) throws BindException {
    BookRecord bookRecord = new BookRecord();
    bookRecord.setBookName(fieldSet.readString("bookname"));
    bookRecord.setBookAuthor(fieldSet.readString("bookauthor"));
    bookRecord.setBookFormat(fieldSet.readString("bookformat"));
    bookRecord.setBookISBN(fieldSet.readString("isbn"));
    bookRecord.setPublishingYear(fieldSet.readString("publishyear"));
    return bookRecord;
}
 
Example #5
Source File: FlatFileItemReaderAutoConfiguration.java    From spring-cloud-task with Apache License 2.0 4 votes vote down vote up
@Override
public Map<Object, Object> mapFieldSet(FieldSet fieldSet) {
	return fieldSet.getProperties();
}