Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JavaRelationshipMappingContext.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JavaRelationshipMappingContext.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JavaRelationshipMappingContext.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JavaRelationshipMappingContext.java
new file mode 100644
index 0000000000..8c5b1f40b7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JavaRelationshipMappingContext.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.platform;
+
+import org.eclipse.jpt.core.internal.IPersistentType;
+import org.eclipse.jpt.core.internal.ITypeMapping;
+import org.eclipse.jpt.core.internal.content.java.mappings.JavaRelationshipMapping;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.IRelationshipMapping;
+
+public abstract class JavaRelationshipMappingContext extends JavaAttributeContext
+{
+ protected JavaRelationshipMappingContext(IContext parentContext, JavaRelationshipMapping mapping) {
+ super(parentContext, mapping);
+ }
+
+ protected IRelationshipMapping getMapping() {
+ return (IRelationshipMapping) super.getMapping();
+ }
+
+ protected IEntity targetEntity(DefaultsContext defaultsContext) {
+ String targetEntity = getMapping().fullyQualifiedTargetEntity();
+ if (targetEntity == null) {
+ return null;
+ }
+ IPersistentType persistentType = defaultsContext.persistentType(targetEntity);
+ if (persistentType != null) {
+ ITypeMapping typeMapping = persistentType.getMapping();
+ if (typeMapping instanceof IEntity) {
+ return (IEntity) typeMapping;
+ }
+ }
+ return null;
+ }
+
+
+ @Override
+ protected Object getDefault(String key, DefaultsContext defaultsContext) {
+ if (key.equals(BaseJpaPlatform.DEFAULT_TARGET_ENTITY_KEY)) {
+ return getMapping().fullyQualifiedTargetEntity();
+ }
+ return super.getDefault(key, defaultsContext);
+ }
+
+}

Back to the top