mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
initial rework for new enhancement
This commit is contained in:
1 parent
eb1eafe98c
commit
4ec62a5772
193 files changed
+2737
-5285
No files matched your search
+11
-24
@@ -65,11 +65,6 @@ public class DeployBeanDescriptor<T> {
|
||||
*/
|
||||
private LinkedHashMap<String, DeployBeanProperty> propMap = new LinkedHashMap<String, DeployBeanProperty>();
|
||||
|
||||
/**
|
||||
* The type of bean this describes.
|
||||
*/
|
||||
private final Class<T> beanType;
|
||||
|
||||
private EntityType entityType;
|
||||
|
||||
private final Map<String, DeployNamedQuery> namedQueries = new LinkedHashMap<String, DeployNamedQuery>();
|
||||
@@ -107,7 +102,7 @@ public class DeployBeanDescriptor<T> {
|
||||
/**
|
||||
* The concurrency mode for beans of this type.
|
||||
*/
|
||||
private ConcurrencyMode concurrencyMode = ConcurrencyMode.ALL;
|
||||
private ConcurrencyMode concurrencyMode;
|
||||
|
||||
private boolean updateChangesOnly;
|
||||
|
||||
@@ -134,11 +129,12 @@ public class DeployBeanDescriptor<T> {
|
||||
* faster than reflection at this stage.
|
||||
*/
|
||||
private BeanReflect beanReflect;
|
||||
private String[] properties;
|
||||
|
||||
/**
|
||||
* The EntityBean type used to create new EntityBeans.
|
||||
*/
|
||||
private Class<?> factoryType;
|
||||
private Class<T> beanType;
|
||||
|
||||
private List<BeanPersistController> persistControllers = new ArrayList<BeanPersistController>();
|
||||
private List<BeanPersistListener<T>> persistListeners = new ArrayList<BeanPersistListener<T>>();
|
||||
@@ -331,6 +327,14 @@ public class DeployBeanDescriptor<T> {
|
||||
return namedUpdates;
|
||||
}
|
||||
|
||||
public String[] getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(String[] props) {
|
||||
this.properties = props;
|
||||
}
|
||||
|
||||
public BeanReflect getBeanReflect() {
|
||||
return beanReflect;
|
||||
}
|
||||
@@ -342,23 +346,6 @@ public class DeployBeanDescriptor<T> {
|
||||
return beanType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class type this BeanDescriptor describes.
|
||||
*/
|
||||
public Class<?> getFactoryType() {
|
||||
return factoryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the class used to create new EntityBean instances.
|
||||
* <p>
|
||||
* Normally this would be a subclass dynamically generated for this bean.
|
||||
* </p>
|
||||
*/
|
||||
public void setFactoryType(Class<?> factoryType) {
|
||||
this.factoryType = factoryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BeanReflect used to create new instances of an EntityBean. This
|
||||
* could use reflection or code generation to do this.
|
||||
|
||||
@@ -198,6 +198,8 @@ public class DeployBeanProperty {
|
||||
*/
|
||||
private Method writeMethod;
|
||||
|
||||
private int propertyIndex;
|
||||
|
||||
private BeanReflectGetter getter;
|
||||
|
||||
private BeanReflectSetter setter;
|
||||
@@ -410,6 +412,14 @@ public class DeployBeanProperty {
|
||||
this.scalarType = scalarType;
|
||||
}
|
||||
|
||||
public int getPropertyIndex() {
|
||||
return propertyIndex;
|
||||
}
|
||||
|
||||
public void setPropertyIndex(int propertyIndex) {
|
||||
this.propertyIndex = propertyIndex;
|
||||
}
|
||||
|
||||
public BeanReflectGetter getGetter() {
|
||||
return getter;
|
||||
}
|
||||
|
||||
+304
-305
@@ -5,6 +5,9 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.avaje.ebean.bean.BeanCollection.ModifyListenMode;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptorMap;
|
||||
@@ -20,347 +23,343 @@ import com.avaje.ebeaninternal.server.deploy.TableJoin;
|
||||
*/
|
||||
public class DeployBeanPropertyLists {
|
||||
|
||||
private BeanProperty derivedFirstVersionProp;
|
||||
private static final Logger logger = LoggerFactory.getLogger(DeployBeanPropertyLists.class);
|
||||
|
||||
private final BeanDescriptor<?> desc;
|
||||
private BeanProperty versionProperty;
|
||||
|
||||
private final LinkedHashMap<String, BeanProperty> propertyMap;
|
||||
private final BeanDescriptor<?> desc;
|
||||
|
||||
private final ArrayList<BeanProperty> ids = new ArrayList<BeanProperty>();
|
||||
private final LinkedHashMap<String, BeanProperty> propertyMap;
|
||||
|
||||
private final ArrayList<BeanProperty> version = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> ids = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanProperty> local = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> local = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanProperty> manys = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> nonManys = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> manys = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> nonManys = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanProperty> ones = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> ones = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanProperty> onesExported = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> onesExported = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanProperty> onesImported = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> onesImported = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanProperty> embedded = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> embedded = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanProperty> baseScalar = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> baseScalar = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanPropertyCompound> baseCompound = new ArrayList<BeanPropertyCompound>();
|
||||
private final ArrayList<BeanPropertyCompound> baseCompound = new ArrayList<BeanPropertyCompound>();
|
||||
|
||||
private final ArrayList<BeanProperty> transients = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> transients = new ArrayList<BeanProperty>();
|
||||
|
||||
private final ArrayList<BeanProperty> nonTransients = new ArrayList<BeanProperty>();
|
||||
private final ArrayList<BeanProperty> nonTransients = new ArrayList<BeanProperty>();
|
||||
|
||||
private final TableJoin[] tableJoins;
|
||||
private final TableJoin[] tableJoins;
|
||||
|
||||
private final BeanPropertyAssocOne<?> unidirectional;
|
||||
private final BeanPropertyAssocOne<?> unidirectional;
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public DeployBeanPropertyLists(BeanDescriptorMap owner, BeanDescriptor<?> desc, DeployBeanDescriptor<?> deploy) {
|
||||
this.desc = desc;
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public DeployBeanPropertyLists(BeanDescriptorMap owner, BeanDescriptor<?> desc, DeployBeanDescriptor<?> deploy) {
|
||||
this.desc = desc;
|
||||
|
||||
DeployBeanPropertyAssocOne<?> deployUnidirectional = deploy.getUnidirectional();
|
||||
if (deployUnidirectional == null) {
|
||||
unidirectional = null;
|
||||
DeployBeanPropertyAssocOne<?> deployUnidirectional = deploy.getUnidirectional();
|
||||
if (deployUnidirectional == null) {
|
||||
unidirectional = null;
|
||||
} else {
|
||||
unidirectional = new BeanPropertyAssocOne(owner, desc, deployUnidirectional);
|
||||
}
|
||||
|
||||
this.propertyMap = new LinkedHashMap<String, BeanProperty>();
|
||||
|
||||
Iterator<DeployBeanProperty> deployIt = deploy.propertiesAll();
|
||||
while (deployIt.hasNext()) {
|
||||
DeployBeanProperty deployProp = deployIt.next();
|
||||
BeanProperty beanProp = createBeanProperty(owner, deployProp);
|
||||
propertyMap.put(beanProp.getName(), beanProp);
|
||||
}
|
||||
|
||||
Iterator<BeanProperty> it = propertyMap.values().iterator();
|
||||
|
||||
int order = 0;
|
||||
while (it.hasNext()) {
|
||||
BeanProperty prop = it.next();
|
||||
prop.setDeployOrder(order++);
|
||||
allocateToList(prop);
|
||||
}
|
||||
|
||||
List<DeployTableJoin> deployTableJoins = deploy.getTableJoins();
|
||||
tableJoins = new TableJoin[deployTableJoins.size()];
|
||||
for (int i = 0; i < deployTableJoins.size(); i++) {
|
||||
tableJoins[i] = new TableJoin(deployTableJoins.get(i), propertyMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the unidirectional.
|
||||
*/
|
||||
public BeanPropertyAssocOne<?> getUnidirectional() {
|
||||
return unidirectional;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the property to a list.
|
||||
*/
|
||||
private void allocateToList(BeanProperty prop) {
|
||||
if (prop.isTransient()) {
|
||||
transients.add(prop);
|
||||
return;
|
||||
}
|
||||
if (prop.isId()) {
|
||||
ids.add(prop);
|
||||
return;
|
||||
} else {
|
||||
nonTransients.add(prop);
|
||||
}
|
||||
|
||||
if (desc.getInheritInfo() != null && prop.isLocal()) {
|
||||
local.add(prop);
|
||||
}
|
||||
|
||||
if (prop instanceof BeanPropertyAssocMany<?>) {
|
||||
manys.add(prop);
|
||||
|
||||
} else {
|
||||
nonManys.add(prop);
|
||||
if (prop instanceof BeanPropertyAssocOne<?>) {
|
||||
if (prop.isEmbedded()) {
|
||||
embedded.add(prop);
|
||||
} else {
|
||||
unidirectional = new BeanPropertyAssocOne(owner, desc, deployUnidirectional);
|
||||
ones.add(prop);
|
||||
BeanPropertyAssocOne<?> assocOne = (BeanPropertyAssocOne<?>) prop;
|
||||
if (assocOne.isOneToOneExported()) {
|
||||
onesExported.add(prop);
|
||||
} else {
|
||||
onesImported.add(prop);
|
||||
}
|
||||
}
|
||||
|
||||
this.propertyMap = new LinkedHashMap<String, BeanProperty>();
|
||||
|
||||
Iterator<DeployBeanProperty> deployIt = deploy.propertiesAll();
|
||||
while (deployIt.hasNext()) {
|
||||
DeployBeanProperty deployProp = deployIt.next();
|
||||
BeanProperty beanProp = createBeanProperty(owner, deployProp);
|
||||
propertyMap.put(beanProp.getName(), beanProp);
|
||||
} else {
|
||||
// its a "base" property...
|
||||
if (prop.isVersion()) {
|
||||
if (versionProperty == null) {
|
||||
versionProperty = prop;
|
||||
} else {
|
||||
logger.warn("Multiple @Version properties - property " + prop.getFullBeanName()
|
||||
+ " not treated as a version property");
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<BeanProperty> it = propertyMap.values().iterator();
|
||||
|
||||
int order = 0;
|
||||
while (it.hasNext()) {
|
||||
BeanProperty prop = it.next();
|
||||
prop.setDeployOrder(order++);
|
||||
allocateToList(prop);
|
||||
}
|
||||
|
||||
List<DeployTableJoin> deployTableJoins = deploy.getTableJoins();
|
||||
tableJoins = new TableJoin[deployTableJoins.size()];
|
||||
for (int i = 0; i < deployTableJoins.size(); i++) {
|
||||
tableJoins[i] = new TableJoin(deployTableJoins.get(i), propertyMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the unidirectional.
|
||||
*/
|
||||
public BeanPropertyAssocOne<?> getUnidirectional() {
|
||||
return unidirectional;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the property to a list.
|
||||
*/
|
||||
private void allocateToList(BeanProperty prop) {
|
||||
if (prop.isTransient()) {
|
||||
transients.add(prop);
|
||||
return;
|
||||
}
|
||||
if (prop.isId()) {
|
||||
ids.add(prop);
|
||||
return;
|
||||
if (prop instanceof BeanPropertyCompound) {
|
||||
baseCompound.add((BeanPropertyCompound) prop);
|
||||
} else {
|
||||
nonTransients.add(prop);
|
||||
baseScalar.add(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (desc.getInheritInfo() != null && prop.isLocal()) {
|
||||
local.add(prop);
|
||||
public LinkedHashMap<String, BeanProperty> getPropertyMap() {
|
||||
return propertyMap;
|
||||
}
|
||||
|
||||
public TableJoin[] getTableJoin() {
|
||||
return tableJoins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the base scalar properties (excludes Id and secondary table
|
||||
* properties).
|
||||
*/
|
||||
public BeanProperty[] getBaseScalar() {
|
||||
return (BeanProperty[]) baseScalar.toArray(new BeanProperty[baseScalar.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyCompound[] getBaseCompound() {
|
||||
return (BeanPropertyCompound[]) baseCompound.toArray(new BeanPropertyCompound[baseCompound.size()]);
|
||||
}
|
||||
|
||||
public BeanProperty getNaturalKey() {
|
||||
String naturalKey = desc.getCacheOptions().getNaturalKey();
|
||||
if (naturalKey != null) {
|
||||
return propertyMap.get(naturalKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BeanProperty[] getId() {
|
||||
return (BeanProperty[]) ids.toArray(new BeanProperty[ids.size()]);
|
||||
}
|
||||
|
||||
public BeanProperty[] getNonTransients() {
|
||||
return (BeanProperty[]) nonTransients.toArray(new BeanProperty[nonTransients.size()]);
|
||||
}
|
||||
|
||||
public BeanProperty[] getTransients() {
|
||||
return (BeanProperty[]) transients.toArray(new BeanProperty[transients.size()]);
|
||||
}
|
||||
|
||||
public BeanProperty getVersionProperty() {
|
||||
return versionProperty;
|
||||
}
|
||||
|
||||
public BeanProperty[] getLocal() {
|
||||
return (BeanProperty[]) local.toArray(new BeanProperty[local.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getEmbedded() {
|
||||
return (BeanPropertyAssocOne[]) embedded.toArray(new BeanPropertyAssocOne[embedded.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneExported() {
|
||||
return (BeanPropertyAssocOne[]) onesExported.toArray(new BeanPropertyAssocOne[onesExported.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneImported() {
|
||||
return (BeanPropertyAssocOne[]) onesImported.toArray(new BeanPropertyAssocOne[onesImported.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOnes() {
|
||||
return (BeanPropertyAssocOne[]) ones.toArray(new BeanPropertyAssocOne[ones.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneExportedSave() {
|
||||
return getOne(false, Mode.Save);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneExportedDelete() {
|
||||
return getOne(false, Mode.Delete);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneImportedSave() {
|
||||
return getOne(true, Mode.Save);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneImportedDelete() {
|
||||
return getOne(true, Mode.Delete);
|
||||
}
|
||||
|
||||
public BeanProperty[] getNonMany() {
|
||||
return (BeanProperty[]) nonManys.toArray(new BeanProperty[nonManys.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocMany<?>[] getMany() {
|
||||
return (BeanPropertyAssocMany[]) manys.toArray(new BeanPropertyAssocMany[manys.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocMany<?>[] getManySave() {
|
||||
return getMany(Mode.Save);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocMany<?>[] getManyDelete() {
|
||||
return getMany(Mode.Delete);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocMany<?>[] getManyToMany() {
|
||||
return getMany2Many();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mode used to determine which BeanPropertyAssoc to include.
|
||||
*/
|
||||
private enum Mode {
|
||||
Save, Delete, Validate;
|
||||
}
|
||||
|
||||
private BeanPropertyAssocOne<?>[] getOne(boolean imported, Mode mode) {
|
||||
ArrayList<BeanPropertyAssocOne<?>> list = new ArrayList<BeanPropertyAssocOne<?>>();
|
||||
for (int i = 0; i < ones.size(); i++) {
|
||||
BeanPropertyAssocOne<?> prop = (BeanPropertyAssocOne<?>) ones.get(i);
|
||||
if (imported != prop.isOneToOneExported()) {
|
||||
switch (mode) {
|
||||
case Save:
|
||||
if (prop.getCascadeInfo().isSave()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Delete:
|
||||
if (prop.getCascadeInfo().isDelete()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Validate:
|
||||
if (prop.getCascadeInfo().isValidate()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prop instanceof BeanPropertyAssocMany<?>) {
|
||||
manys.add(prop);
|
||||
return (BeanPropertyAssocOne[]) list.toArray(new BeanPropertyAssocOne[list.size()]);
|
||||
}
|
||||
|
||||
} else {
|
||||
nonManys.add(prop);
|
||||
if (prop instanceof BeanPropertyAssocOne<?>) {
|
||||
if (prop.isEmbedded()) {
|
||||
embedded.add(prop);
|
||||
} else {
|
||||
ones.add(prop);
|
||||
BeanPropertyAssocOne<?> assocOne = (BeanPropertyAssocOne<?>) prop;
|
||||
if (assocOne.isOneToOneExported()) {
|
||||
onesExported.add(prop);
|
||||
} else {
|
||||
onesImported.add(prop);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// its a "base" property...
|
||||
if (prop.isVersion()) {
|
||||
version.add(prop);
|
||||
if (derivedFirstVersionProp == null) {
|
||||
derivedFirstVersionProp = prop;
|
||||
}
|
||||
}
|
||||
if (prop instanceof BeanPropertyCompound) {
|
||||
baseCompound.add((BeanPropertyCompound) prop);
|
||||
} else {
|
||||
baseScalar.add(prop);
|
||||
}
|
||||
}
|
||||
private BeanPropertyAssocMany<?>[] getMany2Many() {
|
||||
ArrayList<BeanPropertyAssocMany<?>> list = new ArrayList<BeanPropertyAssocMany<?>>();
|
||||
for (int i = 0; i < manys.size(); i++) {
|
||||
BeanPropertyAssocMany<?> prop = (BeanPropertyAssocMany<?>) manys.get(i);
|
||||
if (prop.isManyToMany()) {
|
||||
list.add(prop);
|
||||
}
|
||||
}
|
||||
|
||||
return (BeanPropertyAssocMany[]) list.toArray(new BeanPropertyAssocMany[list.size()]);
|
||||
}
|
||||
|
||||
private BeanPropertyAssocMany<?>[] getMany(Mode mode) {
|
||||
ArrayList<BeanPropertyAssocMany<?>> list = new ArrayList<BeanPropertyAssocMany<?>>();
|
||||
for (int i = 0; i < manys.size(); i++) {
|
||||
BeanPropertyAssocMany<?> prop = (BeanPropertyAssocMany<?>) manys.get(i);
|
||||
|
||||
switch (mode) {
|
||||
case Save:
|
||||
if (prop.getCascadeInfo().isSave() || prop.isManyToMany()
|
||||
|| ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) {
|
||||
// Note ManyToMany always included as we always 'save'
|
||||
// the relationship via insert/delete of intersection table
|
||||
// REMOVALS means including PrivateOwned relationships
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Delete:
|
||||
if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) {
|
||||
// REMOVALS means including PrivateOwned relationships
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Validate:
|
||||
if (prop.getCascadeInfo().isValidate()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public BeanProperty getFirstVersion() {
|
||||
return derivedFirstVersionProp;
|
||||
}
|
||||
return (BeanPropertyAssocMany[]) list.toArray(new BeanPropertyAssocMany[list.size()]);
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, BeanProperty> getPropertyMap() {
|
||||
return propertyMap;
|
||||
}
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private BeanProperty createBeanProperty(BeanDescriptorMap owner, DeployBeanProperty deployProp) {
|
||||
|
||||
public TableJoin[] getTableJoin() {
|
||||
return tableJoins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the base scalar properties (excludes Id and secondary table
|
||||
* properties).
|
||||
*/
|
||||
public BeanProperty[] getBaseScalar() {
|
||||
return (BeanProperty[]) baseScalar.toArray(new BeanProperty[baseScalar.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyCompound[] getBaseCompound() {
|
||||
return (BeanPropertyCompound[]) baseCompound.toArray(new BeanPropertyCompound[baseCompound.size()]);
|
||||
if (deployProp instanceof DeployBeanPropertyAssocOne) {
|
||||
return new BeanPropertyAssocOne(owner, desc, (DeployBeanPropertyAssocOne) deployProp);
|
||||
}
|
||||
|
||||
public BeanProperty getNaturalKey() {
|
||||
String naturalKey = desc.getCacheOptions().getNaturalKey();
|
||||
if (naturalKey != null){
|
||||
return propertyMap.get(naturalKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BeanProperty[] getId() {
|
||||
return (BeanProperty[]) ids.toArray(new BeanProperty[ids.size()]);
|
||||
}
|
||||
|
||||
public BeanProperty[] getNonTransients() {
|
||||
return (BeanProperty[]) nonTransients.toArray(new BeanProperty[nonTransients.size()]);
|
||||
}
|
||||
|
||||
public BeanProperty[] getTransients() {
|
||||
return (BeanProperty[]) transients.toArray(new BeanProperty[transients.size()]);
|
||||
}
|
||||
|
||||
public BeanProperty[] getVersion() {
|
||||
return (BeanProperty[]) version.toArray(new BeanProperty[version.size()]);
|
||||
}
|
||||
|
||||
public BeanProperty[] getLocal() {
|
||||
return (BeanProperty[]) local.toArray(new BeanProperty[local.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getEmbedded() {
|
||||
return (BeanPropertyAssocOne[]) embedded.toArray(new BeanPropertyAssocOne[embedded.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneExported() {
|
||||
return (BeanPropertyAssocOne[]) onesExported.toArray(new BeanPropertyAssocOne[onesExported.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneImported() {
|
||||
return (BeanPropertyAssocOne[]) onesImported.toArray(new BeanPropertyAssocOne[onesImported.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOnes() {
|
||||
return (BeanPropertyAssocOne[]) ones.toArray(new BeanPropertyAssocOne[ones.size()]);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneExportedSave() {
|
||||
return getOne(false, Mode.Save);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneExportedDelete() {
|
||||
return getOne(false, Mode.Delete);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneImportedSave() {
|
||||
return getOne(true, Mode.Save);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocOne<?>[] getOneImportedDelete() {
|
||||
return getOne(true, Mode.Delete);
|
||||
}
|
||||
|
||||
public BeanProperty[] getNonMany() {
|
||||
return (BeanProperty[]) nonManys.toArray(new BeanProperty[nonManys.size()]);
|
||||
if (deployProp instanceof DeployBeanPropertySimpleCollection<?>) {
|
||||
return new BeanPropertySimpleCollection(owner, desc, (DeployBeanPropertySimpleCollection) deployProp);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocMany<?>[] getMany() {
|
||||
return (BeanPropertyAssocMany[]) manys.toArray(new BeanPropertyAssocMany[manys.size()]);
|
||||
if (deployProp instanceof DeployBeanPropertyAssocMany) {
|
||||
return new BeanPropertyAssocMany(owner, desc, (DeployBeanPropertyAssocMany) deployProp);
|
||||
}
|
||||
|
||||
if (deployProp instanceof DeployBeanPropertyCompound) {
|
||||
return new BeanPropertyCompound(owner, desc, (DeployBeanPropertyCompound) deployProp);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocMany<?>[] getManySave() {
|
||||
return getMany(Mode.Save);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocMany<?>[] getManyDelete() {
|
||||
return getMany(Mode.Delete);
|
||||
}
|
||||
|
||||
public BeanPropertyAssocMany<?>[] getManyToMany() {
|
||||
return getMany2Many();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mode used to determine which BeanPropertyAssoc to include.
|
||||
*/
|
||||
private enum Mode {
|
||||
Save, Delete, Validate;
|
||||
}
|
||||
|
||||
private BeanPropertyAssocOne<?>[] getOne(boolean imported, Mode mode) {
|
||||
ArrayList<BeanPropertyAssocOne<?>> list = new ArrayList<BeanPropertyAssocOne<?>>();
|
||||
for (int i = 0; i < ones.size(); i++) {
|
||||
BeanPropertyAssocOne<?> prop = (BeanPropertyAssocOne<?>) ones.get(i);
|
||||
if (imported != prop.isOneToOneExported()) {
|
||||
switch (mode) {
|
||||
case Save:
|
||||
if (prop.getCascadeInfo().isSave()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Delete:
|
||||
if (prop.getCascadeInfo().isDelete()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Validate:
|
||||
if (prop.getCascadeInfo().isValidate()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (BeanPropertyAssocOne[]) list.toArray(new BeanPropertyAssocOne[list.size()]);
|
||||
}
|
||||
|
||||
private BeanPropertyAssocMany<?>[] getMany2Many() {
|
||||
ArrayList<BeanPropertyAssocMany<?>> list = new ArrayList<BeanPropertyAssocMany<?>>();
|
||||
for (int i = 0; i < manys.size(); i++) {
|
||||
BeanPropertyAssocMany<?> prop = (BeanPropertyAssocMany<?>) manys.get(i);
|
||||
if (prop.isManyToMany()) {
|
||||
list.add(prop);
|
||||
}
|
||||
}
|
||||
|
||||
return (BeanPropertyAssocMany[]) list.toArray(new BeanPropertyAssocMany[list.size()]);
|
||||
}
|
||||
|
||||
private BeanPropertyAssocMany<?>[] getMany(Mode mode) {
|
||||
ArrayList<BeanPropertyAssocMany<?>> list = new ArrayList<BeanPropertyAssocMany<?>>();
|
||||
for (int i = 0; i < manys.size(); i++) {
|
||||
BeanPropertyAssocMany<?> prop = (BeanPropertyAssocMany<?>) manys.get(i);
|
||||
|
||||
switch (mode) {
|
||||
case Save:
|
||||
if (prop.getCascadeInfo().isSave() || prop.isManyToMany()
|
||||
|| ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) {
|
||||
// Note ManyToMany always included as we always 'save'
|
||||
// the relationship via insert/delete of intersection table
|
||||
// REMOVALS means including PrivateOwned relationships
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Delete:
|
||||
if (prop.getCascadeInfo().isDelete()
|
||||
|| ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) {
|
||||
// REMOVALS means including PrivateOwned relationships
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Validate:
|
||||
if (prop.getCascadeInfo().isValidate()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (BeanPropertyAssocMany[]) list.toArray(new BeanPropertyAssocMany[list.size()]);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private BeanProperty createBeanProperty(BeanDescriptorMap owner, DeployBeanProperty deployProp) {
|
||||
|
||||
if (deployProp instanceof DeployBeanPropertyAssocOne) {
|
||||
|
||||
return new BeanPropertyAssocOne(owner, desc, (DeployBeanPropertyAssocOne) deployProp);
|
||||
}
|
||||
if (deployProp instanceof DeployBeanPropertySimpleCollection<?>) {
|
||||
|
||||
return new BeanPropertySimpleCollection(owner, desc, (DeployBeanPropertySimpleCollection)deployProp);
|
||||
}
|
||||
if (deployProp instanceof DeployBeanPropertyAssocMany) {
|
||||
|
||||
return new BeanPropertyAssocMany(owner, desc, (DeployBeanPropertyAssocMany) deployProp);
|
||||
}
|
||||
if (deployProp instanceof DeployBeanPropertyCompound) {
|
||||
|
||||
return new BeanPropertyCompound(owner, desc, (DeployBeanPropertyCompound) deployProp);
|
||||
}
|
||||
|
||||
return new BeanProperty(owner, desc, deployProp);
|
||||
}
|
||||
return new BeanProperty(owner, desc, deployProp);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user