You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2013/07/23 21:14:42 UTC
svn commit: r1506224 - in
/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map:
DataMap.java ObjEntity.java
Author: aadamchik
Date: Tue Jul 23 19:14:42 2013
New Revision: 1506224
URL: http://svn.apache.org/r1506224
Log:
CAY-1843 Stop saving listeners in DataMap, add upgrade handler
deprecating defaultEntityListener in DataMap
deprecating listeners in ObjEntity
Modified:
cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java?rev=1506224&r1=1506223&r2=1506224&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java Tue Jul 23 19:14:42 2013
@@ -143,6 +143,10 @@ public class DataMap implements Serializ
private SortedMap<String, Query> queryMap;
private SortedMap<String, SQLResult> results;
+ /**
+ * @deprecated since 3.2 unused as listeners are no longer tied to a
+ * DataMap.
+ */
private List<EntityListener> defaultEntityListeners;
/**
@@ -773,7 +777,10 @@ public class DataMap implements Serializ
* generic Collection is returned.
*
* @since 3.0
+ * @deprecated since 3.2 unused as listeners are no longer tied to a
+ * DataMap.
*/
+ @Deprecated
public List<EntityListener> getDefaultEntityListeners() {
return Collections.unmodifiableList(defaultEntityListeners);
}
@@ -784,7 +791,10 @@ public class DataMap implements Serializ
* @since 3.0
* @throws IllegalArgumentException
* if a listener for the same class name is already registered.
+ * @deprecated since 3.2 unused as listeners are no longer tied to a
+ * DataMap.
*/
+ @Deprecated
public void addDefaultEntityListener(EntityListener listener) {
for (EntityListener next : defaultEntityListeners) {
if (listener.getClassName().equals(next.getClassName())) {
@@ -799,7 +809,10 @@ public class DataMap implements Serializ
* Removes a listener matching class name.
*
* @since 3.0
+ * @deprecated since 3.2 unused as listeners are no longer tied to a
+ * DataMap.
*/
+ @Deprecated
public void removeDefaultEntityListener(String className) {
Iterator<EntityListener> it = defaultEntityListeners.iterator();
while (it.hasNext()) {
@@ -813,7 +826,10 @@ public class DataMap implements Serializ
/**
* @since 3.0
+ * @deprecated since 3.2 unused, as listeners are no longer tied to a
+ * DataMap.
*/
+ @Deprecated
public EntityListener getDefaultEntityListener(String className) {
for (EntityListener listener : defaultEntityListeners) {
if (className.equals(listener.getClassName())) {
Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java?rev=1506224&r1=1506223&r2=1506224&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java Tue Jul 23 19:14:42 2013
@@ -46,23 +46,25 @@ import org.apache.cayenne.util.XMLEncode
import org.apache.commons.collections.Transformer;
/**
- * ObjEntity is a mapping descriptor for a DataObject Java class. It contains the
- * information about the Java class itself, as well as its mapping to the DbEntity layer.
+ * ObjEntity is a mapping descriptor for a DataObject Java class. It contains
+ * the information about the Java class itself, as well as its mapping to the
+ * DbEntity layer.
*/
public class ObjEntity extends Entity implements ObjEntityListener, ConfigurationNode {
final public static int LOCK_TYPE_NONE = 0;
final public static int LOCK_TYPE_OPTIMISTIC = 1;
- // do not import CayenneDataObject as it introduces unneeded client dependency
+ // do not import CayenneDataObject as it introduces unneeded client
+ // dependency
static final String CAYENNE_DATA_OBJECT_CLASS = "org.apache.cayenne.CayenneDataObject";
/**
- * A collection of default "generic" entity classes excluded from class generation.
+ * A collection of default "generic" entity classes excluded from class
+ * generation.
*
* @since 1.2
*/
- protected static final Collection<String> DEFAULT_GENERIC_CLASSES = Arrays
- .asList(CAYENNE_DATA_OBJECT_CLASS);
+ protected static final Collection<String> DEFAULT_GENERIC_CLASSES = Arrays.asList(CAYENNE_DATA_OBJECT_CLASS);
protected String superClassName;
protected String className;
@@ -77,9 +79,14 @@ public class ObjEntity extends Entity im
protected String clientClassName;
protected String clientSuperClassName;
+ @Deprecated
protected List<EntityListener> entityListeners;
protected CallbackMap callbacks;
+
+ @Deprecated
protected boolean excludingDefaultListeners;
+
+ @Deprecated
protected boolean excludingSuperclassListeners;
protected Map<String, String> attributeOverrides;
@@ -95,7 +102,7 @@ public class ObjEntity extends Entity im
this.entityListeners = new ArrayList<EntityListener>(2);
this.attributeOverrides = new TreeMap<String, String>();
}
-
+
/**
* @since 3.1
*/
@@ -145,11 +152,10 @@ public class ObjEntity extends Entity im
}
if (getDbEntityName() != null && getDbEntity() != null) {
-
- // not writing DbEntity name if sub entity has same DbEntity
+
+ // not writing DbEntity name if sub entity has same DbEntity
// as super entity, see CAY-1477
- if (!(getSuperEntity() != null
- && getSuperEntity().getDbEntity() == getDbEntity())) {
+ if (!(getSuperEntity() != null && getSuperEntity().getDbEntity() == getDbEntity())) {
encoder.print("\" dbEntityName=\"");
encoder.print(Util.encodeXmlAttribute(getDbEntityName()));
}
@@ -165,10 +171,12 @@ public class ObjEntity extends Entity im
encoder.print(getClientSuperClassName());
}
+ // deprecated
if (isExcludingSuperclassListeners()) {
encoder.print("\" exclude-superclass-listeners=\"true");
}
+ // deprecated
if (isExcludingDefaultListeners()) {
encoder.print("\" exclude-default-listeners=\"true");
}
@@ -193,6 +201,7 @@ public class ObjEntity extends Entity im
encoder.println("/>");
}
+ // deprecated
// write entity listeners
for (EntityListener entityListener : entityListeners) {
entityListener.encodeAsXML(encoder);
@@ -206,9 +215,9 @@ public class ObjEntity extends Entity im
}
/**
- * Returns an ObjEntity stripped of any server-side information, such as DbEntity
- * mapping. "clientClassName" property of this entity is used to initialize
- * "className" property of returned entity.
+ * Returns an ObjEntity stripped of any server-side information, such as
+ * DbEntity mapping. "clientClassName" property of this entity is used to
+ * initialize "className" property of returned entity.
*
* @since 1.2
*/
@@ -223,8 +232,7 @@ public class ObjEntity extends Entity im
// TODO: should we also copy lock type?
Collection<ObjAttribute> primaryKeys = getMutablePrimaryKeys();
- Collection<ObjAttribute> clientPK = new ArrayList<ObjAttribute>(primaryKeys
- .size());
+ Collection<ObjAttribute> clientPK = new ArrayList<ObjAttribute>(primaryKeys.size());
for (ObjAttribute attribute : getDeclaredAttributes()) {
ObjAttribute clientAttribute = attribute.getClientAttribute();
@@ -235,7 +243,8 @@ public class ObjEntity extends Entity im
}
}
- // after all meaningful pks got removed, here we only have synthetic pks left...
+ // after all meaningful pks got removed, here we only have synthetic pks
+ // left...
for (ObjAttribute attribute : primaryKeys) {
ObjAttribute clientAttribute = attribute.getClientAttribute();
clientPK.add(clientAttribute);
@@ -250,7 +259,8 @@ public class ObjEntity extends Entity im
}
ObjEntity targetEntity = (ObjEntity) relationship.getTargetEntity();
- // note that 'isClientAllowed' also checks parent DataMap client policy
+ // note that 'isClientAllowed' also checks parent DataMap client
+ // policy
// that can be handy in case of cross-map relationships
if (targetEntity == null || !targetEntity.isClientAllowed()) {
continue;
@@ -260,15 +270,15 @@ public class ObjEntity extends Entity im
}
// TODO: andrus 2/5/2007 - copy embeddables
- // TODO: andrus 2/5/2007 - copy listeners and callback methods
+ // TODO: andrus 2/5/2007 - copy callback methods
return entity;
}
/**
- * Returns a non-null class name. For generic entities with no class specified
- * explicitly, default DataMap superclass is used, and if it is not set -
- * CayenneDataObject is used.
+ * Returns a non-null class name. For generic entities with no class
+ * specified explicitly, default DataMap superclass is used, and if it is
+ * not set - CayenneDataObject is used.
*/
String getJavaClassName() {
String name = getClassName();
@@ -285,10 +295,10 @@ public class ObjEntity extends Entity im
}
/**
- * Returns Java class of persistent objects described by this entity. For generic
- * entities with no class specified explicitly, default DataMap superclass is used,
- * and if it is not set - CayenneDataObject is used. Casts any thrown exceptions into
- * CayenneRuntimeException.
+ * Returns Java class of persistent objects described by this entity. For
+ * generic entities with no class specified explicitly, default DataMap
+ * superclass is used, and if it is not set - CayenneDataObject is used.
+ * Casts any thrown exceptions into CayenneRuntimeException.
*
* @since 1.2
*/
@@ -297,22 +307,21 @@ public class ObjEntity extends Entity im
try {
return Util.getJavaClass(name);
- }
- catch (ClassNotFoundException e) {
- throw new CayenneRuntimeException("Failed to load class "
- + name
- + ": "
- + e.getMessage(), e);
+ } catch (ClassNotFoundException e) {
+ throw new CayenneRuntimeException("Failed to load class " + name + ": " + e.getMessage(), e);
}
}
/**
- * Returns an unmodifiable list of registered {@link EntityListener} objects. Note
- * that since the order of listeners is significant a list, not just a generic
- * Collection is returned.
+ * Returns an unmodifiable list of registered {@link EntityListener}
+ * objects. Note that since the order of listeners is significant a list,
+ * not just a generic Collection is returned.
*
* @since 3.0
+ * @deprecated since 3.2 unused, as listeners are no longer mapped in a
+ * DataMap.
*/
+ @Deprecated
public List<EntityListener> getEntityListeners() {
return Collections.unmodifiableList(entityListeners);
}
@@ -321,14 +330,16 @@ public class ObjEntity extends Entity im
* Adds a new EntityListener.
*
* @since 3.0
- * @throws IllegalArgumentException if a listener for the same class name is already
- * registered.
+ * @throws IllegalArgumentException
+ * if a listener for the same class name is already registered.
+ * @deprecated since 3.2 unused, as listeners are no longer mapped in a
+ * DataMap.
*/
+ @Deprecated
public void addEntityListener(EntityListener listener) {
for (EntityListener next : entityListeners) {
if (listener.getClassName().equals(next.getClassName())) {
- throw new IllegalArgumentException("Duplicate listener for "
- + next.getClassName());
+ throw new IllegalArgumentException("Duplicate listener for " + next.getClassName());
}
}
@@ -339,7 +350,10 @@ public class ObjEntity extends Entity im
* Removes a listener matching class name.
*
* @since 3.0
+ * @deprecated since 3.2 unused, as listeners are no longer mapped in a
+ * DataMap.
*/
+ @Deprecated
public void removeEntityListener(String className) {
Iterator<EntityListener> it = entityListeners.iterator();
while (it.hasNext()) {
@@ -353,7 +367,10 @@ public class ObjEntity extends Entity im
/**
* @since 3.0
+ * @deprecated since 3.2 unused, as listeners are no longer mapped in a
+ * DataMap.
*/
+ @Deprecated
public EntityListener getEntityListener(String className) {
for (EntityListener next : entityListeners) {
if (className.equals(next.getClassName())) {
@@ -374,9 +391,9 @@ public class ObjEntity extends Entity im
}
/**
- * Returns the type of lock used by this ObjEntity. If this entity is not locked, this
- * method would look in a super entity recursively, until it finds a lock somewhere in
- * the inheritance hierarchy.
+ * Returns the type of lock used by this ObjEntity. If this entity is not
+ * locked, this method would look in a super entity recursively, until it
+ * finds a lock somewhere in the inheritance hierarchy.
*
* @since 1.1
*/
@@ -392,8 +409,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns the type of lock used by this ObjEntity, regardless of what locking type is
- * used by super entities.
+ * Returns the type of lock used by this ObjEntity, regardless of what
+ * locking type is used by super entities.
*
* @since 1.1
*/
@@ -411,30 +428,28 @@ public class ObjEntity extends Entity im
}
/**
- * Returns whether this entity is "generic", meaning it is not mapped to a unique Java
- * class. Criterion for generic entities is that it either has no Java class mapped or
- * its class is the same as DataMap's default superclass, or it is CayenneDataObject.
+ * Returns whether this entity is "generic", meaning it is not mapped to a
+ * unique Java class. Criterion for generic entities is that it either has
+ * no Java class mapped or its class is the same as DataMap's default
+ * superclass, or it is CayenneDataObject.
*
* @since 1.2
*/
public boolean isGeneric() {
String className = getClassName();
- return className == null
- || DEFAULT_GENERIC_CLASSES.contains(className)
- || (getDataMap() != null && className.equals(getDataMap()
- .getDefaultSuperclass()));
+ return className == null || DEFAULT_GENERIC_CLASSES.contains(className)
+ || (getDataMap() != null && className.equals(getDataMap().getDefaultSuperclass()));
}
/**
- * Returns true if this entity is allowed to be used on the client. Checks that parent
- * DataMap allows client entities and also that this entity is not explicitly disabled
- * for the client use.
+ * Returns true if this entity is allowed to be used on the client. Checks
+ * that parent DataMap allows client entities and also that this entity is
+ * not explicitly disabled for the client use.
*
* @since 1.2
*/
public boolean isClientAllowed() {
- return (getDataMap() == null || isServerOnly()) ? false : getDataMap()
- .isClientSupported();
+ return (getDataMap() == null || isServerOnly()) ? false : getDataMap().isClientSupported();
}
public boolean isAbstract() {
@@ -467,9 +482,9 @@ public class ObjEntity extends Entity im
}
/**
- * Returns a qualifier that imposes a restriction on what objects belong to this
- * entity. Returned qualifier is the one declared in this entity, and does not include
- * qualifiers declared in super entities.
+ * Returns a qualifier that imposes a restriction on what objects belong to
+ * this entity. Returned qualifier is the one declared in this entity, and
+ * does not include qualifiers declared in super entities.
*
* @since 1.1
*/
@@ -487,7 +502,8 @@ public class ObjEntity extends Entity im
}
/**
- * Sets a qualifier that imposes a limit on what objects belong to this entity.
+ * Sets a qualifier that imposes a limit on what objects belong to this
+ * entity.
*
* @since 1.1
*/
@@ -537,9 +553,9 @@ public class ObjEntity extends Entity im
}
/**
- * Returns a fully-qualified name of the super class of the DataObject class. This
- * value is used as a hint for class generation. If the entity inherits from another
- * entity, a superclass is the class of that entity.
+ * Returns a fully-qualified name of the super class of the DataObject
+ * class. This value is used as a hint for class generation. If the entity
+ * inherits from another entity, a superclass is the class of that entity.
*/
public String getSuperClassName() {
ObjEntity superEntity = getSuperEntity();
@@ -547,11 +563,11 @@ public class ObjEntity extends Entity im
}
/**
- * Sets a fully-qualified name of the super class of the DataObject class. This value
- * is used as a hint for class generation.
+ * Sets a fully-qualified name of the super class of the DataObject class.
+ * This value is used as a hint for class generation.
* <p>
- * <i>An attempt to set superclass on an inherited entity has no effect, since a class
- * of the super entity is always used as a superclass.</i>
+ * <i>An attempt to set superclass on an inherited entity has no effect,
+ * since a class of the super entity is always used as a superclass.</i>
* </p>
*/
public void setSuperClassName(String superClassName) {
@@ -559,25 +575,25 @@ public class ObjEntity extends Entity im
}
/**
- * Returns a fully-qualified name of the client-side super class of the DataObject
- * class. This value is used as a hint for class generation. If the entity inherits
- * from another entity, a superclass is the class of that entity.
+ * Returns a fully-qualified name of the client-side super class of the
+ * DataObject class. This value is used as a hint for class generation. If
+ * the entity inherits from another entity, a superclass is the class of
+ * that entity.
*
* @since 1.2
*/
public String getClientSuperClassName() {
ObjEntity superEntity = getSuperEntity();
- return (superEntity != null)
- ? superEntity.getClientClassName()
- : clientSuperClassName;
+ return (superEntity != null) ? superEntity.getClientClassName() : clientSuperClassName;
}
/**
- * Sets a fully-qualified name of the client-side super class of the ClientDataObject
- * class. This value is used as a hint for class generation.
+ * Sets a fully-qualified name of the client-side super class of the
+ * ClientDataObject class. This value is used as a hint for class
+ * generation.
* <p>
- * <i>An attempt to set superclass on an inherited entity has no effect, since a class
- * of the super entity is always used as a superclass. </i>
+ * <i>An attempt to set superclass on an inherited entity has no effect,
+ * since a class of the super entity is always used as a superclass. </i>
* </p>
*
* @since 1.2
@@ -592,8 +608,7 @@ public class ObjEntity extends Entity im
* @since 1.1
*/
public ObjEntity getSuperEntity() {
- return (superEntityName != null) ? getNonNullNamespace().getObjEntity(
- superEntityName) : null;
+ return (superEntityName != null) ? getNonNullNamespace().getObjEntity(superEntityName) : null;
}
/**
@@ -617,8 +632,8 @@ public class ObjEntity extends Entity im
/**
* Sets the DbEntity used by this ObjEntity.
* <p>
- * <i>Setting DbEntity on an inherited entity has no effect, since a class of the
- * super entity is always used as a superclass. </i>
+ * <i>Setting DbEntity on an inherited entity has no effect, since a class
+ * of the super entity is always used as a superclass. </i>
* </p>
*/
public void setDbEntity(DbEntity dbEntity) {
@@ -626,11 +641,11 @@ public class ObjEntity extends Entity im
}
/**
- * Returns an unmodifiable collection of ObjAttributes representing the primary key of
- * the table described by this DbEntity. Note that since PK is very often not an
- * object property, the returned collection may contain "synthetic" ObjAttributes that
- * are created on the fly and are not a part of ObjEntity and will not be a part of
- * entity.getAttributes().
+ * Returns an unmodifiable collection of ObjAttributes representing the
+ * primary key of the table described by this DbEntity. Note that since PK
+ * is very often not an object property, the returned collection may contain
+ * "synthetic" ObjAttributes that are created on the fly and are not a part
+ * of ObjEntity and will not be a part of entity.getAttributes().
*
* @since 3.0
*/
@@ -644,17 +659,14 @@ public class ObjEntity extends Entity im
}
Collection<DbAttribute> pkAttributes = getDbEntity().getPrimaryKeys();
- Collection<ObjAttribute> attributes = new ArrayList<ObjAttribute>(pkAttributes
- .size());
+ Collection<ObjAttribute> attributes = new ArrayList<ObjAttribute>(pkAttributes.size());
for (DbAttribute pk : pkAttributes) {
ObjAttribute attribute = getAttributeForDbAttribute(pk);
// create synthetic attribute
if (attribute == null) {
- attribute = new SyntheticPKObjAttribute(NameConverter.underscoredToJava(
- pk.getName(),
- false));
+ attribute = new SyntheticPKObjAttribute(NameConverter.underscoredToJava(pk.getName(), false));
attribute.setDbAttributePath(pk.getName());
attribute.setType(TypesMapping.getJavaBySqlType(pk.getType()));
}
@@ -667,8 +679,8 @@ public class ObjEntity extends Entity im
/**
* Returns a named attribute that is either declared in this ObjEntity or is
- * inherited. In any case returned attribute 'getEntity' method will return this
- * entity. Returns null if no matching attribute is found.
+ * inherited. In any case returned attribute 'getEntity' method will return
+ * this entity. Returns null if no matching attribute is found.
*/
@Override
public Attribute getAttribute(String name) {
@@ -682,8 +694,7 @@ public class ObjEntity extends Entity im
if (dot > 0 && dot < name.length() - 1) {
Attribute embedded = getAttribute(name.substring(0, dot));
if (embedded instanceof EmbeddedAttribute) {
- return ((EmbeddedAttribute) embedded).getAttribute(name
- .substring(dot + 1));
+ return ((EmbeddedAttribute) embedded).getAttribute(name.substring(dot + 1));
}
}
@@ -696,7 +707,8 @@ public class ObjEntity extends Entity im
return null;
}
- // decorate returned attribute to make it appear as if it belongs to this
+ // decorate returned attribute to make it appear as if it belongs to
+ // this
// entity
ObjAttribute decoratedAttribute = new ObjAttribute(superAttribute);
@@ -714,8 +726,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns a SortedMap of all attributes that either belong to this ObjEntity or
- * inherited.
+ * Returns a SortedMap of all attributes that either belong to this
+ * ObjEntity or inherited.
*/
@Override
public SortedMap<String, ObjAttribute> getAttributeMap() {
@@ -767,8 +779,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns a Collection of all attributes that either belong to this ObjEntity or
- * inherited.
+ * Returns a Collection of all attributes that either belong to this
+ * ObjEntity or inherited.
*/
@Override
public Collection<ObjAttribute> getAttributes() {
@@ -780,8 +792,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns a Collection of all attributes that belong to this ObjEntity, excluding
- * inherited attributes.
+ * Returns a Collection of all attributes that belong to this ObjEntity,
+ * excluding inherited attributes.
*
* @since 1.1
*/
@@ -790,8 +802,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns a named Relationship that either belongs to this ObjEntity or is inherited.
- * Returns null if no matching attribute is found.
+ * Returns a named Relationship that either belongs to this ObjEntity or is
+ * inherited. Returns null if no matching attribute is found.
*/
@Override
public Relationship getRelationship(String name) {
@@ -820,7 +832,8 @@ public class ObjEntity extends Entity im
}
/**
- * Recursively appends all relationships in the entity inheritance hierarchy.
+ * Recursively appends all relationships in the entity inheritance
+ * hierarchy.
*/
final void appendRelationships(Map<String, ObjRelationship> map) {
map.putAll((Map<String, ObjRelationship>) super.getRelationshipMap());
@@ -841,8 +854,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns a Collection of all relationships that belong to this ObjEntity, excluding
- * inherited attributes.
+ * Returns a Collection of all relationships that belong to this ObjEntity,
+ * excluding inherited attributes.
*
* @since 1.1
*/
@@ -864,8 +877,7 @@ public class ObjEntity extends Entity im
if (embeddedAttribute != null) {
return embeddedAttribute;
}
- }
- else {
+ } else {
ObjAttribute objAttr = (ObjAttribute) next;
if (objAttr.getDbAttribute() == dbAttribute) {
return objAttr;
@@ -877,8 +889,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns the names of DbAtributes that comprise the primary key of the parent
- * DbEntity.
+ * Returns the names of DbAtributes that comprise the primary key of the
+ * parent DbEntity.
*
* @since 3.0
*/
@@ -901,8 +913,9 @@ public class ObjEntity extends Entity im
}
/**
- * Returns ObjRelationship of this entity that maps to <code>dbRelationship</code>
- * parameter. Returns null if no such relationship is found.
+ * Returns ObjRelationship of this entity that maps to
+ * <code>dbRelationship</code> parameter. Returns null if no such
+ * relationship is found.
*/
public ObjRelationship getRelationshipForDbRelationship(DbRelationship dbRelationship) {
@@ -920,8 +933,8 @@ public class ObjEntity extends Entity im
}
/**
- * Clears all the mapping between this obj entity and its current db entity. Clears
- * mapping between entities, attributes and relationships.
+ * Clears all the mapping between this obj entity and its current db entity.
+ * Clears mapping between entities, attributes and relationships.
*/
public void clearDbMapping() {
if (dbEntityName == null)
@@ -943,7 +956,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns <code>true</code> if this ObjEntity represents a set of read-only objects.
+ * Returns <code>true</code> if this ObjEntity represents a set of read-only
+ * objects.
*
* @return boolean
*/
@@ -956,8 +970,8 @@ public class ObjEntity extends Entity im
}
/**
- * Returns true if this entity directly or indirectly inherits from a given entity,
- * false otherwise.
+ * Returns true if this entity directly or indirectly inherits from a given
+ * entity, false otherwise.
*
* @since 1.1
*/
@@ -983,21 +997,19 @@ public class ObjEntity extends Entity im
*/
@Override
@SuppressWarnings("unchecked")
- public PathComponent<ObjAttribute, ObjRelationship> lastPathComponent(
- Expression path,
- Map aliasMap) {
+ public PathComponent<ObjAttribute, ObjRelationship> lastPathComponent(Expression path, Map aliasMap) {
return super.lastPathComponent(path, aliasMap);
}
/**
- * Returns an Iterable instance over expression path components based on this entity.
+ * Returns an Iterable instance over expression path components based on
+ * this entity.
*
* @since 3.0
*/
@Override
@SuppressWarnings("unchecked")
- public Iterable<PathComponent<ObjAttribute, ObjRelationship>> resolvePath(
- final Expression pathExp,
+ public Iterable<PathComponent<ObjAttribute, ObjRelationship>> resolvePath(final Expression pathExp,
final Map aliasMap) {
if (pathExp.getType() == Expression.OBJ_PATH) {
@@ -1005,27 +1017,21 @@ public class ObjEntity extends Entity im
return new Iterable<PathComponent<ObjAttribute, ObjRelationship>>() {
public Iterator iterator() {
- return new PathComponentIterator(ObjEntity.this, (String) pathExp
- .getOperand(0), aliasMap);
+ return new PathComponentIterator(ObjEntity.this, (String) pathExp.getOperand(0), aliasMap);
}
};
}
- throw new ExpressionException("Invalid expression type: '"
- + pathExp.expName()
- + "', OBJ_PATH is expected.");
+ throw new ExpressionException("Invalid expression type: '" + pathExp.expName() + "', OBJ_PATH is expected.");
}
@Override
- public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp)
- throws ExpressionException {
+ public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp) throws ExpressionException {
// resolve DB_PATH if we can
if (pathExp.getType() == Expression.DB_PATH) {
if (getDbEntity() == null) {
- throw new ExpressionException("Can't resolve DB_PATH '"
- + pathExp
- + "', DbEntity is not set.");
+ throw new ExpressionException("Can't resolve DB_PATH '" + pathExp + "', DbEntity is not set.");
}
return getDbEntity().resolvePathComponents(pathExp);
@@ -1035,14 +1041,12 @@ public class ObjEntity extends Entity im
return new PathIterator((String) pathExp.getOperand(0));
}
- throw new ExpressionException("Invalid expression type: '"
- + pathExp.expName()
- + "', OBJ_PATH is expected.");
+ throw new ExpressionException("Invalid expression type: '" + pathExp.expName() + "', OBJ_PATH is expected.");
}
/**
- * Transforms an Expression to an analogous expression in terms of the underlying
- * DbEntity.
+ * Transforms an Expression to an analogous expression in terms of the
+ * underlying DbEntity.
*
* @since 1.1
*/
@@ -1053,10 +1057,8 @@ public class ObjEntity extends Entity im
}
if (getDbEntity() == null) {
- throw new CayenneRuntimeException(
- "Can't translate expression to DB_PATH, no DbEntity for '"
- + getName()
- + "'.");
+ throw new CayenneRuntimeException("Can't translate expression to DB_PATH, no DbEntity for '" + getName()
+ + "'.");
}
// converts all OBJ_PATH expressions to DB_PATH expressions
@@ -1065,15 +1067,13 @@ public class ObjEntity extends Entity im
}
/**
- * Transforms an Expression rooted in this entity to an analogous expression rooted in
- * related entity.
+ * Transforms an Expression rooted in this entity to an analogous expression
+ * rooted in related entity.
*
* @since 1.1
*/
@Override
- public Expression translateToRelatedEntity(
- Expression expression,
- String relationshipPath) {
+ public Expression translateToRelatedEntity(Expression expression, String relationshipPath) {
if (expression == null) {
return null;
@@ -1084,8 +1084,7 @@ public class ObjEntity extends Entity im
}
if (getDbEntity() == null) {
- throw new CayenneRuntimeException(
- "Can't transform expression, no DbEntity for '" + getName() + "'.");
+ throw new CayenneRuntimeException("Can't transform expression, no DbEntity for '" + getName() + "'.");
}
// converts all OBJ_PATH expressions to DB_PATH expressions
@@ -1098,17 +1097,22 @@ public class ObjEntity extends Entity im
return getDbEntity().translateToRelatedEntity(dbClone, dbPath);
}
-
+
private PathComponentIterator createPathIterator(String path) {
- return new PathComponentIterator(ObjEntity.this, path,
- new HashMap<String, String>()); //TODO: do we need aliases here?
+ return new PathComponentIterator(ObjEntity.this, path, new HashMap<String, String>()); // TODO:
+ // do
+ // we
+ // need
+ // aliases
+ // here?
}
final class DBPathConverter implements Transformer {
- // TODO: make it a public method - resolveDBPathComponents or something...
+ // TODO: make it a public method - resolveDBPathComponents or
+ // something...
// seems generally useful
-
+
String toDbPath(PathComponentIterator objectPathComponents) {
StringBuilder buf = new StringBuilder();
while (objectPathComponents.hasNext()) {
@@ -1118,15 +1122,10 @@ public class ObjEntity extends Entity im
if (component.getAttribute() != null) {
dbSubpath = ((ObjAttribute) component.getAttribute()).getDbPathIterator();
- }
- else if (component.getRelationship() != null) {
- dbSubpath = ((ObjRelationship) component.getRelationship())
- .getDbRelationships()
- .iterator();
- }
- else {
- throw new CayenneRuntimeException("Unknown path component: "
- + component);
+ } else if (component.getRelationship() != null) {
+ dbSubpath = ((ObjRelationship) component.getRelationship()).getDbRelationships().iterator();
+ } else {
+ throw new CayenneRuntimeException("Unknown path component: " + component);
}
boolean firstComponent = true;
@@ -1187,9 +1186,9 @@ public class ObjEntity extends Entity im
}
/**
- * ObjEntity property changed. May be name, attribute or relationship added or
- * removed, etc. Attribute and relationship property changes are handled in respective
- * listeners.
+ * ObjEntity property changed. May be name, attribute or relationship added
+ * or removed, etc. Attribute and relationship property changes are handled
+ * in respective listeners.
*
* @since 1.2
*/
@@ -1208,10 +1207,8 @@ public class ObjEntity extends Entity im
if (map != null) {
ObjEntity oe = (ObjEntity) e.getEntity();
for (Relationship relationship : oe.getRelationships()) {
- relationship = ((ObjRelationship) relationship)
- .getReverseRelationship();
- if (null != relationship
- && relationship.targetEntityName.equals(oldName)) {
+ relationship = ((ObjRelationship) relationship).getReverseRelationship();
+ if (null != relationship && relationship.targetEntityName.equals(oldName)) {
relationship.targetEntityName = newName;
}
}
@@ -1230,29 +1227,45 @@ public class ObjEntity extends Entity im
}
/**
- * Returns true if the default lifecycle listeners should not be notified of this
- * entity lifecycle events.
+ * Returns true if the default lifecycle listeners should not be notified of
+ * this entity lifecycle events.
*
* @since 3.0
+ * @deprecated since 3.2 unused, as listeners are no longer mapped in a
+ * DataMap.
*/
+ @Deprecated
public boolean isExcludingDefaultListeners() {
return excludingDefaultListeners;
}
+ /**
+ * @deprecated since 3.2 unused, as listeners are no longer mapped in a
+ * DataMap.
+ */
+ @Deprecated
public void setExcludingDefaultListeners(boolean excludingDefaultListeners) {
this.excludingDefaultListeners = excludingDefaultListeners;
}
/**
- * Returns true if the lifeycle listeners defined on the superclasses should not be
- * notified of this entity lifecycle events.
+ * Returns true if the lifeycle listeners defined on the superclasses should
+ * not be notified of this entity lifecycle events.
*
* @since 3.0
+ * @deprecated since 3.2 unused, as listeners are no longer mapped in a
+ * DataMap.
*/
+ @Deprecated
public boolean isExcludingSuperclassListeners() {
return excludingSuperclassListeners;
}
+ /**
+ * @deprecated since 3.2 unused, as listeners are no longer mapped in a
+ * DataMap.
+ */
+ @Deprecated
public void setExcludingSuperclassListeners(boolean excludingSuperclassListeners) {
this.excludingSuperclassListeners = excludingSuperclassListeners;
}