added comments to fields, added extendsMapping
for dbmapping inheritance
This commit is contained in:
parent
c28f67f5dc
commit
9952f9b161
1 changed files with 28 additions and 4 deletions
|
@ -20,12 +20,17 @@ import com.workingdogs.village.*;
|
||||||
|
|
||||||
public class DbMapping implements Updatable {
|
public class DbMapping implements Updatable {
|
||||||
|
|
||||||
|
// DbMappings belong to an application
|
||||||
Application app;
|
Application app;
|
||||||
|
// prototype name of this mapping
|
||||||
String typename;
|
String typename;
|
||||||
|
|
||||||
|
// properties from where the mapping is read
|
||||||
SystemProperties props;
|
SystemProperties props;
|
||||||
|
|
||||||
|
// name of data source to which this mapping writes
|
||||||
DbSource source;
|
DbSource source;
|
||||||
|
// name of db table
|
||||||
String table;
|
String table;
|
||||||
|
|
||||||
ParentInfo[] parent; // list of properties to try for parent
|
ParentInfo[] parent; // list of properties to try for parent
|
||||||
|
@ -40,22 +45,35 @@ public class DbMapping implements Updatable {
|
||||||
// Map of db columns to Relations objects
|
// Map of db columns to Relations objects
|
||||||
public Hashtable db2prop;
|
public Hashtable db2prop;
|
||||||
|
|
||||||
|
// db field used as primary key
|
||||||
String idField;
|
String idField;
|
||||||
|
// db field used as object name
|
||||||
String nameField;
|
String nameField;
|
||||||
|
|
||||||
|
// name of parent prototype, if any
|
||||||
String extendsProto;
|
String extendsProto;
|
||||||
|
// dbmapping of parent prototype, if any
|
||||||
|
DbMapping extendsMapping;
|
||||||
|
|
||||||
// descriptor for key generation method
|
// descriptor for key generation method
|
||||||
private String idgen;
|
private String idgen;
|
||||||
// remember last key generated for this table
|
// remember last key generated for this table
|
||||||
public long lastID;
|
public long lastID;
|
||||||
|
|
||||||
|
// the (village) schema of the database table
|
||||||
Schema schema = null;
|
Schema schema = null;
|
||||||
|
// the (village) keydef of the db table
|
||||||
KeyDef keydef = null;
|
KeyDef keydef = null;
|
||||||
|
|
||||||
|
// timestamp of last modification of the mapping (type.properties)
|
||||||
private long lastTypeChange;
|
private long lastTypeChange;
|
||||||
|
// timestamp of last modification of an object of this type
|
||||||
public long lastDataChange;
|
public long lastDataChange;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an empty DbMapping
|
||||||
|
*/
|
||||||
public DbMapping () {
|
public DbMapping () {
|
||||||
|
|
||||||
prop2db = new Hashtable ();
|
prop2db = new Hashtable ();
|
||||||
|
@ -67,6 +85,9 @@ public class DbMapping implements Updatable {
|
||||||
idField = "id";
|
idField = "id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DbMapping from a type.properties property file
|
||||||
|
*/
|
||||||
public DbMapping (Application app, String typename, SystemProperties props) {
|
public DbMapping (Application app, String typename, SystemProperties props) {
|
||||||
|
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
@ -101,9 +122,12 @@ public class DbMapping implements Updatable {
|
||||||
*/
|
*/
|
||||||
public synchronized void update () {
|
public synchronized void update () {
|
||||||
|
|
||||||
this.table = props.getProperty ("_tablename");
|
table = props.getProperty ("_tablename");
|
||||||
this.idgen = props.getProperty ("_idgen");
|
idgen = props.getProperty ("_idgen");
|
||||||
this.extendsProto = props.getProperty ("_extends");
|
// see if this prototype extends (inherits from) any other prototype
|
||||||
|
extendsProto = props.getProperty ("_extends");
|
||||||
|
if (extendsProto != null)
|
||||||
|
extendsMapping = app.getDbMapping (extendsProto);
|
||||||
|
|
||||||
String sourceName = props.getProperty ("_datasource");
|
String sourceName = props.getProperty ("_datasource");
|
||||||
if (sourceName != null) {
|
if (sourceName != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue