com.sri.emo.dbobj
Class AbstractMatrixHandler

java.lang.Object
  extended by com.sri.emo.dbobj.AbstractAttributeHandler
      extended by com.sri.emo.dbobj.AbstractMatrixHandler
All Implemented Interfaces:
IPartHandler, Cloneable

public abstract class AbstractMatrixHandler
extends AbstractAttributeHandler

base class for custom handler for a matrix

Author:
Larry Hamel

Field Summary
static String CELL_ID
           
static String NAME
           
static String PARAM_PREFIX
           
static String ROW
          XML tag names
static String SM_VAR_ID
           
static String SM_VAR_NAME
           
 
Fields inherited from class com.sri.emo.dbobj.AbstractAttributeHandler
OBSERVABLE_ID_XMLTAG
 
Fields inherited from interface com.sri.emo.dbobj.IPartHandler
FULL_XML, NO_PARAMETERS
 
Constructor Summary
AbstractMatrixHandler(String attribName, Class editorClass, String viewState, String promptEditState)
           
 
Method Summary
static void clearMatrix(HashMap columnHash)
          note: this call is done during 'validate' (which any reader can do), so it uses superuser priv.
 void clone(Attribute existing, Attribute clone)
          clone data from existing to clone
 HashMap collateMatrix(List celllist)
          from list of cells, determine lists of columns
static Attribute createAttrib(Node node, String type)
          Important: we use the ID of the owner of the node in order to add an attribute here.
protected abstract  MatrixCell[] createColumn(Attribute attrib, String colId, Object[] columns, Object[] rows)
           
 void delete(Attribute attribute)
          Delete a part.
 Attribute getAttribute(Node node)
          find single attribute, warning if > 1 are found.
protected abstract  String getColumnID(Object columnObject)
           
protected abstract  Object[] getColumnObjects(Node node)
           
 String[] getInsertStatements(AbstractNodeExportSupport treeExporter, DBObject obj)
           
 MatrixCell[][] getMatrix(Node matrixOwnerNode)
          get matrix, creating it from scratch if necessary
protected  Node getOrigOV(Node[] ovs, Map allNodesByXML_ID)
           
protected  Comparator getRowComparator(Node node)
          ASSUMES that rows are nodes.
protected abstract  String getRowID(Object rowObject)
           
protected abstract  Object[] getRowObjects(Node node)
           
protected static Node getSMV_fromXML(String smvID, Map allNodesByXML_ID, org.dom4j.Element elem, ControllerRequest request)
           
 boolean isNeededInFullXML()
          used especially with matrix items that need default values if not set
protected  void sortMatrixRows(HashMap columnHash, Comparator rowCompare)
           
protected  void validateMatrix(HashMap colHashInNeedOfValidation, Attribute attrib, Object[] columns, Object[] rowObjects)
          note: this call is done as 'validate' (which any reader can do), so it uses superuser priv.
 
Methods inherited from class com.sri.emo.dbobj.AbstractAttributeHandler
addIDs, clone, copyParams, getAttribName, getEditTransition, getLogger, getParentAttrib, getViewComment, getViewTransition, saveInput, setParentAttrib, validate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sri.emo.dbobj.IPartHandler
addXML, parseXML
 

Field Detail

ROW

public static final String ROW
XML tag names

See Also:
Constant Field Values

NAME

public static final String NAME
See Also:
Constant Field Values

SM_VAR_ID

public static final String SM_VAR_ID
See Also:
Constant Field Values

SM_VAR_NAME

public static final String SM_VAR_NAME
See Also:
Constant Field Values

CELL_ID

public static final String CELL_ID
See Also:
Constant Field Values

PARAM_PREFIX

public static final String PARAM_PREFIX
See Also:
Constant Field Values
Constructor Detail

AbstractMatrixHandler

public AbstractMatrixHandler(String attribName,
                             Class editorClass,
                             String viewState,
                             String promptEditState)
Method Detail

getColumnID

protected abstract String getColumnID(Object columnObject)
                               throws DBException
Throws:
DBException

