[JBoss-dev] CVS update: jboss/src/main/org/jboss/metadata RelationshipRoleMetaData.java

2001-07-25 Thread Dain Sundstrom

  User: dsundstrom
  Date: 01/07/25 20:17:04

  Modified:src/main/org/jboss/metadata RelationshipRoleMetaData.java
  Log:
  Changed constructor to take a back pointer to the relation metadata.
  Added method to obtain the role for the other half of the relation.
  
  Revision  ChangesPath
  1.2   +25 -1 jboss/src/main/org/jboss/metadata/RelationshipRoleMetaData.java
  
  Index: RelationshipRoleMetaData.java
  ===
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/metadata/RelationshipRoleMetaData.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RelationshipRoleMetaData.java 2001/07/09 20:49:00 1.1
  +++ RelationshipRoleMetaData.java 2001/07/26 03:17:04 1.2
  @@ -14,7 +14,7 @@
* file's ejb-relation elements.
*
* @author a href=mailto:[EMAIL PROTECTED];Dain Sundstrom/a
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
*/
   public class RelationshipRoleMetaData extends MetaData {
// one is one
  @@ -28,6 +28,11 @@
private String relationshipRoleName;

/**
  +  * The relation to which the role belongs.
  +  */
  +  private RelationMetaData relationMetaData;
  + 
  + /**
 * Multiplicity of role, ONE or MANY.
 */
private int multiplicity;
  @@ -52,6 +57,10 @@
 */
private String cmrFieldType;
   
  + public RelationshipRoleMetaData(RelationMetaData relationMetaData) {
  + this.relationMetaData = relationMetaData;
  + }
  + 
/**
 * Gets the relationship role name
 */
  @@ -59,6 +68,21 @@
return relationshipRoleName;
}
   
  + /**
  +  * Gets the relation meta data to which the role belongs.
  +  * @returns the relation to which the relationship role belongs
  +  */
  + public RelationMetaData getRelationMetaData() {
  + return relationMetaData;
  + }
  + 
  + /**
  +  * Gets the related role's metadata
  +  */
  + public RelationshipRoleMetaData getRelatedRoleMetaData() {
  + return relationMetaData.getOtherRelationshipRole(this);
  + }
  + 
/**
 * Checks if the multiplicity is one.
 */
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/metadata RelationshipRoleMetaData.java

2001-07-09 Thread Dain Sundstrom

  User: dsundstrom
  Date: 01/07/09 13:49:00

  Added:   src/main/org/jboss/metadata RelationshipRoleMetaData.java
  Log:
  Represents one ejb-relationship-role element found in the ejb-jar.xml
  file's ejb-relation elements.
  
  Revision  ChangesPath
  1.1  jboss/src/main/org/jboss/metadata/RelationshipRoleMetaData.java
  
  Index: RelationshipRoleMetaData.java
  ===
  /*
   * JBoss, the OpenSource EJB server
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.metadata;
  
  import org.w3c.dom.Element;
  import org.jboss.ejb.DeploymentException;
  
  /** 
   * Represents one ejb-relationship-role element found in the ejb-jar.xml
   * file's ejb-relation elements.
   *
   * @author a href=mailto:[EMAIL PROTECTED];Dain Sundstrom/a
   * @version $Revision: 1.1 $
   */
  public class RelationshipRoleMetaData extends MetaData {
// one is one
private static int ONE = 1;
// and two is many :)
private static int MANY = 2;

/**
 * Role name
 */
private String relationshipRoleName;

/**
 * Multiplicity of role, ONE or MANY.
 */
private int multiplicity;

/**
 * Should this entity be deleted when related entity is deleted.
 */
private boolean cascadeDelete;

/**
 * Name of the entity that has this role.
 */
private String entityName;

/**
 * Name of the entity's cmr field for this role.
 */
private String cmrFieldName;

/**
 * Type of the cmr field (i.e., collection or set)
 */
private String cmrFieldType;
  
/**
 * Gets the relationship role name
 */
public String getRelationshipRoleName() {
return relationshipRoleName;
}
  
/**
 * Checks if the multiplicity is one.
 */
public boolean isMultiplicityOne() {
return multiplicity == ONE;
}

/**
 * Checks if the multiplicity is many.
 */
public boolean isMultiplicityMany() {
return multiplicity == MANY;
}

/**
 * Should this entity be deleted when related entity is deleted.
 */
public boolean isCascadeDelete() {
return cascadeDelete;
}

/**
 * Gets the name of the entity that has this role.
 */
public String getEntityName() {
return entityName;
}

/**
 * Gets the name of the entity's cmr field for this role.
 */
public String getCMRFieldName() {
return cmrFieldName;
}

/**
 * Gets the type of the cmr field (i.e., collection or set)
 */
public String getCMRFieldType() {
return cmrFieldType;
}

 public void importEjbJarXml (Element element) throws DeploymentException {
   // ejb-relationship-role-name?
relationshipRoleName = getElementContent(getOptionalChild(element, 
ejb-relationship-role-name));

// multiplicity
String multiplicityString = getElementContent(getUniqueChild(element, 
multiplicity));
if(One.equals(multiplicityString)) {
multiplicity = ONE;
} else if(Many.equals(multiplicityString)) {
multiplicity = MANY;
} else {
throw new DeploymentException(multiplicity should be One or 
Many but is  + multiplicityString);
}

// cascade-delete? 
Element cascadeDeleteElement = getOptionalChild(element, 
cascade-delete);
if(cascadeDeleteElement != null) {
cascadeDelete = true;
}

// relationship-role-source
Element relationshipRoleSourceElement = getUniqueChild(element, 
relationship-role-source);
entityName = 
getElementContent(getUniqueChild(relationshipRoleSourceElement, ejb-name));

// cmr-field?
Element cmrFieldElement = getOptionalChild(element, cmr-field);
if(cmrFieldElement != null) {
// cmr-field-name
cmrFieldName = 
getElementContent(getUniqueChild(cmrFieldElement, cmr-field-name));

   // cmr-field-type?
Element cmrFieldTypeElement = 
getOptionalChild(cmrFieldElement, cmr-field-type);
if(cmrFieldTypeElement != null) {