blob: 9a680bf59787902b16300b1963e416dce45bd949 [file] [log] [blame]
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.testing.oxm.mappings.compositecollection.setmethod;
import org.eclipse.persistence.sessions.Project;
import org.eclipse.persistence.oxm.XMLDescriptor;
import org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping;
import org.eclipse.persistence.oxm.mappings.XMLDirectMapping;
public class CustomerProject extends Project {
public CustomerProject() {
super();
this.addDescriptor(getCustomerDescriptor());
this.addDescriptor(getPhoneNumberDescriptor());
}
public XMLDescriptor getCustomerDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Customer.class);
xmlDescriptor.setDefaultRootElement("customer");
XMLCompositeCollectionMapping phoneNumbersMapping = new XMLCompositeCollectionMapping();
phoneNumbersMapping.setAttributeName("phoneNumbers");
phoneNumbersMapping.setGetMethodName("getPhoneNumbers");
phoneNumbersMapping.setSetMethodName("setPhoneNumbers");
phoneNumbersMapping.setXPath("phone-number");
phoneNumbersMapping.setReferenceClass(PhoneNumber.class);
xmlDescriptor.addMapping(phoneNumbersMapping);
return xmlDescriptor;
}
public XMLDescriptor getPhoneNumberDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(PhoneNumber.class);
XMLDirectMapping valueMapping = new XMLDirectMapping();
valueMapping.setAttributeName("value");
valueMapping.setXPath("text()");
xmlDescriptor.addMapping(valueMapping);
return xmlDescriptor;
}
}