Migration from 2.1.x to 2.2.0
Import Status Removed
Previously, the status and information about import jobs was tracked with ImportStatus
and ImportStatusDetail
. However, ImportStatus
, ImportStatusType
, and ImportStatusDetail
have been removed and instead the process module is now used to track information about import jobs. If you do not wish to retain information about past import jobs then you may simply delete the status tables with the following SQL:
DROP TABLE BLC_IMPORT_STATUS;
DROP TABLE BLC_IMPORT_STATUS_DETAIL;
If you do want to maintain information about past import jobs, then we recommend migrating the data from the BLC_IMPORT_STATUS
and BLC_IMPORT_STATUS_DETAIL
tables to the process module tables
Import Type
Previously, the class name was used in the import schedule definition and checked by cell processors and header name mappers during an import to determine which type of import to perform. Now, the enumeration ImportType
has been created so that an import job does not have to be directly related to a specific class. Any cell processors or header name mappers that checked class name will now need to check the import type.
For reference, here is a short snippet of the import type enumeration that lists all of the out of box import types:
public class ImportType implements Serializable, BroadleafEnumerationType {
private static final long serialVersionUID = 1L;
private static final LinkedHashMap<String, ImportType> TYPES = new LinkedHashMap<>();
public static final ImportType CATEGORY = new ImportType("CATEGORY", "Category", Category.class);
public static final ImportType PRODUCT = new ImportType("PRODUCT", "Product", Product.class);
public static final ImportType TRANSLATION = new ImportType("TRANSLATION", "Translation", Translation.class);
public static final ImportType ASSET = new ImportType("ASSET", "Asset");
.
.
.
Here is an example of the migration that we performed for the DefaultParentCategoryCellProcessor
. Previously, this was what the cell processor looked like:
@Component("blDefaultParentCategoryCellProcessor")
public class DefaultParentCategoryCellProcessor extends CategoryRelationshipCellProcessor {
private static final Log LOG = LogFactory.getLog(DefaultParentCategoryCellProcessor.class);
public static final String DEFAULT_PARENT_CATEGORY_FIELD = "defaultParentCategory";
@Resource(name = "blCatalogService")
protected CatalogService catalogService;
@Resource
protected LateIdResolver lateIdResolver;
@Override
public boolean canHandle(String header, Class<?> importingClass) {
return DEFAULT_PARENT_CATEGORY_FIELD.equals(header) && Category.class.isAssignableFrom(importingClass);
}
.
.
.
And here is what the DefaultParentCategoryCellProcessor
looks like after ImportType
was added:
@Component("blDefaultParentCategoryCellProcessor")
public class DefaultParentCategoryCellProcessor extends CategoryRelationshipCellProcessor {
private static final Log LOG = LogFactory.getLog(DefaultParentCategoryCellProcessor.class);
public static final String DEFAULT_PARENT_CATEGORY_FIELD = "defaultParentCategory";
@Resource(name = "blCatalogService")
protected CatalogService catalogService;
@Resource
protected LateIdResolver lateIdResolver;
@Override
public boolean canHandle(String header, ImportType importType) {
return DEFAULT_PARENT_CATEGORY_FIELD.equals(header) && ImportType.CATEGORY.equals(importType);
}
.
.
.
As you can see it is pretty simple to check the import type instead of the class in the canHandle
function. This check will need to be performed in any custom cell processors or header name mappers that were created. If a custom import was created for a specific class outside of the ones provided by default, then a new import type will need to be created and used instead. A new import type can be added easily by simply extending ImportType
and making sure that your new enumeration gets registered with spring as a bean, example:
@Component
public class CustomImportType extends ImportType {
public static final ImportType CUSTOM_IMPORT_TYPE = new ImportType("CUSTOM_IMPORT_TYPE", "Custom Import Type", CustomClass.class);
}