Search in sources :

Example 6 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class XMLEntityMappingsMappingProject method getPrivateOwnedMapping.

/**
 * INTERNAL:
 */
protected XMLDirectMapping getPrivateOwnedMapping() {
    XMLDirectMapping privateOwnedMapping = new XMLDirectMapping();
    privateOwnedMapping.setAttributeName("m_privateOwned");
    privateOwnedMapping.setGetMethodName("getPrivateOwned");
    privateOwnedMapping.setSetMethodName("setPrivateOwned");
    privateOwnedMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy privateOwnedPolicy = new IsSetNullPolicy("isPrivateOwned");
    privateOwnedPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    privateOwnedMapping.setNullPolicy(privateOwnedPolicy);
    privateOwnedMapping.setXPath("orm:private-owned");
    return privateOwnedMapping;
}
Also used : XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)

Example 7 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class SDOProperty method setIsSetPolicyOnMapping.

/**
 * INTERNAL:
 * Create and set an IsSetNodePolicy on the mapping - leaving the policy in default state
 * @param aMapping
 * @param propertyName
 * @return
 */
private AbstractNullPolicy setIsSetPolicyOnMapping(XMLNillableMapping aMapping, Object propertyName) {
    AbstractNullPolicy aNullPolicy = new IsSetNullPolicy();
    // Set the isSet method signature on policy
    ((IsSetNullPolicy) aNullPolicy).setIsSetMethodName(SDOConstants.SDO_ISSET_METHOD_NAME);
    // Set fields even though defaults are set
    // aNullPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    // Parameter type is always String
    ((IsSetNullPolicy) aNullPolicy).setIsSetParameterTypes(new Class<?>[] { ClassConstants.STRING });
    ((IsSetNullPolicy) aNullPolicy).setIsSetParameters(new Object[] { propertyName });
    aMapping.setNullPolicy(aNullPolicy);
    return aNullPolicy;
}
Also used : AbstractNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)

Example 8 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class XmlBindingsGenerator method isDefaultNullPolicy.

/**
 * Indicates is a given AbstractNullPolicy is the default.  This is useful
 * if it is not desirable to write out the default policy in the oxm
 * metadata file.
 *
 * The default policy is NullPolicy, with the following set:
 * <ul>
 * <li>isNullRepresentedByXsiNil = false
 * <li>isNullRepresentedByEmptyNode = true
 * <li>isSetPerformedForAbsentNode = true
 * <li>marshalNullRepresentation = XMLNullRepresentationType.ABSENT_NODE
 * </ul>
 */
protected static boolean isDefaultNullPolicy(AbstractNullPolicy nullPolicy) {
    // default policy is NullPolicy
    if (nullPolicy instanceof IsSetNullPolicy) {
        return false;
    }
    boolean xsiNil = nullPolicy.isNullRepresentedByXsiNil();
    boolean emptyNode = nullPolicy.isNullRepresentedByEmptyNode();
    boolean setForAbsent = nullPolicy.getIsSetPerformedForAbsentNode();
    XMLNullRepresentationType marshalNull = nullPolicy.getMarshalNullRepresentation();
    return (!xsiNil && emptyNode && setForAbsent && marshalNull == XMLNullRepresentationType.ABSENT_NODE);
}
Also used : XMLNullRepresentationType(org.eclipse.persistence.oxm.mappings.nullpolicy.XMLNullRepresentationType) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy) XmlIsSetNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy)

Example 9 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class XMLEntityMappingsMappingProject method getReturnUpdateMapping.

/**
 * INTERNAL:
 */
protected XMLDirectMapping getReturnUpdateMapping() {
    XMLDirectMapping mapping = new XMLDirectMapping();
    mapping.setAttributeName("m_returnUpdate");
    mapping.setGetMethodName("getReturnUpdate");
    mapping.setSetMethodName("setReturnUpdate");
    mapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy returnUpdatePolicy = new IsSetNullPolicy("isReturnUpdate");
    returnUpdatePolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    mapping.setNullPolicy(returnUpdatePolicy);
    mapping.setXPath("orm:return-update");
    return mapping;
}
Also used : XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)

