org.eclipse.persistence.exceptions.DescriptorException Java Examples

The following examples show how to use org.eclipse.persistence.exceptions.DescriptorException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KradEclipseLinkCustomizer.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Checks class descriptors for {@link @RemoveMapping} and {@link RemoveMappings} annotations at the class level
 * and removes any specified mappings from the ClassDescriptor.
 *
 * @param session the current session.
 */
protected void handleRemoveMapping(Session session) {
    Map<Class, ClassDescriptor> descriptors = session.getDescriptors();

    if (descriptors == null || descriptors.isEmpty()) {
        return;
    }

    for (ClassDescriptor classDescriptor : descriptors.values()) {
        List<DatabaseMapping> mappingsToRemove = new ArrayList<DatabaseMapping>();
        List<RemoveMapping> removeMappings = scanForRemoveMappings(classDescriptor);

        for (RemoveMapping removeMapping : removeMappings) {
            if (StringUtils.isBlank(removeMapping.name())) {
                throw DescriptorException.attributeNameNotSpecified();
            }

            DatabaseMapping databaseMapping = classDescriptor.getMappingForAttributeName(removeMapping.name());

            if (databaseMapping == null) {
                throw DescriptorException.mappingForAttributeIsMissing(removeMapping.name(), classDescriptor);
            }

            mappingsToRemove.add(databaseMapping);
        }

        for (DatabaseMapping mappingToRemove : mappingsToRemove) {
            classDescriptor.removeMappingForAttributeName(mappingToRemove.getAttributeName());
        }
    }
}
 
Example #2
Source File: DescriptorEventManagerWrapper.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void executeEvent(DescriptorEvent event) throws DescriptorException {
    delegate.executeEvent(event);
}