on 05-07-2018 3:14 PM
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"/>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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/
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.