diff --git a/.classpath b/.classpath index b55f4d151..80b6e854a 100644 --- a/.classpath +++ b/.classpath @@ -7,7 +7,7 @@ - + diff --git a/src/main/java/ca/sqlpower/architect/CoreUserSettings.java b/src/main/java/ca/sqlpower/architect/CoreUserSettings.java index 6b4c4e470..a3b0f1acf 100644 --- a/src/main/java/ca/sqlpower/architect/CoreUserSettings.java +++ b/src/main/java/ca/sqlpower/architect/CoreUserSettings.java @@ -97,14 +97,14 @@ private final void loadFromPrefs() { logger.debug("Preferences class = " + prefs.getClass()); swingSettings.setBoolean(ArchitectSwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, - prefs.getBoolean(ArchitectSwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); -// if (getDefaultLocale() != null) { - String localeVal = prefs.get(ArchitectSwingUserSettings.DEFAULT_LOCALE, getDefaultLocale().getDisplayLanguage()); - swingSettings.setString(ArchitectSwingUserSettings.DEFAULT_LOCALE,localeVal); - setDefaultLocale(new Locale(localeVal)); -// } else { -// swingSettings.setString(ArchitectSwingUserSettings.DEFAULT_LOCALE,Locale.getDefault().getDisplayName()); -// } + prefs.getBoolean(ArchitectSwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); + if (getDefaultLocale() != null) { + String localeVal = prefs.get(ArchitectSwingUserSettings.DEFAULT_LOCALE, getDefaultLocale().getDisplayLanguage()); + swingSettings.setString(ArchitectSwingUserSettings.DEFAULT_LOCALE,localeVal); + setDefaultLocale(new Locale(localeVal)); + } else { + swingSettings.setString(ArchitectSwingUserSettings.DEFAULT_LOCALE,Locale.getDefault().getDisplayName()); + } etlUserSettings.setString(ETLUserSettings.PROP_PL_ENGINE_PATH, prefs.get(ETLUserSettings.PROP_PL_ENGINE_PATH, "")); etlUserSettings.setString(ETLUserSettings.PROP_ETL_LOG_PATH, diff --git a/src/main/java/ca/sqlpower/architect/etl/kettle/KettleJob.java b/src/main/java/ca/sqlpower/architect/etl/kettle/KettleJob.java index c344e62ed..dd0bdf903 100644 --- a/src/main/java/ca/sqlpower/architect/etl/kettle/KettleJob.java +++ b/src/main/java/ca/sqlpower/architect/etl/kettle/KettleJob.java @@ -38,7 +38,9 @@ import org.pentaho.di.core.util.EnvUtil; import org.pentaho.di.job.JobHopMeta; import org.pentaho.di.job.JobMeta; +import org.pentaho.di.job.entries.job.JobEntryJob; import org.pentaho.di.job.entries.special.JobEntrySpecial; +import org.pentaho.di.job.entries.success.JobEntrySuccess; import org.pentaho.di.job.entries.trans.JobEntryTrans; import org.pentaho.di.job.entry.JobEntryCopy; import org.pentaho.di.repository.Repository; @@ -113,6 +115,15 @@ public class KettleJob implements Monitorable { */ private final KettleSettings settings; + /** + * used when big job spilitted into small + * list of job name + */ + private List jobMetaList = new ArrayList(); + /** + * job number used create inner job + */ + private int job_no = 0; public KettleJob(ArchitectSession session, KettleRepositoryDirectoryChooser chooser) { this(session); dirChooser = chooser; @@ -310,6 +321,7 @@ public void doExport(List tableList, SQLDatabase targetDB ) throws SQL jm.addNote(new NotePadMeta(buffer.toString(), 0, 0, 125, 125)); } + //Start entry JobEntryCopy startEntry = new JobEntryCopy(); JobEntrySpecial start = new JobEntrySpecial("Start", true, false); startEntry.setEntry(start); @@ -339,13 +351,29 @@ public void doExport(List tableList, SQLDatabase targetDB ) throws SQL i++; } + // Success entry + + JobEntrySuccess success = new JobEntrySuccess(); + success.setName("Success"); + JobEntryCopy successEntry = new JobEntryCopy(); + successEntry.setEntry(success); + successEntry.setLocation(i*spacing, spacing); + successEntry.setDrawn(); + jm.addJobEntry(successEntry); + + JobHopMeta hop = new JobHopMeta(oldJobEntry, successEntry); + jm.addJobHop(hop); + if (monitor.isCancelled()) { cancel(); return; } - - jm.setName(settings.getJobName()); - + String jobname = settings.getJobName(); + if (settings.isSplittingJob() && getJob_no() > 0) { + jobname += "_"+getJob_no(); + } + jm.setName(jobname); + // System.out.println("setting job name: "+jobname); if (settings.isSavingToFile()) { outputToXML(transformations, jm); } else { @@ -357,6 +385,176 @@ public void doExport(List tableList, SQLDatabase targetDB ) throws SQL } } + /** + * + * @param tableList + * @param targetDB + * @param splitno, is a number of tables(transformation) per job + * @throws Exception + */ + public void doSplitedJobExport(List tableList, SQLDatabase targetDB ) throws Exception { + if (settings.isSplittingJob() && tableList.size() > settings.getSplitJobNo()) { + jobMetaList.clear(); + // split a big job into small a jobs of splitno of (table)transformation/job + List> splitedTableList = chopped(tableList, settings.getSplitJobNo()); + for (List newtableList:splitedTableList) { + job_no++; + doExport(newtableList,targetDB); + } + try { + EnvUtil.environmentInit(); + LogWriter lw = LogWriter.getInstance(); + JobMeta jm = new JobMeta(lw); + //Start Entry + JobEntryCopy startEntry = new JobEntryCopy(); + JobEntrySpecial start = new JobEntrySpecial("Start", true, false); + startEntry.setEntry(start); + startEntry.setLocation(10, spacing); + startEntry.setDrawn(); + jm.addJobEntry(startEntry); + + + JobEntryCopy oldJobEntry = null; + int i = 1; + for (JobMeta job : jobMetaList) { + JobEntryCopy entry = new JobEntryCopy(); + JobEntryJob jn = new JobEntryJob(job.getName()); + jn.setJobName(job.getName()); + entry.setEntry(jn); + entry.setLocation(i*spacing, spacing); + entry.setDrawn(); + jm.addJobEntry(entry); + if (oldJobEntry != null) { + JobHopMeta hop = new JobHopMeta(oldJobEntry, entry); + jm.addJobHop(hop); + } else { + JobHopMeta hop = new JobHopMeta(startEntry, entry); + jm.addJobHop(hop); + } + oldJobEntry = entry; + i++; + } + +// // Success entry + JobEntrySuccess success = new JobEntrySuccess(); + success.setName("Success"); + JobEntryCopy successEntry = new JobEntryCopy(); + successEntry.setEntry(success); + successEntry.setLocation(i*spacing, spacing); + successEntry.setDrawn(); + jm.addJobEntry(successEntry); + + JobHopMeta hop = new JobHopMeta(oldJobEntry, successEntry); + jm.addJobHop(hop); + + if (monitor.isCancelled()) { + cancel(); + return; + } + + jm.setName( settings.getJobName()); + job_no=0; + if (settings.isSavingToFile()) { + jobOutputToXML(jobMetaList, jm); + } else { + jm.setDirectory(new RepositoryDirectory()); + jobOutputToRepository(jm, jobMetaList, createRepository()); + } + } finally { + job_no=0; + } + + } else { + doExport(tableList,targetDB); + } + } + + private void jobOutputToRepository(JobMeta jm, List jmList, Repository createRepository) { + // TODO Auto-generated method stub + + } + +private void jobOutputToXML(List jmList, JobMeta jm) throws IOException { + Map outputs = new LinkedHashMap(); + + + //This sets the location of the transformations in the job + //The first entry is not a transformation so skip it + //This is done here so we know where the files are being saved and that they are saved + for (int i = 1; i < jm.nrJobEntries() -1; i++) { + JobEntryJob jobs = (JobEntryJob)(jm.getJobEntry(i).getEntry()); + jobs.setFileName(getJobFilePath(jobs.getName())); + System.out.println("\n jobOutputToXML::jobs fileName: "+jobs.getFileName()); + } + + String fileName = settings.getFilePath() ; + if (!fileName.toUpperCase().endsWith(".KJB")) { + fileName += ".kjb"; + } + jm.setFilename(fileName); + outputs.put(new File(fileName), jm.getXML()); + if (getJob_no() > 0) { + jobMetaList.add(jm); + } + UserPrompter up = session.createUserPrompter( + "The file {0} already exists. Overwrite?", UserPromptType.BOOLEAN, UserPromptOptions.OK_NOTOK_CANCEL, UserPromptResponse.NOT_OK, + false, "Overwrite", "Don't Overwrite", "Cancel"); + for (File f : outputs.keySet()) { + try { + logger.debug("jobOutputToXML :: The file to output is " + f.getPath()); + if (f.exists()) { + UserPromptResponse overwriteOption = up.promptUser(f.getAbsolutePath()); + if (overwriteOption == UserPromptResponse.OK) { + f.delete(); + } else if (overwriteOption == UserPromptResponse.NOT_OK) { + continue; + } else if (overwriteOption == UserPromptResponse.CANCEL) { + cancel(); + return; + } else { + throw new IllegalStateException( + "Unknown response value from user prompt: " + overwriteOption); + } + } + f.createNewFile(); + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new + FileOutputStream(f), "utf-8")); + out.write(outputs.get(f)); + out.flush(); + out.close(); + monitor.setProgress(monitor.getProgress() + 1); + + if (monitor.isCancelled()) { + cancel(); + return; + } + } catch (IOException er) { + tasksToDo.clear(); + tasksToDo.add("File " + f.getName() + " was not created"); + throw er; + } + } + + } + +private String getJobFilePath(String jobName) { + String parentPath = new File(settings.getFilePath()).getParentFile().getPath(); + logger.debug("Parent file path is " + parentPath +" for job"); + return new File(parentPath, jobName + ".kjb").getPath(); +} + +// chops a list into sublists of length L + static List> chopped(List list, final int L) { + List> parts = new ArrayList>(); + final int N = list.size(); + for (int i = 0; i < N; i += L) { + parts.add(new ArrayList( + list.subList(i, Math.min(N, i + L))) + ); + } + return parts; + } + /** * This is a helper method that sets the taskToDo list with * the correct message to display. @@ -410,6 +608,7 @@ void outputToXML(List transformations, JobMeta job) throws IOExceptio for (TransMeta transMeta : transformations) { File file = new File(getTransFilePath(transMeta.getName())); + System.out.println("\n transformation file: "+file.getAbsolutePath()); transMeta.setFilename(file.getName()); try { outputs.put(file, transMeta.getXML()); @@ -425,24 +624,31 @@ void outputToXML(List transformations, JobMeta job) throws IOExceptio //This sets the location of the transformations in the job //The first entry is not a transformation so skip it //This is done here so we know where the files are being saved and that they are saved - for (int i = 1; i < job.nrJobEntries(); i++) { + for (int i = 1; i < job.nrJobEntries()-1; i++) { JobEntryTrans trans = (JobEntryTrans)(job.getJobEntry(i).getEntry()); trans.setFileName(getTransFilePath(trans.getName())); } - String fileName = settings.getFilePath(); + String fileName = settings.getFilePath() ; + if (settings.isSplittingJob() && getJob_no() > 0) { + String parentPath = new File(settings.getFilePath()).getParentFile().getPath(); + fileName = parentPath+"/"+job.getName()+".kjb"; + } if (!fileName.toUpperCase().endsWith(".KJB")) { + fileName += ".kjb"; } job.setFilename(fileName); outputs.put(new File(fileName), job.getXML()); - + if (settings.isSplittingJob() && getJob_no() > 0) { + jobMetaList.add(job); + } UserPrompter up = session.createUserPrompter( "The file {0} already exists. Overwrite?", UserPromptType.BOOLEAN, UserPromptOptions.OK_NOTOK_CANCEL, UserPromptResponse.NOT_OK, false, "Overwrite", "Don't Overwrite", "Cancel"); for (File f : outputs.keySet()) { try { - logger.debug("The file to output is " + f.getPath()); + logger.debug("outputToXML :: The file to output is " + f.getPath()); if (f.exists()) { UserPromptResponse overwriteOption = up.promptUser(f.getAbsolutePath()); if (overwriteOption == UserPromptResponse.OK) { @@ -784,4 +990,28 @@ public void setRepositoryDirectoryChooser(KettleRepositoryDirectoryChooser choos public SPDataSource getRepository() { return settings.getRepository(); } + + public int getSplitJobNo() { + return settings.getSplitJobNo(); + } + + + public void setSplitJobNo(int newValue) { + settings.setSplitJobNo(newValue); + } + + /** + * return the current job no + */ + private int getJob_no() { + return job_no; + } + + public boolean isSplittingJob() { + return settings.isSplittingJob(); + } + + public void setSplittingJob(boolean newValue) { + settings.setSplittingJob(newValue); + } } diff --git a/src/main/java/ca/sqlpower/architect/etl/kettle/KettleSettings.java b/src/main/java/ca/sqlpower/architect/etl/kettle/KettleSettings.java index e0de8c960..c387673d8 100644 --- a/src/main/java/ca/sqlpower/architect/etl/kettle/KettleSettings.java +++ b/src/main/java/ca/sqlpower/architect/etl/kettle/KettleSettings.java @@ -71,6 +71,16 @@ public class KettleSettings extends AbstractSPObject { private boolean isTimeStampExcluded = false; + private boolean isSplittingJob = false; + + /** + * split job number + * used to split the big job into smaller batch of spliJob no + * minimum job number is 2 + */ + private int splitJobNo = 2; + + @Constructor public KettleSettings() { setName("Kettle Settings"); @@ -180,4 +190,34 @@ public List getDependencies() { public void removeDependency(SPObject dependency) { } + + @Accessor + public int getSplitJobNo() { + return splitJobNo; + } + + @Mutator + public void setSplitJobNo(int newValue) { + int oldValue = splitJobNo; + this.splitJobNo = newValue; + firePropertyChange("splitJobNo", oldValue, splitJobNo); + } + + /** + * @return the isSplittingJob + */ + @Accessor + public boolean isSplittingJob() { + return isSplittingJob; + } + + /** + * @param isSplittingJob the isSplittingJob to set + */ + @Mutator + public void setSplittingJob(boolean newValue) { + boolean oldValue = isSplittingJob; + this.isSplittingJob = newValue; + firePropertyChange("isSplittingJob", oldValue, isSplittingJob); + } } diff --git a/src/main/java/ca/sqlpower/architect/etl/kettle/KettleUtils.java b/src/main/java/ca/sqlpower/architect/etl/kettle/KettleUtils.java index ecbf36f8d..f36dae767 100644 --- a/src/main/java/ca/sqlpower/architect/etl/kettle/KettleUtils.java +++ b/src/main/java/ca/sqlpower/architect/etl/kettle/KettleUtils.java @@ -94,6 +94,9 @@ public static DatabaseMeta createDatabaseMeta(JDBCDataSource target) { // Extra Attributes databaseMeta.setSQLServerInstance(instancename); } + if (port!=null) { + databaseMeta.setDBPort(port); + } return databaseMeta; } } diff --git a/src/main/java/ca/sqlpower/architect/swingui/ASUtils.java b/src/main/java/ca/sqlpower/architect/swingui/ASUtils.java index 5229f157e..c04ee5126 100644 --- a/src/main/java/ca/sqlpower/architect/swingui/ASUtils.java +++ b/src/main/java/ca/sqlpower/architect/swingui/ASUtils.java @@ -132,8 +132,8 @@ public void startFocusDebugger() { * of "(Target Database)" if it is customized or it will make sure that only one * copy of the target's connection is in the list */ - public static void setupTargetDBComboBox(final ArchitectSwingSession session, final JComboBox targetDB) { - JComboBox newTargetDB = new JComboBox(); + public static void setupTargetDBComboBox(final ArchitectSwingSession session, final JComboBox databaseComboBox) { + JComboBox newTargetDB = new JComboBox(); JDBCDataSource currentTarget = session.getTargetDatabase().getDataSource(); newTargetDB.addItem(currentTarget); for (JDBCDataSource dbcs : session.getDataSources().getConnections()) { @@ -142,15 +142,15 @@ public static void setupTargetDBComboBox(final ArchitectSwingSession session, fi } } newTargetDB.setSelectedIndex(0); - targetDB.setModel(newTargetDB.getModel()); - targetDB.addActionListener(new ActionListener() { + databaseComboBox.setModel(newTargetDB.getModel()); + databaseComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JDBCDataSource projectDS = session.getTargetDatabase().getDataSource(); - JDBCDataSource comboBoxDS = (JDBCDataSource)((JComboBox)e.getSource()).getSelectedItem(); + JDBCDataSource comboBoxDS = (JDBCDataSource)((JComboBox)e.getSource()).getSelectedItem(); if(!projectDS.equals(comboBoxDS)) { projectDS.copyFrom(comboBoxDS); } - setupTargetDBComboBox(session, targetDB); + setupTargetDBComboBox(session, databaseComboBox); } }); } @@ -163,7 +163,7 @@ public void actionPerformed(ActionEvent e) { public static void showTargetDbcsDialog( Window parentWindow, final ArchitectSwingSession session, - final JComboBox targetDB) { + final JComboBox targetDB) { JDialog d = showDbcsDialog(parentWindow, session.getTargetDatabase().getDataSource(), null, false); @@ -277,7 +277,7 @@ public static DataEntryPanel createDataSourceOptionsPanel(JDBCDataSource ds, boo // update kettle fields if/when user picks new driver generalPanel.getDataSourceTypeBox().addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - JComboBox cb = (JComboBox) e.getSource(); + JComboBox cb = (JComboBox) e.getSource(); JDBCDataSourceType parentType = (JDBCDataSourceType) cb.getSelectedItem(); kettlePanel.parentTypeChanged(parentType); } diff --git a/src/main/java/ca/sqlpower/architect/swingui/KettleJobPanel.java b/src/main/java/ca/sqlpower/architect/swingui/KettleJobPanel.java index f8b4bac8c..3077875f8 100644 --- a/src/main/java/ca/sqlpower/architect/swingui/KettleJobPanel.java +++ b/src/main/java/ca/sqlpower/architect/swingui/KettleJobPanel.java @@ -22,19 +22,28 @@ import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.io.File; +import java.util.List; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFileChooser; +import javax.swing.JFormattedTextField; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.JSpinner; import javax.swing.JTextField; +import javax.swing.SpinnerNumberModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -43,6 +52,8 @@ import ca.sqlpower.architect.etl.kettle.KettleJob; import ca.sqlpower.sql.JDBCDataSource; +import ca.sqlpower.sqlobject.SQLObjectException; +import ca.sqlpower.sqlobject.SQLTable; import ca.sqlpower.swingui.DataEntryPanel; import ca.sqlpower.swingui.SPSUtils; @@ -72,7 +83,7 @@ public class KettleJobPanel implements DataEntryPanel { * The combo box that lists all of the target databases. This is used to * select the database to copy all of the data to. */ - private JComboBox databaseComboBox; + private JComboBox databaseComboBox; /** * This button brings up a new DBCS panel to make a new connection to select @@ -90,6 +101,16 @@ public class KettleJobPanel implements DataEntryPanel { */ private JCheckBox timeStampCheckBox; + /** + * checkbox used to split the job + */ + private JCheckBox splitJobCheckBox; + + /** + * user can select/write the number to split the job + */ + private JSpinner splitSpinner; + /** * This field allows the user to specify an absolute path to where the file should be * saved if the kettle job is to be saved as a file in XML format. @@ -105,7 +126,7 @@ public class KettleJobPanel implements DataEntryPanel { /** * The default join type to set Kettle joins to if they are required in a transformation. */ - private JComboBox defaultJoinType; + private JComboBox defaultJoinType; /** * The label that shows the user the path to the Job file to let them know that the @@ -142,6 +163,10 @@ public class KettleJobPanel implements DataEntryPanel { */ private final ArchitectSwingSession session; + private List tableList; + + private KettleJob settings; + /** * This constructor creates a Kettle job panel and displays it to the user. * @@ -159,12 +184,16 @@ public KettleJobPanel(ArchitectSwingSession session) { * Kettle job properties. */ private void buildUI(){ - KettleJob settings = session.getKettleJob(); + settings = session.getKettleJob(); panel.setLayout(new FormLayout()); panel.setPreferredSize(new Dimension(500,450)); - + try { + tableList = session.getPlayPen().getTables(); + } catch (SQLObjectException e1) { + e1.printStackTrace(); + } nameField = new JTextField(settings.getJobName()); - databaseComboBox = new JComboBox(); + databaseComboBox = new JComboBox(); ASUtils.setupTargetDBComboBox(session, databaseComboBox); newDatabaseButton = new JButton(); newDatabaseButton.setText(Messages.getString("KettleJobPanel.propertiesButton")); //$NON-NLS-1$ @@ -256,7 +285,49 @@ public void actionPerformed(ActionEvent e) { saveByButtonGroup.add(saveFileRadioButton); saveByButtonGroup.add(saveReposRadioButton); timeStampCheckBox = new JCheckBox("Exclude Column with 'TimeStamp' dataType"); - defaultJoinType = new JComboBox(); + // to split the main job into multiple inner job + splitJobCheckBox = new JCheckBox("Split the job"); + splitSpinner = new JSpinner(new SpinnerNumberModel(settings.getSplitJobNo(), 2, null, 1)); + splitSpinner.setEnabled(splitJobCheckBox.isSelected()); + splitJobCheckBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + AbstractButton abstractButton = (AbstractButton) e.getSource(); + splitSpinner.setEnabled(abstractButton.getModel().isSelected()); + } + + }); + JComponent editor = splitSpinner.getEditor(); + final JFormattedTextField tf = ((JSpinner.DefaultEditor) editor).getTextField(); + tf.setColumns(3); + tf.addFocusListener(new FocusListener() { + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void focusLost(FocusEvent e) { + System.out.println(tf.getText()); + if (!isValidSplitNo()) { + tf.setFocusable(true); + } + } + + }); + splitSpinner.addChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + if (!isValidSplitNo()) { + tf.setFocusable(true); + } + } + }); + defaultJoinType = new JComboBox(); for (int joinType = 0; joinType < MergeJoinMeta.join_types.length; joinType++) { defaultJoinType.addItem(MergeJoinMeta.join_types[joinType]); } @@ -283,6 +354,9 @@ public void actionPerformed(ActionEvent e) { builder.append(timeStampCheckBox, 3); builder.nextLine(); builder.append(""); //$NON-NLS-1$ + builder.append(splitJobCheckBox, splitSpinner); + builder.nextLine(); + builder.append(""); //$NON-NLS-1$ builder.append(Messages.getString("KettleJobPanel.defaultJoinTypeLabel")); //$NON-NLS-1$ builder.append(defaultJoinType); builder.nextLine(); @@ -317,13 +391,30 @@ public void actionPerformed(ActionEvent e) { builder.append(check, 5); } - + /** + * check if user entered a valid split number + */ + private boolean isValidSplitNo() { + if (splitSpinner.getValue() instanceof Integer) { + int splitno = (Integer)splitSpinner.getValue(); + if (tableList.size() <= splitno) { + JOptionPane.showMessageDialog(panel, "The split number must be greater then two or less then the number of tables in a PlayPen", "Invalid Split Number", JOptionPane.WARNING_MESSAGE); + return false; + } + } else { + JOptionPane.showMessageDialog(panel, "Enter a valid number to split the job", "Invalid Split Number", JOptionPane.WARNING_MESSAGE); + return false; + } + return true; + } + /** * Copies the settings to the project and verifies that the Job name is not empty and the file path is not * empty if the job is to be saved to a file. */ public boolean applyChanges() { copySettingsToProject(); + if (!isValidSplitNo()) return false; if (nameField.getText().equals("")) { //$NON-NLS-1$ JOptionPane.showMessageDialog(panel, Messages.getString("KettleJobPanel.jobNameNotSetError")); //$NON-NLS-1$ return false; @@ -380,6 +471,8 @@ private void copySettingsToProject() { settings.setRepository((JDBCDataSource)reposDB.getSelectedItem()); settings.setSavingToFile(isSaveFile()); settings.setTimeStampExcluded(timeStampCheckBox.isSelected()); + settings.setSplittingJob(splitJobCheckBox.isSelected()); + settings.setSplitJobNo((Integer)splitSpinner.getValue()); session.getWorkspace().commit(); } diff --git a/src/main/java/ca/sqlpower/architect/swingui/action/KettleJobAction.java b/src/main/java/ca/sqlpower/architect/swingui/action/KettleJobAction.java index fd608ae34..ddd182e33 100644 --- a/src/main/java/ca/sqlpower/architect/swingui/action/KettleJobAction.java +++ b/src/main/java/ca/sqlpower/architect/swingui/action/KettleJobAction.java @@ -108,7 +108,7 @@ public void doStuff() throws Exception { createKettleJobMonitor.setLocationRelativeTo(frame); createKettleJobMonitor.setVisible(true); List tableList = getSession().getPlayPen().getTables(); - kettleJob.doExport(tableList, getSession().getTargetDatabase()); + kettleJob.doSplitedJobExport(tableList, getSession().getTargetDatabase()); } @Override