public void addEmployeeDescriptor(boolean methodAccess) {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");

    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);

    XMLDirectMapping firstNameMapping = new XMLDirectMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setXPath("first-name/text()");
    descriptor.addMapping(firstNameMapping);

    XMLDirectMapping lastNameMapping = new XMLDirectMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setXPath("last-name/text()");
    descriptor.addMapping(lastNameMapping);

    XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
    addressMapping.setAttributeName("address");
    addressMapping.setReferenceClass(Address.class);
    addressMapping.setXPath("address");
    descriptor.addMapping(addressMapping);

    XMLCompositeCollectionMapping phoneMapping = new XMLCompositeCollectionMapping();
    phoneMapping.setAttributeName("phoneNumbers");
    phoneMapping.setReferenceClass(PhoneNumber.class);
    phoneMapping.setXPath("phone-numbers/number");
    phoneMapping.setContainerPolicy(ContainerPolicy.buildPolicyFor(ArrayList.class));
    descriptor.addMapping(phoneMapping);
    this.addDescriptor(descriptor);
  }
  public XMLDescriptor addEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");

    XMLCompositeObjectMapping addr = new XMLCompositeObjectMapping();
    addr.setAttributeName("address");
    addr.setXPath("address");
    addr.setReferenceClass(Address.class);
    descriptor.addMapping(addr);

    XMLCompositeCollectionMapping phone = new XMLCompositeCollectionMapping();
    phone.setAttributeName("phoneNumbers");
    phone.setXPath("phone-number");
    phone.setReferenceClass(PhoneNumber.class);
    phone.useCollectionClass(ArrayList.class);
    descriptor.addMapping(phone);

    XMLAnyObjectMapping object = new XMLAnyObjectMapping();
    object.setAttributeName("anyObject");
    object.setXPath("any-object");
    descriptor.addMapping(object);

    XMLAnyCollectionMapping anyCollection = new XMLAnyCollectionMapping();
    anyCollection.setAttributeName("anyCollection");
    anyCollection.setXPath("any-collection");
    anyCollection.useCollectionClass(ArrayList.class);
    descriptor.addMapping(anyCollection);

    this.addDescriptor(descriptor);
    return descriptor;
  }
  public XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Employee.class);
    xmlDescriptor.setDefaultRootElement("employee");

    XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
    addressMapping.setReferenceClass(Address.class);
    addressMapping.setAttributeName("address");
    addressMapping.setXPath(".");
    xmlDescriptor.addMapping(addressMapping);

    return xmlDescriptor;
  }
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(ModelGroupDefinition.class);
    descriptor.getInheritancePolicy().setParentClass(AbstractNamedSchemaComponent.class);

    XMLCompositeObjectMapping modelGroupMapping = new XMLCompositeObjectMapping();
    modelGroupMapping.setAttributeName("modelGroup");
    modelGroupMapping.setReferenceClass(ExplicitModelGroup.class);
    modelGroupMapping.setXPath("model-group");
    descriptor.addMapping(modelGroupMapping);

    return descriptor;
  }
  public void addEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");

    XMLCompositeObjectMapping addr = new XMLCompositeObjectMapping();
    addr.setAttributeName("primaryAddress");
    addr.setXPath("primary-address");
    addr.setReferenceClass(Address.class);
    addr.readOnly();
    descriptor.addMapping(addr);

    this.addDescriptor(descriptor);
  }
