|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.scooterframework.orm.activerecord.Relation
public abstract class Relation
Relation class has information about relationship between objects. There are three types of binary relations supported:
1. has-one: A has one B. 2. has-many: A has many B. 3. belongs-to: A belongs to B.For has-many-through relation, the HasManyThroughRelation subclass should be used.
| Field Summary | |
|---|---|
protected java.lang.String |
associationId
|
static java.lang.String |
BELONGS_TO_TYPE
|
static java.lang.String |
CASCADE_DELETE
Cascade key to indicate the delete of child record(s). |
static java.lang.String |
CASCADE_NONE
Cascade key to indicate no cascade effect. |
static java.lang.String |
CASCADE_NULLIFY
Cascade key to indicate the nullifying of the foreign key field in its child record(s). |
static java.lang.String |
CASCADE_SIMPLY_DELETE
Simply delete the children without triggering any actions caused by the removal of the child record such as counter decrement in its parent record. |
static java.lang.String |
HAS_MANY_THROUGH_TYPE
|
static java.lang.String |
HAS_MANY_TYPE
|
static java.lang.String |
HAS_ONE_TYPE
|
protected java.lang.String |
key
|
protected java.lang.String |
mapping
|
protected java.lang.Class<? extends ActiveRecord> |
ownerClass
|
protected java.lang.String |
ownerModel
|
protected java.util.Map<java.lang.String,java.lang.String> |
properties
|
static java.lang.String |
REVERSE_RELATION
Specifies reverse relation name. |
protected java.lang.Class<? extends ActiveRecord> |
targetClass
|
protected java.lang.String |
targetModel
|
protected java.lang.String |
type
|
| Constructor Summary | |
|---|---|
Relation(java.lang.Class<? extends ActiveRecord> ownerClass,
java.lang.String type,
java.lang.String associationId,
java.lang.String targetModel)
|
|
| Method Summary | |
|---|---|
boolean |
allowCascade(java.lang.String cascadeType)
Checks if a cascade type is allowed. |
boolean |
allowCascadeDelete()
Checks if the value of cascade property is delete. |
boolean |
allowCascadeNone()
Checks if the value of cascade property is none. |
boolean |
allowCascadeNullify()
Checks if the value of cascade property is nullify. |
boolean |
allowCascadeSimplyDelete()
Checks if the value of cascade property is simply_delete. |
java.lang.String |
getAssociation()
Returns the association target. |
java.lang.String |
getConditionsString()
Returns the conditions_sql in the property map. |
java.lang.String |
getConditionsString(java.lang.String tableName,
java.lang.String aliasTableName)
Returns the conditions_sql in the property map. |
java.lang.String[] |
getLeftSideMappingItems()
Returns an array of all strings on the left-side of the mapping. |
java.lang.String |
getMapping()
Returns the mapping string. |
java.util.Map<java.lang.String,java.lang.String> |
getMappingMap()
Returns a Map of mapping string For belongs-to relation, the key is the foreign-key column of Class A, while the corresponding value is the primary-key field of Class B. |
java.lang.Class<? extends ActiveRecord> |
getOwnerClass()
Returns owner class. |
java.lang.String |
getOwnerModel()
Returns owner model name. |
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Returns the property map. |
java.lang.String |
getRelationKey()
Returns a representation of the relation. |
java.lang.String |
getRelationType()
Returns the relation type. |
java.lang.String |
getReverseMapping()
Returns the reverse mapping. |
java.util.Map<java.lang.String,java.lang.String> |
getReverseMappingMap()
|
Relation |
getReverseRelation()
Returns reverse relation. |
java.lang.String |
getReverseRelationName()
Returns reverse relation association id. |
java.lang.String |
getReverseRelationType()
Returns the type of the reverse relation. |
java.lang.String[] |
getRightSideMappingItems()
Returns an array of all strings on the right-side of the mapping. |
java.lang.Class<? extends ActiveRecord> |
getTargetClass()
Returns target class. |
java.lang.String |
getTargetModel()
Returns target model name. |
void |
setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
Sets the property map. |
void |
setRelationKey(java.lang.String key)
Sets relation key. |
void |
setTargetClass(java.lang.Class<? extends ActiveRecord> targetClass)
Sets target class. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String BELONGS_TO_TYPE
public static final java.lang.String HAS_ONE_TYPE
public static final java.lang.String HAS_MANY_TYPE
public static final java.lang.String HAS_MANY_THROUGH_TYPE
public static final java.lang.String CASCADE_NONE
public static final java.lang.String CASCADE_NULLIFY
public static final java.lang.String CASCADE_DELETE
public static final java.lang.String CASCADE_SIMPLY_DELETE
public static final java.lang.String REVERSE_RELATION
protected java.lang.Class<? extends ActiveRecord> ownerClass
protected java.lang.String type
protected java.lang.String associationId
protected java.lang.Class<? extends ActiveRecord> targetClass
protected java.lang.String ownerModel
protected java.lang.String targetModel
protected java.lang.String mapping
protected java.util.Map<java.lang.String,java.lang.String> properties
protected java.lang.String key
| Constructor Detail |
|---|
public Relation(java.lang.Class<? extends ActiveRecord> ownerClass,
java.lang.String type,
java.lang.String associationId,
java.lang.String targetModel)
| Method Detail |
|---|
public java.lang.String getRelationType()
public java.lang.String getAssociation()
public java.lang.String getReverseRelationType()
Returns the type of the reverse relation. For has-one and has-many relations, the reverse relation type must always be of belongs-to.
To ease any confusion, it is better to state reverse relation by using the reverse key word in the properties attribute when declaring a relation.
This is mostly used by a belongs-to class to figure out if the reverse relation type is has-one or has-many.
public Relation getReverseRelation()
Returns reverse relation.
To ease any confusion, it is better to state reverse relation by using the reverse key word in the properties attribute when declaring a relation.
The reverse relation for a has-one or has-many relation is always of belongs-to type.
public java.lang.String getReverseRelationName()
Returns reverse relation association id.
To ease any confusion, it is better to state reverse relation by using the reverse key word in the properties attribute when declaring a relation.
public java.lang.Class<? extends ActiveRecord> getOwnerClass()
public java.lang.Class<? extends ActiveRecord> getTargetClass()
public void setTargetClass(java.lang.Class<? extends ActiveRecord> targetClass)
targetClass - target classpublic java.lang.String getOwnerModel()
public java.lang.String getTargetModel()
public java.lang.String getMapping()
public java.lang.String getReverseMapping()
public java.lang.String[] getLeftSideMappingItems()
public java.lang.String[] getRightSideMappingItems()
public java.util.Map<java.lang.String,java.lang.String> getMappingMap()
public java.util.Map<java.lang.String,java.lang.String> getReverseMappingMap()
public java.util.Map<java.lang.String,java.lang.String> getProperties()
public java.lang.String getConditionsString()
public java.lang.String getConditionsString(java.lang.String tableName,
java.lang.String aliasTableName)
public void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
public java.lang.String getRelationKey()
public void setRelationKey(java.lang.String key)
key - relation key stringpublic boolean allowCascadeNone()
public boolean allowCascadeNullify()
public boolean allowCascadeDelete()
public boolean allowCascadeSimplyDelete()
public boolean allowCascade(java.lang.String cascadeType)
cascadeType - a cascade type string constant
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||