diff --git a/uk/ac/sanger/artemis/ExternalProgram.java b/uk/ac/sanger/artemis/ExternalProgram.java index 03f5d469cdabb271d2b0577706affd1cf80709cd..9a73b7c7ba8f47ad6b6ae630ca7c817bf7ee77af 100644 --- a/uk/ac/sanger/artemis/ExternalProgram.java +++ b/uk/ac/sanger/artemis/ExternalProgram.java @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ExternalProgram.java,v 1.2 2004-06-09 13:00:09 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ExternalProgram.java,v 1.3 2005-08-11 16:12:43 tjc Exp $ **/ package uk.ac.sanger.artemis; @@ -41,7 +41,7 @@ import java.util.Enumeration; * and contains methods for invoking it. * * @author Kim Rutherford - * @version $Id: ExternalProgram.java,v 1.2 2004-06-09 13:00:09 tjc Exp $ + * @version $Id: ExternalProgram.java,v 1.3 2005-08-11 16:12:43 tjc Exp $ **/ public class ExternalProgram @@ -146,6 +146,18 @@ public class ExternalProgram // { try { + if(System.getProperty("j2ssh") != null) + { + String [] args = { "-f", file_of_filenames.getPath(), + "-cmd", getRealName(), + "-d", getProgramOptions()}; + uk.ac.sanger.artemis.j2ssh.SftpPSUClient ssh = + new uk.ac.sanger.artemis.j2ssh.SftpPSUClient( args ); + ssh.start(); + + return null; + } + final String [] arguments; switch(program_type) diff --git a/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java b/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java index 1cf849977b12a241bf58452db01387c6475c050c..b50665037cbb851cb00d4e6970a11755082c6e9a 100644 --- a/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java +++ b/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java @@ -24,6 +24,8 @@ package uk.ac.sanger.artemis.chado; +import uk.ac.sanger.artemis.Feature; +import uk.ac.sanger.artemis.Entry; import uk.ac.sanger.artemis.sequence.SequenceChangeListener; import uk.ac.sanger.artemis.sequence.SequenceChangeEvent; import uk.ac.sanger.artemis.io.QualifierVector; @@ -37,7 +39,8 @@ import uk.ac.sanger.artemis.util.StringVector; import uk.ac.sanger.artemis.util.DatabaseDocument; import uk.ac.sanger.artemis.FeatureChangeListener; import uk.ac.sanger.artemis.FeatureChangeEvent; - +import uk.ac.sanger.artemis.EntryChangeListener; +import uk.ac.sanger.artemis.EntryChangeEvent; import java.util.Vector; import javax.swing.JOptionPane; @@ -48,7 +51,7 @@ import javax.swing.JOptionPane; * **/ public class ChadoTransactionManager - implements FeatureChangeListener, SequenceChangeListener + implements FeatureChangeListener, EntryChangeListener, SequenceChangeListener { private Vector sql = new Vector(); @@ -117,6 +120,22 @@ public class ChadoTransactionManager } } + public void entryChanged(EntryChangeEvent event) + { + System.out.println("HERE"); + if(event.getType() == EntryChangeEvent.FEATURE_ADDED) + System.out.println("HERE FEATURE_ADDED"); + + Feature feature = event.getFeature(); + + if(feature == null) + System.out.println("HERE feature == null"); + else + System.out.println("HERE feature != null"); + + System.out.println(event.getEntry().getName()); + } + /** * * Return a string containing one qualifier per line. These are the diff --git a/uk/ac/sanger/artemis/components/EntryEdit.java b/uk/ac/sanger/artemis/components/EntryEdit.java index e0c92bbc006935ea8f40e49a56eec993585a05ce..f2a760e2558a322e0db6d9107d04edbf5d92b26d 100644 --- a/uk/ac/sanger/artemis/components/EntryEdit.java +++ b/uk/ac/sanger/artemis/components/EntryEdit.java @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/EntryEdit.java,v 1.18 2005-08-08 10:56:46 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/EntryEdit.java,v 1.19 2005-08-11 16:12:43 tjc Exp $ */ package uk.ac.sanger.artemis.components; @@ -56,7 +56,7 @@ import javax.swing.border.BevelBorder; * Each object of this class is used to edit an EntryGroup object. * * @author Kim Rutherford - * @version $Id: EntryEdit.java,v 1.18 2005-08-08 10:56:46 tjc Exp $ + * @version $Id: EntryEdit.java,v 1.19 2005-08-11 16:12:43 tjc Exp $ * */ public class EntryEdit extends JFrame @@ -939,6 +939,7 @@ public class EntryEdit extends JFrame { final ChadoTransactionManager ctm = new ChadoTransactionManager(); getEntryGroup().addFeatureChangeListener(ctm); + getEntryGroup().addEntryChangeListener(ctm); JMenuItem commit = new JMenuItem("Commit to Database"); commit.addActionListener(new ActionListener() diff --git a/uk/ac/sanger/artemis/components/RunMenu.java b/uk/ac/sanger/artemis/components/RunMenu.java index 8fc5f2a1d685975035d2e85425f2c904f403a61c..f912871313680f06973b92d04e383bdbe948121a 100644 --- a/uk/ac/sanger/artemis/components/RunMenu.java +++ b/uk/ac/sanger/artemis/components/RunMenu.java @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/RunMenu.java,v 1.7 2004-12-21 13:46:47 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/RunMenu.java,v 1.8 2005-08-11 16:12:43 tjc Exp $ **/ package uk.ac.sanger.artemis.components; @@ -43,7 +43,7 @@ import javax.swing.*; * A JMenu of external commands/functions. * * @author Kim Rutherford - * @version $Id: RunMenu.java,v 1.7 2004-12-21 13:46:47 tjc Exp $ + * @version $Id: RunMenu.java,v 1.8 2005-08-11 16:12:43 tjc Exp $ **/ public class RunMenu extends SelectionMenu @@ -171,6 +171,9 @@ public class RunMenu extends SelectionMenu final ExternalProgramMonitor monitor = program.run(selection_features, Splash.getLogger()); + if(monitor == null) + return; + monitor.addExternalProgramListener(new ExternalProgramListener() { public void statusChanged(final ExternalProgramEvent e) @@ -288,53 +291,53 @@ public class RunMenu extends SelectionMenu /** * **/ - private int[] getIds() - { - final FeatureVector selected_features = getSelection().getAllFeatures(); - final Vector ids_vector = new Vector(); +//private int[] getIds() +//{ +// final FeatureVector selected_features = getSelection().getAllFeatures(); +// final Vector ids_vector = new Vector(); - for(int feature_index = 0; feature_index < selected_features.size(); - ++feature_index) - { - final Feature this_feature = selected_features.elementAt(feature_index); - - try - { - final Qualifier job_qualifier = - this_feature.getQualifierByName("job"); - - final StringVector values = job_qualifier.getValues(); +// for(int feature_index = 0; feature_index < selected_features.size(); +// ++feature_index) +// { +// final Feature this_feature = selected_features.elementAt(feature_index); - if(values != null && values.size() > 0) - { - for(int value_index=0; value_index<values.size(); - ++value_index) - { - final String job_value = values.elementAt(value_index); - final StringVector bits = StringVector.getStrings(job_value); +// try +// { +// final Qualifier job_qualifier = +// this_feature.getQualifierByName("job"); +// +// final StringVector values = job_qualifier.getValues(); - if(bits.size() > 4 && bits.elementAt(2).equals("task:")) - { - try - { - final Integer task_id = Integer.valueOf(bits.elementAt(3)); - - if(!ids_vector.contains(task_id)) - ids_vector.add(task_id); - } - catch(NumberFormatException e) {} - } - } - } - } - catch(InvalidRelationException e) {} - } +// if(values != null && values.size() > 0) +// { +// for(int value_index=0; value_index<values.size(); +// ++value_index) +// { +// final String job_value = values.elementAt(value_index); +// final StringVector bits = StringVector.getStrings(job_value); + +// if(bits.size() > 4 && bits.elementAt(2).equals("task:")) +// { +// try +// { +// final Integer task_id = Integer.valueOf(bits.elementAt(3)); + +// if(!ids_vector.contains(task_id)) +// ids_vector.add(task_id); +// } +// catch(NumberFormatException e) {} +// } +// } +// } +// } +// catch(InvalidRelationException e) {} +// } - final int[] ids = new int[ids_vector.size()]; +// final int[] ids = new int[ids_vector.size()]; - for(int i=0 ; i<ids.length ; ++i) - ids[i] =((Integer)ids_vector.elementAt(i)).intValue(); +// for(int i=0 ; i<ids.length ; ++i) +// ids[i] =((Integer)ids_vector.elementAt(i)).intValue(); - return ids; - } +// return ids; +//} } diff --git a/uk/ac/sanger/artemis/j2ssh/SftpPSUClient.java b/uk/ac/sanger/artemis/j2ssh/SftpPSUClient.java index 52f37dc6189eee2b82b3b6d09e0dcc5759d24420..684a52b53ccb0dff5a0c0ca1ee1297c9f1a9a2c5 100644 --- a/uk/ac/sanger/artemis/j2ssh/SftpPSUClient.java +++ b/uk/ac/sanger/artemis/j2ssh/SftpPSUClient.java @@ -50,7 +50,7 @@ import java.util.logging.SimpleFormatter; /** * */ -public class SftpPSUClient +public class SftpPSUClient extends Thread { private String hostname = null; @@ -65,7 +65,7 @@ public class SftpPSUClient public SftpPSUClient(String args[]) { - + // process arguments if(args != null && args.length > 0) { for(int i=0; i<args.length; i++) @@ -90,8 +90,12 @@ public class SftpPSUClient wdir = args[i+1]; } } + } - // get properties + public void run() + { + String program = cmd; + // get properties from j2ssh.properties Properties settings = getProperties(); if(hostname == null && settings.getProperty("host") != null) hostname = settings.getProperty("host"); @@ -108,8 +112,10 @@ public class SftpPSUClient else db = "%uniprot"; } - if(cmd.equals("blast") && settings.getProperty("blast") != null) - cmd = settings.getProperty("blast"); + if(cmd.equals("blastp") && settings.getProperty("blastp") != null) + cmd = settings.getProperty("blastp"); + if(cmd.equals("fasta") && settings.getProperty("fasta") != null) + cmd = settings.getProperty("fasta"); try { @@ -127,42 +133,53 @@ public class SftpPSUClient ConfigurationLoader.initialize(false); - if(hostname == null) - hostname = (String)JOptionPane.showInputDialog( - null, "Name of server machine:", - "Server hostname", - JOptionPane.PLAIN_MESSAGE, null, - null, null); +// if(hostname == null) +// hostname = (String)JOptionPane.showInputDialog( +// null, "Name of server machine:", +// "Server hostname", +// JOptionPane.PLAIN_MESSAGE, null, +// null, null); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); - // Make a client connection - SshClient ssh = new SshClient(); - // Connect to the host - if(port < 0) - ssh.connect(hostname); - else - ssh.connect(hostname,port); - // Create a password authentication instance PasswordAuthenticationClient pwd = new PasswordAuthenticationClient(); // Get the users name - JPanel promptPanel = new JPanel(new GridLayout(2,2)); + JPanel promptPanel = new JPanel(new GridLayout(4,2)); + + JTextField hostfield = new JTextField(16); + if(hostname != null) + hostfield.setText(hostname); + + JTextField portfield = new JTextField(16); + if(port >-1) + portfield.setText(Integer.toString(port)); + JTextField ufield = new JTextField(16); if(user != null) ufield.setText(user); JPasswordField pfield = new JPasswordField(16); + JLabel hostlab = new JLabel(" Hostname:", SwingConstants.LEFT); + JLabel portlab = new JLabel(" Port:", SwingConstants.LEFT); + JLabel ulab = new JLabel(" Username:", SwingConstants.LEFT); JLabel plab = new JLabel(" Password:", SwingConstants.LEFT); //add labels etc + promptPanel.add(hostlab); + promptPanel.add(hostfield); + + promptPanel.add(portlab); + promptPanel.add(portfield); + promptPanel.add(ulab); promptPanel.add(ufield); + promptPanel.add(plab); promptPanel.add(pfield); - + Object[] options = { "CANCEL", "LOGIN"}; int select = JOptionPane.showOptionDialog(null, promptPanel, @@ -173,9 +190,22 @@ public class SftpPSUClient options, options[1]); - if(select == 0) - System.exit(0); + return; + + // Make a client connection + SshClient ssh = new SshClient(); + hostname = hostfield.getText().trim(); + if(portfield.getText().trim().equals("")) + port = -1; + else + port = Integer.parseInt(portfield.getText().trim()); + + // Connect to the host + if(port < 0) + ssh.connect(hostname); + else + ssh.connect(hostname,port); user = ufield.getText().trim(); pwd.setUsername(user); @@ -194,7 +224,7 @@ public class SftpPSUClient if(returnVal == JFileChooser.APPROVE_OPTION) listfilepath = chooser.getSelectedFile().getAbsolutePath(); else - System.exit(0); + return; } SftpClient sftp = ssh.openSftpClient(); @@ -219,11 +249,21 @@ public class SftpPSUClient SessionChannelClient session = ssh.openSessionChannel(); String outputfile = wdir+filename+".out"; + final String actualCMD; - cmd = bsub+" -o "+ outputfile +" "+ + if(cmd.indexOf("fasta33") > -1) + { + if(settings.getProperty(db) != null) + db = settings.getProperty(db); + actualCMD = bsub+" -o "+ outputfile +" -e "+ outputfile + ".err " + + cmd+" "+wdir+filename+" "+db; + } + else + actualCMD = bsub+" -o "+ outputfile +" -e "+ outputfile + ".err " + cmd+" "+db+" "+wdir+filename; - System.out.println(cmd); - session.executeCommand(cmd); + + System.out.println(actualCMD); + session.executeCommand(actualCMD); // Reading from the session InputStream StdoutStdErrHandler stdouth = new StdoutStdErrHandler(session, true); @@ -267,9 +307,11 @@ public class SftpPSUClient System.out.println(stdouth.getOutput()); System.out.println(stderrh.getOutput()); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - sftp.get(outputfile, os); - System.out.println(os.toString()); +// ByteArrayOutputStream os = new ByteArrayOutputStream(); +// sftp.get(outputfile, os); +// System.out.println(os.toString()); + + sftp.get(outputfile, filepath+".out"); session.close(); } @@ -280,15 +322,18 @@ public class SftpPSUClient } else JOptionPane.showMessageDialog(null, - "Problem logging in!\nCheck username and password.", - "Authentication Problem", - JOptionPane.ERROR_MESSAGE); + "Problem logging in!\nCheck username and password.", + "Authentication Problem", + JOptionPane.ERROR_MESSAGE); } catch(IOException ioe){} finally { - System.out.println("ENDED"); + JOptionPane.showMessageDialog(null, + "Finished \n" + program, + "Process Finished", + JOptionPane.INFORMATION_MESSAGE); } }