Exemplo n.º 1
0
 @Override
 public String toString() {
   return org.eclipse.persistence.internal.helper.Helper.getShortClassName(getClass())
       + "("
       + getName()
       + ") ";
 }
Exemplo n.º 2
0
 /**
  * Returns a String that represents the value of this object.
  *
  * @return a string representation of the receiver
  */
 public String toString() {
   return org.eclipse.persistence.internal.helper.Helper.getShortClassName(this.getClass())
       + ": "
       + this.getFirstName()
       + " "
       + this.getLastName();
 }
 public void printClasses(List classes) {
   for (Iterator iterator = classes.iterator(); iterator.hasNext(); ) {
     System.out.print(
         org.eclipse.persistence.internal.helper.Helper.getShortClassName(
             (Class) iterator.next()));
     System.out.print(", ");
   }
   System.out.println(":");
 }
 public String toString() {
   if (isInstantiated()) {
     return "{" + getValue() + "}";
   } else {
     return "{"
         + Helper.getShortClassName(getClass())
         + ": "
         + ToStringLocalization.buildMessage("not_instantiated", (Object[]) null)
         + "}";
   }
 }
  /** INTERNAL: */
  public String toString() {
    StringWriter writer = new StringWriter();
    writer.write(Helper.getShortClassName(getClass()));
    writer.write("(");

    for (int index = 0; index < getFields().size(); index++) {
      writer.write(Helper.cr());
      writer.write("\t");
      writer.write(String.valueOf((getFields().elementAt(index))));
      writer.write(" => ");
      writer.write(String.valueOf((getValues().elementAt(index))));
    }
    writer.write(")");

    return writer.toString();
  }
Exemplo n.º 6
0
  /**
   * INTERNAL: For this Type generate classes
   *
   * @param packageName
   * @param nr
   */
  public void preInitialize(String packageName, List namespaceResolvers) {
    String instanceClassName = getInstanceClassName();
    if (null == instanceClassName) {
      if (null == packageName) {
        String uri = getURI();
        if (null == uri) {
          packageName = SDOUtil.getDefaultPackageName() + SDOConstants.JAVA_PACKAGE_NAME_SEPARATOR;
        } else {
          packageName =
              SDOUtil.getPackageNameFromURI(uri) + SDOConstants.JAVA_PACKAGE_NAME_SEPARATOR;
        }
      }

      // Verify and fix any Class name that does not conform to conventions
      // run the class name through the JAXB mangler
      String mangledClassName = SDOUtil.className(getName(), false, true, true);

      // we will not fix any type collision at this time as a result of class renaming
      // write fully qualified java class name
      StringBuffer fullClassName = new StringBuffer(packageName);
      fullClassName.append(mangledClassName);
      setInstanceClassName(fullClassName.toString());
    }
    AbstractSessionLog.getLog()
        .log(
            AbstractSessionLog.FINER, //
            "sdo_type_generation_processing_type", //
            new Object[] {Helper.getShortClassName(getClass()), getInstanceClassName()});

    initializeNamespaces(namespaceResolvers);
    getXmlDescriptor().setJavaClassName(getImplClassName());

    // See SDOResolvable enhancement
    String schemaContext = getName();
    if (getXmlDescriptor().getNamespaceResolver() != null) {
      String prefix = getXmlDescriptor().getNamespaceResolver().resolveNamespaceURI(getURI());
      if ((prefix != null) && !prefix.equals(SDOConstants.EMPTY_STRING)) {
        schemaContext = prefix + SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT + schemaContext;
      }
    }
    String schemaContextWithSlash = SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT + schemaContext;

    XMLSchemaReference schemaRef = new XMLSchemaClassPathReference();
    schemaRef.setSchemaContext(schemaContextWithSlash);
    schemaRef.setType(XMLSchemaReference.COMPLEX_TYPE);
    getXmlDescriptor().setSchemaReference(schemaRef);
  }
  public void addDescriptors(DatabaseSession session) {
    if (project == null) {
      if (getAdapter().isOriginalSetupRequired()) {
        try {
          // If called twice, method TestSystem.addDescriptors(Session)
          // may behave wrong during the second call
          // (typically because during the second call project value is no longer null,
          // which causes problems in case more than one project is used).
          // Therefore another instance of TestSystem is created - not to spoil the original.
          TestSystem tempTestSystem = getTestSystem().getClass().newInstance();
          tempTestSystem.addDescriptors(session);
          try {
            tempTestSystem.createTables(session);
          } catch (Exception ex2) {
            throw new TestProblemException(
                "Exception thrown by "
                    + Helper.getShortClassName(tempTestSystem)
                    + ".createTables() ",
                ex2);
          }
        } catch (Exception ex1) {
          throw new TestProblemException(
              "Failed to create an instance of " + getTestSystem().getClass() + " ", ex1);
        }
      }
      // This trick stores all descriptors used by testSystem into project
      DatabaseSession dummyDatabaseSession =
          new Project((Login) session.getLogin().clone()).createDatabaseSession();
      getTestSystem().addDescriptors(dummyDatabaseSession);
      project = dummyDatabaseSession.getProject();

      getAdapter().updateProject(project, session);
    }
    (session).addDescriptors(project);
    afterAddDescriptors(session, getTestSystem());
  }
 protected static boolean verifyFieldAndMapping(
     AbstractSession session,
     DatabaseField field,
     ClassDescriptor descriptor,
     DatabaseMapping mapping) {
   verifyField(session, field, descriptor);
   while (mapping.isAggregateObjectMapping()) {
     ClassDescriptor referenceDescriptor =
         ((AggregateObjectMapping) mapping).getReferenceDescriptor();
     mapping = referenceDescriptor.getObjectBuilder().getMappingForField(field);
     verifyFieldAndMapping(session, field, referenceDescriptor, mapping);
   }
   if (!mapping.isDirectToFieldMapping() && !mapping.isTransformationMapping()) {
     String mappingTypeName = Helper.getShortClassName(mapping);
     session
         .getIntegrityChecker()
         .handleError(
             DescriptorException.returningPolicyMappingNotSupported(
                 field.getName(), mappingTypeName, mapping));
     return false;
   } else {
     return true;
   }
 }
 /** INTERNAL: Return the upper case java class that defines this accessor. */
 protected String getUpperCaseShortJavaClassName() {
   return Helper.getShortClassName(getJavaClassName()).toUpperCase();
 }
 public String toString() {
   return Helper.getShortClassName(getTestSystem())
       + " using "
       + Helper.getShortClassName(getAdapter());
 }
