Class ImportPatchAction

java.lang.Object
de.hybris.platform.patches.actions.AbstractImportPatchAction
de.hybris.platform.patches.actions.ImportPatchAction
All Implemented Interfaces:
PatchAction

public class ImportPatchAction extends AbstractImportPatchAction implements 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.)
  • Constructor Details

    • ImportPatchAction

      public ImportPatchAction()
  • Method Details

    • perform

      public void perform(PatchActionData data)
      Specified by:
      perform in interface PatchAction
    • updateImpexOptions

      protected void updateImpexOptions(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.
      Parameters:
      importPackList - container for ImpexImportPack
      data - PatchActionData object where array of ImpexImportUnitOption could be defined. In case this parameter was not set, this method will not do anything
    • importPacks

      protected boolean importPacks(List<ImpexImportPack> importPacks, String fileName)
      Iterates over packs and import them by using PatchImportService.importImpexUnit(ImpexImportUnit).
      Parameters:
      importPacks - packs that should be imported
      fileName - impex file name
      Returns:
      true if all packs were successfully imported, false otherwise
    • 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.
      Check PermutationUtils.permutate(ImpexHeaderOption[][]) for more details about permutations.
      Parameters:
      importPacks - previously created import pack without header options
      dataHeaderOptions - options that should be considered when do permutation
      Returns:
      list of packs per header option set
    • getHeaderOptionsPermutations

      protected ImpexHeaderOption[][] getHeaderOptionsPermutations(ImpexHeaderOption[][] headerOptions)
      Creates permutation of given headerOptions. Check PermutationUtils for more details about permutations.
      Parameters:
      headerOptions - array of ImpexHeaderOption
      Returns:
      permutated array of ImpexHeaderOption
    • createGlobalPack

      protected ImpexImportPack createGlobalPack(String basePath, String fileName, String filePrefix)
      This method creates ImpexImportPack (not language specific).
      Parameters:
      basePath - basePath that is unit independent
      fileName - name of file to be imported
      filePrefix - release/patch specific file prefix
      Returns:
      ImpexImportPack
    • createOrganisationPacks

      protected ImpexImportPack createOrganisationPacks(String basePath, String fileName, String filePrefix, ImportOrganisationUnit unit)
      This method creates base ImpexImportPack (without languages and options) for given ImportOrganisationUnit.
      Parameters:
      basePath - basePath that is unit independent
      fileName - name of file to be imported
      filePrefix - release/patch specific file prefix
      unit - 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:
      1. /E/E/E
      2. /E/E/F
      3. /E/F/F
      4. /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 created
      basePath - 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

      protected List<ImportOrganisationUnit> createUnitHierarchy(ImportOrganisationUnit unit)
      This method creates for given ImportOrganisationUnit a hierarchy path (list of parent units) starting from one that is on top of hierarchy.
      Parameters:
      unit - ImportOrganisationUnit for which hierarchy is build
      Returns:
      list of given units parents starting from one that is on very top
    • createGlobalUnit

      protected ImpexImportUnit createGlobalUnit(String basePath, String fileName, String filePrefix)
      This method creates ImpexImportUnit for 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 patch
      fileName - name of file to be imported
      filePrefix - release/patch specific file prefix (in example 01_00)
      Returns:
      ImpexImportUnit for 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 cloned
      languages - 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:
      1. unit that have file name with country isocode suffix. In example create from aaa.impex aaa_en_US.impex
      2. unit that have file name with _lang suffix. In example aaa.impex will be changed to aaa_lang.impex.

      3. 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 cloned
      language - given language that should be used to create clone
      Returns:
      list (2 elements) of language specific ImpexImportUnit to be imported
    • updatedHeaderOptionsWithLanguageAndAddLangFileSuffix

      protected void updatedHeaderOptionsWithLanguageAndAddLangFileSuffix(ImpexImportUnit unit, ImportLanguage language)
      This method updates file name with "_lang" suffix.
      Check updatedFilePathWithString(ImpexImportUnit, String).
      It also extends unit with new option:
      $lang=[isocode]
      Parameters:
      unit - that contain file path that should be modified
      language - that has isocode used as file suffix
    • updateHeaderOptionsWithLanguage

      protected void updateHeaderOptionsWithLanguage(ImpexImportUnit unit, ImportLanguage language)
      This method extends unit with new option:
      $lang=[isocode]
      Parameters:
      unit - that contain file path that should be modified
      language - that has isocode used as file suffix
    • setPatchImportService

      public void setPatchImportService(PatchImportService patchImportService)