edu.sdsc.inca.depot.persistent
Class PersistentObject

java.lang.Object
  extended by edu.sdsc.inca.depot.persistent.PersistentObject
Direct Known Subclasses:
AcceptedOutput, Arg, ArgSignature, ComparisonResult, InstanceInfo, Limits, Notification, Report, RunInfo, Schedule, Series, SeriesConfig, Suite

public abstract class PersistentObject
extends java.lang.Object

This is an abstract base class that defines common behavior for all objects that the Depot stores in the database.

Author:
jhayes

Field Summary
static java.lang.String DB_EMPTY_STRING
          Value used to store null/empty strings in the database.
protected static org.apache.log4j.Logger logger
           
static int MAX_DB_LONG_STRING_LENGTH
           
static int MAX_DB_STRING_LENGTH
          Maximum length for string DB fields.
 
Constructor Summary
PersistentObject()
           
 
Method Summary
abstract  PersistentObject fromBean(org.apache.xmlbeans.XmlObject o)
          Copies information from an Inca schema XmlBean object so that this object contains equivalent information.
abstract  org.apache.xmlbeans.XmlObject toBean()
          Returns a Inca schema XmlBean object that contains information equivalent to this object.
 java.lang.String toXml()
          Returns XML that represents the information in this object.
 java.lang.String truncate(java.lang.String s, int max, java.lang.String label)
          A convenience function for implementations that checks the length of a string and truncates with a warning if it's too long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

MAX_DB_STRING_LENGTH

public static final int MAX_DB_STRING_LENGTH
Maximum length for string DB fields. MAX_STRING_LENGTH applies to those fields with no length attribute in the HBM files; MAX_LONG_STRING_LENGTH is the minimum upper bound across underlying DBs for those with a length attribute. Unfortunately, there seems to be no programmatic way to know one from the other, so implementing classes will simply need to "know" which string fields have been given the larger length bound.

See Also:
Constant Field Values

MAX_DB_LONG_STRING_LENGTH

public static final int MAX_DB_LONG_STRING_LENGTH
See Also:
Constant Field Values

DB_EMPTY_STRING

public static final java.lang.String DB_EMPTY_STRING
Value used to store null/empty strings in the database. We avoid storing null because it complicates constructing select statements (must is "is null" rather than "=="). We avoid "" because of Oracle bizarreness--it translates "" into null when storing records in a table. Ideally, we'd like to limit use of this hack to DAO.java, since all DB storage and retrieval goes through the class. At the moment, though, each persistent object class tests incoming values in each String setter method and overrides null and "" with this value. Trying to replace string values before and after DB use seems to run afoul of Hibernates auto update feature.

See Also:
Constant Field Values
Constructor Detail

PersistentObject

public PersistentObject()
Method Detail

fromBean

public abstract PersistentObject fromBean(org.apache.xmlbeans.XmlObject o)
Copies information from an Inca schema XmlBean object so that this object contains equivalent information.

Parameters:
o - the XmlBean object to copy
Returns:
this, for convenience

toBean

public abstract org.apache.xmlbeans.XmlObject toBean()
Returns a Inca schema XmlBean object that contains information equivalent to this object.

Returns:
an XmlBean object that contains equivalent information

toXml

public java.lang.String toXml()
Returns XML that represents the information in this object.


truncate

public java.lang.String truncate(java.lang.String s,
                                 int max,
                                 java.lang.String label)
A convenience function for implementations that checks the length of a string and truncates with a warning if it's too long.

Parameters:
s - the string to check
max - the maximum length
label - included in the warning message if truncation occurs
Returns:
s, truncated if necessary