Skip to main content
summaryrefslogtreecommitdiffstats
blob: a4e66fee61cbda2b90743829b7451bc5a7d5858c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************************************
 * Copyright (c)2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
 * 
 * Contributors:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.core.internal.jpa2.context.orm;

import org.eclipse.emf.common.util.EList;
import org.eclipse.jpt.core.context.JoinTable;
import org.eclipse.jpt.core.context.JoinTableJoiningStrategy;
import org.eclipse.jpt.core.context.JoiningStrategy;
import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
import org.eclipse.jpt.core.internal.context.orm.VirtualXmlAssociationOverride;
import org.eclipse.jpt.core.internal.context.orm.VirtualXmlJoinTable;
import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
import org.eclipse.jpt.core.resource.orm.XmlJoinTable;

public class VirtualXmlAssociationOverride2_0 extends XmlAssociationOverride
{
	protected OrmTypeMapping ormTypeMapping;
	
	protected final JoiningStrategy joiningStrategy;
	
	protected final VirtualXmlAssociationOverride virtualXmlAssociationOverride;

	public VirtualXmlAssociationOverride2_0(String name, OrmTypeMapping ormTypeMapping, JoiningStrategy joiningStrategy) {
		super();
		this.ormTypeMapping = ormTypeMapping;
		this.joiningStrategy = joiningStrategy;
		this.virtualXmlAssociationOverride = new VirtualXmlAssociationOverride(name, ormTypeMapping, joiningStrategy);
	}
	
	protected boolean isOrmMetadataComplete() {
		return this.ormTypeMapping.isMetadataComplete();
	}

	@Override
	public String getName() {
		return this.virtualXmlAssociationOverride.getName();
	}
	
	@Override
	public void setName(String value) {
		this.virtualXmlAssociationOverride.setName(value);
	}

	@Override
	public EList<XmlJoinColumn> getJoinColumns() {
		return this.virtualXmlAssociationOverride.getJoinColumns();
	}
	
	@Override
	public XmlJoinTable getJoinTable() {
		if (this.joiningStrategy instanceof JoinTableJoiningStrategy) {
			JoinTable joinTable = ((JoinTableJoiningStrategy) this.joiningStrategy).getJoinTable();
			if (joinTable != null) {
				return new VirtualXmlJoinTable(
					this.ormTypeMapping, 
					joinTable);
			}
		}
		return null;
	}
	
	@Override
	public void setJoinTable(XmlJoinTable newJoinTable) {
		throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
	}
}

Back to the top