Exemplo n.º 6
0
  /**
   * For isMany=false properties set the value to null. For isMany=true set the value to an empty
   * container of the appropriate type.
   */
  public void unsetDeclaredProperty(int propertyIndex) {
    SDOProperty declaredProperty =
        (SDOProperty) dataObject.getType().getDeclaredProperties().get(propertyIndex);
    Mapping mapping = this.getJAXBMappingForProperty(declaredProperty);
    if (declaredProperty.isMany()) {
      ContainerMapping containerMapping = (ContainerMapping) mapping;
      ContainerPolicy containerPolicy = containerMapping.getContainerPolicy();

      // OLD VALUE
      if (mapping.isAbstractCompositeCollectionMapping()) {
        XMLCompositeCollectionMapping compositeMapping = (XMLCompositeCollectionMapping) mapping;
        if (compositeMapping.getContainerAccessor() != null) {

          Object oldContainer = mapping.getAttributeValueFromObject(entity);
          if (oldContainer != null) {
            AbstractSession session =
                ((JAXBContext) jaxbHelperContext.getJAXBContext())
                    .getXMLContext()
                    .getSession(entity);
            Object iterator = containerPolicy.iteratorFor(oldContainer);
            while (containerPolicy.hasNext(iterator)) {
              Object oldValue = containerPolicy.next(iterator, session);
              compositeMapping.getContainerAccessor().setAttributeValueInObject(oldValue, null);
            }
          }
        }
      }

      // NEW VALUE
      Object container = containerPolicy.containerInstance();
      mapping.getAttributeAccessor().setAttributeValueInObject(entity, container);
    } else {
      // OLD VALUE
      Object oldValue = mapping.getAttributeAccessor().getAttributeValueFromObject(entity);
      if (mapping.isAbstractCompositeObjectMapping()) {
        XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
        if (compositeMapping.getContainerAccessor() != null) {
          if (oldValue != null) {
            compositeMapping.getContainerAccessor().setAttributeValueInObject(oldValue, null);
          }
        }
      }

      // NEW VALUE
      mapping.getAttributeAccessor().setAttributeValueInObject(entity, null);
    }
  }
  private XMLDescriptor getCustomerDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Customer.class);
    xmlDescriptor.setDefaultRootElement("ns:customer");

    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("ns", "urn:example");
    xmlDescriptor.setNamespaceResolver(nsResolver);

    XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
    addressMapping.setAttributeName("address");
    addressMapping.setXPath("//ns:customer/ns:phone-number/preceding-sibling::*[1]");
    addressMapping.setReferenceClass(Address.class);
    xmlDescriptor.addMapping(addressMapping);

    return xmlDescriptor;
  }
 private XMLDescriptor getRootDescriptor() {
   XMLDescriptor descriptor = new XMLDescriptor();
   descriptor.setJavaClass(Root.class);
   descriptor.setDefaultRootElement("root");
   // create employee mapping
   XMLCompositeObjectMapping empMapping = new XMLCompositeObjectMapping();
   empMapping.setAttributeName("employee");
   empMapping.setXPath("employee");
   empMapping.setReferenceClass(Employee.class);
   descriptor.addMapping(empMapping);
   // create address mapping
   XMLCompositeCollectionMapping addMapping = new XMLCompositeCollectionMapping();
   addMapping.setAttributeName("addresses");
   addMapping.setXPath("address");
   addMapping.setReferenceClass(Address.class);
   descriptor.addMapping(addMapping);
   return descriptor;
 }
  public ClassDescriptor buildWrapperDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Wrapper.class);
    descriptor.setDefaultRootElement("myns:wrapper");

    XMLCompositeObjectMapping mapping = new XMLCompositeObjectMapping();
    mapping.setReferenceClass(Root.class);
    mapping.setAttributeName("theRoot");
    mapping.setXPath("myns:root");
    descriptor.addMapping(mapping);

    NamespaceResolver nr = new NamespaceResolver();
    nr.put("myns", "www.example.com/some-dir/some.xsd");
    nr.put("ns0", "www.example.com/test.xsd");
    descriptor.setNamespaceResolver(nr);

    return descriptor;
  }
  // Persistence
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(MWLiteralArgument.class);
    descriptor.getInheritancePolicy().setParentClass(MWArgument.class);

    // 1:1 - type
    XMLCompositeObjectMapping typeMapping = new XMLCompositeObjectMapping();
    typeMapping.setAttributeName("type");
    typeMapping.setReferenceClass(MWTypeDeclaration.class);
    typeMapping.setXPath("type");
    descriptor.addMapping(typeMapping);

    // DTF Object value
    XMLDirectMapping valueMapping =
        (XMLDirectMapping) descriptor.addDirectMapping("value", "value/text()");
    valueMapping.setNullValue("");

    return descriptor;
  }
  protected XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    // descriptor.setDefaultRootElement("employee");
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setXPath("id/text()");
    idMapping.setAttributeName("id");
    descriptor.addMapping(idMapping);

    XMLCompositeObjectMapping emailMapping = new XMLCompositeObjectMapping();
    emailMapping.setAttributeName("emailAddress");
    emailMapping.setXPath("info/email-address");
    emailMapping.setGetMethodName("getEmailAddress");
    emailMapping.setSetMethodName("setEmailAddress");
    emailMapping.setReferenceClass(EmailAddress.class);
    descriptor.addMapping(emailMapping);

    URL schemaURL =
        ClassLoader.getSystemResource("org/eclipse/persistence/testing/oxm/jaxb/Employee.xsd");
    XMLSchemaURLReference schemaRef = new XMLSchemaURLReference(schemaURL);
    schemaRef.setType(XMLSchemaURLReference.COMPLEX_TYPE);
    schemaRef.setSchemaContext("employee-root");
    descriptor.setSchemaReference(schemaRef);

    /*
    NamespaceResolver try_test = new NamespaceResolver();
    try_test.put("xsi", XMLConstants.SCHEMA_INSTANCE_URL);
    descriptor.setNamespaceResolver(try_test);*/
    return descriptor;
  }
  protected ClassDescriptor buildDocumentPreservationPolicyConfigDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(DocumentPreservationPolicyConfig.class);
    descriptor.setDefaultRootElement("document-preservation-policy");

    XMLCompositeObjectMapping nodeOrderingPolicyMapping = new XMLCompositeObjectMapping();
    nodeOrderingPolicyMapping.setReferenceClass(NodeOrderingPolicyConfig.class);
    nodeOrderingPolicyMapping.setAttributeName("m_nodeOrderingPolicy");
    nodeOrderingPolicyMapping.setGetMethodName("getNodeOrderingPolicy");
    nodeOrderingPolicyMapping.setSetMethodName("setNodeOrderingPolicy");
    nodeOrderingPolicyMapping.setXPath("node-ordering-policy");
    descriptor.addMapping(nodeOrderingPolicyMapping);

    descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
    descriptor
        .getInheritancePolicy()
        .addClassIndicator(
            DescriptorLevelDocumentPreservationPolicyConfig.class,
            "descriptor-level-document-preservation-policy");
    descriptor
        .getInheritancePolicy()
        .addClassIndicator(
            NoDocumentPreservationPolicyConfig.class, "no-document-preservation-policy");
    descriptor
        .getInheritancePolicy()
        .addClassIndicator(XMLBinderPolicyConfig.class, "xml-binder-policy");

    return descriptor;
  }
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(MWMapContainerPolicy.class);

    descriptor.getInheritancePolicy().setParentClass(MWContainerPolicy.MWContainerPolicyRoot.class);

    XMLCompositeObjectMapping keyMethodHandleMapping = new XMLCompositeObjectMapping();
    keyMethodHandleMapping.setAttributeName("keyMethodHandle");
    keyMethodHandleMapping.setReferenceClass(MWMethodHandle.class);
    keyMethodHandleMapping.setSetMethodName("setKeyMethodHandleForTopLink");
    keyMethodHandleMapping.setGetMethodName("getKeyMethodHandleForTopLink");
    keyMethodHandleMapping.setXPath("key-method-handle");
    descriptor.addMapping(keyMethodHandleMapping);

    XMLCompositeObjectMapping containerClassMapping = new XMLCompositeObjectMapping();
    containerClassMapping.setAttributeName("containerClass");
    containerClassMapping.setReferenceClass(DefaultingContainerClass.class);
    containerClassMapping.setXPath("container-class");
    descriptor.addMapping(containerClassMapping);

    return descriptor;
  }
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();

    descriptor.setJavaClass(MWQueryableArgumentElement.class);

    XMLCompositeObjectMapping queryableHandleMapping = new XMLCompositeObjectMapping();
    queryableHandleMapping.setAttributeName("queryableHandle");
    queryableHandleMapping.setGetMethodName("getQueryableHandleForTopLink");
    queryableHandleMapping.setSetMethodName("setQueryableHandleForTopLink");
    queryableHandleMapping.setReferenceClass(MWQueryableHandle.class);
    queryableHandleMapping.setXPath("queryable-handle");
    descriptor.addMapping(queryableHandleMapping);

    ((XMLDirectMapping) descriptor.addDirectMapping("allowsNull", "allows-null/text()"))
        .setNullValue(Boolean.FALSE);

    XMLCompositeObjectMapping joinedQueryableElementMapping = new XMLCompositeObjectMapping();
    joinedQueryableElementMapping.setAttributeName("joinedQueryableElement");
    joinedQueryableElementMapping.setReferenceClass(MWQueryableArgumentElement.class);
    joinedQueryableElementMapping.setXPath("joined-queryable-element");
    descriptor.addMapping(joinedQueryableElementMapping);

    return descriptor;
  }
Exemplo n.º 15
0
  /** Set the value on the underlying POJO, unwrapping values as necessary. */
  public void setDeclaredProperty(int propertyIndex, Object value) {
    SDOProperty declaredProperty =
        (SDOProperty) dataObject.getType().getDeclaredProperties().get(propertyIndex);
    if (declaredProperty.getType().isChangeSummaryType()) {
      return;
    }

    Mapping mapping = this.getJAXBMappingForProperty(declaredProperty);

    Object newValue = value;
    Object oldValue = mapping.getAttributeAccessor().getAttributeValueFromObject(entity);

    if (declaredProperty.getType().isDataType()) {
      if (!declaredProperty.isMany()) {
        AbstractSession session =
            ((JAXBContext) jaxbHelperContext.getJAXBContext()).getXMLContext().getSession(entity);
        XMLDirectMapping directMapping = (XMLDirectMapping) mapping;
        if (directMapping.hasConverter()) {
          newValue = directMapping.getConverter().convertDataValueToObjectValue(newValue, session);
        } else {
          CoreField field = mapping.getField();
          newValue =
              session
                  .getDatasourcePlatform()
                  .getConversionManager()
                  .convertObject(
                      newValue,
                      descriptor.getObjectBuilder().getFieldClassification((XMLField) field));
        }
      }
      mapping.setAttributeValueInObject(entity, newValue);
    } else if (declaredProperty.isMany()) {
      // Get a ListWrapper and set it's current elements
      ListWrapper listWrapper = (ListWrapper) getDeclaredProperty(propertyIndex);
      listWrapper.addAll((List) newValue);
    } else {
      // OLD VALUE
      if (mapping.isAbstractCompositeObjectMapping()) {
        XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
        if (oldValue != null && compositeMapping.getContainerAccessor() != null) {
          compositeMapping.getContainerAccessor().setAttributeValueInObject(oldValue, null);
        }
      }

      // NEW VALUE
      newValue = jaxbHelperContext.unwrap((DataObject) value);
      mapping.getAttributeAccessor().setAttributeValueInObject(entity, newValue);
      if (mapping.isAbstractCompositeObjectMapping()) {
        XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
        if (value != null && compositeMapping.getContainerAccessor() != null) {
          compositeMapping.getContainerAccessor().setAttributeValueInObject(newValue, entity);
        }
      }
    }
  }
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();

    descriptor.setJavaClass(MWDirectContainerMapping.class);
    descriptor.getInheritancePolicy().setParentClass(MWMapping.class);

    XMLCompositeObjectMapping converterMapping = new XMLCompositeObjectMapping();
    converterMapping.setReferenceClass(MWConverter.class);
    converterMapping.setAttributeName("directValueConverter");
    converterMapping.setGetMethodName("getConverterForTopLink");
    converterMapping.setSetMethodName("setConverterForTopLink");
    converterMapping.setXPath("direct-value-converter");
    descriptor.addMapping(converterMapping);

    return descriptor;
  }
  public static XMLDescriptor legacy60BuildDescriptor() {
    XMLDescriptor descriptor = MWModel.legacy60BuildStandardDescriptor();

    descriptor.setJavaClass(MWTypeDeclaration.class);

    // 'type' will never be null
    XMLCompositeObjectMapping typeHandleMapping = new XMLCompositeObjectMapping();
    typeHandleMapping.setAttributeName("typeHandle");
    typeHandleMapping.setReferenceClass(MWClassHandle.class);
    typeHandleMapping.setGetMethodName("getTypeHandleForTopLink");
    typeHandleMapping.setSetMethodName("setTypeHandleForTopLink");
    typeHandleMapping.setXPath("type-handle");
    descriptor.addMapping(typeHandleMapping);

    XMLDirectMapping dimMapping =
        (XMLDirectMapping) descriptor.addDirectMapping("dimensionality", "dimensionality/text()");
    dimMapping.setNullValue(new Integer(0));

    return descriptor;
  }
  public ClassDescriptor buildXMLLoginConfigDescriptor() {
    ClassDescriptor descriptor = super.buildXMLLoginConfigDescriptor();

    XMLDirectMapping equalNamespaceResolversMapping = new XMLDirectMapping();
    equalNamespaceResolversMapping.setAttributeName("m_equalNamespaceResolvers");
    equalNamespaceResolversMapping.setGetMethodName("getEqualNamespaceResolvers");
    equalNamespaceResolversMapping.setSetMethodName("setEqualNamespaceResolvers");
    equalNamespaceResolversMapping.setXPath("equal-namespace-resolvers/text()");
    equalNamespaceResolversMapping.setNullValue(Boolean.TRUE);
    descriptor.addMapping(equalNamespaceResolversMapping);

    XMLCompositeObjectMapping documentPreservationPolicyMapping = new XMLCompositeObjectMapping();
    documentPreservationPolicyMapping.setReferenceClass(DocumentPreservationPolicyConfig.class);
    documentPreservationPolicyMapping.setAttributeName("m_documentPreservationPolicy");
    documentPreservationPolicyMapping.setGetMethodName("getDocumentPreservationPolicy");
    documentPreservationPolicyMapping.setSetMethodName("setDocumentPreservationPolicy");
    documentPreservationPolicyMapping.setXPath("document-preservation-policy");
    descriptor.addMapping(documentPreservationPolicyMapping);

    return descriptor;
  }