Exemplo n.º 11
0
 /** INTERNAL: */
 public void validationAfterDescriptorInitialization(AbstractSession session) {
   Hashtable mapped = new Hashtable();
   for (int operation = INSERT; operation <= UPDATE; operation++) {
     if ((main[operation][MAPPED] != null) && !main[operation][MAPPED].isEmpty()) {
       Iterator it = main[operation][MAPPED].iterator();
       while (it.hasNext()) {
         DatabaseField field = (DatabaseField) it.next();
         mapped.put(field, field);
       }
     }
   }
   if (!mapped.isEmpty()) {
     for (Enumeration fields = getDescriptor().getFields().elements();
         fields.hasMoreElements(); ) {
       DatabaseField fieldInDescriptor = (DatabaseField) fields.nextElement();
       DatabaseField fieldInMain = (DatabaseField) mapped.get(fieldInDescriptor);
       if (fieldInMain != null) {
         if (fieldInMain.getType() == null) {
           if (getDescriptor().isReturnTypeRequiredForReturningPolicy()) {
             session
                 .getIntegrityChecker()
                 .handleError(
                     DescriptorException.returningPolicyMappedFieldTypeNotSet(
                         fieldInMain.getName(), getDescriptor()));
           }
         } else if (isThereATypeConflict(fieldInMain, fieldInDescriptor)) {
           session
               .getIntegrityChecker()
               .handleError(
                   DescriptorException.returningPolicyAndDescriptorFieldTypeConflict(
                       fieldInMain.getName(),
                       fieldInMain.getType().getName(),
                       fieldInDescriptor.getType().getName(),
                       getDescriptor()));
         }
       }
     }
   }
   if (!(session.getDatasourcePlatform() instanceof DatabasePlatform)) {
     // don't attempt further diagnostics on non-relational platforms
     return;
   }
   WriteObjectQuery[] query = {
     getDescriptor().getQueryManager().getInsertQuery(),
     getDescriptor().getQueryManager().getUpdateQuery()
   };
   String[] queryTypeName = {"InsertObjectQuery", "UpdateObjectQuery"};
   for (int operation = INSERT; operation <= UPDATE; operation++) {
     if ((main[operation][ALL] != null) && !main[operation][ALL].isEmpty()) {
       // this operation requires some fields to be returned
       if ((query[operation] == null) || (query[operation].getDatasourceCall() == null)) {
         if (!session.getPlatform().canBuildCallWithReturning()) {
           session
               .getIntegrityChecker()
               .handleError(
                   DescriptorException.noCustomQueryForReturningPolicy(
                       queryTypeName[operation],
                       Helper.getShortClassName(session.getPlatform()),
                       getDescriptor()));
         }
       } else if (query[operation].getDatasourceCall() instanceof StoredProcedureCall) {
         // SQLCall with custom SQL calculates its outputRowFields later (in prepare() method) -
         // that's why SQLCall can't be verified here.
         DatabaseCall customCall = (DatabaseCall) query[operation].getDatasourceCall();
         Enumeration outputRowFields = customCall.getOutputRowFields().elements();
         Collection notFoundInOutputRow = createCollection();
         notFoundInOutputRow.addAll(main[operation][ALL]);
         while (outputRowFields.hasMoreElements()) {
           notFoundInOutputRow.remove(outputRowFields.nextElement());
         }
         if (!notFoundInOutputRow.isEmpty()) {
           Iterator it = notFoundInOutputRow.iterator();
           while (it.hasNext()) {
             DatabaseField field = (DatabaseField) it.next();
             session
                 .getIntegrityChecker()
                 .handleError(
                     DescriptorException.customQueryAndReturningPolicyFieldConflict(
                         field.getName(), queryTypeName[operation], getDescriptor()));
           }
         }
       }
     }
   }
 }
Exemplo n.º 12
0
 /** Print the in progress depth. */
 public String toString() {
   Object[] args = {Integer.valueOf(this.commitDepth)};
   return Helper.getShortClassName(getClass())
       + ToStringLocalization.buildMessage("commit_depth", args);
 }