Class ImportPatchAction
java.lang.Object
de.hybris.platform.patches.actions.AbstractImportPatchAction
de.hybris.platform.patches.actions.ImportPatchAction
- All Implemented Interfaces:
PatchAction
This class is responsible for importing data (impexes) to the system. It's based on PatchActionData object that knows
file name and all other options (languages, catalogVersions etc.)
-
Field Summary
Fields inherited from class de.hybris.platform.patches.actions.AbstractImportPatchAction
configurationService, extensionPath, globalPath, patchPath, releasePath, releasesPath -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ImpexImportPackcreateGlobalPack(String basePath, String fileName, String filePrefix) This method createsImpexImportPack(not language specific).protected ImpexImportUnitcreateGlobalUnit(String basePath, String fileName, String filePrefix) This method createsImpexImportUnitfor global data (not related with organisation unit).protected List<ImpexImportPack>createLanguagesVariantsForUnit(ImpexImportPack pack, Collection<ImportLanguage> languages) This method creates unit packages for given array of languages.protected List<ImpexImportUnit>createLanguageVariantsForUnit(ImpexImportUnit unit, ImportLanguage language) This method gets given basic unit and clone it to have: unit that have file name with country isocode suffix.protected ImpexImportPackcreateOrganisationPacks(String basePath, String fileName, String filePrefix, ImportOrganisationUnit unit) This method creates baseImpexImportPack(without languages and options) for givenImportOrganisationUnit.createPaths(List<ImportOrganisationUnit> hierarchy, String basePath, String fileName) This method iterates over unit hierarchy and creates all possible (valid) paths where file that should be imported can be located.protected List<ImportOrganisationUnit>This method creates for givenImportOrganisationUnita hierarchy path (list of parent units) starting from one that is on top of hierarchy.protected ImpexHeaderOption[][]getHeaderOptionsPermutations(ImpexHeaderOption[][] headerOptions) Creates permutation of given headerOptions.protected booleanimportPacks(List<ImpexImportPack> importPacks, String fileName) Iterates over packs and import them by usingPatchImportService.importImpexUnit(ImpexImportUnit).voidperform(PatchActionData data) voidsetPatchImportService(PatchImportService patchImportService) protected voidThis method updates file name with "_lang" suffix.
CheckupdatedFilePathWithString(ImpexImportUnit, String).
It also extends unit with new option:
$lang=[isocode]protected voidupdateHeaderOptionsWithLanguage(ImpexImportUnit unit, ImportLanguage language) This method extends unit with new option:
$lang=[isocode]protected voidupdateImpexOptions(List<ImpexImportPack> importPackList, PatchActionData data) This method will update all ImpexImportUnits that belong to given importPackList with ImpexImportUnitOptions in case there were defined in data object.protected List<ImpexImportPack>useHeaderOptions(List<ImpexImportPack> importPacks, ImpexHeaderOption[][] dataHeaderOptions) If dataHeaderOptions is empty this method will return importPacks directly.Methods inherited from class de.hybris.platform.patches.actions.AbstractImportPatchAction
getBasePath, getConfigurationService, getExtensionPath, getGlobalPath, getPatchPath, getPatchPath, getReleasePath, getReleasePath, getReleasesPath, setConfigurationService, setExtensionPath, setGlobalPath, setPatchPath, setReleasePath, setReleasesPathMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.hybris.platform.patches.actions.PatchAction
getCustomizedName
-
Constructor Details
-
ImportPatchAction
public ImportPatchAction()
-
-
Method Details
-
perform
- Specified by:
performin interfacePatchAction
-
updateImpexOptions
This method will update all ImpexImportUnits that belong to given importPackList with ImpexImportUnitOptions in case there were defined in data object.- Parameters:
importPackList- container forImpexImportPackdata-PatchActionDataobject where array ofImpexImportUnitOptioncould be defined. In case this parameter was not set, this method will not do anything
-
importPacks
Iterates over packs and import them by usingPatchImportService.importImpexUnit(ImpexImportUnit).- Parameters:
importPacks- packs that should be importedfileName- impex file name- Returns:
trueif all packs were successfully imported,falseotherwise
-
useHeaderOptions
protected List<ImpexImportPack> useHeaderOptions(List<ImpexImportPack> importPacks, ImpexHeaderOption[][] dataHeaderOptions) If dataHeaderOptions is empty this method will return importPacks directly. Otherwise it will create all permutation of dataHeaderOptions and create clone of importPacks per each option.
CheckPermutationUtils.permutate(ImpexHeaderOption[][])for more details about permutations.- Parameters:
importPacks- previously created import pack without header optionsdataHeaderOptions- options that should be considered when do permutation- Returns:
- list of packs per header option set
-
getHeaderOptionsPermutations
Creates permutation of given headerOptions. CheckPermutationUtilsfor more details about permutations.- Parameters:
headerOptions- array ofImpexHeaderOption- Returns:
- permutated array of
ImpexHeaderOption
-
createGlobalPack
This method createsImpexImportPack(not language specific).- Parameters:
basePath- basePath that is unit independentfileName- name of file to be importedfilePrefix- release/patch specific file prefix- Returns:
ImpexImportPack
-
createOrganisationPacks
protected ImpexImportPack createOrganisationPacks(String basePath, String fileName, String filePrefix, ImportOrganisationUnit unit) This method creates baseImpexImportPack(without languages and options) for givenImportOrganisationUnit.- Parameters:
basePath- basePath that is unit independentfileName- name of file to be importedfilePrefix- release/patch specific file prefixunit-ImportOrganisationUnit- Returns:
- base
ImpexImportPack
-
createPaths
protected List<String> createPaths(List<ImportOrganisationUnit> hierarchy, String basePath, String fileName) This method iterates over unit hierarchy and creates all possible (valid) paths where file that should be imported can be located. In example there are 3 levels of organisations, then for each there are two possibilities Fallback or Exact location can be used. In result paths will look like that:
- /E/E/E
- /E/E/F
- /E/F/F
- /F/F/F
first one leads to exact place (3x E) where last one uses in each level fallback (3x F) location.- Parameters:
hierarchy- list of parent units (including unit itself, in order top one first) for which unit that file path will be createdbasePath- basePath that is unit independent (common for all files in given patch)fileName- name of file to be imported- Returns:
- list of all possible (valid) paths where file that should be imported can be located
-
createUnitHierarchy
This method creates for givenImportOrganisationUnita hierarchy path (list of parent units) starting from one that is on top of hierarchy.- Parameters:
unit-ImportOrganisationUnitfor which hierarchy is build- Returns:
- list of given units parents starting from one that is on very top
-
createGlobalUnit
This method createsImpexImportUnitfor global data (not related with organisation unit). In result there is only one package created (this method doesn't handle language specific imports).- Parameters:
basePath- path to common folder for all impexes from given patchfileName- name of file to be importedfilePrefix- release/patch specific file prefix (in example 01_00)- Returns:
ImpexImportUnitfor global data
-
createLanguagesVariantsForUnit
protected List<ImpexImportPack> createLanguagesVariantsForUnit(ImpexImportPack pack, Collection<ImportLanguage> languages) This method creates unit packages for given array of languages.- Parameters:
pack- base not language specific pack that should be clonedlanguages- collection of languages that should be used for import- Returns:
- list of
ImpexImportPack
-
createLanguageVariantsForUnit
protected List<ImpexImportUnit> createLanguageVariantsForUnit(ImpexImportUnit unit, ImportLanguage language) This method gets given basic unit and clone it to have:- unit that have file name with country isocode suffix. In example create from aaa.impex aaa_en_US.impex
- unit that have file name with _lang suffix. In example aaa.impex will be changed to aaa_lang.impex.
In both cases a new isocode macro will be added to content of impex e.g.: $lang=en_US- Parameters:
unit- not language specific unit to be clonedlanguage- given language that should be used to create clone- Returns:
- list (2 elements) of language specific
ImpexImportUnitto be imported
-
updatedHeaderOptionsWithLanguageAndAddLangFileSuffix
protected void updatedHeaderOptionsWithLanguageAndAddLangFileSuffix(ImpexImportUnit unit, ImportLanguage language) This method updates file name with "_lang" suffix.
CheckupdatedFilePathWithString(ImpexImportUnit, String).
It also extends unit with new option:
$lang=[isocode]- Parameters:
unit- that contain file path that should be modifiedlanguage- that has isocode used as file suffix
-
updateHeaderOptionsWithLanguage
This method extends unit with new option:
$lang=[isocode]- Parameters:
unit- that contain file path that should be modifiedlanguage- that has isocode used as file suffix
-
setPatchImportService
-