Class 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 Detail

      • ImportPatchAction

        public ImportPatchAction()
    • Method Detail

      • updateImpexOptions

        protected void updateImpexOptions​(java.util.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​(java.util.List<ImpexImportPack> importPacks,
                                      java.lang.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 java.util.List<ImpexImportPack> useHeaderOptions​(java.util.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
      • createGlobalPack

        protected ImpexImportPack createGlobalPack​(java.lang.String basePath,
                                                   java.lang.String fileName,
                                                   java.lang.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
      • createPaths

        protected java.util.List<java.lang.String> createPaths​(java.util.List<ImportOrganisationUnit> hierarchy,
                                                               java.lang.String basePath,
                                                               java.lang.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
      • createGlobalUnit

        protected ImpexImportUnit createGlobalUnit​(java.lang.String basePath,
                                                   java.lang.String fileName,
                                                   java.lang.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 java.util.List<ImpexImportPack> createLanguagesVariantsForUnit​(ImpexImportPack pack,
                                                                                 java.util.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 java.util.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)