Class DefaultSpecification
- All Implemented Interfaces:
ImportSpecification
- Direct Known Subclasses:
CampaignCodeSpecification
,CompleteProductImportSpecification
,CustomerSegmentMemberSpecification
,CustomerSpecification
,OfferCodeSpecification
,PriceDataSpecification
,ProductSpecification
,SkuInventoryImportSpecification
,UpdatePricesSpecification
- Author:
- Phillip Verheyden (phillipuniverse)
-
Field Summary
Modifier and TypeFieldDescriptionDependency mappings don't change, so define a immutable instance of them for efficiency.protected LinkedHashMap<String,
ImportFieldConfig> Deprecated, for removal: This API element is subject to removal in a future version.Fields inherited from interface com.broadleafcommerce.dataimport.processor.specification.ImportSpecification
ROW_DETERMINATION_COLUMN
-
Constructor Summary
ConstructorDescriptionDefaultSpecification
(String importType) DefaultSpecification
(String importType, String name) DefaultSpecification
(String importType, List<String> requiredAuthorities, List<String> requiredScopes) DefaultSpecification
(String importType, List<String> requiredAuthorities, List<String> requiredScopes, String name) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether or not this specification can actually handle the given import.Dependency mappings don't change, so define a immutable instance of them for efficiency.protected Map<String,
List<DynamicHeaderFieldMapping>> Deprecated.These represent the fields expected for this specification.Which import type this specification is valid forgetName()
This is an arbitrary name for the specification, potentially allowing more than one specification for a particular type for a particular tenant or application.The list of required authorities necessary for carrying out a specific import.Deprecated, for removal: This API element is subject to removal in a future version.getRequiredHeaders
(String rowType) Gets all the required headers for the provided row type.The list of required scopes necessary for carrying out a specific import.boolean
Whether or not the import requires a header forrow_type
.mapDynamicFieldToHeader
(String field, String rowType) Similar toImportSpecification.mapDynamicHeaderToField(String, String)
, but for reverse mappings from field names back to header names.mapDynamicHeaderToField
(String header, String rowType) The specification may support dynamic header-field mappings beyond any hardcoded configuration inImportSpecification.getHeaderFieldConfigsByRowType()
.protected void
populateDynamicHeaderMappingsByRowType
(Map<String, List<DynamicHeaderFieldMapping>> dynamicHeaderMappingConfigsByRowType) This method is always invoked in the constructor - seecreateUnmodifiableDynamicHeaderMappingsByRowType()
.protected void
populateHeaderFieldConfigsByRowType
(Map<String, Map<String, ImportFieldConfig>> headerFieldConfigsByRowType) This method is always invoked in the constructor - seecreateUnmodifiableHeaderFieldConfigsByRowType()
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.dataimport.processor.specification.ImportSpecification
getImportDataNormalizers, getMainRecordType, isCatalogDiscriminated, isSandboxDiscriminated, parentEntityIdRequiredInRequest, resolveAndRemoveRecordType, resolveRecordTypeBeforePropertyMapping, shouldAllowUnmappedHeaders, shouldAutoGenerateOperationTypeForEachRecord, shouldAutoGenerateResourceTierIdForEachRecord
-
Field Details
-
fieldConfigMap
@Deprecated(since="1.8.1", forRemoval=true) protected LinkedHashMap<String,ImportFieldConfig> fieldConfigMapDeprecated, for removal: This API element is subject to removal in a future version.This has been deprecated in favor ofgetHeaderFieldConfigsByRowType()
. -
dependencyMappings
Dependency mappings don't change, so define a immutable instance of them for efficiency.This is important, as
getDependencyMappings()
is invoked multiple times for each row of an import.
-
-
Constructor Details
-
DefaultSpecification
-
DefaultSpecification
-
DefaultSpecification
-
DefaultSpecification
-
-
Method Details
-
canHandle
Description copied from interface:ImportSpecification
Whether or not this specification can actually handle the given import. Checks will generally be based on the import type.- Specified by:
canHandle
in interfaceImportSpecification
- Returns:
- whether or not this specification can actually handle the given import
-
populateHeaderFieldConfigsByRowType
protected void populateHeaderFieldConfigsByRowType(Map<String, Map<String, ImportFieldConfig>> headerFieldConfigsByRowType) This method is always invoked in the constructor - seecreateUnmodifiableHeaderFieldConfigsByRowType()
.Extensions of this class should override this method and use it to populate the values that they want to ultimately be in
getHeaderFieldConfigsByRowType()
.- Parameters:
headerFieldConfigsByRowType
- a special, mutable map instance which implementations should populate with field configurations. This map will ultimately be copied into an unmodifiable separate instance that will actually be used forgetHeaderFieldConfigsByRowType()
.
-
populateDynamicHeaderMappingsByRowType
protected void populateDynamicHeaderMappingsByRowType(Map<String, List<DynamicHeaderFieldMapping>> dynamicHeaderMappingConfigsByRowType) This method is always invoked in the constructor - seecreateUnmodifiableDynamicHeaderMappingsByRowType()
.Extensions of this class should override this method and use it to populate the values that they want to ultimately be in
getDynamicHeaderMappingConfigsByRowType()
.- Parameters:
dynamicHeaderMappingConfigsByRowType
- a special, mutable map instance which implementations should populate with dynamic header mappings. This map will ultimately be copied into an unmodifiable separate instance that will actually be used forgetDynamicHeaderMappingConfigsByRowType()
.
-
isRequiresRowTypeHeader
public boolean isRequiresRowTypeHeader()Description copied from interface:ImportSpecification
Whether or not the import requires a header forrow_type
. This is generally only required when there are multiple record types in an import, but could also be used to dynamically determine the row type during processing- Specified by:
isRequiresRowTypeHeader
in interfaceImportSpecification
- Returns:
- whether or not this import requires a row type header
-
getRequiredHeaders
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:ImportSpecification
This should represent the required headers that will be validated for _all_ row types. For consistency, the implementation of this should be backed byImportSpecification.getFieldConfigMap()
.- Specified by:
getRequiredHeaders
in interfaceImportSpecification
- Returns:
- the list of required headers for all row types
- See Also:
-
getRequiredHeaders
Description copied from interface:ImportSpecification
Gets all the required headers for the provided row type. Each row of the given type should be required to provide a value for each of the returned headers.For consistency, this should ideally be backed by the implementation of
ImportSpecification.getHeaderFieldConfigsByRowType()
.The default implementation in this interface will be removed at the time
ImportSpecification.getRequiredHeaders()
is removed, with the expectation that a realImportSpecification.getHeaderFieldConfigsByRowType()
will be backing the implementation..- Specified by:
getRequiredHeaders
in interfaceImportSpecification
- Parameters:
rowType
- the row type to get the required headers for- Returns:
- a list of required headers for the provided row type. Should be empty if there are no required headers.
- See Also:
-
mapDynamicHeaderToField
Description copied from interface:ImportSpecification
The specification may support dynamic header-field mappings beyond any hardcoded configuration inImportSpecification.getHeaderFieldConfigsByRowType()
. If so, then this method should be overridden to attempt performing such mappings on the given header for the given row type. If the mapping is successful, the mapped field should be returned, elsenull
.Typically, any hard-coded mappings in
ImportSpecification.getHeaderFieldConfigsByRowType()
should take precedence over this, so consumers should check for a mapping there first.- Specified by:
mapDynamicHeaderToField
in interfaceImportSpecification
- Parameters:
header
- the raw input header that needs to be mapped to a fieldrowType
- the row type that this mapping is being performed for- Returns:
- the mapped field if supported, else
null
- See Also:
-
mapDynamicFieldToHeader
Description copied from interface:ImportSpecification
Similar toImportSpecification.mapDynamicHeaderToField(String, String)
, but for reverse mappings from field names back to header names.- Specified by:
mapDynamicFieldToHeader
in interfaceImportSpecification
- Parameters:
field
- the raw field that needs to be mapped back to a headerrowType
- the row type that this mapping is being performed for- Returns:
- the mapped header if supported, else
null
- See Also:
-
getRequiredAuthorities
Description copied from interface:ImportSpecification
The list of required authorities necessary for carrying out a specific import. For example, a Product import requires you to be able to READ_PRODUCT, UPDATE_PRODUCT, and of course, CREATE_PRODUCT. So we need to be sure to check that a person has access to those authorities when they try to start a Product import.- Specified by:
getRequiredAuthorities
in interfaceImportSpecification
- Returns:
- the list of required authorities
-
getRequiredScopes
Description copied from interface:ImportSpecification
The list of required scopes necessary for carrying out a specific import. This is required for the global-level imports to display the import types that match the current user's permissions.- Specified by:
getRequiredScopes
in interfaceImportSpecification
- Returns:
- the list of required scopes
-
getImportType
Description copied from interface:ImportSpecification
Which import type this specification is valid for- Specified by:
getImportType
in interfaceImportSpecification
- Returns:
- the
Import.getType()
that should match this specification
-
getName
Description copied from interface:ImportSpecification
This is an arbitrary name for the specification, potentially allowing more than one specification for a particular type for a particular tenant or application.It's possible for this to be used as the
Import.getSpecificationRef()
.- Specified by:
getName
in interfaceImportSpecification
- Returns:
- name of this
ImportSpecification
-
getFieldConfigMap
Deprecated.This has been deprecated in favor ofgetHeaderFieldConfigsByRowType()
.- Specified by:
getFieldConfigMap
in interfaceImportSpecification
- Returns:
- a map from header name to the field config for it
- See Also:
-
getHeaderFieldConfigsByRowType
These represent the fields expected for this specification.The key of the top level map is the row type, and the value is itself a map from header name to field config. This enables validation to only enforce certain field requirements in specific row types.
If the import type represented by this specification doesn't have the concept of multiple row types, then field configs should be added here under the
ImportSpecification.getMainRecordType()
.- Specified by:
getHeaderFieldConfigsByRowType
in interfaceImportSpecification
- Returns:
- a map from row type to another map of headers to field configs. Ideally, the map should be fully immutable (including the nested maps) to prevent inadvertent modification by consumers.
- See Also:
-
createUnmodifiableHeaderFieldConfigsByRowType()
populateHeaderFieldConfigsByRowType(Map)
-
getDynamicHeaderMappingConfigsByRowType
- See Also:
-
mapDynamicHeaderToField(String, String)
mapDynamicFieldToHeader(String, String)
createUnmodifiableDynamicHeaderMappingsByRowType()
populateDynamicHeaderMappingsByRowType(Map)
-
getDependencyMappings
Dependency mappings don't change, so define a immutable instance of them for efficiency.This is important, as
getDependencyMappings()
is invoked multiple times for each row of an import.- Specified by:
getDependencyMappings
in interfaceImportSpecification
-