* Use new ResourceProperties.getSubProperties(String prefix) feature to

get our config props.
* Introduce getConfig() method to get the relations's config props.
This commit is contained in:
hns 2006-01-27 11:21:53 +00:00
parent 0e43265cb8
commit 8509b4b6c3

View file

@ -20,6 +20,7 @@ import helma.framework.core.Application;
import helma.objectmodel.INode; import helma.objectmodel.INode;
import helma.objectmodel.IProperty; import helma.objectmodel.IProperty;
import helma.util.StringUtils; import helma.util.StringUtils;
import helma.util.ResourceProperties;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
@ -140,7 +141,7 @@ public final class Relation {
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
// parse methods for new file format // parse methods for new file format
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
public void update(String desc, Properties props) { public void update(String desc, ResourceProperties props) {
Application app = ownType.getApplication(); Application app = ownType.getApplication();
if ((desc == null) || "".equals(desc.trim())) { if ((desc == null) || "".equals(desc.trim())) {
@ -196,15 +197,17 @@ public final class Relation {
} }
} }
readonly = "true".equalsIgnoreCase(props.getProperty(propName + ".readonly")); ResourceProperties config = props.getSubProperties(propName + '.');
isPrivate = "true".equalsIgnoreCase(props.getProperty(propName + ".private")); readonly = "true".equalsIgnoreCase(config.getProperty("readonly"));
isPrivate = "true".equalsIgnoreCase(config.getProperty("private"));
// the following options only apply to object and collection relations // the following options only apply to object and collection relations
if ((reftype != PRIMITIVE) && (reftype != INVALID)) { if ((reftype != PRIMITIVE) && (reftype != INVALID)) {
Vector newConstraints = new Vector(); Vector newConstraints = new Vector();
parseOptions(newConstraints, props); parseOptions(newConstraints, config);
constraints = new Constraint[newConstraints.size()]; constraints = new Constraint[newConstraints.size()];
newConstraints.copyInto(constraints); newConstraints.copyInto(constraints);
@ -249,26 +252,26 @@ public final class Relation {
} }
} }
protected void parseOptions(Vector cnst, Properties props) { protected void parseOptions(Vector cnst, Properties config) {
String loading = props.getProperty(propName + ".loadmode"); String loading = config.getProperty("loadmode");
aggressiveLoading = (loading != null) && aggressiveLoading = (loading != null) &&
"aggressive".equalsIgnoreCase(loading.trim()); "aggressive".equalsIgnoreCase(loading.trim());
String caching = props.getProperty(propName + ".cachemode"); String caching = config.getProperty("cachemode");
aggressiveCaching = (caching != null) && aggressiveCaching = (caching != null) &&
"aggressive".equalsIgnoreCase(caching.trim()); "aggressive".equalsIgnoreCase(caching.trim());
// get order property // get order property
order = props.getProperty(propName + ".order"); order = config.getProperty("order");
if ((order != null) && (order.trim().length() == 0)) { if ((order != null) && (order.trim().length() == 0)) {
order = null; order = null;
} }
// get additional filter property // get additional filter property
filter = props.getProperty(propName + ".filter"); filter = config.getProperty("filter");
if (filter != null) { if (filter != null) {
if (filter.trim().length() == 0) { if (filter.trim().length() == 0) {
@ -291,7 +294,7 @@ public final class Relation {
} }
// get additional tables // get additional tables
additionalTables = props.getProperty(propName + ".filter.additionalTables"); additionalTables = config.getProperty("filter.additionalTables");
if (additionalTables != null) { if (additionalTables != null) {
if (additionalTables.trim().length() == 0) { if (additionalTables.trim().length() == 0) {
@ -321,10 +324,10 @@ public final class Relation {
} }
// get query hints // get query hints
queryHints = props.getProperty(propName + ".hints"); queryHints = config.getProperty("hints");
// get max size of collection // get max size of collection
String max = props.getProperty(propName + ".maxSize"); String max = config.getProperty("maxSize");
if (max != null) { if (max != null) {
try { try {
@ -337,20 +340,20 @@ public final class Relation {
} }
// get group by property // get group by property
groupby = props.getProperty(propName + ".group"); groupby = config.getProperty("group");
if ((groupby != null) && (groupby.trim().length() == 0)) { if ((groupby != null) && (groupby.trim().length() == 0)) {
groupby = null; groupby = null;
} }
if (groupby != null) { if (groupby != null) {
groupbyOrder = props.getProperty(propName + ".group.order"); groupbyOrder = config.getProperty("group.order");
if ((groupbyOrder != null) && (groupbyOrder.trim().length() == 0)) { if ((groupbyOrder != null) && (groupbyOrder.trim().length() == 0)) {
groupbyOrder = null; groupbyOrder = null;
} }
groupbyPrototype = props.getProperty(propName + ".group.prototype"); groupbyPrototype = config.getProperty("group.prototype");
if ((groupbyPrototype != null) && (groupbyPrototype.trim().length() == 0)) { if ((groupbyPrototype != null) && (groupbyPrototype.trim().length() == 0)) {
groupbyPrototype = null; groupbyPrototype = null;
@ -361,11 +364,11 @@ public final class Relation {
} }
// check if subnode condition should be applied for property relations // check if subnode condition should be applied for property relations
accessName = props.getProperty(propName + ".accessname"); accessName = config.getProperty("accessname");
// parse contstraints // parse contstraints
String local = props.getProperty(propName + ".local"); String local = config.getProperty("local");
String foreign = props.getProperty(propName + ".foreign"); String foreign = config.getProperty("foreign");
if ((local != null) && (foreign != null)) { if ((local != null) && (foreign != null)) {
cnst.addElement(new Constraint(local, foreign, false)); cnst.addElement(new Constraint(local, foreign, false));
@ -374,8 +377,8 @@ public final class Relation {
// parse additional contstraints from *.1 to *.9 // parse additional contstraints from *.1 to *.9
for (int i=1; i<10; i++) { for (int i=1; i<10; i++) {
local = props.getProperty(propName + ".local."+i); local = config.getProperty("local."+i);
foreign = props.getProperty(propName + ".foreign."+i); foreign = config.getProperty("foreign."+i);
if ((local != null) && (foreign != null)) { if ((local != null) && (foreign != null)) {
cnst.addElement(new Constraint(local, foreign, false)); cnst.addElement(new Constraint(local, foreign, false));
@ -384,7 +387,7 @@ public final class Relation {
// parse constraints logic // parse constraints logic
if (cnst.size() > 1) { if (cnst.size() > 1) {
String logic = props.getProperty(propName + ".logicalOperator"); String logic = config.getProperty("logicalOperator");
if ("and".equalsIgnoreCase(logic)) { if ("and".equalsIgnoreCase(logic)) {
logicalOperator = AND; logicalOperator = AND;
} else if ("or".equalsIgnoreCase(logic)) { } else if ("or".equalsIgnoreCase(logic)) {
@ -402,6 +405,13 @@ public final class Relation {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
/**
* Get the configuration properties for this relation.
*/
public ResourceProperties getConfig() {
return ownType.getProperties().getSubProperties(propName + '.');
}
/** /**
* Does this relation describe a virtual (collection) node? * Does this relation describe a virtual (collection) node?
*/ */