ex1
Class WepsDBFile

java.lang.Object
  extended byex1.WepsDBFile

public class WepsDBFile
extends java.lang.Object

This class holds basic information about a weps crop or operation xml file. Each xml data file loaded is bound to a new instance of this class.


Constructor Summary
WepsDBFile(java.lang.String f, boolean isCrop, DefnFileParser p)
          Creates a new instance of WepsDBFile
 
Method Summary
 boolean addParm(java.lang.String name, java.lang.String val)
          Adds a parameter and its value to the list for crops or if this is an operation to the currrent action node being built.
 void changeName(java.lang.String mcrewCfgDir, java.lang.String newName)
          Change the name of an existing file.
 boolean changeProcess(int procNum, int newProc, ActionValue av)
          This function changes a process to a different type.
 boolean checkProcesses(boolean displayMessage)
          This function determines if the WEPS operations process and group ordering is valid.
 void createClone(java.lang.String mcrewCfgDir, WepsDBFile wf, boolean stripActions)
          Create a copy of this file.
 boolean deleteFile()
          Get rid of this file
 boolean deleteProcess(int index)
          This function deletes a process from an operation.
 ActionValue endActionNode(ex1.OpAction act)
          This closes building an action node by setting its type and then adding it to the list.
 ActionValue find(ex1.OpAction a)
          Finds the first action of a specific type in the operation.
 ActionValue getAction(int inx)
          Return the ith action in the list or null if we don't have it.
 int getActionCount()
          For operations return the number of processes/actions that make up this operation
 java.lang.String getActionName(int index)
          For an operation file return the name of the ith action.
 java.util.Collection getAllParms()
          Returns a list of all the parameters.
 java.lang.String getBaseName()
          The basename of the file without the .CROP or .OPRN extension
 java.lang.String getFileName()
          Return the basename and extension of this file.
 java.lang.String getPathName()
          Return the full pathname for this file.
 java.lang.String getPathOnly(java.lang.String dbDir)
          Get the path part of this file rooted at the main weps database directory.
 int getRowsSpanned(int code, char ty)
          This determines how many rows in a detail operations table this file occupies for the indicated code and type, like P24, P32, etc.
 int getSub(ActionValue a)
          This returns the subIndex of this action within the operation.
 java.lang.String getValue(ParamDef p, boolean altUnits)
          Get the value of a specific crop parameter.
 java.lang.String getValueAt(int tab, int col, int sub, boolean altUnits)
          This reads a particular value from an operations record.
 boolean insertProcess(int procNum, int newProc, boolean before, ActionValue av)
          This function inserts a new process before (or after) a given process.
 boolean isModified()
          Return true if any parameter has changed.
 boolean isOutOfOrder()
          Return true if the process sequence is incorrect, set proviously as a result of checking processes.
 boolean isReadOnly()
          Basic test to see if the file can be written.
 void moveLeft(int col)
          Shifts the process one to the left in the process list.
 void moveRight(int col)
          Shifts the process one to the right in the process list.
 boolean saveFile(java.lang.String mcrewCfgDir)
          Save the database file as an XML file specified by the DTD's in mcrewCfgDir
 boolean setValue(ParamDef p, java.lang.String val, boolean altUnits)
          Sets the value of a specific crop parameter.
 boolean setValueAt(int tab, int col, int sub, java.lang.String val, boolean altUnits)
          The matching function to setValueAt() for operations data.
 ActionValue startActionNode()
          This starts off the first action node of an operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WepsDBFile

public WepsDBFile(java.lang.String f,
                  boolean isCrop,
                  DefnFileParser p)
Creates a new instance of WepsDBFile

Parameters:
f - name of file to load
isCrop - true if crop file
p - structure holding all parameter info
Method Detail

isReadOnly

public boolean isReadOnly()
Basic test to see if the file can be written. Read-only files will be displayed in gray in the user interface.

Returns:
true if read-only file, false if file writeable

startActionNode

public ActionValue startActionNode()
This starts off the first action node of an operation.

Returns:
a new ActionValue node

getSub

public int getSub(ActionValue a)
This returns the subIndex of this action within the operation. This occurs if an operation contains the same process/action more than once.

Parameters:
a - the structure to search for
Returns:
the occurance of this specific type of process in the operation (0 is first)

endActionNode

public ActionValue endActionNode(ex1.OpAction act)
This closes building an action node by setting its type and then adding it to the list.

Parameters:
act - type of process this node is to represent

find

public ActionValue find(ex1.OpAction a)
Finds the first action of a specific type in the operation. If there is no action of the requested type than null is returned.

Parameters:
a - type of process to search for
Returns:
an instance of this process type if found

addParm

public boolean addParm(java.lang.String name,
                       java.lang.String val)
Adds a parameter and its value to the list for crops or if this is an operation to the currrent action node being built.

Parameters:
name - parameter name
val - value of the parameter

getRowsSpanned

public int getRowsSpanned(int code,
                          char ty)
This determines how many rows in a detail operations table this file occupies for the indicated code and type, like P24, P32, etc. If an operation has 3 P24 processes and we are checking for 24 and 'P' this will return 3. If the operation has 0 or 1 of the actions then one is returned because we at least display the file name.

