Foundation for new type mapping support in DbMapping class.
This commit is contained in:
parent
48205c183e
commit
1ef841f9c0
2 changed files with 19 additions and 14 deletions
|
@ -25,6 +25,8 @@ public class DbMapping implements Updatable {
|
||||||
// prototype name of this mapping
|
// prototype name of this mapping
|
||||||
String typename;
|
String typename;
|
||||||
|
|
||||||
|
int version;
|
||||||
|
|
||||||
// properties from where the mapping is read
|
// properties from where the mapping is read
|
||||||
SystemProperties props;
|
SystemProperties props;
|
||||||
|
|
||||||
|
@ -83,7 +85,6 @@ public class DbMapping implements Updatable {
|
||||||
// timestamp of last modification of an object of this type
|
// timestamp of last modification of an object of this type
|
||||||
long lastDataChange;
|
long lastDataChange;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an empty DbMapping
|
* Create an empty DbMapping
|
||||||
*/
|
*/
|
||||||
|
@ -137,7 +138,14 @@ public class DbMapping implements Updatable {
|
||||||
*/
|
*/
|
||||||
public synchronized void update () {
|
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");
|
idgen = props.getProperty ("_idgen");
|
||||||
// see if there is a field which specifies the prototype of objects, if different prototypes
|
// see if there is a field which specifies the prototype of objects, if different prototypes
|
||||||
// can be stored in this table
|
// 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
|
// see if this prototype extends (inherits from) any other prototype
|
||||||
extendsProto = props.getProperty ("_extends");
|
extendsProto = props.getProperty ("_extends");
|
||||||
|
|
||||||
sourceName = props.getProperty ("_datasource");
|
sourceName = props.getProperty (version == 0 ? "_datasource" : "_db");
|
||||||
if (sourceName != null) {
|
if (sourceName != null) {
|
||||||
source = app.getDbSource (sourceName);
|
source = app.getDbSource (sourceName);
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
|
@ -205,14 +213,14 @@ public class DbMapping implements Updatable {
|
||||||
String propName = (String) e.nextElement ();
|
String propName = (String) e.nextElement ();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// ignore internal properties (starting with "_") and sub-options (containing a ".")
|
||||||
if (!propName.startsWith ("_") && propName.indexOf (".") < 0) {
|
if (!propName.startsWith ("_") && propName.indexOf (".") < 0) {
|
||||||
String dbField = props.getProperty (propName);
|
String dbField = props.getProperty (propName);
|
||||||
// check if a relation for this propery already exists. If so, reuse it
|
// check if a relation for this propery already exists. If so, reuse it
|
||||||
Relation rel = propertyToRelation (propName);
|
Relation rel = propertyToRelation (propName);
|
||||||
if (rel == null)
|
if (rel == null)
|
||||||
rel = new Relation (dbField, propName, this, props);
|
rel = new Relation (dbField, propName, this, props);
|
||||||
else
|
rel.update (dbField, props, version);
|
||||||
rel.update (dbField, props);
|
|
||||||
p2d.put (propName, rel);
|
p2d.put (propName, rel);
|
||||||
if (rel.columnName != null &&
|
if (rel.columnName != null &&
|
||||||
(rel.reftype == Relation.PRIMITIVE ||
|
(rel.reftype == Relation.PRIMITIVE ||
|
||||||
|
@ -234,9 +242,8 @@ public class DbMapping implements Updatable {
|
||||||
// check if subnode relation already exists. If so, reuse it
|
// check if subnode relation already exists. If so, reuse it
|
||||||
if (subnodesRel == null)
|
if (subnodesRel == null)
|
||||||
subnodesRel = new Relation (subnodeMapping, "_subnodes", this, props);
|
subnodesRel = new Relation (subnodeMapping, "_subnodes", this, props);
|
||||||
else
|
subnodesRel.update (subnodeMapping, props, version);
|
||||||
subnodesRel.update (subnodeMapping, props);
|
|
||||||
|
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
app.logEvent ("Error reading _subnodes relation for "+typename+": "+x.getMessage ());
|
app.logEvent ("Error reading _subnodes relation for "+typename+": "+x.getMessage ());
|
||||||
// subnodesRel = null;
|
// subnodesRel = null;
|
||||||
|
@ -250,15 +257,15 @@ public class DbMapping implements Updatable {
|
||||||
// check if property relation already exists. If so, reuse it
|
// check if property relation already exists. If so, reuse it
|
||||||
if (propertiesRel == null)
|
if (propertiesRel == null)
|
||||||
propertiesRel = new Relation (propertiesMapping, "_properties", this, props);
|
propertiesRel = new Relation (propertiesMapping, "_properties", this, props);
|
||||||
else
|
propertiesRel.update (propertiesMapping, props, version);
|
||||||
propertiesRel.update (propertiesMapping, props);
|
|
||||||
// take over groupby flag from subnodes, if properties are subnodes
|
// take over groupby flag from subnodes, if properties are subnodes
|
||||||
if (propertiesRel.subnodesAreProperties && subnodesRel != null) {
|
if (propertiesRel.subnodesAreProperties && subnodesRel != null) {
|
||||||
propertiesRel.groupby = subnodesRel.groupby;
|
propertiesRel.groupby = subnodesRel.groupby;
|
||||||
propertiesRel.constraints = subnodesRel.constraints;
|
propertiesRel.constraints = subnodesRel.constraints;
|
||||||
propertiesRel.filter = subnodesRel.filter;
|
propertiesRel.filter = subnodesRel.filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
app.logEvent ("Error reading _properties relation for "+typename+": "+x.getMessage ());
|
app.logEvent ("Error reading _properties relation for "+typename+": "+x.getMessage ());
|
||||||
// propertiesRel = null;
|
// propertiesRel = null;
|
||||||
|
|
|
@ -86,11 +86,9 @@ public class Relation {
|
||||||
this.ownType = ownType;
|
this.ownType = ownType;
|
||||||
this.propName = propName;
|
this.propName = propName;
|
||||||
otherType = null;
|
otherType = null;
|
||||||
|
|
||||||
update (desc, props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update (String desc, Properties props) {
|
public void update (String desc, Properties props, int version) {
|
||||||
|
|
||||||
boolean mountpoint = false;
|
boolean mountpoint = false;
|
||||||
Vector cnst = null;
|
Vector cnst = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue