Initialization and Update hook up
- 26th Dec 2016
- 5
- 291353
- How to configure an impex to load during initialization time or update time how to define @SystemSetup methods and class in hybris how to import impex during initialization or update process How to make my custom class to be considered for impex loading during initialization and update process what is type and process in initialization of impex
Initialization and Update hook up in hybris
We can configure the impexes to load during Initialization and update process through code.
Hybris has already provided a class called CoreSystemSetup.java and InitialDataSystemSetup.java to achieve the same.
Before understanding this, we should know about Type and Process that we use in the initialization/update hook up process.
Steps to configure an impex to import during initialization/Update process
Create a class and annotate it with @SystemSetup as below
Step 1
- @SystemSetup(extension = TrainingCoreConstants.EXTENSIONNAME)
- public class CoreSystemSetup extends AbstractSystemSetup
- {
- }
@SystemSetup(extension = TrainingCoreConstants.EXTENSIONNAME) public class CoreSystemSetup extends AbstractSystemSetup { }
Step 2
Create public methods and annotate them with @SystemSetup by specifying “Type” and “Process”.
CoreSystemSetup.java
- @SystemSetup(extension = TrainingCoreConstants.EXTENSIONNAME)
- public class CoreSystemSetup extends AbstractSystemSetup
- {
- public static final String IMPORT_ACCESS_RIGHTS = "accessRights";
- @SystemSetup(type = Type.ESSENTIAL, process = Process.ALL)
- public void createEssentialData(final SystemSetupContext context)
- {
- importImpexFile(context, "/trainingcore/import/common/essential-data.impex");
- importImpexFile(context, "/trainingcore/import/common/countries.impex");
- importImpexFile(context, "/trainingcore/import/common/delivery-modes.impex");
- importImpexFile(context, "/trainingcore/import/common/themes.impex");
- importImpexFile(context, "/trainingcore/import/common/user-groups.impex");
- }
- @SystemSetup(type = Type.PROJECT, process = Process.ALL)
- public void createProjectData(final SystemSetupContext context)
- {
- final boolean importAccessRights = getBooleanSystemSetupParameter(context,
- IMPORT_ACCESS_RIGHTS);
- final List<String> extensionNames = getExtensionNames();
- if (importAccessRights && extensionNames.contains("cmscockpit"))
- {
- importImpexFile(context, "/trainingcore/import/cockpits/cmscockpit
- /cmscockpit-users.impex");
- importImpexFile(context, "/trainingcore/import/cockpits/cmscockpit
- /cmscockpit-access-rights.impex");
- }
- }
- }
@SystemSetup(extension = TrainingCoreConstants.EXTENSIONNAME) public class CoreSystemSetup extends AbstractSystemSetup { public static final String IMPORT_ACCESS_RIGHTS = "accessRights"; @SystemSetup(type = Type.ESSENTIAL, process = Process.ALL) public void createEssentialData(final SystemSetupContext context) { importImpexFile(context, "/trainingcore/import/common/essential-data.impex"); importImpexFile(context, "/trainingcore/import/common/countries.impex"); importImpexFile(context, "/trainingcore/import/common/delivery-modes.impex"); importImpexFile(context, "/trainingcore/import/common/themes.impex"); importImpexFile(context, "/trainingcore/import/common/user-groups.impex"); } @SystemSetup(type = Type.PROJECT, process = Process.ALL) public void createProjectData(final SystemSetupContext context) { final boolean importAccessRights = getBooleanSystemSetupParameter(context, IMPORT_ACCESS_RIGHTS); final List<String> extensionNames = getExtensionNames(); if (importAccessRights && extensionNames.contains("cmscockpit")) { importImpexFile(context, "/trainingcore/import/cockpits/cmscockpit /cmscockpit-users.impex"); importImpexFile(context, "/trainingcore/import/cockpits/cmscockpit /cmscockpit-access-rights.impex"); } } }
We have defined 2 methods in the above class.
Both will be executed during Initialization process but one will be executed during essential data creation process
other will be executed during project data creation process.
We have passed a parameter to a method of type SystemSetupContext which can be used to get some additional details like user selected parameter value.
Step 3
Register the class which is annotated with @SystemSetup as a spring bean
hybris\bin\custom\training\trainingcore\resources\trainingcore-spring.xml
- <bean id="acceleratorCoreSystemSetup" class="org.training.core.setup.CoreSystemSetup" parent="abstractCoreSystemSetup"/>
<bean id="acceleratorCoreSystemSetup" class="org.training.core.setup.CoreSystemSetup" parent="abstractCoreSystemSetup"/>
Hi,
CoreSystemSetup is there in initaldatasetup extension.
If i want create the new java class like MyCoreSystemSetup i should follow the same steps or any more step are required.plse help on this.
Regards
ragahvendra
Hi KB
Can you tell the difference between essential data and project data.
Means i want know exactly, what is essential data and project data.
Thanks
Essential and Project Data are two sets of data that are used in hybris’ init/update process.
each extension will have a particular Annotations on classes and method to create it.
We have an option to perform either essential or project or both imports while updating the system(you can see checkbox on top of update window in HAC)
Hi KB,
Thank you.
We understood what u have explained but What is exactly difference between Essential Data and Project Data?
Thanks in Advance.
can we achieve the same using command line arguments during system init or update? like if I want to init my system without essential data.