org.objectweb.jonas_ejb.deployment.api
Class EjbRelationshipRoleDesc

java.lang.Object
  extended by org.objectweb.jonas_ejb.deployment.api.EjbRelationshipRoleDesc

public class EjbRelationshipRoleDesc
extends java.lang.Object

Class to hold meta-information related to an ejb-relation-role Created on July 7, 2002

Author:
Christophe Ney [cney@batisseurs.com] : Initial developer, Helene Joanin on May 2003: code cleanup, Helene Joanin on May 2003: complement for legacy first version

Field Summary
protected  java.lang.String cmrFieldName
           
protected  java.lang.Class cmrFieldType
           
static byte INDEX
          This constant can be used to represent an index of a gen class.
protected  boolean isJOnASCMR
           
static byte MMB
           
static byte MMU
           
static byte MOB
           
static byte MOU
           
static byte OMB
           
static byte OMU
           
static byte OOB
           
static byte OOU
          Don't change these values without looking at getRelationType() !
static byte SOURCE
          This constant can be used to represent the source of the relation, ie the element which references the other.
static byte TARGET
          This constant can be used to represent the target of the relation, ie the element which is referenced by the other.
 
Constructor Summary
EjbRelationshipRoleDesc(EjbRelationDesc rd, java.lang.String name, EjbRelationshipRole role, JonasEjbRelationshipRole jrole, EjbRelationshipRole opposite, boolean isSlave, org.objectweb.util.monolog.api.Logger logger)
          constructor to be used by parent node
 
Method Summary
protected  void fillMappingInfo()
          Fills the mapping information of this relation-ship role with the values defined in jonas DD.
protected  void fillMappingInfoWithDefault()
          Fills the mapping information of this relation-ship role with default values if the mapping information is not already initialized.
 java.lang.String getCmrFieldName()
          get the name of the cmr-field.
 java.lang.Class getCmrFieldType()
          get the type of the cmr-field when set in the deployment descriptor.
 java.lang.String getForeignKeyJdbcName(java.lang.String jdbcFieldName)
           
 java.lang.String getName()
          return the name of this relationship role.
 EjbRelationshipRoleDesc getOppositeRelationshipRole()
          get the opposite relation-ship-role of this relation-ship-role.
 EjbRelationDesc getRelation()
          get the parent ejb relation of this relation-ship-role.
 byte getRelationType()
          This method depends on static values OOB,OOU,...
 EntityCmp2Desc getSourceBean()
          Get the ejb involved in this relation-ship-role.
 java.lang.String getSourceBeanName()
          Get the name of the ejb involved in this relation-ship-role.
 EntityCmp2Desc getTargetBean()
          It retrieves the EntityCmp2Desc which is linked to the EntityCmp2Desc associated to this EjbRelationshipRoleDesc.
 boolean hasCmrField()
          It retrieves true if the EntityCmp2Desc associated to this EjbRelationshipRoleDesc has a cmr field to the linked EntityCmp2Desc
 boolean hasJdbcMapping()
          Is a jdbc mapping is defined for this relationship role ?
 boolean isJOnASCmrField()
          It returns a boolean value which indicates if the cmr has been added by JOnAS (true) or if the user has specified a cmr field in the descriptor.
 boolean isSlave()
          In M-N relationships, only 1 role will write data on DB.
 boolean isSourceMultiple()
          Get state of opposite relationship-role is relation multiple.
 boolean isTargetMultiple()
          Get state of this relationship-role is relation multiple.
 boolean mustCascade()
           
protected  void setCmrFieldName(java.lang.String name)
           
protected  void setCmrFieldType(java.lang.String type)
           
protected  void setIsJOnASCmrField()
          mark the cmr as added by JOnAS
protected  void setSourceBean(EntityCmp2Desc led)
          set the source bean of this relation-ship role.
protected  void setTargetBean(EntityCmp2Desc led)
          set the target bean of this relation-ship role.
 java.lang.String toString()
          String representation of the object for test purpose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INDEX

public static final byte INDEX
This constant can be used to represent an index of a gen class.

See Also:
Constant Field Values

SOURCE

public static final byte SOURCE
This constant can be used to represent the source of the relation, ie the element which references the other.

See Also:
Constant Field Values

TARGET

public static final byte TARGET
This constant can be used to represent the target of the relation, ie the element which is referenced by the other.

See Also:
Constant Field Values

OOU

public static final byte OOU
Don't change these values without looking at getRelationType() !

See Also:
Constant Field Values

OOB

public static final byte OOB
See Also:
Constant Field Values

OMU

public static final byte OMU
See Also:
Constant Field Values

OMB

public static final byte OMB
See Also:
Constant Field Values

MOU

public static final byte MOU
See Also:
Constant Field Values

MOB

public static final byte MOB
See Also:
Constant Field Values

MMU

public static final byte MMU
See Also:
Constant Field Values

MMB

public static final byte MMB
See Also:
Constant Field Values

cmrFieldName

protected java.lang.String cmrFieldName

cmrFieldType

protected java.lang.Class cmrFieldType

isJOnASCMR

protected boolean isJOnASCMR
Constructor Detail

EjbRelationshipRoleDesc

