Search code examples
sap-commerce-cloudimpex

How to import Cronjob using impexes?


I have written the following impexes in:

trainingcore/resources/trainingcore/import/common/cronjob.impex

The impexes are :

     INSERT_UPDATE ServicelayerJob;code[unique=true];springId;
    ;myJob;myJob;

     INSERT_UPDATE 
     MyCronJob;code[unique=true];job(code);sessionLanguage(isocode);categoryCode;thresholdTime;
    ;myCronJob;myJob;en;xyz;5;

    # Fires every 1 minute
    INSERT_UPDATE Trigger;cronJob(code)[unique=true];active;cronExpression;
    ;myCronJob;true;0 0/1 * 1/1 * ? *

But when I'm updating the system, the impexes are not being loaded. Can someone please help?


Solution

  • These impexes are not picked up automatically. You need to have a System setup in your project where you need to add a link to the file.

    From the location of your file, I assume you started from the starter template for a core project. In that case, there should be a file CoreSystemSetup in your core project. Somewhere in the location <classpathprefix/>setup/CoreSystemSetup

    You need to add your file here as a new line in this file. This will be something like this

    @SystemSetup(extension = TrainingCoreCoreConstants.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/cronjob.impex");
        }
    }
    

    You can also add this file in the project data part of this setup file. Depending on your needs.