Exemplo n.º 19
0
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();

    descriptor.setJavaClass(MWEisLoginSpec.class);

    descriptor.addDirectMapping("name", "name/text()");

    descriptor.addDirectMapping(
        "j2cAdapterName",
        "getJ2CAdapterNameForTopLink",
        "setJ2CAdapterNameForTopLink",
        "j2c-adapter-name/text()");

    descriptor.addDirectMapping("userName", "user-name/text()");
    descriptor.addDirectMapping(
        "password", "getPasswordForTopLink", "setPasswordForTopLink", "password/text()");
    descriptor.addDirectMapping("connectionFactoryUrl", "connection-factory-url/text()");
    ((XMLDirectMapping) descriptor.addDirectMapping("savePassword", "save-password/text()"))
        .setNullValue(Boolean.FALSE);

    XMLCompositeObjectMapping connectionSpecClassHandleMapping = new XMLCompositeObjectMapping();
    connectionSpecClassHandleMapping.setAttributeName("connectionSpecClassHandle");
    connectionSpecClassHandleMapping.setGetMethodName("getConnectionSpecClassHandleForTopLink");
    connectionSpecClassHandleMapping.setSetMethodName("setConnectionSpecClassHandleForTopLink");
    connectionSpecClassHandleMapping.setReferenceClass(MWClassHandle.class);
    connectionSpecClassHandleMapping.setXPath("connection-spec-class-handle");
    descriptor.addMapping(connectionSpecClassHandleMapping);

    XMLCompositeCollectionMapping propertiesMapping = new XMLCompositeCollectionMapping();
    propertiesMapping.setReferenceClass(MWProperty.class);
    propertiesMapping.setAttributeName("properties");
    propertiesMapping.setGetMethodName("getPropertiesForTopLink");
    propertiesMapping.setSetMethodName("setPropertiesForTopLink");
    propertiesMapping.setXPath("property");
    descriptor.addMapping(propertiesMapping);

    return descriptor;
  }
  // **************** TopLink Methods *****************
  @SuppressWarnings("deprecation")
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(MWAbstractXmlDirectCollectionMapping.class);
    descriptor.getInheritancePolicy().setParentClass(MWDirectContainerMapping.class);

    XMLCompositeObjectMapping xmlFieldMapping = new XMLCompositeObjectMapping();
    xmlFieldMapping.setReferenceClass(MWXmlField.class);
    xmlFieldMapping.setAttributeName("xmlField");
    xmlFieldMapping.setGetMethodName("getXmlFieldForTopLink");
    xmlFieldMapping.setSetMethodName("setXmlFieldForTopLink");
    xmlFieldMapping.setXPath("xpath");
    descriptor.addMapping(xmlFieldMapping);

    XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping();
    containerPolicyMapping.setAttributeName("containerPolicy");
    containerPolicyMapping.setReferenceClass(MWContainerPolicy.MWContainerPolicyRoot.class);
    containerPolicyMapping.setGetMethodName("getContainerPolicyForToplink");
    containerPolicyMapping.setSetMethodName("setContainerPolicyForToplink");
    containerPolicyMapping.setXPath("container-policy");
    descriptor.addMapping(containerPolicyMapping);

    return descriptor;
  }
 @Override
 public void handleObjectType(String objectTypeName, String targetTypeName, int numAttributes) {
   // JDBC Advanced type?
   if (numAttributes > 0) {
     // trim-off dotted-prefix, toLowerCase
     String objectTypeNameAlias = trimDotPrefix(objectTypeName).toLowerCase();
     XMLDescriptor xdesc = descriptorMap.get(objectTypeNameAlias);
     String userType = nct.generateSchemaAlias(objectTypeNameAlias);
     if (xdesc == null) {
       xdesc = new XMLDescriptor();
       xdesc.setAlias(objectTypeNameAlias);
       xdesc.setJavaClassName(packageName.toLowerCase() + "." + objectTypeNameAlias);
       xdesc.getQueryManager();
       XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
       schemaReference.setSchemaContext("/" + userType);
       schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
       xdesc.setSchemaReference(schemaReference);
       NamespaceResolver nr = new NamespaceResolver();
       nr.setDefaultNamespaceURI(targetNamespace);
       xdesc.setNamespaceResolver(nr);
       descriptorMap.put(objectTypeNameAlias, xdesc);
     }
     // before we push the new ObjectTypeHelper, check stac to see if we are part
     // of nested chain of object types
     if (!stac.isEmpty()) {
       ListenerHelper listenerHelper = stac.peek();
       if (listenerHelper.isAttribute()) {
         AttributeFieldHelper fieldHelper = (AttributeFieldHelper) stac.pop();
         fieldHelper.setSqlTypeName(objectTypeNameAlias);
         String fieldName = fieldHelper.attributeFieldName();
         String attributeName = fieldName.toLowerCase();
         ListenerHelper listenerHelper2 = stac.peek();
         if (listenerHelper2.isObject()) {
           ObjectTypeHelper objectTypeHelper2 = (ObjectTypeHelper) listenerHelper2;
           String objectTypeNameAlias2 = objectTypeHelper2.objectTypename();
           XMLDescriptor xdesc2 = descriptorMap.get(objectTypeNameAlias2);
           if (xdesc2 != null) {
             DatabaseMapping dm = xdesc2.getMappingForAttributeName(attributeName);
             if (dm == null) {
               XMLCompositeObjectMapping compMapping = new XMLCompositeObjectMapping();
               compMapping.setAttributeName(attributeName);
               compMapping.setReferenceClassName(xdesc.getJavaClassName());
               compMapping.setXPath(attributeName);
               XMLField xField = (XMLField) compMapping.getField();
               xField.setRequired(true);
               xdesc2.addMapping(compMapping);
             }
             // last attribute, pop ObjectTypeHelper off stack
             int numAttributes2 = objectTypeHelper2.decrNumAttributes();
             if (numAttributes2 == 0) {
               stac.pop();
             }
           }
         }
       } else if (listenerHelper.isArray()) {
         SqlArrayTypeHelper sqlArrayTypeHelper = (SqlArrayTypeHelper) stac.pop();
         String sqlArrayTypeAlias = sqlArrayTypeHelper.arrayTypename();
         XMLDescriptor xdesc2 = descriptorMap.get(sqlArrayTypeAlias);
         if (xdesc2 != null) {
           boolean itemsMappingFound =
               xdesc2.getMappingForAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME) == null
                   ? false
                   : true;
           if (!itemsMappingFound) {
             XMLCompositeCollectionMapping itemsMapping = new XMLCompositeCollectionMapping();
             itemsMapping.setAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME);
             itemsMapping.setXPath(ITEM_MAPPING_NAME);
             itemsMapping.useCollectionClassName("java.util.ArrayList");
             itemsMapping.setReferenceClassName(xdesc.getJavaClassName());
             xdesc2.addMapping(itemsMapping);
           }
         }
       } else if (listenerHelper.isReturnArg()) {
         // ReturnArgHelper returnArgHelper = (ReturnArgHelper)stac.pop();
         stac.pop();
         xdesc.setDefaultRootElement(userType);
       }
     }
     stac.push(new ObjectTypeHelper(objectTypeNameAlias, targetTypeName, numAttributes));
   }
 }
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(MWEisOneToManyMapping.class);
    descriptor.getInheritancePolicy().setParentClass(MWEisReferenceMapping.class);

    // use an object type mapping so we can preserve object identity
    ObjectTypeConverter foreignKeyLocationConverter = new ObjectTypeConverter();
    foreignKeyLocationConverter.addConversionValue(KEYS_ON_TARGET, KEYS_ON_TARGET);
    foreignKeyLocationConverter.addConversionValue(KEYS_ON_SOURCE, KEYS_ON_SOURCE);
    XMLDirectMapping foreignKeyLocationMapping = new XMLDirectMapping();
    foreignKeyLocationMapping.setAttributeName("foreignKeyLocation");
    foreignKeyLocationMapping.setXPath("foreign-key-location/text()");
    foreignKeyLocationMapping.setNullValue(KEYS_ON_SOURCE);
    foreignKeyLocationMapping.setConverter(foreignKeyLocationConverter);
    descriptor.addMapping(foreignKeyLocationMapping);

    XMLCompositeObjectMapping groupingElementMapping = new XMLCompositeObjectMapping();
    groupingElementMapping.setAttributeName("foreignKeyGroupingElement");
    groupingElementMapping.setReferenceClass(MWXmlField.class);
    groupingElementMapping.setGetMethodName("getGroupingElementForTopLink");
    groupingElementMapping.setSetMethodName("setGroupingElementForTopLink");
    groupingElementMapping.setXPath("foreign-key-grouping-element");
    descriptor.addMapping(groupingElementMapping);

    XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping();
    containerPolicyMapping.setAttributeName("containerPolicy");
    containerPolicyMapping.setReferenceClass(MWContainerPolicy.MWContainerPolicyRoot.class);
    containerPolicyMapping.setXPath("container-policy");
    descriptor.addMapping(containerPolicyMapping);

    XMLCompositeObjectMapping deleteAllInteractionMapping = new XMLCompositeObjectMapping();
    deleteAllInteractionMapping.setAttributeName("deleteAllInteraction");
    deleteAllInteractionMapping.setReferenceClass(MWEisInteraction.class);
    deleteAllInteractionMapping.setXPath("delete-all-interaction");
    descriptor.addMapping(deleteAllInteractionMapping);

    return descriptor;
  }