cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Override the Perform method of ImportCockpit

Former Member
0 Kudos

Hello All,

I need to override the perform method in the ImportCockpitJob and write my own logic. Since the ImportCockpitJob class is not registered as a spring bean, I couldn't do the bean overriding. And hence, I created an item type which extends the item ImportCockpitJob and then defined a jalo class ImportCockpitJobSession. In this class I had to override the performCronJob method. But my job's code doesn't get executed! Any help highly appreciated. Thanks!!!!!

Itemtype definition:

itemtype code="ImportCockpitJobSession" autocreate="true" generate="true" jaloclass="de.valtech.henkel.cronjob.jalo.ImportCockpitJobSession" extends="ImportCockpitCronJob">

Overriding the method:

   public class ImportCockpitJobSession extends ImportCockpitJob
  {

 public ImportCockpitJobSession()
 {
     //
 }

 public static final String INSTANCE_NAME = "ImportCockpit-ImportJob";
 private static final Logger LOG = Logger.getLogger(ImportCockpitJob.class);
 private final transient ModelService modelService = (ModelService) Registry.getApplicationContext().getBean("modelService");
 private final transient ImportCockpitCronJobService importCockpitService = (ImportCockpitCronJobService) Registry
         .getApplicationContext().getBean("importCockpitCronJobService");

 @Override
 public CronJob.CronJobResult performCronJob(final CronJob cronJob) throws AbortCronJobException
 {
     super.performCronJob(cronJob);
     System.out.println("!!!!!!!!!!!!!Inside my class!!!!!!!!!!!!!");
     final CronJob.CronJobResult result = null;
     final ImportCockpitCronJobModel cronJobModel = (ImportCockpitCronJobModel) this.modelService.get(cronJob);

     final String mySession = cronJobModel.getSessionUser().getUid();
     System.out.println("!!!!!!!!!!!!!!!!!Inside my overriden class!!!!!!!!!!!!!" + mySession);
     cronJobModel.setLastRun(mySession);
     cronJobModel.setSessionUser(cronJobModel.getSessionUser());

     return result;
 }

}

I have also declared a bean for this class:

 <bean id="ImportCockpitJobSession" class="de.valtech.henkel.cronjob.jalo.ImportCockpitJobSession" scope="prototype"/>

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Vinay,

You'll need to create an instance of ImportCockpitCronJob which uses you custom import job.

For instance (via Impex):

 INSERT_UPDATE ImportCockpitJobLastSessionUser;code[unique=true,allownull=true];active
 ;importCockpitJobSession;TRUE
 
 INSERT_UPDATE ImportCockpitCronJob;code[forceWrite=true,unique=true];job(code)[allownull=true];mapping(code)[forceWrite=true];inputMedia(code)[forceWrite=true,allownull=true];locale(code);sessionCurrency(isocode);sessionLanguage(isocode);sessionUser(uid)
 ;Product Import;importCockpitJobSession;Product_Mapping;ProductMediaFile;en;USD;en;importmanager
Former Member
0 Kudos

Hello Pablo,

Thanks for the response.! I have created a new instance, but when I try to run the cronjob through the import cockpit I get the below error. Do you have any idea on what could be wrong?

[de.hybris.platform.servicelayer.cronjob.impl.JobPerformableGenericTypeValidator@576fd071]: unexpected validator error: de.valtech.henkel.cronjob.model.ImportCockpitJobSessionModel cannot be cast to de.hybris.platform.cronjob.model.JobModel

Thanks/