edu.harvard.mgh.purcell.gCLINE.data
Class Record

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by edu.harvard.mgh.purcell.gCLINE.data.Record
All Implemented Interfaces:
KeyWords, java.io.Serializable, javax.swing.tree.TreeModel
Direct Known Subclasses:
Project, TestFrame.myProject

public abstract class Record
extends javax.swing.tree.DefaultTreeModel
implements KeyWords

This class manages the operation annotations. Notes: All files are identified by their full file names. All operation names are unique.

Author:
Kathe Todd-Brown
See Also:
Serialized Form

Nested Class Summary
private static class Record.myHostKeyValidator
          This is a host key validator that automatically accepts any host key sent but doesn't actually save any of them.
 
Field Summary
private  com.sshtools.j2ssh.SshClient conn
          A String that holds the ssh connection.
static java.lang.String DEFAULT_EDITOR
          default editor
 StartFrame frame
          A JFrame that holds the main GUI
protected  java.util.Properties globalConfig
          Holds the global configuration data.
private  java.util.HashMap<java.lang.String,java.lang.String> globalFileNotes
          A HashMap that carries the global file notes
 boolean isNew
           
protected  java.util.Properties localConfig
          Holds the local project configuration data.
private static org.apache.log4j.Logger logger
          Optionally log messages.
 Lock myLock
          Locking information for the folder
 java.lang.String OP_LOG_EXT
          A string that identifies the file extention for the operation log file.
protected  java.util.Properties remoteConfig
          Holds the information for the remote connection.
 AutoUpdater update
          Automatically checks the home directory for new files and updates the displays.
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Fields inherited from interface edu.harvard.mgh.purcell.gCLINE.data.KeyWords
BROWSE_KEY, CLINE_KEY, COMMAND_KEY, COMMAND_PREFIX_KEY, FILE_KEY, FOLDER_KEY, GLOBAL_CONFIG, HOME_KEY, HOST_KEY, INFILE_KEY, LOCAL_DIR, LOCAL_FOLDER_KEY, LOCK_FILE, META_FILE, NAME_KEY, OP_KEY, OUTFILE_KEY, P1_KEY, P2_KEY, P3_KEY, P4_KEY, PORT_KEY, REMOTE_CONFIG_FILE, REMOTE_FOLDER_KEY, REMOTE_GLOBAL_CONFIG, TIMESTAMP_KEY, UPDATE_INTERVAL_KEY, USER_EDITOR_KEY, USER_KEY, VS_KEY
 
Constructor Summary
Record()
          Create a Record with null or empty fields.
Record(StartFrame f)
          Create a Record initalized to a particular StartFrame.
Record(StartFrame f, java.lang.String localName)
          Create a Record.
Record(StartFrame f, java.lang.String localName, java.lang.String remoteFileName, java.lang.String hostname, java.lang.String username, java.lang.String portnum, com.sshtools.j2ssh.SshClient c)
          Create a Record.
 
Method Summary
 boolean addOperation(java.lang.String opName, java.lang.String opDisc, java.lang.String cline, java.lang.String createTime, java.util.Vector<java.lang.String[]> infiles, java.util.Vector<java.lang.String[]> outfiles)
          Add an operation to the info document, if there is an operation of that name then replace it with this new one.
 boolean backupInfo()
           
 boolean connect()
           
static com.sshtools.j2ssh.SshClient connect(ErrorManager em, javax.swing.JFrame frame, java.lang.String host, java.lang.String user, int port)
          Connect the ssh client.
 java.util.Vector<OperationInfo> getAllOp()
          Get a list of all the operations
 java.lang.String getAltEditor()
          Get the alternative editor
 com.sshtools.j2ssh.SshClient getConn()
          get the connection to the remote directory
 java.lang.String getGlobalNote(java.lang.String filename)
          Get a specific file note
 java.util.Vector<java.lang.String> getHomeFiles()
          Get a list of files that are in your working directory
 java.lang.String getHomeFolder()
          Get the home folder that the data is stored in.
 java.io.File getLocalFolder()
          Get the name of the local file
 OperationInfo getOp(java.lang.String opName)
          Get the full information on an operation
 java.lang.String getP1()
          Get the first project name
 java.lang.String getP2()
          Get the second project name
 java.lang.String getP3()
          Get the third project name
 java.lang.String getP4()
          Get the forth project name
 java.lang.String getRemoteFolder()
          Get the name of the remote file
static boolean getSavedBrowse()
          Get the what browse option is saved in the global config file.
 java.lang.String getStatusExt()
          Get the log extention
 int getUpdateSec()
           
 boolean isRemote()
          Is this record tied to a remote directory?
 boolean loadData(java.io.File metaFile, java.lang.String homefile, boolean remote)
          Load the info document from xml file, otherwise set as default.
private  void loadGlobalConfig()
          Load the config values from a Properties formated file.
protected abstract  void loadRemoteConfig()
           
private  void populateNodes(org.w3c.dom.Document info)
          Populate the operations and global file notes from a Document.
private  org.w3c.dom.Document processNodes()
          Create a Document from the operations and global file notes that we can then write as an xml document easily.
 void properClosing()
          Close the Record up properly.
 int removeOperation(java.lang.String opName)
          Remove an operation from the document.
 void saveConfig()
          Save the config values
 boolean saveInfo()
           
 boolean saveInfo(java.io.File metaFile)
          Write the information to the project file of the xml format.
protected abstract  void saveRemoteConfig()
           
 void setAltEditor(java.lang.String editor)
          Set the alternative editor
abstract  void setAutoUpdater(AutoUpdater given)
          This is mainly abstract to remind programers to initalize it
 void setConnData(com.sshtools.j2ssh.SshClient c, java.lang.String host, java.lang.String port, java.lang.String user)
          Set the connection data
 void setGlobalFileDisc(java.lang.String fileName, java.lang.String fileDisc)
          Set a global file discriptor
 void setLastProject()
          Add the current project to our list so that we can launch the recent projects quickly from the associated menu bar.
 void setLog(java.lang.String ext)
          Set the log extention
 void setP1(java.lang.String name)
          Set the first project name if it's not equal to null.
 void setP2(java.lang.String name)
          Set the second project name if it's not equal to null
 void setP3(java.lang.String name)
          Set the third project name if it's not equal to null
 void setP4(java.lang.String name)
          Set the forth project name if it's not equal to null
private  void setSavedBrowse()
           
 void setUpdateSec(int sec)
           
 java.lang.String toString()
          Print the home folder of the record.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_EDITOR

public static java.lang.String DEFAULT_EDITOR
default editor


OP_LOG_EXT

public java.lang.String OP_LOG_EXT
A string that identifies the file extention for the operation log file. Note that this can be changed by the user


frame

public StartFrame frame
A JFrame that holds the main GUI


remoteConfig

protected java.util.Properties remoteConfig
Holds the information for the remote connection. populated from info including: user name, host name, port number, remote project folder name


globalConfig

protected java.util.Properties globalConfig
Holds the global configuration data. Includes: Alternative editor


localConfig

protected java.util.Properties localConfig
Holds the local project configuration data. Includes: local project folder name, home folder name


isNew

public boolean isNew

globalFileNotes

private java.util.HashMap<java.lang.String,java.lang.String> globalFileNotes
A HashMap that carries the global file notes


myLock

public Lock myLock
Locking information for the folder


conn

private com.sshtools.j2ssh.SshClient conn
A String that holds the ssh connection.


update

public AutoUpdater update
Automatically checks the home directory for new files and updates the displays.


logger

private static org.apache.log4j.Logger logger
Optionally log messages.

Constructor Detail

Record

public Record()
Create a Record with null or empty fields.


Record

public Record(StartFrame f)
Create a Record initalized to a particular StartFrame.

Parameters:
f - The StartFrame we are attaching this Record to.

Record

public Record(StartFrame f,
              java.lang.String localName)
Create a Record.

Parameters:
f - The StartFrame w are attaching this Record to.
localName - A String that is the name of the local project folder for this project.

Record

public Record(StartFrame f,
              java.lang.String localName,
              java.lang.String remoteFileName,
              java.lang.String hostname,
              java.lang.String username,
              java.lang.String portnum,
              com.sshtools.j2ssh.SshClient c)
Create a Record.

Parameters:
f - The StartFrame w are attaching this Record to.
localName - A String that is the name of the local project folder for this project.
remoteFileName - A String that is the name of the remote project folder for this project.
hostname - A String that is the name of the remote host
username - A String that is the name of the user on the remote host.
portnum - A String that is the port number we wish to connect to.
c - A SshClient that is used to connect to the remote host.
Method Detail

setUpdateSec

public void setUpdateSec(int sec)

setAutoUpdater

public abstract void setAutoUpdater(AutoUpdater given)
This is mainly abstract to remind programers to initalize it


setLog

public void setLog(java.lang.String ext)
Set the log extention

Parameters:
ext - a string discribing the log extention

setConnData

public void setConnData(com.sshtools.j2ssh.SshClient c,
                        java.lang.String host,
                        java.lang.String port,
                        java.lang.String user)
Set the connection data

Parameters:
c - the actual connection
host - a string holding the host name
port - a string holding the port number
user - a string holding the user name

setAltEditor

public void setAltEditor(java.lang.String editor)
Set the alternative editor


setLastProject

public void setLastProject()
Add the current project to our list so that we can launch the recent projects quickly from the associated menu bar.


setP1

public void setP1(java.lang.String name)
Set the first project name if it's not equal to null.

Parameters:
name - The name of the project

setP2

public void setP2(java.lang.String name)
Set the second project name if it's not equal to null

Parameters:
name - The name of the project

setP3

public void setP3(java.lang.String name)
Set the third project name if it's not equal to null

Parameters:
name - The name of the project

setP4

public void setP4(java.lang.String name)
Set the forth project name if it's not equal to null

Parameters:
name - The name of the project

setSavedBrowse

private void setSavedBrowse()

getUpdateSec

public int getUpdateSec()

getP1

public java.lang.String getP1()
Get the first project name

Returns:
The first project name, null if it's not set.

getP2

public java.lang.String getP2()
Get the second project name

Returns:
The second project name, null if it's not set

getP3

public java.lang.String getP3()
Get the third project name

Returns:
The third project name, null if it's not set

getP4

public java.lang.String getP4()
Get the forth project name

Returns:
The forth project name, null if it's not set.

getAltEditor

public java.lang.String getAltEditor()
Get the alternative editor

Returns:
The user defined alternative editor.

getStatusExt

public java.lang.String getStatusExt()
Get the log extention

Returns:
a string that is the log extention

getConn

public com.sshtools.j2ssh.SshClient getConn()
get the connection to the remote directory

Returns:
the connection to the remote directory

getRemoteFolder

public java.lang.String getRemoteFolder()
Get the name of the remote file

Returns:
a string that discribes the remote file

getLocalFolder

public java.io.File getLocalFolder()
Get the name of the local file

Returns:
a string that discribes the local file

getHomeFolder

public java.lang.String getHomeFolder()
Get the home folder that the data is stored in. If the project is remote then this is the folder name on the remote server, otherwise it's the full name of the local folder.

Returns:
A string that holds the full name of the folder that holds the data.

getHomeFiles

public java.util.Vector<java.lang.String> getHomeFiles()
Get a list of files that are in your working directory

Returns:
a vector of the files in your working directory

getGlobalNote

public java.lang.String getGlobalNote(java.lang.String filename)
Get a specific file note

Parameters:
filename - A string that is the file name
Returns:
A global discription for this file.

getAllOp

public java.util.Vector<OperationInfo> getAllOp()
Get a list of all the operations

Returns:
a vector of all the operations information

getOp

public OperationInfo getOp(java.lang.String opName)
Get the full information on an operation

Parameters:
opName - A string that is the name of the operation
Returns:
The full operation information

getSavedBrowse

public static boolean getSavedBrowse()
Get the what browse option is saved in the global config file.

Returns:
true if it the browse is configured as true and false otherwise

loadData

public boolean loadData(java.io.File metaFile,
                        java.lang.String homefile,
                        boolean remote)
Load the info document from xml file, otherwise set as default.

Parameters:
metaFile - the file that holds the xml document
homefile - the string that is our project root
Returns:
true if data was loaded from a file, false if we had to create a empty Record

populateNodes

private void populateNodes(org.w3c.dom.Document info)
Populate the operations and global file notes from a Document.

Parameters:
info - A document that holds all the global discriptions and operatoin nodes

processNodes

private org.w3c.dom.Document processNodes()
Create a Document from the operations and global file notes that we can then write as an xml document easily. Returns null if unable to create a document.

Returns:
A Document containing all the global file notes and operation.

loadGlobalConfig

private void loadGlobalConfig()
Load the config values from a Properties formated file.


loadRemoteConfig

protected abstract void loadRemoteConfig()

saveRemoteConfig

protected abstract void saveRemoteConfig()

saveConfig

public void saveConfig()
Save the config values


addOperation

public boolean addOperation(java.lang.String opName,
                            java.lang.String opDisc,
                            java.lang.String cline,
                            java.lang.String createTime,
                            java.util.Vector<java.lang.String[]> infiles,
                            java.util.Vector<java.lang.String[]> outfiles)
Add an operation to the info document, if there is an operation of that name then replace it with this new one.

Parameters:
opName - The operation name.
opDisc - The discription of the operation.
cline - The command line that is tied to the operaiton
infiles - A vector of the names of the input files.
outfiles - A vector of the names of the output files.
Returns:
a boolean flagging the success of the addition.

removeOperation

public int removeOperation(java.lang.String opName)
Remove an operation from the document.

Parameters:
opName - the name of the operation we are removing
Returns:
the index that this operation was at, -1 if the operation was not found.

setGlobalFileDisc

public void setGlobalFileDisc(java.lang.String fileName,
                              java.lang.String fileDisc)
Set a global file discriptor

Parameters:
fileName - a string identifing the file (absolute path name)
fileDisc - a string for local file discription

isRemote

public boolean isRemote()
Is this record tied to a remote directory?

Returns:
true if it is false otherwise

saveInfo

public boolean saveInfo()

backupInfo

public boolean backupInfo()

saveInfo

public boolean saveInfo(java.io.File metaFile)
Write the information to the project file of the xml format.

Returns:
true if writing is sucessfull, false otherwise

toString

public java.lang.String toString()
Print the home folder of the record. If the record is remote then the home folder is the pwd of the remote folder otherwise it is the full path name of the local folder.

Overrides:
toString in class java.lang.Object
Returns:
a string that is the path of the home folder

connect

public boolean connect()

connect

public static com.sshtools.j2ssh.SshClient connect(ErrorManager em,
                                                   javax.swing.JFrame frame,
                                                   java.lang.String host,
                                                   java.lang.String user,
                                                   int port)
Connect the ssh client.

Returns:
false if an error that we can cetch happened (not always the case!) true otherwise.

properClosing

public void properClosing()
Close the Record up properly. Set everything to null.