diff --git a/src/helma/objectmodel/DbMapping.java b/src/helma/objectmodel/DbMapping.java index d63d053d..61d29157 100644 --- a/src/helma/objectmodel/DbMapping.java +++ b/src/helma/objectmodel/DbMapping.java @@ -25,10 +25,10 @@ public class DbMapping { DbSource source; String table; - DbMapping parent; + String[] parent; // list of properties to try for parent + Boolean[] anonymous; // are parent relations anonymous or not? DbMapping subnodes; DbMapping properties; - private Relation parentRel; private Relation subnodesRel; private Relation propertiesRel; @@ -80,7 +80,7 @@ public class DbMapping { /** * Read the mapping from the Properties. Return true if the properties were changed. */ - public boolean read () { + public synchronized boolean read () { long lastmod = props.lastModified (); if (lastmod == lastTypeChange) @@ -98,7 +98,7 @@ public class DbMapping { return true; } - public void rewire () { + public synchronized void rewire () { // if (table != null && source != null) { // IServer.getLogger().log ("set data source for "+typename+" to "+source); @@ -116,25 +116,34 @@ public class DbMapping { d2p.put (rel.localField, rel); // IServer.getLogger().log ("Mapping "+propName+" -> "+dbField); - } else if ("_id".equalsIgnoreCase (propName)) { - idField = props.getProperty (propName); - - } else if ("_name".equalsIgnoreCase (propName)) { - nameField = props.getProperty (propName); } } prop2db = p2d; db2prop = d2p; + idField = props.getProperty ("_id"); + + nameField = props.getProperty ("_name"); + + String ano = props.getProperty ("_anonymous"); + if (ano != null) { + // comma-separated list of true/false values + StringTokenizer st = new StringTokenizer (ano, ",; "); + anonymous = new Boolean[st.countTokens()]; + for (int i=0; i i) + anonymous = ano[i].booleanValue(); + return pn; + } + } + } + + // fall back to heuristic parent (the node that fetched this one from db) if (parentID == null) return null; - - DbMapping pm = parentmap; - if (pm == null && dbmap != null) - pm = dbmap.getParentMapping (); - return nmgr.getNode (parentID, pm); + return nmgr.getNode (parentID, parentmap); }