return jobToRun.run();
}
public void saveJob() {
// Save job data
IntegrationJob newIntegrationJob = new IntegrationJob();
newIntegrationJob.setDatasetID(datasetIDTextField.getText());
newIntegrationJob.setFileToPublish(fileToPublishTextField.getText());
newIntegrationJob.setPublishMethod(
(PublishMethod) publishMethodComboBox.getSelectedItem());
newIntegrationJob.setFileToPublishHasHeaderRow(fileToPublishHasHeaderCheckBox.isSelected());
newIntegrationJob.setPublishViaFTP(ftpButton.isSelected());
newIntegrationJob.setPublishViaDi2Http(httpButton.isSelected());
newIntegrationJob.setPathToControlFile(controlFileTextField.getText());
newIntegrationJob.setControlFileContent(controlFileContentTextArea.getText());
newIntegrationJob.setPathToSavedFile(jobFileLocation);
// TODO If an existing file was selected WARN user of overwriting
// if first time saving this job: Open dialog box to select "Save as..." location
// otherwise save to existing file
boolean updateJobCommandTextField = false;
String selectedJobFileLocation = jobFileLocation;
if(selectedJobFileLocation.equals("")) {
JFileChooser savedJobFileChooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
JOB_FILE_NAME + " (*." + JOB_FILE_EXTENSION + ")", JOB_FILE_EXTENSION);
savedJobFileChooser.setFileFilter(filter);
int returnVal = savedJobFileChooser.showSaveDialog(mainFrame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = savedJobFileChooser.getSelectedFile();
selectedJobFileLocation = file.getAbsolutePath();
if(!selectedJobFileLocation.endsWith("." + JOB_FILE_EXTENSION)) {
selectedJobFileLocation += "." + JOB_FILE_EXTENSION;
}
jobFileLocation = selectedJobFileLocation;
newIntegrationJob.setPathToSavedFile(selectedJobFileLocation);
jobTabTitleLabel.setText(newIntegrationJob.getJobFilename());
updateJobCommandTextField = true;
}
}
saveJobAsFile(newIntegrationJob, updateJobCommandTextField, selectedJobFileLocation);