java.lang.Object
org.tentackle.model.impl.RelationImpl
- All Implemented Interfaces:
Cloneable,Comparable<RelationImpl>,ModelElement,Relation
Relation implementation.
- Author:
- harald
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringproperty args = ...static final Stringadd blunt method to interface.static final Stringcached selection flag.static final Stringcascade delete flag.static final Stringproperty comment = ...static final Stringcomposite relation flag.static final Stringproperty count = ...static final Stringproperty default (if object non-composite lazy).static final Stringproperty delete = ...static final Stringsets the relation to immutable after loading.static final Stringproperty link = ...static final Stringproperty method = ...static final Stringproperty name = ...static final Stringproperty nm = ...static final Stringreadonly + writeonly.static final Stringadd toString value to the partOfNormText.static final Stringproperty prefix = ...static final Stringprocessed relation flag.static final Stringreadonly relation flag.static final Stringreferenced relation flag.static final Stringproperty relation = ...static final Stringclear-on-remote-save relation flag.static final Stringmap list relation to reversed 1:1 object relation.static final Stringproperty scope = ...static final Stringproperty select = ...static final Stringserialized relation flag.static final Stringskip relation in snapshots or copies.static final Stringtracked relation flag.static final Stringwriteonly relation flag. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected RelationImplclone()intcreateEmbedded(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.booleanGets 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.intGets 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.inthashCode()booleanReturns whether the blunt-method becomes part if the interface.booleanReturns whether the relation should be cleared before save.
Used for non-composite serialized relations that should not be transmitted to the server.booleanReturns whether the relation points to components of a composite.booleanReturns whether this relation is a deep reference.
Deep references point to components of another composite entity.booleanReturns whether deletion is cascaded to elements in lists.booleanReturns whether delete method is invoked on main class instead of relation class.booleanReturns whether the relation belongs to an embedded entity.booleanReturns whether the relation points to an embedded entity.booleanReturns whether the relation should be set to immutable after loading.booleanReturns whether the relation becomes part of the normtext.booleanReturns 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.booleanReturns whether the relation is read only.booleanReturns whether the parent object is referenced by a variable.booleanReturns whether this is list relation with only one element.
A.k.a. reversed 1:1 object relation.booleanReturns whether the select method is a caching one.booleanReturns whether selection type was determined by rule.booleanReturns whether the relation is serialized.
Used for non-composite relations to make them non-transient.booleanReturns whether the relation should be skipped in snapshot and copy operations.booleanReturns whether the modification state of the relation is available.booleanReturns whether the relation is write-only.voidparse(Entity entity, RelationLine line) Parses a relation line.voidsetAccessScope(AccessScope accessScope) voidsetAnnotations(List<String> annotations) voidsetAttribute(Attribute attribute) voidsetBluntDeclared(boolean bluntDeclared) voidsetClassName(String className) voidsetClearOnRemoteSave(boolean clearOnRemoteSave) voidsetColumnPrefix(String columnPrefix) voidsetComment(String comment) voidsetComposite(boolean composite) voidsetCountAttribute(Attribute countAttribute) voidsetDeepReference(boolean deepReference) voidsetDefiningNmRelation(Relation definingNmRelation) voidsetDeletionCascaded(boolean deletionCascaded) voidsetDeletionFromMainClass(boolean deletionFromMainClass) voidsetForeignAttribute(Attribute foreignAttribute) voidsetForeignEntity(Entity foreignEntity) voidsetForeignRelation(Relation foreignRelation) voidsetImmutable(boolean immutable) voidsetLinkMethodIndex(String linkMethodIndex) voidsetLinkMethodName(String linkMethodName) voidsetMethodArgs(List<MethodArgument> methodArgs) voidsetMethodName(String methodName) voidvoidsetNmMethodName(String nmMethodName) voidvoidsetNmRelation(Relation nmRelation) voidsetNmScope(AccessScope nmScope) voidsetOrdinal(int ordinal) voidsetPartOfNormText(boolean partOfNormText) voidsetProcessed(boolean processed) voidsetReadOnly(boolean readOnly) voidsetReferenced(boolean referenced) voidsetRelationType(RelationType relationType) voidsetReversed(boolean reversed) voidsetSelectionCached(boolean selectionCached) voidsetSelectionType(SelectionType selectionType) voidsetSelectionTypeDetermined(boolean selectionTypeDetermined) voidsetSelectionWurbletArguments(String selectionWurbletArguments) voidsetSerialized(boolean serialized) voidsetShallow(boolean shallow) voidsetSourceLine(RelationLine sourceLine) Sets the source line.voidsetStereotypes(List<String> stereotypes) voidsetTracked(boolean tracked) voidsetWriteOnly(boolean writeOnly) toString()voidvalidate()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:RelationCreates an embedded copy of this relation.- Specified by:
createEmbeddedin interfaceRelation- Parameters:
embeddingEntity- the embedding entitypathName- the logical pathnamecolumnPrefixPath- the column prefix path- Returns:
- the created relation
-
clone
-
getSourceInfo
Description copied from interface:ModelElementGets the information about the source where this element is defined.- Specified by:
getSourceInfoin interfaceModelElement- Returns:
- the source info
-
getParent
Description copied from interface:ModelElementGets the parent element.- Specified by:
getParentin interfaceModelElement- Returns:
- the parent, null if none
-
getOrdinal
public int getOrdinal()Description copied from interface:ModelElementGets the ordinal along the inheritance path.- Specified by:
getOrdinalin interfaceModelElement- Returns:
- the ordinal, starting at 0
-
setOrdinal
public void setOrdinal(int ordinal) -
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin 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:RelationGets the entity this relation belongs to. -
getEmbeddingEntity
Description copied from interface:RelationGets 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:
getEmbeddingEntityin interfaceRelation- Returns:
- the embedding entity, null if not an embedded relation
-
getEmbeddingPath
Description copied from interface:RelationGets the path of embedding entities.
The first entity is non-embedded.- Specified by:
getEmbeddingPathin interfaceRelation- Returns:
- the embedding path (never empty), null if relation is not embedded
-
getPathName
Description copied from interface:RelationGets 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:
getPathNamein interfaceRelation- Returns:
- the pathname
-
getColumnPrefixPath
Description copied from interface:RelationGets the column prefix path for embedded relations.- Specified by:
getColumnPrefixPathin interfaceRelation- Returns:
- the column path, null if not embedded
-
getAnnotations
Description copied from interface:RelationGets 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.
@=~MyAnnowill be applied to the implementation of the setter only.- Specified by:
getAnnotationsin interfaceRelation- Returns:
- the annotations
-
setAnnotations
-
getStereotypes
Description copied from interface:RelationGets the list of custom stereotypes.- Specified by:
getStereotypesin 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:RelationGets the comment line for getter and setter.- Specified by:
getGetterSetterCommentin interfaceRelation- Returns:
- the comment
-
toString
-
validate
Description copied from interface:RelationValidates the relation.- Specified by:
validatein 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:
getNamein 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:RelationGets the comment.- Specified by:
getCommentin interfaceRelation- Returns:
- the comment
-
getClassName
Description copied from interface:RelationGets the name of the related class.- Specified by:
getClassNamein interfaceRelation- Returns:
- the classname
-
getRelationType
Description copied from interface:RelationGets the relation type.- Specified by:
getRelationTypein interfaceRelation- Returns:
- list or object
-
getAccessScope
Description copied from interface:RelationGets the access scope for generated methods.- Specified by:
getAccessScopein interfaceRelation- Returns:
- the scope
-
getAttribute
Description copied from interface:RelationGets the associated attribute.- Specified by:
getAttributein interfaceRelation- Returns:
- the attribute, null if ID of foreign entity
-
getForeignEntity
Description copied from interface:RelationGets the related entity.- Specified by:
getForeignEntityin interfaceRelation- Returns:
- the foreign entity
-
getForeignAttribute
Description copied from interface:RelationGets the foreign attribute.- Specified by:
getForeignAttributein interfaceRelation- Returns:
- the attribute, null if ID of this entity
-
getForeignRelation
Description copied from interface:RelationGets the foreign (opposite) relation.- Specified by:
getForeignRelationin interfaceRelation- Returns:
- the foreign relation, null if no such relation
-
getNmRelation
Description copied from interface:RelationGets the N:M relation of the foreign entity.- Specified by:
getNmRelationin interfaceRelation- Returns:
- the nm-relation, null if this is no nm-relation
-
getDefiningNmRelation
Description copied from interface:RelationGets the relation of the entity defining the nm-relation.- Specified by:
getDefiningNmRelationin interfaceRelation- Returns:
- the defining relation
-
isComposite
public boolean isComposite()Description copied from interface:RelationReturns whether the relation points to components of a composite.- Specified by:
isCompositein interfaceRelation- Returns:
- true if composite relation
-
isEmbedding
public boolean isEmbedding()Description copied from interface:RelationReturns whether the relation points to an embedded entity.- Specified by:
isEmbeddingin interfaceRelation- Returns:
- true if embedded 1:1 relation
-
isEmbedded
public boolean isEmbedded()Description copied from interface:RelationReturns whether the relation belongs to an embedded entity.- Specified by:
isEmbeddedin interfaceRelation- Returns:
- true if embedded
-
getColumnPrefix
Description copied from interface:RelationGets the prefix for the column names.
Only applicable to embedded entities!- Specified by:
getColumnPrefixin interfaceRelation- Returns:
- the column name prefix
-
isTracked
public boolean isTracked()Description copied from interface:RelationReturns whether the modification state of the relation is available. -
isReferenced
public boolean isReferenced()Description copied from interface:RelationReturns whether the parent object is referenced by a variable.- Specified by:
isReferencedin interfaceRelation- Returns:
- true if referenced
-
isProcessed
public boolean isProcessed()Description copied from interface:RelationReturns 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:
isProcessedin interfaceRelation- Returns:
- true if processed
-
isReadOnly
public boolean isReadOnly()Description copied from interface:RelationReturns whether the relation is read only.- Specified by:
isReadOnlyin interfaceRelation- Returns:
- true if no setter method
-
isWriteOnly
public boolean isWriteOnly()Description copied from interface:RelationReturns whether the relation is write-only.- Specified by:
isWriteOnlyin interfaceRelation- Returns:
- true if no getter method
-
isSerialized
public boolean isSerialized()Description copied from interface:RelationReturns whether the relation is serialized.
Used for non-composite relations to make them non-transient.- Specified by:
isSerializedin interfaceRelation- Returns:
- true if serialized, false if transient
-
isClearOnRemoteSave
public boolean isClearOnRemoteSave()Description copied from interface:RelationReturns whether the relation should be cleared before save.
Used for non-composite serialized relations that should not be transmitted to the server.- Specified by:
isClearOnRemoteSavein interfaceRelation- Returns:
- true if transient on save
-
isReversed
public boolean isReversed()Description copied from interface:RelationReturns whether this is list relation with only one element.
A.k.a. reversed 1:1 object relation.- Specified by:
isReversedin interfaceRelation- Returns:
- true if reversed
-
isShallow
public boolean isShallow()Description copied from interface:RelationReturns 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:RelationReturns whether the relation should be set to immutable after loading.- Specified by:
isImmutablein interfaceRelation- Returns:
- true if immutable
-
setImmutable
public void setImmutable(boolean immutable) -
isPartOfNormText
public boolean isPartOfNormText()Description copied from interface:RelationReturns whether the relation becomes part of the normtext.- Specified by:
isPartOfNormTextin interfaceRelation- Returns:
- true if add to normtext
-
setPartOfNormText
public void setPartOfNormText(boolean partOfNormText) -
isBluntDeclared
public boolean isBluntDeclared()Description copied from interface:RelationReturns whether the blunt-method becomes part if the interface.- Specified by:
isBluntDeclaredin interfaceRelation- Returns:
- true if declared in interface, false if only implementation generated
-
setBluntDeclared
public void setBluntDeclared(boolean bluntDeclared) -
getCountAttribute
Description copied from interface:RelationReturns 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:
getCountAttributein interfaceRelation- Returns:
- the counter attribute, null if none
-
getMethodName
Description copied from interface:RelationGets the name-part for select- and delete-methods.- Specified by:
getMethodNamein interfaceRelation- Returns:
- the method name, null if default from foreign entity name
-
getMethodArgs
Description copied from interface:RelationGets the effective method arguments for select- and delete-methods.- Specified by:
getMethodArgsin interfaceRelation- Returns:
- the args, never null, at least 1 element
-
getNmName
Description copied from interface:RelationGets the name of the nm-relation. -
getNmMethodName
Description copied from interface:RelationSame asRelation.getMethodName()but for nm relation.- Specified by:
getNmMethodNamein interfaceRelation- Returns:
- the list method name, null if default
-
getNmScope
Description copied from interface:RelationGets the access scope for the nm-method.
Defaults to the access scope of the relation.- Specified by:
getNmScopein interfaceRelation- Returns:
- the access scope, never null
-
getLinkMethodName
Description copied from interface:RelationGets the name for the link method.- Specified by:
getLinkMethodNamein interfaceRelation- Returns:
- the link method, null if default
-
getLinkMethodIndex
Description copied from interface:RelationReturns the optional link method index parameter.- Specified by:
getLinkMethodIndexin interfaceRelation- Returns:
- the index parameter, null if no index
-
getSelectionType
Description copied from interface:RelationGets the selection type.- Specified by:
getSelectionTypein interfaceRelation- Returns:
- the selection type
-
isSelectionCached
public boolean isSelectionCached()Description copied from interface:RelationReturns whether the select method is a caching one.- Specified by:
isSelectionCachedin interfaceRelation- Returns:
- true if cached
-
getSelectionWurbletArguments
Description copied from interface:RelationGets the optional wurblet arguments.
Only available for composite list relations.- Specified by:
getSelectionWurbletArgumentsin interfaceRelation- Returns:
- the extra wurblet args
-
isDeletionFromMainClass
public boolean isDeletionFromMainClass()Description copied from interface:RelationReturns whether delete method is invoked on main class instead of relation class.- Specified by:
isDeletionFromMainClassin interfaceRelation- Returns:
- true if delete from main class
-
isDeletionCascaded
public boolean isDeletionCascaded()Description copied from interface:RelationReturns whether deletion is cascaded to elements in lists.- Specified by:
isDeletionCascadedin 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:
getVariableNamein 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:
getMethodNameSuffixin interfaceRelation- Returns:
- the suffix
-
getGetterName
Description copied from interface:RelationGets the getter method name.- Specified by:
getGetterNamein interfaceRelation- Returns:
- the getter
-
getSetterName
Description copied from interface:RelationGets the setter method name.- Specified by:
getSetterNamein interfaceRelation- Returns:
- the setter
-
getDeclaredJavaType
Description copied from interface:RelationGets the declared java type of the relation.- Specified by:
getDeclaredJavaTypein 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:RelationGets the effective java type of the relation.Example: the effective type is ArrayList and the declared type is List.
- Specified by:
getJavaTypein interfaceRelation- Returns:
- the effective java type
-
isDeepReference
public boolean isDeepReference()Description copied from interface:RelationReturns whether this relation is a deep reference.
Deep references point to components of another composite entity.- Specified by:
isDeepReferencein interfaceRelation- Returns:
- true if deep reference
-
setDeepReference
public void setDeepReference(boolean deepReference)
-