Class AbstractJsonArrayToCSVFileTransformer<S,D>
java.lang.Object
com.broadleafcommerce.datafeed.service.publisher.file.transformer.AbstractJsonArrayToCSVFileTransformer<S,D>
- Type Parameters:
S- seeDataFeedElementTransformer.getSourceElementType()D- seeDataFeedElementTransformer.getDestinationElementType(). This should contain any CSV serialization configuration details as necessary, since it will be used to build the CSV schema. SeebuildCsvSchema(CsvMapper)
- All Implemented Interfaces:
DataFeedFileTransformer,org.springframework.core.Ordered
- Direct Known Subclasses:
CollectedProductJsonArrayToCommerceManagerFeedCSVFileTransformer
public abstract class AbstractJsonArrayToCSVFileTransformer<S,D>
extends Object
implements DataFeedFileTransformer
Common starting point for a
DataFeedFileTransformer for transforming a source JSON array
to a destination CSV.
This is not intended for use as a singleton bean, and each eligible use-case should
define its own new extension of this type. Due to delegation of actual element
conversion to DataFeedElementTransformer, this component is fairly generic and multiple
beans of this type can be declared (with different names) as needed with different element
transformers.
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractJsonArrayToCSVFileTransformer(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, DataFeedElementTransformer<S, D> elementTransformer, int maxSourceElementsToReadInBatch) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.fasterxml.jackson.dataformat.csv.CsvMapperGenerally sensible defaults for a CSV mapper.protected com.fasterxml.jackson.dataformat.csv.CsvSchemabuildCsvSchema(com.fasterxml.jackson.dataformat.csv.CsvMapper csvMapper) protected DataFeedFileTransformResponseDetailsbuildFailedResponse(List<String> errorDetails) protected DataFeedFileTransformResponseDetailsbuildSuccessResponse(boolean resultShouldBeSubmitted) protected DataFeedElementTransformer<S,D> Delegate for converting source elements into destination elements.protected intLimits the number of elements that are read from the source file at a time.protected com.fasterxml.jackson.databind.ObjectMapperprotected com.broadleafcommerce.common.extension.TypeFactorytransform(AbstractFileFeedPublisher.FilePublishContext publishContext) For reference, see this article on writing CSV with JacksonMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.datafeed.service.publisher.file.transformer.DataFeedFileTransformer
canHandle, createLocalOutputFile, getOrder
-
Constructor Details
-
AbstractJsonArrayToCSVFileTransformer
public AbstractJsonArrayToCSVFileTransformer(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, DataFeedElementTransformer<S, D> elementTransformer, int maxSourceElementsToReadInBatch)
-
-
Method Details
-
transform
public DataFeedFileTransformResponseDetails transform(AbstractFileFeedPublisher.FilePublishContext publishContext) For reference, see this article on writing CSV with Jackson- Specified by:
transformin interfaceDataFeedFileTransformer- Parameters:
publishContext- details around the file publish process- Returns:
- details about the success/failure of the operation
-
buildCsvMapper
protected com.fasterxml.jackson.dataformat.csv.CsvMapper buildCsvMapper()Generally sensible defaults for a CSV mapper.- Returns:
- the CsvMapper to write with
-
buildCsvSchema
protected com.fasterxml.jackson.dataformat.csv.CsvSchema buildCsvSchema(com.fasterxml.jackson.dataformat.csv.CsvMapper csvMapper) - Parameters:
csvMapper- the csvMapper that can be used to help construct this schema- Returns:
- the CsvSchema to write with
-
buildFailedResponse
-
buildSuccessResponse
protected DataFeedFileTransformResponseDetails buildSuccessResponse(boolean resultShouldBeSubmitted) -
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getElementTransformer
Delegate for converting source elements into destination elements. -
getMaxSourceElementsToReadInBatch
protected int getMaxSourceElementsToReadInBatch()Limits the number of elements that are read from the source file at a time.
-