#461 - ENH: Add @Draftable support - @DraftDirty

This commit is contained in:
Robin Bygrave committed 2015-11-23 23:11:15 +13:00
1 parent db371cbc6a
commit 5e8afbe50d
7 files changed
+146 -82

No files matched your search

@@ -158,6 +158,8 @@ public class BeanDescriptor<T> implements MetaBeanInfo, SpiBeanType<T> {
private final boolean draftableElement;
private final BeanProperty draftDirty;
/**
* Map of BeanProperty Linked so as to preserve order.
*/
@@ -393,6 +395,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo, SpiBeanType<T> {
this.idProperty = listHelper.getId();
this.versionProperty = listHelper.getVersionProperty();
this.draftDirty = listHelper.getDraftDirty();
this.propMap = listHelper.getPropertyMap();
this.propertiesTransient = listHelper.getTransients();
this.propertiesNonTransient = listHelper.getNonTransients();
@@ -833,6 +836,13 @@ public class BeanDescriptor<T> implements MetaBeanInfo, SpiBeanType<T> {
return draftHelp.publish(draftBean, liveBean);
}
/**
* Return the draft dirty boolean property or null if there is not one assigned to this bean type.
*/
public BeanProperty getDraftDirty() {
return draftDirty;
}
/**
* Set the bean caching on or off.
*/
@@ -1918,6 +1928,19 @@ public class BeanDescriptor<T> implements MetaBeanInfo, SpiBeanType<T> {
return draftableElement;
}
/**
* If there is a @DraftDirty property set it's value on the bean.
*/
public void setDraftDirty(EntityBean entityBean, boolean value) {
if (draftDirty != null) {
// check to see if the dirty property has already
// been set and if so do not set the value
if (!entityBean._ebean_getIntercept().isChangedProperty(draftDirty.getPropertyIndex())) {
draftDirty.setValueIntercept(entityBean, value);
}
}
}
/**
* Return true if this entity bean has history support.
*/
@@ -28,6 +28,8 @@ public class DeployBeanPropertyLists {
private BeanProperty versionProperty;
private BeanProperty draftDirty;
private final BeanDescriptor<?> desc;
private final LinkedHashMap<String, BeanProperty> propertyMap;
@@ -175,6 +177,8 @@ public class DeployBeanPropertyLists {
logger.warn("Multiple @Version properties - property " + prop.getFullBeanName()
+ " not treated as a version property");
}
} else if (prop.isDraftDirty()) {
draftDirty = prop;
}
if (prop instanceof BeanPropertyCompound) {
baseCompound.add((BeanPropertyCompound) prop);
@@ -285,6 +289,10 @@ public class DeployBeanPropertyLists {
return getMany2Many();
}
public BeanProperty getDraftDirty() {
return draftDirty;
}
/**
* Mode used to determine which BeanPropertyAssoc to include.
*/