|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Dictionary<K,V> java.util.Hashtable org.paneris.util.ExtendedHash org.paneris.jal.model.DDRecord
public class DDRecord
A DDRecord holds data and metadata for a single record from the database it is passed into the webcontext and introspected by the template.
Note that a DDRecord represents one record in a particular table. It will always hold the metadata (as defined in the datadictionary tables in the DB).It may also contain values for each field in the record. We say that it is "empty" if it does not contain such values.
Field Summary | |
---|---|
protected DBConnectionManager |
connMgr
|
protected java.lang.String |
database
|
DataCache |
dataCache
|
protected static boolean |
debug
|
TableMetaData |
metaData
|
Constructor Summary | |
---|---|
DDRecord(java.lang.String db,
java.lang.Integer tn)
Constructor to build an empty DDRecord given an Integer denoting the table number in the DataDictionary. |
|
DDRecord(java.lang.String db,
java.lang.Integer tn,
java.lang.Integer record)
Constructor to build a DDRecord given an integer denoting the table and an Integer indicating the record to read into this DDRecord |
|
DDRecord(java.lang.String db,
java.lang.Integer tn,
java.sql.ResultSet rs)
Constructor to build a DDRecord given an integer denoting the table and a java.sql.resultSet to find the values from. |
|
DDRecord(java.lang.String db,
java.lang.String tn)
Constructor to build an empty DDRecord given a String describing the table name. |
|
DDRecord(java.lang.String db,
java.lang.String tn,
java.lang.Integer record)
Constructor to build a DDRecord given an integer denoting the table and an Integer indicating the record to read into this DDRecord |
|
DDRecord(java.lang.String db,
java.lang.String tn,
java.sql.ResultSet rs)
Constructor to build a DDRecord given a string describing the table and a java.sql.resultSet to find the values from |
Method Summary | |
---|---|
void |
appendFieldValue(java.lang.String field,
java.lang.String v)
append a value to the value of this field |
void |
delete()
Deletes this record from the database |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the specified key is mapped in this ExtendedHash. |
RecordSet |
getChildren(java.lang.String table,
java.lang.String field)
|
DDField |
getField(java.lang.String field)
Returns the DDField for a named field |
java.lang.String |
getFieldValue(java.lang.String field)
Get the value of the given field as a String |
java.util.Vector |
getLinksToThis(boolean full)
Get a list of records which link to this record. |
java.util.Vector |
getLinksToThis(boolean full,
boolean force)
|
TableMetaData |
getMetaData()
Get the metadata for the table that this DDRecord is in |
RecordSet |
getOrderedChildren(java.lang.String table,
java.lang.String field,
java.lang.String orderField)
gets an ordered record set of child data for this record for a given table |
java.util.Vector |
getProblems()
Get any validation problems with this record |
protected java.sql.ResultSet |
getResultSet(java.lang.Integer record,
java.sql.Statement s)
Gets a ResultSet representing the record indicated by record |
protected void |
init(java.sql.ResultSet rs)
Sets the values of this DDRecord from a ResultsSet (a record in the DB) |
boolean |
isDuplicated(DDField field,
java.lang.String value)
Find out if any other record in the database has the relevant field set to this value. |
void |
setFieldValue(java.lang.String field,
java.lang.Object value)
Set the value of the given field from a Object |
void |
setFieldValue(java.lang.String field,
java.lang.String value)
Set the value of the given field from a String |
void |
setFromDefaults()
fill in the values for this DDRecord From the defaults set in the DataDictionary |
void |
setFromForm(org.webmacro.servlet.WebContext context)
fill in the values for this DDRecord by reading them in from a CGI Form - The idea is that this DDRecord will not have any values set, just the metaData and DDField structure. |
void |
setFromForm(org.webmacro.servlet.WebContext context,
java.lang.String postfix)
|
void |
setFromForm(org.webmacro.servlet.WebContext context,
java.lang.String postfix,
boolean force)
|
void |
write()
Write this record to the database. |
void |
write(boolean forceid)
Write this record to the database. |
Methods inherited from class org.paneris.util.ExtendedHash |
---|
clear, elements, joinKeys, keys, put, remove |
Methods inherited from class java.util.Hashtable |
---|
clone, contains, containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keySet, putAll, rehash, size, toString, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public TableMetaData metaData
protected static final boolean debug
public DataCache dataCache
protected DBConnectionManager connMgr
protected java.lang.String database
Constructor Detail |
---|
public DDRecord(java.lang.String db, java.lang.String tn) throws java.lang.Exception
db
- a String indicating which database to use. This
is used to look up the full (JDBC) database detailstn
- the name of the table that this DDRecord is from
can
- throw exceptions if we can't connect to the db
java.lang.Exception
public DDRecord(java.lang.String db, java.lang.Integer tn) throws java.lang.Exception
db
- a String indicating which database to use. This
is used to look up the full (JDBC) database detailstn
- the number of the table that this DDRecord is from
as defined by the DataDictionaryTables table
can
- throw exceptions if we can't connect to the db
java.lang.Exception
public DDRecord(java.lang.String db, java.lang.String tn, java.sql.ResultSet rs) throws java.lang.Exception
db
- a String indicating which database to use. This
is used to look up the full (JDBC) database detailstn
- the name of the table that this DDRecord is fromrs
- a record used to fill in the values of this DDRecord
can
- throw exceptions if we can't connect to the db
java.lang.Exception
public DDRecord(java.lang.String db, java.lang.Integer tn, java.sql.ResultSet rs) throws java.lang.Exception
db
- a String indicating which database to use. This
is used to look up the full (JDBC) database detailstn
- the number of the table that this DDRecord is from
as defined by the DataDictionaryTables tablers
- a record used to fill in the values of this DDRecord
can
- throw exceptions if we can't connect to the db
java.lang.Exception
public DDRecord(java.lang.String db, java.lang.String tn, java.lang.Integer record) throws java.lang.Exception
db
- a String indicating which database to use. This
is used to look up the full (JDBC) database detailstn
- the name of the table that this DDRecord is fromrecord
- the id of a record used to fill in the values of
this DDRecord
can
- throw exceptions if we can't connect to the db
java.lang.Exception
public DDRecord(java.lang.String db, java.lang.Integer tn, java.lang.Integer record) throws java.lang.Exception
db
- a String indicating which database to use. This
is used to look up the full (JDBC) database detailstn
- the number of the table that this DDRecord is from
as defined by the DataDictionaryTables tablerecord
- the id of a record used to fill in the values of
this DDRecord
java.lang.Exception
- if we can't connect to the dbMethod Detail |
---|
protected void init(java.sql.ResultSet rs) throws java.lang.Exception
rs
- the ResultSet to use in setting the values of the DDRecord
java.lang.Exception
- if cannot connect to the DB or column not foundprotected java.sql.ResultSet getResultSet(java.lang.Integer record, java.sql.Statement s) throws java.lang.Exception
record
- the id of a records
- a Statement used to execute a query
can
- throw exceptions if we can't connect to the db
java.lang.Exception
public TableMetaData getMetaData()
public java.lang.String getFieldValue(java.lang.String field)
field
- the name of the field
public void setFieldValue(java.lang.String field, java.lang.String value)
field
- the name of the fieldvalue
- the value we wish to set the field topublic void appendFieldValue(java.lang.String field, java.lang.String v)
public DDField getField(java.lang.String field)
field
- the name of the field
public void setFieldValue(java.lang.String field, java.lang.Object value)
field
- the name of the fieldvalue
- the value we wish to set the field topublic java.util.Vector getProblems() throws java.lang.Exception
Database
- problems only?
java.lang.Exception
public void setFromForm(org.webmacro.servlet.WebContext context) throws java.lang.Exception
It may, however, have the id set. If an id is read in from the form then this will override the current value. If there is no id in the form then the current value is left.
If postfix is set, then it is appended to the name of the to read the value from the form. For example, normally the field "myfield" will be set to the value of the form field "myfield". If postfix is set to "_default" then the field will be set from the form field "myfield_default".
context
- a WebContext which contains the Form
object from which we read the valuespostfix
- A string to append to the fieldnames before
getting the values from the formforce
- Set fields to null if input is null
useful to set this to false when not all fields are on the form
watch out for checkboxes which return null when unchecked
Database
- problems only?
java.lang.Exception
public void setFromForm(org.webmacro.servlet.WebContext context, java.lang.String postfix) throws java.lang.Exception
java.lang.Exception
public void setFromForm(org.webmacro.servlet.WebContext context, java.lang.String postfix, boolean force) throws java.lang.Exception
java.lang.Exception
public void setFromDefaults() throws java.lang.Exception
Database
- problems only?
java.lang.Exception
public void write() throws java.lang.Exception
Write this record to the database.
If this record has a autorandom field, and we are 'inserting', the autorandom field will be set to (surprise) a random number. This is then used by the reread() method to reload the record from the database. This means the the id field will be set, and can be used in your program.
Database
- problems only?
java.lang.Exception
public void write(boolean forceid) throws java.lang.Exception
Write this record to the database.
The id of the record should be 0 (or forceid should be true) if you wish to create a new record. If this is not the case then we update the record that already exists (and we'll get an error if it doesn't!)
If this record has a autorandom field, and we are 'inserting', the autorandom field will be set to (surprise) a random number. This is then used by the reread() method to reload the record from the database. This means the the id field will be set, and can be used in your program.
forceid
- Write a new record into the database, even if one
already exists (i.e. don't just update the existing record)
Database
- problems only?
java.lang.Exception
public void delete() throws java.lang.Exception
Database
- problems only?
java.lang.Exception
public boolean isDuplicated(DDField field, java.lang.String value) throws java.lang.Exception
It is assumed that the id of this DDField is already set to a value which we are going to use to insert this record into the DB under (which could be 0)
field
- the field we want to be uniquevalue
- the value we don't want to already exist for this field
Database
- problems only?
java.lang.Exception
public java.util.Vector getLinksToThis(boolean full) throws java.lang.Exception
full
- if true then the return Vector will have one entry
for each record linking to this one. Otherwise, the
vector will only contain one (representative, i.e. only
containing metadata) DDRecord for each table/field
combination which links to this recrodforce
- if true, then the eturn Vector will have an entry even if
no data in the child table links to this record
If
- the id field is not set, we cannot find out
if any records link to us, so we get an exception
java.lang.Exception
public java.util.Vector getLinksToThis(boolean full, boolean force) throws java.lang.Exception
java.lang.Exception
public RecordSet getChildren(java.lang.String table, java.lang.String field) throws java.lang.Exception
java.lang.Exception
public RecordSet getOrderedChildren(java.lang.String table, java.lang.String field, java.lang.String orderField) throws java.lang.Exception
java.lang.Exception
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
get
in class java.util.Hashtable
key
- a key in the DDRecord.
if the key is not mapped to any value in
this DDRecord, as that means the field name is wrong.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |