From 92bdf2693974e027e1de2f25b277dadf48bf2dc8 Mon Sep 17 00:00:00 2001 From: aramos Date: Thu, 1 Feb 2024 08:47:34 -0500 Subject: [PATCH] [BACKLOG-39390, BACKLOG-39800] Fixed missing scheduler xml's cron job element --- .../exporter/PentahoPlatformExporter.java | 2 +- .../importexport/ZipExportProcessor.java | 6 +++- .../exportManifest/ExportManifestUtil.java | 28 +++++++++++++++---- .../bindings/JobScheduleRequest.java | 4 +-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/exporter/PentahoPlatformExporter.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/exporter/PentahoPlatformExporter.java index b68f6b2169c..e91313ba6a9 100644 --- a/extensions/src/main/java/org/pentaho/platform/plugin/services/exporter/PentahoPlatformExporter.java +++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/exporter/PentahoPlatformExporter.java @@ -173,7 +173,7 @@ public File performExport( RepositoryFile exportRepositoryFile ) throws ExportEx zos.close(); // clean up - exportManifest = null; + initManifest(); zos = null; return exportFile; diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessor.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessor.java index 7243275e2a9..c6026881c79 100644 --- a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessor.java +++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessor.java @@ -85,6 +85,10 @@ public ZipExportProcessor( String path, IUnifiedRepository repository, boolean w this.exportHandlerList = new ArrayList<>(); + initManifest(); + } + + protected void initManifest() { this.exportManifest = new ExportManifest(); // set created by and create date in manifest information @@ -96,7 +100,7 @@ public ZipExportProcessor( String path, IUnifiedRepository repository, boolean w exportManifest.getManifestInformation().setExportBy( session.getName() ); exportManifest.getManifestInformation().setExportDate( - dateFormat.format( todaysDate ) + " " + timeFormat.format( todaysDate ) ); + dateFormat.format( todaysDate ) + " " + timeFormat.format( todaysDate ) ); exportManifest.getManifestInformation().setManifestVersion( "2" ); } diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/exportManifest/ExportManifestUtil.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/exportManifest/ExportManifestUtil.java index 23da8f153de..045e7c505d9 100644 --- a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/exportManifest/ExportManifestUtil.java +++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/exportManifest/ExportManifestUtil.java @@ -74,8 +74,9 @@ private static List fromSchedulerToBindingRequestJobParameters } private static SimpleJobTrigger fromSchedulerToBindingRequestJobTrigger( ISimpleJobTrigger incomingJobTrigger ) { - SimpleJobTrigger outgoingJobTrigger = new SimpleJobTrigger(); + SimpleJobTrigger outgoingJobTrigger = null; if ( incomingJobTrigger != null ) { + outgoingJobTrigger = new SimpleJobTrigger(); outgoingJobTrigger.setRepeatCount( incomingJobTrigger.getRepeatCount() ); outgoingJobTrigger.setRepeatInterval( incomingJobTrigger.getRepeatInterval() ); } @@ -83,9 +84,14 @@ private static SimpleJobTrigger fromSchedulerToBindingRequestJobTrigger( ISimple } private static CronJobTrigger fromSchedulerToBindingRequestCronJobTrigger( ICronJobTrigger incomingCronJobTrigger ) { - CronJobTrigger outgoingCronJobTrigger = new CronJobTrigger(); + CronJobTrigger outgoingCronJobTrigger = null; if ( incomingCronJobTrigger != null ) { + outgoingCronJobTrigger = new CronJobTrigger(); outgoingCronJobTrigger.setCronString( incomingCronJobTrigger.getCronString() ); + outgoingCronJobTrigger.setDuration( incomingCronJobTrigger.getDuration() ); + outgoingCronJobTrigger.setEndTime( XmlGregorianCalendarConverter.asXMLGregorianCalendar( incomingCronJobTrigger.getEndTime() ) ); + outgoingCronJobTrigger.setStartTime( XmlGregorianCalendarConverter.asXMLGregorianCalendar( incomingCronJobTrigger.getStartTime() ) ); + outgoingCronJobTrigger.setUiPassParam( incomingCronJobTrigger.getUiPassParam() ); } return outgoingCronJobTrigger; } @@ -133,15 +139,27 @@ private static List fromBindingToSchedulerRequestJobParameter private static ISimpleJobTrigger fromBindingToSchedulerRequestJobTrigger( SimpleJobTrigger incomingSimpleJobTrigger ) { IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", null ); //$NON-NLS-1$ - return scheduler.createSimpleJobTrigger( new Date(), null, incomingSimpleJobTrigger.getRepeatCount(), - incomingSimpleJobTrigger.getRepeatInterval() ); + ISimpleJobTrigger outgoingJobTrigger = null; + if ( incomingSimpleJobTrigger != null ) { + outgoingJobTrigger = scheduler.createSimpleJobTrigger( + new Date(), + null, + incomingSimpleJobTrigger.getRepeatCount(), + incomingSimpleJobTrigger.getRepeatInterval() ); + } + return outgoingJobTrigger; } private static ICronJobTrigger fromBindingToSchedulerRequestCronJobTrigger( CronJobTrigger incomingCronJobTrigger ) { IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", null ); //$NON-NLS-1$ - ICronJobTrigger outgoingCronJobTrigger = scheduler.createCronJobTrigger(); + ICronJobTrigger outgoingCronJobTrigger = null; if( incomingCronJobTrigger != null ) { + outgoingCronJobTrigger = scheduler.createCronJobTrigger(); outgoingCronJobTrigger.setCronString( incomingCronJobTrigger.getCronString() ); + outgoingCronJobTrigger.setDuration( incomingCronJobTrigger.getDuration() ); + outgoingCronJobTrigger.setEndTime( XmlGregorianCalendarConverter.asDate( incomingCronJobTrigger.getEndTime() ) ); + outgoingCronJobTrigger.setStartTime( XmlGregorianCalendarConverter.asDate( incomingCronJobTrigger.getStartTime() ) ); + outgoingCronJobTrigger.setUiPassParam( incomingCronJobTrigger.getUiPassParam() ); } return outgoingCronJobTrigger; } diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/exportManifest/bindings/JobScheduleRequest.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/exportManifest/bindings/JobScheduleRequest.java index d479e254aee..454cd226fcf 100644 --- a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/exportManifest/bindings/JobScheduleRequest.java +++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/exportManifest/bindings/JobScheduleRequest.java @@ -80,7 +80,7 @@ public class JobScheduleRequest { protected String actionClass; protected ComplexJobTriggerProxy complexJobTrigger; - @XmlElement( namespace = "http://www.pentaho.com/schema/" ) + @XmlElement protected CronJobTrigger cronJobTrigger; protected long duration; protected String inputFile; @@ -89,7 +89,7 @@ public class JobScheduleRequest { @XmlElement( nillable = true ) protected List jobParameters; protected String outputFile; - @XmlElement( namespace = "http://www.pentaho.com/schema/" ) + @XmlElement protected SimpleJobTrigger simpleJobTrigger; protected String timeZone; protected JobState jobState;