Foundation for new type mapping support in DbMapping class.

This commit is contained in:
hns 2002-02-26 16:56:13 +00:00
parent 48205c183e
commit 1ef841f9c0
2 changed files with 19 additions and 14 deletions

View file

@ -25,6 +25,8 @@ public class DbMapping implements Updatable {
// prototype name of this mapping
String typename;
int version;
// properties from where the mapping is read
SystemProperties props;
@ -83,7 +85,6 @@ public class DbMapping implements Updatable {
// timestamp of last modification of an object of this type
long lastDataChange;
/**
* Create an empty DbMapping
*/
@ -137,7 +138,14 @@ public class DbMapping implements Updatable {
*/
public synchronized void update () {
table = props.getProperty ("_tablename");
// determin file format version of type.properties file
String versionInfo = props.getProperty ("_version");
if ("1.2".equals (versionInfo))
version = 1;
else
version = 0;
table = props.getProperty (version == 0 ? "_tablename" : "_table");
idgen = props.getProperty ("_idgen");
// see if there is a field which specifies the prototype of objects, if different prototypes
// can be stored in this table
@ -145,7 +153,7 @@ public class DbMapping implements Updatable {
// see if this prototype extends (inherits from) any other prototype
extendsProto = props.getProperty ("_extends");
sourceName = props.getProperty ("_datasource");
sourceName = props.getProperty (version == 0 ? "_datasource" : "_db");
if (sourceName != null) {
source = app.getDbSource (sourceName);
if (source == null) {
@ -205,14 +213,14 @@ public class DbMapping implements Updatable {
String propName = (String) e.nextElement ();
try {
// ignore internal properties (starting with "_") and sub-options (containing a ".")
if (!propName.startsWith ("_") && propName.indexOf (".") < 0) {
String dbField = props.getProperty (propName);
// check if a relation for this propery already exists. If so, reuse it
Relation rel = propertyToRelation (propName);
if (rel == null)
rel = new Relation (dbField, propName, this, props);
else
rel.update (dbField, props);
rel.update (dbField, props, version);
p2d.put (propName, rel);
if (rel.columnName != null &&
(rel.reftype == Relation.PRIMITIVE ||
@ -234,9 +242,8 @@ public class DbMapping implements Updatable {
// check if subnode relation already exists. If so, reuse it
if (subnodesRel == null)
subnodesRel = new Relation (subnodeMapping, "_subnodes", this, props);
else
subnodesRel.update (subnodeMapping, props);
subnodesRel.update (subnodeMapping, props, version);
} catch (Exception x) {
app.logEvent ("Error reading _subnodes relation for "+typename+": "+x.getMessage ());
// subnodesRel = null;
@ -250,15 +257,15 @@ public class DbMapping implements Updatable {
// check if property relation already exists. If so, reuse it
if (propertiesRel == null)
propertiesRel = new Relation (propertiesMapping, "_properties", this, props);
else
propertiesRel.update (propertiesMapping, props);
propertiesRel.update (propertiesMapping, props, version);
// take over groupby flag from subnodes, if properties are subnodes
if (propertiesRel.subnodesAreProperties && subnodesRel != null) {
propertiesRel.groupby = subnodesRel.groupby;
propertiesRel.constraints = subnodesRel.constraints;
propertiesRel.filter = subnodesRel.filter;
}
} catch (Exception x) {
app.logEvent ("Error reading _properties relation for "+typename+": "+x.getMessage ());
// propertiesRel = null;

View file

@ -86,11 +86,9 @@ public class Relation {
this.ownType = ownType;
this.propName = propName;
otherType = null;
update (desc, props);
}
public void update (String desc, Properties props) {
public void update (String desc, Properties props, int version) {
boolean mountpoint = false;
Vector cnst = null;