Parameters:
code - numeric part of process to search for
ty - charcter (P,G,O) type of process to search for
Returns:
number of rows this process will occupy

getValueAt

public java.lang.String getValueAt(int tab,
                                   int col,
                                   int sub,
                                   boolean altUnits)
This reads a particular value from an operations record.

Parameters:
tab - what process type, corresponds to table index of detail tables
col - what column(parameter) to get
sub - if there are more than 1 process of this type selects which on
altUnits - true if the value should be returned in the alternate units

setValueAt

public boolean setValueAt(int tab,
                          int col,
                          int sub,
                          java.lang.String val,
                          boolean altUnits)
The matching function to setValueAt() for operations data.

Parameters:
tab - what process type, corresponds to table index of detail tables
col - what column(parameter) to get
sub - if there are more than 1 process of this type selects which on
val - string to save
altUnits - true if the value is in alternate units and needs to be converted before storing
Returns:
true if value set ok

getAllParms

public java.util.Collection getAllParms()
Returns a list of all the parameters. Only valid for a crop file because the operations data has a heirarchy.

Returns:
a Collection (ParameterVal) of all parms

getValue

public java.lang.String getValue(ParamDef p,
                                 boolean altUnits)
Get the value of a specific crop parameter. The definition passed in indicates what to search for If altUnits is true then the value is converted before it is returned.

Parameters:
p - Info about parameter
altUnits - true if alternate(english) conversion should be done

setValue

public boolean setValue(ParamDef p,
                        java.lang.String val,
                        boolean altUnits)
Sets the value of a specific crop parameter.

Parameters:
p - the parameter info about what to set
val - the value that is to be saved
altUnits - true if the value is in English units

getActionCount

public int getActionCount()
For operations return the number of processes/actions that make up this operation

Returns:
number of processes in this operation file.

getAction

public ActionValue getAction(int inx)
Return the ith action in the list or null if we don't have it.

Parameters:
inx - the index of the process to get
Returns:
the ActionValue structure of the process or null if the operation does not have process at the requested index

getActionName

public java.lang.String getActionName(int index)
For an operation file return the name of the ith action.

Parameters:
index - what process to return name for
Returns:
name of the process at the index or "--" if nothing there

getFileName

public java.lang.String getFileName()
Return the basename and extension of this file.

Returns:
the base and extension of the file

getPathName

public java.lang.String getPathName()
Return the full pathname for this file.

Returns:
full filename of this file.

getPathOnly

public java.lang.String getPathOnly(java.lang.String dbDir)
Get the path part of this file rooted at the main weps database directory.

Parameters:
dbDir - directory where crop or operation files are located
Returns:
path part of name relative to dbdir

getBaseName

public java.lang.String getBaseName()
The basename of the file without the .CROP or .OPRN extension

Returns:
the basename without the .CROP or .OPRN extension

isModified

public boolean isModified()
Return true if any parameter has changed.

Returns:
true if any part of this file has changed.

saveFile

public boolean saveFile(java.lang.String mcrewCfgDir)
Save the database file as an XML file specified by the DTD's in mcrewCfgDir

Parameters:
mcrewCfgDir - directory of mcrew config files
Returns:
true if file saved ok

createClone

public void createClone(java.lang.String mcrewCfgDir,
                        WepsDBFile wf,
                        boolean stripActions)
Create a copy of this file.

Parameters:
mcrewCfgDir - directory where the mcrew config xml and dtd files are
wf - base file structure where data comes from
stripActions - true to remove all actions

changeName

public void changeName(java.lang.String mcrewCfgDir,
                       java.lang.String newName)
Change the name of an existing file.

Parameters:
mcrewCfgDir - directory where mcrew config files are located
newName - new name for file

deleteFile

public boolean deleteFile()
Get rid of this file

Returns:
true if the file was deleted ok

changeProcess

public boolean changeProcess(int procNum,
                             int newProc,
                             ActionValue av)
This function changes a process to a different type.

Parameters:
procNum - process index in operation to change
newProc - index of new process
av - template to use to fill in parm values or null

insertProcess

public boolean insertProcess(int procNum,
                             int newProc,
                             boolean before,
                             ActionValue av)
This function inserts a new process before (or after) a given process.

Parameters:
procNum - index of current process in this operation
newProc - type of new operation to insert
before - true if this should be inserted before, false for after
av - set of parameters to use as template or null

deleteProcess

public boolean deleteProcess(int index)
This function deletes a process from an operation.

Parameters:
index - index in list of processes that is to be deleted
Returns:
true if process could be deleted, false otherwise

checkProcesses

public boolean checkProcesses(boolean displayMessage)
This function determines if the WEPS operations process and group ordering is valid.

Parameters:
displayMessage - true if a dialog is to be displayed
Returns:
true of process order is ok, false if things need fixing

moveRight

public void moveRight(int col)
Shifts the process one to the right in the process list.

Parameters:
col - column that is to be logically shifted right

moveLeft

public void moveLeft(int col)
Shifts the process one to the left in the process list.

Parameters:
col - column that is to be shifted logically left

isOutOfOrder

public boolean isOutOfOrder()
Return true if the process sequence is incorrect, set proviously as a result of checking processes.

Returns:
true if process order is not correct