Example 10 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class XMLEntityMappingsMappingProject method buildPersistenceUnitMetadataDescriptor.

/**
 * INTERNAL:
 * XSD: persistence-unit-metadata
 */
protected ClassDescriptor buildPersistenceUnitMetadataDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(XMLPersistenceUnitMetadata.class);
    XMLDirectMapping xmlMappingMetadataCompleteMapping = new XMLDirectMapping();
    xmlMappingMetadataCompleteMapping.setAttributeName("m_xmlMappingMetadataComplete");
    xmlMappingMetadataCompleteMapping.setGetMethodName("getXMLMappingMetadataComplete");
    xmlMappingMetadataCompleteMapping.setSetMethodName("setXMLMappingMetadataComplete");
    xmlMappingMetadataCompleteMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy xmlMappingMetadataCompletePolicy = new IsSetNullPolicy("isXMLMappingMetadataComplete");
    xmlMappingMetadataCompletePolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    xmlMappingMetadataCompleteMapping.setNullPolicy(xmlMappingMetadataCompletePolicy);
    xmlMappingMetadataCompleteMapping.setXPath("orm:xml-mapping-metadata-complete");
    descriptor.addMapping(xmlMappingMetadataCompleteMapping);
    XMLDirectMapping excludeDefaultMappingsMapping = new XMLDirectMapping();
    excludeDefaultMappingsMapping.setAttributeName("m_excludeDefaultMappings");
    excludeDefaultMappingsMapping.setGetMethodName("getExcludeDefaultMappings");
    excludeDefaultMappingsMapping.setSetMethodName("setExcludeDefaultMappings");
    excludeDefaultMappingsMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy excludeDefaultMappingsPolicy = new IsSetNullPolicy("excludeDefaultMappings");
    excludeDefaultMappingsPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    excludeDefaultMappingsMapping.setNullPolicy(excludeDefaultMappingsPolicy);
    excludeDefaultMappingsMapping.setXPath("orm:exclude-default-mappings");
    descriptor.addMapping(excludeDefaultMappingsMapping);
    XMLCompositeObjectMapping persistenceUnitDefaultsMapping = new XMLCompositeObjectMapping();
    persistenceUnitDefaultsMapping.setAttributeName("m_persistenceUnitDefaults");
    persistenceUnitDefaultsMapping.setGetMethodName("getPersistenceUnitDefaults");
    persistenceUnitDefaultsMapping.setSetMethodName("setPersistenceUnitDefaults");
    persistenceUnitDefaultsMapping.setReferenceClass(XMLPersistenceUnitDefaults.class);
    persistenceUnitDefaultsMapping.setXPath("orm:persistence-unit-defaults");
    descriptor.addMapping(persistenceUnitDefaultsMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)

Aggregations

IsSetNullPolicy (org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)14 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)11 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)4 XmlIsSetNullPolicy (org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy)3 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)2 AbstractNullPolicy (org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy)2 ArrayList (java.util.ArrayList)1 CoreDescriptor (org.eclipse.persistence.core.descriptors.CoreDescriptor)1 CoreMapping (org.eclipse.persistence.core.mappings.CoreMapping)1 CoreConverter (org.eclipse.persistence.core.mappings.converters.CoreConverter)1 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)1 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)1 JAXBException (org.eclipse.persistence.exceptions.JAXBException)1 InstanceVariableAttributeAccessor (org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor)1 MethodAttributeAccessor (org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor)1 VirtualAttributeAccessor (org.eclipse.persistence.internal.descriptors.VirtualAttributeAccessor)1 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)1 CustomAccessorAttributeAccessor (org.eclipse.persistence.internal.jaxb.CustomAccessorAttributeAccessor)1 DefaultElementConverter (org.eclipse.persistence.internal.jaxb.DefaultElementConverter)1 DomHandlerConverter (org.eclipse.persistence.internal.jaxb.DomHandlerConverter)1