/** INTERNAL: Create a new policy. Only descriptor involved in interface should have a policy. */
 public InterfacePolicy() {
   this.childDescriptors =
       org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
   this.parentInterfaces =
       org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(2);
   this.parentInterfaceNames =
       org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(2);
   this.parentDescriptors =
       org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(2);
 }
  /**
   * INTERNAL: This methods clones all the fields and ensures that each collection refers to the
   * same clones.
   */
  @Override
  public Object clone() {
    VariableOneToOneMapping clone = (VariableOneToOneMapping) super.clone();
    Map setOfKeys = new HashMap(getSourceToTargetQueryKeyNames().size());
    Map sourceToTarget = new HashMap(getSourceToTargetQueryKeyNames().size());
    Vector foreignKeys =
        org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(
            getForeignKeyFields().size());

    if (getTypeField() != null) {
      clone.setTypeField((DatabaseField) this.getTypeField().clone());
    }

    for (Iterator enumtr = getSourceToTargetQueryKeyNames().keySet().iterator();
        enumtr.hasNext(); ) {
      // Clone the SourceKeyFields
      DatabaseField field = (DatabaseField) enumtr.next();
      DatabaseField clonedField = (DatabaseField) field.clone();
      setOfKeys.put(field, clonedField);
      // on the next line I'm cloning the query key names
      sourceToTarget.put(clonedField, getSourceToTargetQueryKeyNames().get(field));
    }

    for (Enumeration enumtr = getForeignKeyFields().elements(); enumtr.hasMoreElements(); ) {
      DatabaseField field = (DatabaseField) enumtr.nextElement();
      foreignKeys.addElement(setOfKeys.get(field));
    }
    clone.setSourceToTargetQueryKeyFields(sourceToTarget);
    clone.setForeignKeyFields(foreignKeys);
    clone.setTypeIndicatorTranslation(new HashMap(this.getTypeIndicatorTranslation()));
    return clone;
  }
  /** PUBLIC: Default constructor. */
  public VariableOneToOneMapping() {
    this.selectionQuery = new ReadObjectQuery();
    this.sourceToTargetQueryKeyNames = new HashMap(2);
    this.typeIndicatorTranslation = new HashMap(5);
    this.typeIndicatorNameTranslation = new HashMap(5);
    this.foreignKeyFields = NonSynchronizedVector.newInstance(1);

    // right now only ForeignKeyRelationships are supported
    this.isForeignKeyRelationship = false;
  }
Ejemplo n.º 4
0
 /** Create the log operator for this platform */
 private static final ExpressionOperator createLogOperator() {
   ExpressionOperator result = new ExpressionOperator();
   result.setSelector(ExpressionOperator.Log);
   Vector v = NonSynchronizedVector.newInstance(2);
   v.addElement("LOG(10,");
   v.addElement(")");
   result.printsAs(v);
   result.bePrefix();
   result.setNodeClass(FunctionExpression.class);
   return result;
 }
  /** Return the constraint ordered classes. */
  public Vector getOrderedClasses() {
    Vector orderedClasses =
        org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(
            getOrderedDescriptors().size());
    for (Enumeration orderedDescriptorsEnum = getOrderedDescriptors().elements();
        orderedDescriptorsEnum.hasMoreElements(); ) {
      orderedClasses.addElement(
          ((ClassDescriptor) orderedDescriptorsEnum.nextElement()).getJavaClass());
    }

    return orderedClasses;
  }
  /**
   * PUBLIC: Return the foreign key field names associated with the mapping. These are only the
   * source fields that are writable.
   */
  public void setForeignKeyFieldNames(Vector fieldNames) {
    Vector fields =
        org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(
            fieldNames.size());
    for (Enumeration fieldNamesEnum = fieldNames.elements(); fieldNamesEnum.hasMoreElements(); ) {
      fields.addElement(new DatabaseField((String) fieldNamesEnum.nextElement()));
    }

    setForeignKeyFields(fields);
    if (!fields.isEmpty()) {
      setIsForeignKeyRelationship(true);
    }
  }
Ejemplo n.º 7
0
 private static final ExpressionOperator createNullifOperator() {
   ExpressionOperator exOperator = new ExpressionOperator();
   exOperator.setType(ExpressionOperator.FunctionOperator);
   exOperator.setSelector(ExpressionOperator.NullIf);
   Vector v = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(4);
   v.addElement(" (CASE WHEN ");
   v.addElement(" = ");
   v.addElement(" THEN NULL ELSE ");
   v.addElement(" END) ");
   exOperator.printsAs(v);
   exOperator.bePrefix();
   int[] indices = {0, 1, 0};
   exOperator.setArgumentIndices(indices);
   exOperator.setNodeClass(ClassConstants.FunctionExpression_Class);
   return exOperator;
 }
Ejemplo n.º 8
0
 /** INTERNAL: Return all attributes specified for batch reading. */
 public Vector getBatchReadAttributeExpressions() {
   if (batchReadAttributeExpressions == null) {
     batchReadAttributeExpressions = NonSynchronizedVector.newInstance();
   }
   return batchReadAttributeExpressions;
 }
 public ObjectRelationalDataTypeDescriptor() {
   this.orderedFields =
       org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
 }