public EjbRelationshipRoleDesc(EjbRelationDesc rd,
                               java.lang.String name,
                               EjbRelationshipRole role,
                               JonasEjbRelationshipRole jrole,
                               EjbRelationshipRole opposite,
                               boolean isSlave,
                               org.objectweb.util.monolog.api.Logger logger)
                        throws DeploymentDescException
constructor to be used by parent node

Parameters:
rd - parent node = EjbRelationDesc
role - this role (standard EjbRelationshipRole)
jrole - this Jonas role (JonasEjbRelationshipRole). This param may be null.
opposite - opposite role in the relation (standard EjbRelationshipRole)
Throws:
DeploymentDescException - in error case.
Method Detail

fillMappingInfo

protected void fillMappingInfo()
                        throws DeploymentDescException
Fills the mapping information of this relation-ship role with the values defined in jonas DD.

Throws:
DeploymentDescException - in error case.

fillMappingInfoWithDefault

protected void fillMappingInfoWithDefault()
Fills the mapping information of this relation-ship role with default values if the mapping information is not already initialized.


getName

public java.lang.String getName()
return the name of this relationship role.

Returns:
the String name of this relationship role.

setCmrFieldName

protected void setCmrFieldName(java.lang.String name)
                        throws DeploymentDescException
Throws:
DeploymentDescException

setCmrFieldType

protected void setCmrFieldType(java.lang.String type)
                        throws DeploymentDescException
Throws:
DeploymentDescException

setIsJOnASCmrField

protected void setIsJOnASCmrField()
mark the cmr as added by JOnAS


setSourceBean

protected void setSourceBean(EntityCmp2Desc led)
set the source bean of this relation-ship role.

Parameters:
led - EntityCmp2Desc for the source bean of this relation-ship role.

setTargetBean

protected void setTargetBean(EntityCmp2Desc led)
set the target bean of this relation-ship role.

Parameters:
led - EntityCmp2Desc for the target bean of this relation-ship role.

getRelation

public EjbRelationDesc getRelation()
get the parent ejb relation of this relation-ship-role.

Returns:
the EjbRelationDesc of this relation-ship-role.

getOppositeRelationshipRole

public EjbRelationshipRoleDesc getOppositeRelationshipRole()
get the opposite relation-ship-role of this relation-ship-role.

Returns:
the opposite EjbRelationshipRoleDesc of this relation-ship-role.

getSourceBeanName

public java.lang.String getSourceBeanName()
Get the name of the ejb involved in this relation-ship-role. This is the source bean name of this relation.

Returns:
the String ejb-name of the source bean.

getSourceBean

public EntityCmp2Desc getSourceBean()
Get the ejb involved in this relation-ship-role. this is the source bean of this relation.

Returns:
the EntityCmp2Desc of the source bean.

getTargetBean

public EntityCmp2Desc getTargetBean()
It retrieves the EntityCmp2Desc which is linked to the EntityCmp2Desc associated to this EjbRelationshipRoleDesc. This is the target bean of this relationship role

Returns:
the EntityCmp2Desc of the target bean.

isSourceMultiple

public boolean isSourceMultiple()
Get state of opposite relationship-role is relation multiple.

Returns:
true if the opposite relationship-role is relation multiple.

isTargetMultiple

public boolean isTargetMultiple()
Get state of this relationship-role is relation multiple. (get state of field is relation multiple).

Returns:
true if the relationship-role is relation multiple.

mustCascade

public boolean mustCascade()
Returns:
true if this bean must cascade delete the other bean in this relation.

isJOnASCmrField

public boolean isJOnASCmrField()
It returns a boolean value which indicates if the cmr has been added by JOnAS (true) or if the user has specified a cmr field in the descriptor. A CMR field is be added to manage the coherence of the relation OXu

Returns:
true if the CMR field is not a bean's programmer CMR field.

hasCmrField

public boolean hasCmrField()
It retrieves true if the EntityCmp2Desc associated to this EjbRelationshipRoleDesc has a cmr field to the linked EntityCmp2Desc

Returns:
true if the relation-ship-role has a CMR field.

getCmrFieldName

public java.lang.String getCmrFieldName()
get the name of the cmr-field.

Returns:
the String name of the cmr-field.

getCmrFieldType

public java.lang.Class getCmrFieldType()
get the type of the cmr-field when set in the deployment descriptor.

Returns:
Collection or Set for multiple rel. and null for non multiple rel.

getRelationType

public byte getRelationType()
This method depends on static values OOB,OOU,... defined upper !

Returns:
the type of the relation: OO-u, OO-b, OM-u, ....

hasJdbcMapping

public boolean hasJdbcMapping()
Is a jdbc mapping is defined for this relationship role ?

Returns:
true if a jdbc mapping is defined for this relationship role.

isSlave

public boolean isSlave()
In M-N relationships, only 1 role will write data on DB.

Returns:
true if role will not write MN relations on database

getForeignKeyJdbcName

public java.lang.String getForeignKeyJdbcName(java.lang.String jdbcFieldName)
Parameters:
jdbcFieldName - a primary key column name of the table associated to the target bean.
Returns:
the foreign key column name associated to the given primary key column name.

toString

public java.lang.String toString()
String representation of the object for test purpose

Overrides:
toString in class java.lang.Object
Returns:
String representation of this object