java.lang.Object
org.tentackle.model.impl.RelationImpl
- All Implemented Interfaces:
Cloneable
,Comparable<RelationImpl>
,ModelElement
,Relation
Relation implementation.
- Author:
- harald
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
property args = ...static final String
add blunt method to interface.static final String
cached selection flag.static final String
cascade delete flag.static final String
property comment = ...static final String
composite relation flag.static final String
property count = ...static final String
property default (if object non-composite lazy).static final String
property delete = ...static final String
sets the relation to immutable after loading.static final String
property link = ...static final String
property method = ...static final String
property name = ...static final String
property nm = ...static final String
readonly + writeonly.static final String
add toString value to the partOfNormText.static final String
property prefix = ...static final String
processed relation flag.static final String
readonly relation flag.static final String
referenced relation flag.static final String
property relation = ...static final String
clear-on-remote-save relation flag.static final String
map list relation to reversed 1:1 object relation.static final String
property scope = ...static final String
property select = ...static final String
serialized relation flag.static final String
skip relation in snapshots or copies.static final String
tracked relation flag.static final String
writeonly relation flag. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected RelationImpl
clone()
int
createEmbedded
(Entity embeddingEntity, String pathName, String columnPrefixPath) Creates an embedded copy of this relation.createModelException
(String message) Creates a model exception.createModelException
(String message, Throwable cause) Creates a model exception.boolean
Gets the access scope for generated methods.Gets the list of annotations.
Annotations start with an @.Gets the associated attribute.Gets the name of the related class.Gets the prefix for the column names.
Only applicable to embedded entities!Gets the column prefix path for embedded relations.Gets the comment.Returns the attribute that holds the number of elements of a 1:N relation.
Applies only to composite non-reversed list relations.
If set, this column gets the number of elements in the list when the PDO is persisted.getDeclaredJavaType
(boolean withinForeignEntity) Gets the declared java type of the relation.Gets the relation of the entity defining the nm-relation.Gets the embedding entity.
Please notice that the embedding entity is determined by the specific relation path, andRelation.isEmbedded()
just means that the relation is part of an embeddable entity.Gets the path of embedding entities.
The first entity is non-embedded.Gets the entity this relation belongs to.Gets the foreign attribute.Gets the related entity.Gets the foreign (opposite) relation.Gets the getter method name.Gets the comment line for getter and setter.Gets the effective java type of the relation.Returns the optional link method index parameter.Gets the name for the link method.Gets the effective method arguments for select- and delete-methods.Gets the name-part for select- and delete-methods.Gets the suffix to be used in method names.getName()
Gets the name of this relation.
If no explicit name set, it defaults to the className.Same asRelation.getMethodName()
but for nm relation.Gets the name of the nm-relation.Gets the N:M relation of the foreign entity.Gets the access scope for the nm-method.
Defaults to the access scope of the relation.int
Gets the ordinal along the inheritance path.Gets the parent element.Gets the pathname.
The pathname is identical to the java name for non-embedded relations.
For embedded entities, the pathname consists of the dotted path from the parent entity to the embedded attribute.Gets the relation type.Gets the selection type.Gets the optional wurblet arguments.
Only available for composite list relations.Gets the setter method name.Gets the information about the source where this element is defined.Gets the source line.Gets the list of custom stereotypes.Gets the variable name.int
hashCode()
boolean
Returns whether the blunt-method becomes part if the interface.boolean
Returns whether the relation should be cleared before save.
Used for non-composite serialized relations that should not be transmitted to the server.boolean
Returns whether the relation points to components of a composite.boolean
Returns whether this relation is a deep reference.
Deep references point to components of another composite entity.boolean
Returns whether deletion is cascaded to elements in lists.boolean
Returns whether delete method is invoked on main class instead of relation class.boolean
Returns whether the relation belongs to an embedded entity.boolean
Returns whether the relation points to an embedded entity.boolean
Returns whether the relation should be set to immutable after loading.boolean
Returns whether the relation becomes part of the normtext.boolean
Returns whether a process-method is invoked after initialization, select and before save.
The method has the same name as the getter with "get" replaced by "process" and must be provided by the application.
This flag applies to composite relations only.boolean
Returns whether the relation is read only.boolean
Returns whether the parent object is referenced by a variable.boolean
Returns whether this is list relation with only one element.
A.k.a. reversed 1:1 object relation.boolean
Returns whether the select method is a caching one.boolean
Returns whether selection type was determined by rule.boolean
Returns whether the relation is serialized.
Used for non-composite relations to make them non-transient.boolean
Returns whether the relation should be skipped in snapshot and copy operations.boolean
Returns whether the modification state of the relation is available.boolean
Returns whether the relation is write-only.void
parse
(Entity entity, RelationLine line) Parses a relation line.void
setAccessScope
(AccessScope accessScope) void
setAnnotations
(List<String> annotations) void
setAttribute
(Attribute attribute) void
setBluntDeclared
(boolean bluntDeclared) void
setClassName
(String className) void
setClearOnRemoteSave
(boolean clearOnRemoteSave) void
setColumnPrefix
(String columnPrefix) void
setComment
(String comment) void
setComposite
(boolean composite) void
setCountAttribute
(Attribute countAttribute) void
setDeepReference
(boolean deepReference) void
setDefiningNmRelation
(Relation definingNmRelation) void
setDeletionCascaded
(boolean deletionCascaded) void
setDeletionFromMainClass
(boolean deletionFromMainClass) void
setForeignAttribute
(Attribute foreignAttribute) void
setForeignEntity
(Entity foreignEntity) void
setForeignRelation
(Relation foreignRelation) void
setImmutable
(boolean immutable) void
setLinkMethodIndex
(String linkMethodIndex) void
setLinkMethodName
(String linkMethodName) void
setMethodArgs
(List<MethodArgument> methodArgs) void
setMethodName
(String methodName) void
void
setNmMethodName
(String nmMethodName) void
void
setNmRelation
(Relation nmRelation) void
setNmScope
(AccessScope nmScope) void
setOrdinal
(int ordinal) void
setPartOfNormText
(boolean partOfNormText) void
setProcessed
(boolean processed) void
setReadOnly
(boolean readOnly) void
setReferenced
(boolean referenced) void
setRelationType
(RelationType relationType) void
setReversed
(boolean reversed) void
setSelectionCached
(boolean selectionCached) void
setSelectionType
(SelectionType selectionType) void
setSelectionTypeDetermined
(boolean selectionTypeDetermined) void
setSelectionWurbletArguments
(String selectionWurbletArguments) void
setSerialized
(boolean serialized) void
setShallow
(boolean shallow) void
setSourceLine
(RelationLine sourceLine) Sets the source line.void
setStereotypes
(List<String> stereotypes) void
setTracked
(boolean tracked) void
setWriteOnly
(boolean writeOnly) toString()
void
validate()
Validates the relation.
-
Field Details
-
DEFAULT
property default (if object non-composite lazy).- See Also:
-
RELATION
property relation = ...- See Also:
-
SELECT
property select = ...- See Also:
-
DELETE
property delete = ...- See Also:
-
LINK
property link = ...- See Also:
-
ARGS
property args = ...- See Also:
-
NM
property nm = ...- See Also:
-
METHOD
property method = ...- See Also:
-
NAME
property name = ...- See Also:
-
PREFIX
property prefix = ...- See Also:
-
SCOPE
property scope = ...- See Also:
-
COMMENT
property comment = ...- See Also:
-
COUNT
property count = ...- See Also:
-
COMPOSITE
composite relation flag.- See Also:
-
TRACKED
tracked relation flag.- See Also:
-
REFERENCED
referenced relation flag.- See Also:
-
PROCESSED
processed relation flag.- See Also:
-
READONLY
readonly relation flag.- See Also:
-
WRITEONLY
writeonly relation flag.- See Also:
-
NOMETHOD
readonly + writeonly.- See Also:
-
SERIALIZED
serialized relation flag.- See Also:
-
REMOTECLEAR
clear-on-remote-save relation flag.- See Also:
-
REVERSED
map list relation to reversed 1:1 object relation.- See Also:
-
SHALLOW
skip relation in snapshots or copies.- See Also:
-
IMMUTABLE
sets the relation to immutable after loading.- See Also:
-
PART_OF_NORMTEXT
add toString value to the partOfNormText.- See Also:
-
BLUNT_DECLARED
add blunt method to interface.- See Also:
-
CACHED
cached selection flag.- See Also:
-
CASCADE
cascade delete flag.- See Also:
-
-
Constructor Details
-
RelationImpl
Creates a relation.- Parameters:
entity
- the entity this relation belongs tosourceInfo
- the source info
-
-
Method Details
-
createEmbedded
public RelationImpl createEmbedded(Entity embeddingEntity, String pathName, String columnPrefixPath) Description copied from interface:Relation
Creates an embedded copy of this relation.- Specified by:
createEmbedded
in interfaceRelation
- Parameters:
embeddingEntity
- the embedding entitypathName
- the logical pathnamecolumnPrefixPath
- the column prefix path- Returns:
- the created relation
-
clone
-
getSourceInfo
Description copied from interface:ModelElement
Gets the information about the source where this element is defined.- Specified by:
getSourceInfo
in interfaceModelElement
- Returns:
- the source info
-
getParent
Description copied from interface:ModelElement
Gets the parent element.- Specified by:
getParent
in interfaceModelElement
- Returns:
- the parent, null if none
-
getOrdinal
public int getOrdinal()Description copied from interface:ModelElement
Gets the ordinal along the inheritance path.- Specified by:
getOrdinal
in interfaceModelElement
- Returns:
- the ordinal, starting at 0
-
setOrdinal
public void setOrdinal(int ordinal) -
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<RelationImpl>
-
parse
Parses a relation line.- Parameters:
entity
- the entityline
- the source line- Throws:
ModelException
- if parsing the model failed
-
getEntity
Description copied from interface:Relation
Gets the entity this relation belongs to. -
getEmbeddingEntity
Description copied from interface:Relation
Gets the embedding entity.
Please notice that the embedding entity is determined by the specific relation path, andRelation.isEmbedded()
just means that the relation is part of an embeddable entity.- Specified by:
getEmbeddingEntity
in interfaceRelation
- Returns:
- the embedding entity, null if not an embedded relation
-
getEmbeddingPath
Description copied from interface:Relation
Gets the path of embedding entities.
The first entity is non-embedded.- Specified by:
getEmbeddingPath
in interfaceRelation
- Returns:
- the embedding path (never empty), null if relation is not embedded
-
getPathName
Description copied from interface:Relation
Gets the pathname.
The pathname is identical to the java name for non-embedded relations.
For embedded entities, the pathname consists of the dotted path from the parent entity to the embedded attribute.- Specified by:
getPathName
in interfaceRelation
- Returns:
- the pathname
-
getColumnPrefixPath
Description copied from interface:Relation
Gets the column prefix path for embedded relations.- Specified by:
getColumnPrefixPath
in interfaceRelation
- Returns:
- the column path, null if not embedded
-
getAnnotations
Description copied from interface:Relation
Gets the list of annotations.
Annotations start with an @. By default, they are applied to the getters of the interfaces only. However, the at-sign may be followed by one or two modifiers that changes the code generation:=
: annotate setter only.+
: annotate setter and getter.~
: annotation is hidden, i.e. applied to the implementations instead of the interfaces.
@=~MyAnno
will be applied to the implementation of the setter only.- Specified by:
getAnnotations
in interfaceRelation
- Returns:
- the annotations
-
setAnnotations
-
getStereotypes
Description copied from interface:Relation
Gets the list of custom stereotypes.- Specified by:
getStereotypes
in interfaceRelation
- Returns:
- the stereotypes
-
setStereotypes
-
isSelectionTypeDetermined
public boolean isSelectionTypeDetermined()Returns whether selection type was determined by rule.- Returns:
- false if provided by the model, true if by automatic rule
-
setSelectionTypeDetermined
public void setSelectionTypeDetermined(boolean selectionTypeDetermined) -
getGetterSetterComment
Description copied from interface:Relation
Gets the comment line for getter and setter.- Specified by:
getGetterSetterComment
in interfaceRelation
- Returns:
- the comment
-
toString
-
validate
Description copied from interface:Relation
Validates the relation.- Specified by:
validate
in interfaceRelation
- Throws:
ModelException
- if validation failed
-
getName
Gets the name of this relation.
If no explicit name set, it defaults to the className.- Specified by:
getName
in interfaceModelElement
- Returns:
- the name
-
setName
-
getSourceLine
Gets the source line.- Returns:
- the line
-
setSourceLine
Sets the source line.- Parameters:
sourceLine
- the line
-
createModelException
Creates a model exception.Refers to the source line if set, otherwise just the message.
- Parameters:
message
- the message- Returns:
- the exception
-
createModelException
Creates a model exception.Refers to the source line if set, otherwise just the message.
- Parameters:
message
- the messagecause
- the cause- Returns:
- the exception
-
getComment
Description copied from interface:Relation
Gets the comment.- Specified by:
getComment
in interfaceRelation
- Returns:
- the comment
-
getClassName
Description copied from interface:Relation
Gets the name of the related class.- Specified by:
getClassName
in interfaceRelation
- Returns:
- the classname
-
getRelationType
Description copied from interface:Relation
Gets the relation type.- Specified by:
getRelationType
in interfaceRelation
- Returns:
- list or object
-
getAccessScope
Description copied from interface:Relation
Gets the access scope for generated methods.- Specified by:
getAccessScope
in interfaceRelation
- Returns:
- the scope
-
getAttribute
Description copied from interface:Relation
Gets the associated attribute.- Specified by:
getAttribute
in interfaceRelation
- Returns:
- the attribute, null if ID of foreign entity
-
getForeignEntity
Description copied from interface:Relation
Gets the related entity.- Specified by:
getForeignEntity
in interfaceRelation
- Returns:
- the foreign entity
-
getForeignAttribute
Description copied from interface:Relation
Gets the foreign attribute.- Specified by:
getForeignAttribute
in interfaceRelation
- Returns:
- the attribute, null if ID of this entity
-
getForeignRelation
Description copied from interface:Relation
Gets the foreign (opposite) relation.- Specified by:
getForeignRelation
in interfaceRelation
- Returns:
- the foreign relation, null if no such relation
-
getNmRelation
Description copied from interface:Relation
Gets the N:M relation of the foreign entity.- Specified by:
getNmRelation
in interfaceRelation
- Returns:
- the nm-relation, null if this is no nm-relation
-
getDefiningNmRelation
Description copied from interface:Relation
Gets the relation of the entity defining the nm-relation.- Specified by:
getDefiningNmRelation
in interfaceRelation
- Returns:
- the defining relation
-
isComposite
public boolean isComposite()Description copied from interface:Relation
Returns whether the relation points to components of a composite.- Specified by:
isComposite
in interfaceRelation
- Returns:
- true if composite relation
-
isEmbedding
public boolean isEmbedding()Description copied from interface:Relation
Returns whether the relation points to an embedded entity.- Specified by:
isEmbedding
in interfaceRelation
- Returns:
- true if embedded 1:1 relation
-
isEmbedded
public boolean isEmbedded()Description copied from interface:Relation
Returns whether the relation belongs to an embedded entity.- Specified by:
isEmbedded
in interfaceRelation
- Returns:
- true if embedded
-
getColumnPrefix
Description copied from interface:Relation
Gets the prefix for the column names.
Only applicable to embedded entities!- Specified by:
getColumnPrefix
in interfaceRelation
- Returns:
- the column name prefix
-
isTracked
public boolean isTracked()Description copied from interface:Relation
Returns whether the modification state of the relation is available. -
isReferenced
public boolean isReferenced()Description copied from interface:Relation
Returns whether the parent object is referenced by a variable.- Specified by:
isReferenced
in interfaceRelation
- Returns:
- true if referenced
-
isProcessed
public boolean isProcessed()Description copied from interface:Relation
Returns whether a process-method is invoked after initialization, select and before save.
The method has the same name as the getter with "get" replaced by "process" and must be provided by the application.
This flag applies to composite relations only.- Specified by:
isProcessed
in interfaceRelation
- Returns:
- true if processed
-
isReadOnly
public boolean isReadOnly()Description copied from interface:Relation
Returns whether the relation is read only.- Specified by:
isReadOnly
in interfaceRelation
- Returns:
- true if no setter method
-
isWriteOnly
public boolean isWriteOnly()Description copied from interface:Relation
Returns whether the relation is write-only.- Specified by:
isWriteOnly
in interfaceRelation
- Returns:
- true if no getter method
-
isSerialized
public boolean isSerialized()Description copied from interface:Relation
Returns whether the relation is serialized.
Used for non-composite relations to make them non-transient.- Specified by:
isSerialized
in interfaceRelation
- Returns:
- true if serialized, false if transient
-
isClearOnRemoteSave
public boolean isClearOnRemoteSave()Description copied from interface:Relation
Returns whether the relation should be cleared before save.
Used for non-composite serialized relations that should not be transmitted to the server.- Specified by:
isClearOnRemoteSave
in interfaceRelation
- Returns:
- true if transient on save
-
isReversed
public boolean isReversed()Description copied from interface:Relation
Returns whether this is list relation with only one element.
A.k.a. reversed 1:1 object relation.- Specified by:
isReversed
in interfaceRelation
- Returns:
- true if reversed
-
isShallow
public boolean isShallow()Description copied from interface:Relation
Returns whether the relation should be skipped in snapshot and copy operations. -
setShallow
public void setShallow(boolean shallow) -
isImmutable
public boolean isImmutable()Description copied from interface:Relation
Returns whether the relation should be set to immutable after loading.- Specified by:
isImmutable
in interfaceRelation
- Returns:
- true if immutable
-
setImmutable
public void setImmutable(boolean immutable) -
isPartOfNormText
public boolean isPartOfNormText()Description copied from interface:Relation
Returns whether the relation becomes part of the normtext.- Specified by:
isPartOfNormText
in interfaceRelation
- Returns:
- true if add to normtext
-
setPartOfNormText
public void setPartOfNormText(boolean partOfNormText) -
isBluntDeclared
public boolean isBluntDeclared()Description copied from interface:Relation
Returns whether the blunt-method becomes part if the interface.- Specified by:
isBluntDeclared
in interfaceRelation
- Returns:
- true if declared in interface, false if only implementation generated
-
setBluntDeclared
public void setBluntDeclared(boolean bluntDeclared) -
getCountAttribute
Description copied from interface:Relation
Returns the attribute that holds the number of elements of a 1:N relation.
Applies only to composite non-reversed list relations.
If set, this column gets the number of elements in the list when the PDO is persisted. This avoids an initial select when the list is accessed the first time and the list is empty.- Specified by:
getCountAttribute
in interfaceRelation
- Returns:
- the counter attribute, null if none
-
getMethodName
Description copied from interface:Relation
Gets the name-part for select- and delete-methods.- Specified by:
getMethodName
in interfaceRelation
- Returns:
- the method name, null if default from foreign entity name
-
getMethodArgs
Description copied from interface:Relation
Gets the effective method arguments for select- and delete-methods.- Specified by:
getMethodArgs
in interfaceRelation
- Returns:
- the args, never null, at least 1 element
-
getNmName
Description copied from interface:Relation
Gets the name of the nm-relation. -
getNmMethodName
Description copied from interface:Relation
Same asRelation.getMethodName()
but for nm relation.- Specified by:
getNmMethodName
in interfaceRelation
- Returns:
- the list method name, null if default
-
getNmScope
Description copied from interface:Relation
Gets the access scope for the nm-method.
Defaults to the access scope of the relation.- Specified by:
getNmScope
in interfaceRelation
- Returns:
- the access scope, never null
-
getLinkMethodName
Description copied from interface:Relation
Gets the name for the link method.- Specified by:
getLinkMethodName
in interfaceRelation
- Returns:
- the link method, null if default
-
getLinkMethodIndex
Description copied from interface:Relation
Returns the optional link method index parameter.- Specified by:
getLinkMethodIndex
in interfaceRelation
- Returns:
- the index parameter, null if no index
-
getSelectionType
Description copied from interface:Relation
Gets the selection type.- Specified by:
getSelectionType
in interfaceRelation
- Returns:
- the selection type
-
isSelectionCached
public boolean isSelectionCached()Description copied from interface:Relation
Returns whether the select method is a caching one.- Specified by:
isSelectionCached
in interfaceRelation
- Returns:
- true if cached
-
getSelectionWurbletArguments
Description copied from interface:Relation
Gets the optional wurblet arguments.
Only available for composite list relations.- Specified by:
getSelectionWurbletArguments
in interfaceRelation
- Returns:
- the extra wurblet args
-
isDeletionFromMainClass
public boolean isDeletionFromMainClass()Description copied from interface:Relation
Returns whether delete method is invoked on main class instead of relation class.- Specified by:
isDeletionFromMainClass
in interfaceRelation
- Returns:
- true if delete from main class
-
isDeletionCascaded
public boolean isDeletionCascaded()Description copied from interface:Relation
Returns whether deletion is cascaded to elements in lists.- Specified by:
isDeletionCascaded
in interfaceRelation
- Returns:
- true if cascaded
-
setNmRelation
-
setDefiningNmRelation
-
setAttribute
-
setForeignEntity
-
setForeignAttribute
-
setForeignRelation
-
setClassName
-
setComment
-
setComposite
public void setComposite(boolean composite) -
setColumnPrefix
-
setLinkMethodName
-
setMethodArgs
-
setNmName
-
setNmMethodName
-
setNmScope
-
setMethodName
-
setReadOnly
public void setReadOnly(boolean readOnly) -
setReferenced
public void setReferenced(boolean referenced) -
setProcessed
public void setProcessed(boolean processed) -
setRelationType
-
setSerialized
public void setSerialized(boolean serialized) -
setClearOnRemoteSave
public void setClearOnRemoteSave(boolean clearOnRemoteSave) -
setReversed
public void setReversed(boolean reversed) -
setCountAttribute
-
setTracked
public void setTracked(boolean tracked) -
setWriteOnly
public void setWriteOnly(boolean writeOnly) -
setSelectionType
-
setSelectionCached
public void setSelectionCached(boolean selectionCached) -
setSelectionWurbletArguments
-
setAccessScope
-
setDeletionCascaded
public void setDeletionCascaded(boolean deletionCascaded) -
setDeletionFromMainClass
public void setDeletionFromMainClass(boolean deletionFromMainClass) -
setLinkMethodIndex
-
getVariableName
Gets the variable name.- Specified by:
getVariableName
in interfaceRelation
- Returns:
- the variable name
-
getMethodNameSuffix
Gets the suffix to be used in method names.Example:
"set" + getMethodNameSuffix() would return "setBlah" if the classname is "Blah" or the name is "blah".
- Specified by:
getMethodNameSuffix
in interfaceRelation
- Returns:
- the suffix
-
getGetterName
Description copied from interface:Relation
Gets the getter method name.- Specified by:
getGetterName
in interfaceRelation
- Returns:
- the getter
-
getSetterName
Description copied from interface:Relation
Gets the setter method name.- Specified by:
getSetterName
in interfaceRelation
- Returns:
- the setter
-
getDeclaredJavaType
Description copied from interface:Relation
Gets the declared java type of the relation.- Specified by:
getDeclaredJavaType
in interfaceRelation
- Parameters:
withinForeignEntity
- true if we need the type from within the foreign entity, else from within the relation's entity- Returns:
- the declared java type
-
getJavaType
Description copied from interface:Relation
Gets the effective java type of the relation.Example: the effective type is ArrayList and the declared type is List.
- Specified by:
getJavaType
in interfaceRelation
- Returns:
- the effective java type
-
isDeepReference
public boolean isDeepReference()Description copied from interface:Relation
Returns whether this relation is a deep reference.
Deep references point to components of another composite entity.- Specified by:
isDeepReference
in interfaceRelation
- Returns:
- true if deep reference
-
setDeepReference
public void setDeepReference(boolean deepReference)
-