on 2015 Jul 22 1:28 PM
I could not find an answer to this question here so I posted. If an answer already exists I would appreciate a pointer.
I want to write a CI Jenkins job to load multiple impex data files to setup testdata / test-configurations. So far I could not find a command line interface for impex. I am convinced that this is a pretty common usecase so please share your ideas with me.
Note: I already tried to automate the admin console upload using curl but the session handling proves to be difficult/impossible.
The only other approach I can think of is to build the CLI myself using the ServiceLayer: https://wiki.hybris.com/display/release5/ImpEx+-+User+Guide#ImpEx-UserGuide-ImpExServiceLayerAPI Is that the recommended approach?
Request clarification before answering.
I've previously done something similar using the system setup class for an extension to loop through and impex files in a folder and execute each in turn using the ImpExManager. However, this hasn't been entirely reliable and sometimes it doesn't seem to execute correctly and so I'm planning on migrating to use the CLI as it will give me more control and reliability when I need to execute impex during a deployment.
Here's the code we've been using:
@SystemSetup(extension = "web", process = SystemSetup.Process.ALL)
public class MySystemSetup extends AbstractSystemSetup {
private static final Logger LOG = Logger.getLogger(MySystemSetup.class.getName());
/**
* This method will be called during the system initialization.
*
* @param context
* the context provides the selected parameters and values
*/
@SystemSetup(type = Type.PROJECT, process = SystemSetup.Process.ALL)
public void createProjectData(final SystemSetupContext context) {
File releaseDataFolder = new File(RELEASE_DATA_FOLDER);
if (releaseDataFolder.isDirectory()) {
for (File impexFile : releaseDataFolder.listFiles()) {
importCSVFromResources(RELEASE_DATA_FOLDER + "/" + impexFile.getName());
}
}
private void importCSVFromResources(final String impex) {
LOG.info("Importing resource " + impex);
final InputStream is = WebManager.class.getResourceAsStream(impex);
try {
ImpExManager.getInstance().importDataLight(is, UTF_ENCODING, true);
} catch (final ImpExException e) {
LOG.error("Error while importing " + impex, e);
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could use hot folders to drop files in. These will be picked up automatically by hybris and imported:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.