getRowID

protected abstract String getRowID(Object rowObject)
                            throws DBException
Throws:
DBException

getRowObjects

protected abstract Object[] getRowObjects(Node node)
                                   throws DBException
Throws:
DBException

getColumnObjects

protected abstract Object[] getColumnObjects(Node node)
                                      throws DBException
Throws:
DBException

getMatrix

public MatrixCell[][] getMatrix(Node matrixOwnerNode)
                         throws DBException
get matrix, creating it from scratch if necessary

Parameters:
matrixOwnerNode - node which owns matrix attribute
Throws:
DBException

createColumn

protected abstract MatrixCell[] createColumn(Attribute attrib,
                                             String colId,
                                             Object[] columns,
                                             Object[] rows)
                                      throws DBException
Throws:
DBException

sortMatrixRows

protected void sortMatrixRows(HashMap columnHash,
                              Comparator rowCompare)

getAttribute

public Attribute getAttribute(Node node)
                       throws DBException
find single attribute, warning if > 1 are found.

Returns:
attribute found, or null
Throws:
DBException

clearMatrix

public static void clearMatrix(HashMap columnHash)
                        throws DBException
note: this call is done during 'validate' (which any reader can do), so it uses superuser priv.

Throws:
DBException

getRowComparator

protected Comparator getRowComparator(Node node)
                               throws DBException
ASSUMES that rows are nodes. override if this isn't true!

Throws:
DBException

validateMatrix

protected void validateMatrix(HashMap colHashInNeedOfValidation,
                              Attribute attrib,
                              Object[] columns,
                              Object[] rowObjects)
                       throws DBException
note: this call is done as 'validate' (which any reader can do), so it uses superuser priv.

Parameters:
colHashInNeedOfValidation - hash of all columns in matrix now--may be incomplete, or have items that are obsolete
columns - canonical list of columns
rowObjects - canonical list of rows
Throws:
DBException

collateMatrix

public HashMap collateMatrix(List celllist)
                      throws DBException
from list of cells, determine lists of columns

Throws:
DBException

clone

public void clone(Attribute existing,
                  Attribute clone)
           throws DBException
clone data from existing to clone

Parameters:
existing - The source attribute.
clone - The target Attribute.
Throws:
DBException - upon database error.

delete

public void delete(Attribute attribute)
            throws DBException
Description copied from interface: IPartHandler
Delete a part.

Parameters:
attribute - Attribute the attribute to delete.
Throws:
DBException - upon database error.

getSMV_fromXML

protected static Node getSMV_fromXML(String smvID,
                                     Map allNodesByXML_ID,
                                     org.dom4j.Element elem,
                                     ControllerRequest request)
                              throws DBException
Throws:
DBException - if smv not found w/i map, or w/i system if external IDs are allowed

getOrigOV

protected Node getOrigOV(Node[] ovs,
                         Map allNodesByXML_ID)
                  throws DBException
Throws:
DBException

createAttrib

public static Attribute createAttrib(Node node,
                                     String type)
                              throws DBException
Important: we use the ID of the owner of the node in order to add an attribute here. Attributes are created on-the-fly for the design matrix and scoring matrix, whenever someone views or edits for the first time before saving. Therefore, the viewer may not have the correct rights, but the owner of the node (the measurement model) does have these rights.

Throws:
DBException

isNeededInFullXML

public boolean isNeededInFullXML()
Description copied from class: AbstractAttributeHandler
used especially with matrix items that need default values if not set

Specified by:
isNeededInFullXML in interface IPartHandler
Overrides:
isNeededInFullXML in class AbstractAttributeHandler
Returns:
true if this attribute should be included when an XML request is made for 'FULL_XML'

getInsertStatements

public String[] getInsertStatements(AbstractNodeExportSupport treeExporter,
                                    DBObject obj)
                             throws DBException
Returns:
an array of SQL Insert statements that are equivalent to the contents of this attribute; can be empty but never null
Throws:
DBException


Copyright © 2004-2006 Codeguild, Inc.. All Rights Reserved.