r9927 - helma/helma/trunk/src/helma/objectmodel/db
[email protected] Fri, 18 Sep 2009 21:36:42 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090918193642.3C4C43D0E3@mia> |
Author: hannes
Date: 2009-09-18 21:36:42 +0200 (Fri, 18 Sep 2009)
New Revision: 9927
Modified:
helma/helma/trunk/src/helma/objectmodel/db/DbMapping.java
helma/helma/trunk/src/helma/objectmodel/db/Node.java
helma/helma/trunk/src/helma/objectmodel/db/NodeManager.java
helma/helma/trunk/src/helma/objectmodel/db/Relation.java
Log:
Collateral code cleanup: add some comments, remove superfluous parentheses
Details at http://dev.helma.org/trac/helma/changeset/9927
Modified: helma/helma/trunk/src/helma/objectmodel/db/DbMapping.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/db/DbMapping.java 2009-09-18 19:09:52 UTC (rev 9926)
+++ helma/helma/trunk/src/helma/objectmodel/db/DbMapping.java 2009-09-18 19:36:42 UTC (rev 9927)
@@ -313,7 +313,7 @@
String propName = (String) entry.getKey();
// ignore internal properties (starting with "_") and sub-options (containing a ".")
- if (!propName.startsWith("_") && (propName.indexOf(".") < 0)) {
+ if (!propName.startsWith("_") && propName.indexOf(".") < 0) {
Object propValue = entry.getValue();
// check if a relation for this propery already exists. If so, reuse it
Modified: helma/helma/trunk/src/helma/objectmodel/db/Node.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/db/Node.java 2009-09-18 19:09:52 UTC (rev 9926)
+++ helma/helma/trunk/src/helma/objectmodel/db/Node.java 2009-09-18 19:36:42 UTC (rev 9927)
@@ -769,7 +769,6 @@
if (!ignoreSubnodeChange()) {
checkWriteLock();
}
-
node.checkWriteLock();
}
@@ -780,7 +779,7 @@
}
// if the new node is marked as TRANSIENT and this node is not, mark new node as NEW
- if ((state != TRANSIENT) && (node.state == TRANSIENT)) {
+ if (state != TRANSIENT && node.state == TRANSIENT) {
node.makePersistable();
}
Modified: helma/helma/trunk/src/helma/objectmodel/db/NodeManager.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/db/NodeManager.java 2009-09-18 19:09:52 UTC (rev 9926)
+++ helma/helma/trunk/src/helma/objectmodel/db/NodeManager.java 2009-09-18 19:36:42 UTC (rev 9927)
@@ -1357,7 +1357,7 @@
throws Exception {
Node node = null;
- if ((rel != null) && rel.virtual) {
+ if (rel != null && rel.virtual) {
if (rel.needsPersistence()) {
node = (Node) home.createNode(kstr);
} else {
Modified: helma/helma/trunk/src/helma/objectmodel/db/Relation.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/db/Relation.java 2009-09-18 19:09:52 UTC (rev 9926)
+++ helma/helma/trunk/src/helma/objectmodel/db/Relation.java 2009-09-18 19:36:42 UTC (rev 9927)
@@ -143,14 +143,19 @@
otherType = null;
}
- ////////////////////////////////////////////////////////////////////////////////////////////
- // parse methods for new file format
- ////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Update this relation object from a properties object.
+ * @param desc the top level relation descriptor. For relations
+ * defined in a type.properties file, this is a string like
+ * "collection(Type)", but for relations defined from
+ * JavaScript, it is the top level descriptor object.
+ * @param props The subproperties for this relation.
+ */
public void update(Object desc, Properties props) {
Application app = ownType.getApplication();
if (desc instanceof Properties || parseDescriptor(desc, props)) {
- // new style foo.collectionOf = Bar mapping
+ // converted to internal foo.collection = Bar representation
String proto;
if (props.containsKey("collection")) {
proto = props.getProperty("collection");
@@ -249,7 +254,7 @@
protected boolean parseDescriptor(Object value, Map config) {
String desc = value instanceof String ? (String) value : null;
- if ((desc == null) || "".equals(desc.trim())) {
+ if (desc == null || "".equals(desc.trim())) {
if (propName != null) {
reftype = PRIMITIVE;
columnName = propName;
@@ -262,9 +267,9 @@
desc = desc.trim();
int open = desc.indexOf("(");
- int close = desc.indexOf(")");
+ int close = desc.indexOf(")", open);
- if ((open > -1) && (close > open)) {
+ if (open > -1 && close > open) {
String ref = desc.substring(0, open).trim();
String proto = desc.substring(open + 1, close).trim();
@@ -585,14 +590,19 @@
}
// collections/mountpoints need to be persisted if the
- // child object type is non-relational.
+ // child object type is non-relational. Depending on
+ // whether prototype is null or not, we need to look at
+ // otherType itself or otherType's subnode mapping.
if (prototype == null) {
+ // an ordinary, unprototyped virtual node -
+ // otherType is the content type
return !otherType.isRelational();
+ } else {
+ // a prototyped virtual node or mountpoint -
+ // otherType is the virtual node type itself
+ DbMapping sub = otherType.getSubnodeMapping();
+ return sub != null && !sub.isRelational();
}
-
- DbMapping sub = otherType.getSubnodeMapping();
-
- return (sub != null) && !sub.isRelational();
}
/**