| /******************************************************************************* |
| * Copyright (c) 2008, 2015 Oracle. All rights reserved. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License 2.0, which accompanies this distribution |
| * and is available at https://www.eclipse.org/legal/epl-2.0/. |
| * |
| * Contributors: |
| * Oracle - initial API and implementation |
| ******************************************************************************/ |
| package org.eclipse.jpt.jpa.eclipselink.core.internal.context.java; |
| |
| import java.util.List; |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement; |
| import org.eclipse.jpt.common.utility.internal.iterable.IterableTools; |
| import org.eclipse.jpt.jpa.core.context.java.JavaConverter; |
| import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute; |
| import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaIdMapping; |
| import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkIdMapping2_0; |
| import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMutable; |
| import org.eclipse.jpt.jpa.eclipselink.core.context.java.EclipseLinkJavaConverterContainer; |
| import org.eclipse.jpt.jpa.eclipselink.core.context.java.EclipseLinkJavaConvertibleMapping; |
| import org.eclipse.wst.validation.internal.provisional.core.IMessage; |
| import org.eclipse.wst.validation.internal.provisional.core.IReporter; |
| |
| public class EclipseLinkJavaIdMapping |
| extends AbstractJavaIdMapping |
| implements |
| EclipseLinkIdMapping2_0, |
| EclipseLinkJavaConvertibleMapping |
| { |
| protected final EclipseLinkJavaMutable mutable; |
| |
| protected final EclipseLinkJavaConverterContainer converterContainer; |
| |
| |
| public EclipseLinkJavaIdMapping(JavaSpecifiedPersistentAttribute parent) { |
| super(parent); |
| this.mutable = new EclipseLinkJavaMutable(this); |
| this.converterContainer = this.buildConverterContainer(); |
| } |
| |
| |
| // ********** synchronize/update ********** |
| |
| @Override |
| public void synchronizeWithResourceModel(IProgressMonitor monitor) { |
| super.synchronizeWithResourceModel(monitor); |
| this.mutable.synchronizeWithResourceModel(monitor); |
| this.converterContainer.synchronizeWithResourceModel(monitor); |
| } |
| |
| @Override |
| public void update(IProgressMonitor monitor) { |
| super.update(monitor); |
| this.mutable.update(monitor); |
| this.converterContainer.update(monitor); |
| } |
| |
| |
| // ********** mutable ********** |
| |
| public EclipseLinkMutable getMutable() { |
| return this.mutable; |
| } |
| |
| |
| // ********** converters ********** |
| |
| public EclipseLinkJavaConverterContainer getConverterContainer() { |
| return this.converterContainer; |
| } |
| |
| protected EclipseLinkJavaConverterContainer buildConverterContainer() { |
| return new EclipseLinkJavaConverterContainerImpl(this); |
| } |
| |
| // ********** converter container parent ********** |
| |
| public JavaResourceAnnotatedElement getJavaResourceAnnotatedElement() { |
| return this.getResourceAttribute(); |
| } |
| |
| public boolean supportsConverters() { |
| return ! this.getPersistentAttribute().isVirtual(); |
| } |
| |
| // ********** converter adapters ********** |
| |
| /** |
| * put the EclipseLink convert adapter first - this is the order EclipseLink searches |
| */ |
| @Override |
| protected Iterable<JavaConverter.Adapter> getConverterAdapters() { |
| return IterableTools.insert(EclipseLinkJavaConvert.Adapter.instance(), super.getConverterAdapters()); |
| } |
| |
| |
| // ********** validation ********** |
| |
| @Override |
| public void validate(List<IMessage> messages, IReporter reporter) { |
| super.validate(messages, reporter); |
| this.mutable.validate(messages, reporter); |
| } |
| } |