Interface DataFeedFileTransformer
- All Superinterfaces:
org.springframework.core.Ordered
- All Known Implementing Classes:
AbstractJsonArrayToCSVFileTransformer
,AbstractJsonArrayToXMLFileTransformer
,CollectedProductJsonArrayToCommerceManagerFeedCSVFileTransformer
,CollectedProductJsonArrayToMerchantCenterXMLFileTransformer
AbstractFileFeedPublisher
implementations will inject and delegate to
components of this type.
Capable of processing a source data file (ex:
DataFeedPublishRequestDetails.getQueriedDataFileLocalCopy()
) and transforming it into a
final file ready for submission to a destination (ex:
AbstractFileFeedPublisher.FilePublishContext.getLocalOutputFile()
.
Typically, implementations of this component will delegate transformation of source POJO elements
to destination POJO elements via DataFeedElementTransformer
, and then serialize the
results.
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(DataFeedPublishRequestDetails requestDetails) Reports whether this component can handle processing a file transformation for the givenDataFeedPublishRequestDetails
.createLocalOutputFile
(DataFeedPublishRequestDetails publishRequest) Create the local output file that will ultimately be populated bytransform(FilePublishContext)
.default int
getOrder()
transform
(AbstractFileFeedPublisher.FilePublishContext filePublishContext) Prepares theAbstractFileFeedPublisher.FilePublishContext.getLocalOutputFile()
such that it is ready for submission.
-
Method Details
-
canHandle
Reports whether this component can handle processing a file transformation for the givenDataFeedPublishRequestDetails
.- Parameters:
requestDetails
- request details around the publish process- Returns:
- true if this component can handle the transformation for the given file, false otherwise
-
createLocalOutputFile
Create the local output file that will ultimately be populated bytransform(FilePublishContext)
.In almost all cases, this should point to a temporary file (ex:
Files.createTempFile(String, String, FileAttribute[])
)Note that this method is intentionally simple and is not intended to be a place where file contents are initialized.
Since this is the file that will ultimately be uploaded to the destination, ensure it has the appropriate file name/extensions required by the provider.
- Parameters:
publishRequest
- the publish request details- Returns:
- a reference to the created file
- Throws:
Exception
- if something went wrong- See Also:
-
transform
DataFeedFileTransformResponseDetails transform(AbstractFileFeedPublisher.FilePublishContext filePublishContext) Prepares theAbstractFileFeedPublisher.FilePublishContext.getLocalOutputFile()
such that it is ready for submission. This includes reading through source data fromDataFeedPublishRequestDetails.getQueriedDataFileLocalCopy()
and transforming + serializing its contents to the destination file in the expected format.- Parameters:
filePublishContext
- details around the file publish process- Returns:
- details about the success/failure of the operation
-
getOrder
default int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-