Add Period support via CompoundTypePeriod, rename server/reflect to server/properties

This commit is contained in:
rbygrave committed 2014-11-18 23:09:26 +13:00
1 parent 98f6e1e6af
commit 07cdb69a5b
27 files changed
+501 -333

No files matched your search

@@ -36,7 +36,7 @@ import com.avaje.ebeaninternal.server.deploy.DRawSqlMeta;
import com.avaje.ebeaninternal.server.deploy.DeployNamedQuery;
import com.avaje.ebeaninternal.server.deploy.DeployNamedUpdate;
import com.avaje.ebeaninternal.server.deploy.InheritInfo;
import com.avaje.ebeaninternal.server.reflect.BeanReflect;
import com.avaje.ebeaninternal.server.properties.BeanPropertyInfo;
/**
* Describes Beans including their deployment information.
@@ -127,7 +127,7 @@ public class DeployBeanDescriptor<T> {
* Used to provide mechanism to new EntityBean instances. Generated code
* faster than reflection at this stage.
*/
private BeanReflect beanReflect;
private BeanPropertyInfo beanReflect;
private String[] properties;
/**
@@ -302,7 +302,7 @@ public class DeployBeanDescriptor<T> {
this.properties = props;
}
public BeanReflect getBeanReflect() {
public BeanPropertyInfo getBeanReflect() {
return beanReflect;
}
@@ -317,7 +317,7 @@ public class DeployBeanDescriptor<T> {
* Set the BeanReflect used to create new instances of an EntityBean. This
* could use reflection or code generation to do this.
*/
public void setBeanReflect(BeanReflect beanReflect) {
public void setBeanReflect(BeanPropertyInfo beanReflect) {
this.beanReflect = beanReflect;
}
@@ -20,8 +20,8 @@ import com.avaje.ebeaninternal.server.core.InternString;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
import com.avaje.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty;
import com.avaje.ebeaninternal.server.el.ElPropertyValue;
import com.avaje.ebeaninternal.server.reflect.BeanReflectGetter;
import com.avaje.ebeaninternal.server.reflect.BeanReflectSetter;
import com.avaje.ebeaninternal.server.properties.BeanPropertyGetter;
import com.avaje.ebeaninternal.server.properties.BeanPropertySetter;
import com.avaje.ebeaninternal.server.type.ScalarType;
import com.avaje.ebeaninternal.server.type.ScalarTypeEnum;
import com.avaje.ebeaninternal.server.type.ScalarTypeWrapper;
@@ -202,9 +202,9 @@ public class DeployBeanProperty {
private int propertyIndex;
private BeanReflectGetter getter;
private BeanPropertyGetter getter;
private BeanReflectSetter setter;
private BeanPropertySetter setter;
/**
* Generator for insert or update timestamp etc.
@@ -439,11 +439,11 @@ public class DeployBeanProperty {
this.propertyIndex = propertyIndex;
}
public BeanReflectGetter getGetter() {
public BeanPropertyGetter getGetter() {
return getter;
}
public BeanReflectSetter getSetter() {
public BeanPropertySetter getSetter() {
return setter;
}
@@ -482,14 +482,14 @@ public class DeployBeanProperty {
/**
* Set the getter used to read the property value from a bean.
*/
public void setGetter(BeanReflectGetter getter) {
public void setGetter(BeanPropertyGetter getter) {
this.getter = getter;
}
/**
* Set the setter used to set the property value to a bean.
*/
public void setSetter(BeanReflectSetter setter) {
public void setSetter(BeanPropertySetter setter) {
this.setter = setter;
}
@@ -21,99 +21,99 @@ import com.avaje.ebeaninternal.server.type.ScalarType;
*/
public class DeployBeanPropertyCompound extends DeployBeanProperty {
final CtCompoundType<?> compoundType;
final CtCompoundType<?> compoundType;
final ScalarTypeConverter<?, ?> typeConverter;
final ScalarTypeConverter<?, ?> typeConverter;
DeployBeanEmbedded deployEmbedded;
/**
* Create the property.
*/
public DeployBeanPropertyCompound(DeployBeanDescriptor<?> desc, Class<?> targetType,
CtCompoundType<?> compoundType, ScalarTypeConverter<?, ?> typeConverter) {
super(desc, targetType, null, null);
this.compoundType = compoundType;
this.typeConverter = typeConverter;
}
DeployBeanEmbedded deployEmbedded;
public BeanPropertyCompoundRoot getFlatProperties(BeanDescriptorMap owner, BeanDescriptor<?> descriptor) {
// get a 'flat' list of all the scalar types, their relative property names
// and also set their matching dbColumn
// represents the root property
BeanPropertyCompoundRoot rootProperty = new BeanPropertyCompoundRoot(this);
// Walk the tree of a compound type collecting the
// scalar types and non-scalar properties
CtCompoundTypeScalarList ctMeta = new CtCompoundTypeScalarList();
compoundType.accumulateScalarTypes(null, ctMeta);
List<BeanProperty> beanPropertyList = new ArrayList<BeanProperty>();
// for each of the scalar types inside a compound value object
// build a BeanPropertyCompoundScalar with appropriate deployment
// information.
for (Entry<String, ScalarType<?>> entry : ctMeta.entries()) {
/**
* Create the property.
*/
public DeployBeanPropertyCompound(DeployBeanDescriptor<?> desc, Class<?> targetType,
CtCompoundType<?> compoundType, ScalarTypeConverter<?, ?> typeConverter) {
String relativePropertyName = entry.getKey();
ScalarType<?> scalarType = entry.getValue();
CtCompoundProperty ctProp = ctMeta.getCompoundType(relativePropertyName);
String dbColumn = relativePropertyName.replace(".", "_");
dbColumn = getDbColumn(relativePropertyName, dbColumn);
DeployBeanProperty deploy = new DeployBeanProperty(null, scalarType.getType(), scalarType, null);
deploy.setScalarType(scalarType);
deploy.setDbColumn(dbColumn);
deploy.setName(relativePropertyName);
deploy.setDbInsertable(true);
deploy.setDbUpdateable(true);
deploy.setDbRead(true);
BeanPropertyCompoundScalar bp = new BeanPropertyCompoundScalar(rootProperty, deploy, ctProp, typeConverter);
beanPropertyList.add(bp);
rootProperty.register(bp);
}
rootProperty.setNonScalarProperties(ctMeta.getNonScalarProperties());
return rootProperty;
}
private String getDbColumn(String propName, String defaultDbColumn){
if (deployEmbedded == null){
return defaultDbColumn;
}
String dbColumn = deployEmbedded.getPropertyColumnMap().get(propName);
return dbColumn == null ? defaultDbColumn : dbColumn;
}
/**
* Return the deploy information specifically for the deployment
* of Embedded beans.
*/
public DeployBeanEmbedded getDeployEmbedded() {
// deployment should be single threaded
if (deployEmbedded == null){
deployEmbedded = new DeployBeanEmbedded();
}
return deployEmbedded;
}
super(desc, targetType, null, null);
this.compoundType = compoundType;
this.typeConverter = typeConverter;
}
public ScalarTypeConverter<?, ?> getTypeConverter() {
return typeConverter;
public BeanPropertyCompoundRoot getFlatProperties(BeanDescriptorMap owner, BeanDescriptor<?> descriptor) {
// get a 'flat' list of all the scalar types, their relative property names
// and also set their matching dbColumn
// represents the root property
BeanPropertyCompoundRoot rootProperty = new BeanPropertyCompoundRoot(this);
// Walk the tree of a compound type collecting the
// scalar types and non-scalar properties
CtCompoundTypeScalarList ctMeta = new CtCompoundTypeScalarList();
compoundType.accumulateScalarTypes(null, ctMeta);
List<BeanProperty> beanPropertyList = new ArrayList<BeanProperty>();
// for each of the scalar types inside a compound value object
// build a BeanPropertyCompoundScalar with appropriate deployment
// information.
for (Entry<String, ScalarType<?>> entry : ctMeta.entries()) {
String relativePropertyName = entry.getKey();
ScalarType<?> scalarType = entry.getValue();
CtCompoundProperty ctProp = ctMeta.getCompoundType(relativePropertyName);
String dbColumn = (getName() + "." + relativePropertyName).replace(".", "_");
dbColumn = getDbColumn(relativePropertyName, dbColumn);
DeployBeanProperty deploy = new DeployBeanProperty(null, scalarType.getType(), scalarType, null);
deploy.setScalarType(scalarType);
deploy.setDbColumn(dbColumn);
deploy.setName(relativePropertyName);
deploy.setDbInsertable(true);
deploy.setDbUpdateable(true);
deploy.setDbRead(true);
BeanPropertyCompoundScalar bp = new BeanPropertyCompoundScalar(rootProperty, deploy, ctProp, typeConverter);
beanPropertyList.add(bp);
rootProperty.register(bp);
}
public CtCompoundType<?> getCompoundType() {
return compoundType;
rootProperty.setNonScalarProperties(ctMeta.getNonScalarProperties());
return rootProperty;
}
private String getDbColumn(String propName, String defaultDbColumn) {
if (deployEmbedded == null) {
return defaultDbColumn;
}
String dbColumn = deployEmbedded.getPropertyColumnMap().get(propName);
return dbColumn == null ? defaultDbColumn : dbColumn;
}
/**
* Return the deploy information specifically for the deployment
* of Embedded beans.
*/
public DeployBeanEmbedded getDeployEmbedded() {
// deployment should be single threaded
if (deployEmbedded == null) {
deployEmbedded = new DeployBeanEmbedded();
}
return deployEmbedded;
}
public ScalarTypeConverter<?, ?> getTypeConverter() {
return typeConverter;
}
public CtCompoundType<?> getCompoundType() {
return compoundType;
}
}