Package com.sun.jdo.spi.persistence.support.ejb.model.util

Examples of com.sun.jdo.spi.persistence.support.ejb.model.util.NameMapper


    // translate the class name to corresponding ejb name's abstract
    // bean or key class if necessary
    if (className != null)
    {
      NameMapper nameMapper = getNameMapper();
      String ejbName =
        (isPCClassName(className) ? getEjbName(className) : className);

      if (nameMapper.isEjbName(ejbName))
        testClass = nameMapper.getAbstractBeanClassForEjbName(ejbName);
      else
      {
        String keyClass =
          nameMapper.getKeyClassForPersistenceKeyClass(className);

        if (keyClass != null)
        {
          // if it's a pk field of type primitive, byte[],
          // or other array, return the primitive class or a
View Full Code Here


      return returnList;
    }
    else
    {
      NameMapper nameMapper = getNameMapper();
      String ejbName =
        nameMapper.getEjbNameForPersistenceKeyClass(className);

      switch (getPersistenceKeyClassType(className))
      {
        // find the field names we need in the corresponding
        // ejb key class
        case NameMapper.USER_DEFINED_KEY_CLASS:
          testClass = nameMapper.getKeyClassForEjbName(ejbName);
          break;
        // find the field name we need in the abstract bean
        case NameMapper.PRIMARY_KEY_FIELD:
          return Arrays.asList(new String[]{
            getCMPDescriptor(ejbName).
            getPrimaryKeyFieldDesc().getName()});
        // find the field name we need in the persistence capable
        case NameMapper.UNKNOWN_KEY_CLASS:
          String pcClassName =
            nameMapper.getPersistenceClassForEjbName(ejbName);
          PersistenceFieldElement[] fields =
            getPersistenceClass(pcClassName).getFields();
          int i, count = ((fields != null) ? fields.length : 0);

          for (i = 0; i < count; i++)
View Full Code Here

    String testClass = className;
    Object returnObject = null;

    if (className != null)
    {
      NameMapper nameMapper = getNameMapper();
      boolean isPCClass = isPCClassName(className);
      boolean isPKClassName = false;
      String searchClassName = className;
      String searchFieldName = fieldName;

      // translate the class name & field names to corresponding
      // ejb name's abstract bean equivalents if necessary
      if (isPCClass)
      {
        searchFieldName = nameMapper.
          getEjbFieldForPersistenceField(className, fieldName);
        searchClassName = getEjbName(className);
      }
      else  // check if it's a pk class without a user defined key class
      {
        String ejbName =
          nameMapper.getEjbNameForPersistenceKeyClass(className);

        switch (getPersistenceKeyClassType(className))
        {
          // find the field we need in the corresponding
          // abstract bean (translated below from ejbName)
          case NameMapper.PRIMARY_KEY_FIELD:
            testClass = ejbName;
            searchClassName = ejbName;
            isPKClassName = true;
            break;
          // find the field we need by called updateFieldWrapper
          // below which handles the generated field for the
          // unknown key class - need to use the
          // persistence-capable class name and flag to call that
          // code, so we configure it here
          case NameMapper.UNKNOWN_KEY_CLASS:
            testClass = nameMapper.
              getPersistenceClassForEjbName(ejbName);
            isPCClass = true;
            isPKClassName = true;
            break;
        }
      }

      if (nameMapper.isEjbName(searchClassName))
      {
        searchClassName = nameMapper.
          getAbstractBeanClassForEjbName(searchClassName);
      }

      returnObject = super.getField(searchClassName, searchFieldName);
View Full Code Here

  {
    String returnType = super.getFieldType(className, fieldName);

    if (!isCollection(returnType) && isPCClassName(className))
    {
      NameMapper nameMapper = getNameMapper();
      String ejbName =
        nameMapper.getEjbNameForPersistenceClass(className);
      String ejbField =
        nameMapper.getEjbFieldForPersistenceField(className, fieldName);

      if (nameMapper.isGeneratedEjbRelationship(ejbName, ejbField))
      {
        String[] inverse =
          nameMapper.getEjbFieldForGeneratedField(ejbName, ejbField);
           
        returnType = nameMapper.
          getPersistenceClassForEjbName(inverse[0]);
      }

      if (nameMapper.isLocalInterface(returnType))
      {
        returnType = nameMapper.getPersistenceClassForLocalInterface(
          className, fieldName, returnType);
      }
    }

    return returnType;
View Full Code Here

  {
    int returnValue = -1;

    if (getCMPDescriptor(className) == null)
    {
      NameMapper nameMapper = getNameMapper();
      String ejbName =
        nameMapper.getEjbNameForPersistenceKeyClass(className);

      if (ejbName != null)
        returnValue = nameMapper.getKeyClassTypeForEjbName(ejbName);
    }

    return returnValue;
  }
View Full Code Here

  }

  private MemberWrapper updateFieldWrapper (MemberWrapper returnObject,
    String className, String fieldName)
  {
    NameMapper nameMapper = getNameMapper();

    if (returnObject == null)
    {
      // can't call isPersistent or isKey because that calls
      // hasField which calls getField and that would end up
      // in an endless loop
      PersistenceFieldElement field =
        getPersistenceFieldInternal(className, fieldName);

      if (field != null)
      {
        String ejbName = getEjbName(className);
        String ejbFieldName = nameMapper.
          getEjbFieldForPersistenceField(className, fieldName);

        // Check if this is the auto-added field for unknown pk
        // support.  If so, return a private field of type Long.
        if (field.isKey() && (ejbName != null) &&
          (nameMapper.getKeyClassTypeForEjbName(ejbName) ==
          NameMapper.UNKNOWN_KEY_CLASS))
        {
          returnObject = new MemberWrapper(ejbFieldName,
            Long.class, Modifier.PRIVATE,
            (Class)getClass(className));
        }

        // Check if this is the auto-added field for 2 way managed rels
        // support.  If so, return a private field of type according to
        // cardinality of the relationship.
        else if ((field instanceof RelationshipElement) &&
          nameMapper.isGeneratedEjbRelationship(ejbName,
          ejbFieldName))
        {
          RelationshipElement rel = (RelationshipElement)field;
          Class classType = null;

          // figure out the type
          if (rel.getUpperBound() > 1)
            classType = java.util.HashSet.class;
          else
          {
            String[] inverse = nameMapper.
              getEjbFieldForGeneratedField(ejbName, ejbFieldName);

            classType = (Class)getClass(inverse[0]);
          }

          if (classType != null)
          {
            returnObject = new MemberWrapper(ejbFieldName,
              classType, Modifier.PRIVATE,
              (Class)getClass(className));
          }
        }
        // Check if this is the auto-added version field.
        // If so, return a private field of type long.
        else if (ejbFieldName.startsWith(
          NameMapper.GENERATED_VERSION_FIELD_PREFIX) &&
          nameMapper.isGeneratedField(ejbName, ejbFieldName))
        {
          returnObject = new MemberWrapper(ejbFieldName,
            Long.TYPE, Modifier.PRIVATE,
            (Class)getClass(className));
        }
View Full Code Here

    // translate the class name to corresponding ejb name's abstract
    // bean or key class if necessary
    if (className != null)
    {
      NameMapper nameMapper = getNameMapper();
      String ejbName =
        (isPCClassName(className) ? getEjbName(className) : className);

      if (nameMapper.isEjbName(ejbName))
        testClass = nameMapper.getAbstractBeanClassForEjbName(ejbName);
      else
      {
        String keyClass =
          nameMapper.getKeyClassForPersistenceKeyClass(className);

        if (keyClass != null)
        {
          // if it's a pk field of type primitive, byte[],
          // or other array, return the primitive class or a
View Full Code Here

      return returnList;
    }
    else
    {
      NameMapper nameMapper = getNameMapper();
      String ejbName =
        nameMapper.getEjbNameForPersistenceKeyClass(className);

      switch (getPersistenceKeyClassType(className))
      {
        // find the field names we need in the corresponding
        // ejb key class
        case NameMapper.USER_DEFINED_KEY_CLASS:
          testClass = nameMapper.getKeyClassForEjbName(ejbName);
          break;
        // find the field name we need in the abstract bean
        case NameMapper.PRIMARY_KEY_FIELD:
          return Arrays.asList(new String[]{
            getCMPDescriptor(ejbName).
            getPrimaryKeyFieldDesc().getName()});
        // find the field name we need in the persistence capable
        case NameMapper.UNKNOWN_KEY_CLASS:
          String pcClassName =
            nameMapper.getPersistenceClassForEjbName(ejbName);
          PersistenceFieldElement[] fields =
            getPersistenceClass(pcClassName).getFields();
          int i, count = ((fields != null) ? fields.length : 0);

          for (i = 0; i < count; i++)
View Full Code Here

    String testClass = className;
    Object returnObject = null;

    if (className != null)
    {
      NameMapper nameMapper = getNameMapper();
      boolean isPCClass = isPCClassName(className);
      boolean isPKClassName = false;
      String searchClassName = className;
      String searchFieldName = fieldName;

      // translate the class name & field names to corresponding
      // ejb name's abstract bean equivalents if necessary
      if (isPCClass)
      {
        searchFieldName = nameMapper.
          getEjbFieldForPersistenceField(className, fieldName);
        searchClassName = getEjbName(className);
      }
      else  // check if it's a pk class without a user defined key class
      {
        String ejbName =
          nameMapper.getEjbNameForPersistenceKeyClass(className);

        switch (getPersistenceKeyClassType(className))
        {
          // find the field we need in the corresponding
          // abstract bean (translated below from ejbName)
          case NameMapper.PRIMARY_KEY_FIELD:
            testClass = ejbName;
            searchClassName = ejbName;
            isPKClassName = true;
            break;
          // find the field we need by called updateFieldWrapper
          // below which handles the generated field for the
          // unknown key class - need to use the
          // persistence-capable class name and flag to call that
          // code, so we configure it here
          case NameMapper.UNKNOWN_KEY_CLASS:
            testClass = nameMapper.
              getPersistenceClassForEjbName(ejbName);
            isPCClass = true;
            isPKClassName = true;
            break;
        }
      }

      if (nameMapper.isEjbName(searchClassName))
      {
        searchClassName = nameMapper.
          getAbstractBeanClassForEjbName(searchClassName);
      }

      returnObject = super.getField(searchClassName, searchFieldName);
View Full Code Here

  {
    String returnType = super.getFieldType(className, fieldName);

    if (!isCollection(returnType) && isPCClassName(className))
    {
      NameMapper nameMapper = getNameMapper();
      String ejbName =
        nameMapper.getEjbNameForPersistenceClass(className);
      String ejbField =
        nameMapper.getEjbFieldForPersistenceField(className, fieldName);

      if (nameMapper.isGeneratedEjbRelationship(ejbName, ejbField))
      {
        String[] inverse =
          nameMapper.getEjbFieldForGeneratedField(ejbName, ejbField);
           
        returnType = nameMapper.
          getPersistenceClassForEjbName(inverse[0]);
      }

      if (nameMapper.isLocalInterface(returnType))
      {
        returnType = nameMapper.getPersistenceClassForLocalInterface(
          className, fieldName, returnType);
      }
    }

    return returnType;
View Full Code Here

TOP

Related Classes of com.sun.jdo.spi.persistence.support.ejb.model.util.NameMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.