groupbyMapping.subnodesRel = subnodesRel == null ? null : subnodesRel.getGroupbySubnodeRelation (); groupbyMapping.propertiesRel = propertiesRel == null ? null : propertiesRel.getGroupbyPropertyRelation ();
initGroupbyMapping ();
    public synchronized void rewire () {	if (extendsProto != null) {	    parentMapping = app.getDbMapping (extendsProto);	}		// if (table != null && source != null) {	// app.logEvent ("set data source for "+typename+" to "+source);	Hashtable p2d = new Hashtable ();	Hashtable d2p = new Hashtable ();	for (Enumeration e=props.keys(); e.hasMoreElements(); ) {	    String propName = (String) e.nextElement ();	    try {	        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);	            p2d.put (propName, rel);	            if (rel.columnName != null &&	            		(rel.reftype == Relation.PRIMITIVE ||	            		rel.reftype == Relation.REFERENCE))	                d2p.put (rel.columnName, rel);	            // app.logEvent ("Mapping "+propName+" -> "+dbField);	        }	    } catch (Exception x) {	        app.logEvent ("Error in type.properties: "+x.getMessage ());	    }	}	prop2db = p2d;	db2prop = d2p;	String subnodeMapping = props.getProperty ("_subnodes");	if (subnodeMapping != null) {	    try {	        // 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);		    } catch (Exception x) {	        app.logEvent ("Error reading _subnodes relation for "+typename+": "+x.getMessage ());	        // subnodesRel = null;	    }	} else	    subnodesRel = null;	String propertiesMapping = props.getProperty ("_properties");	if (propertiesMapping != null) {	    try {	        // 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);	        // 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;	    }	} else	    propertiesRel = null;	if (groupbyMapping != null) {	    groupbyMapping.subnodesRel = subnodesRel == null ? null : subnodesRel.getGroupbySubnodeRelation ();	    groupbyMapping.propertiesRel = propertiesRel == null ? null : propertiesRel.getGroupbyPropertyRelation ();	    groupbyMapping.lastTypeChange = this.lastTypeChange;	}    }