| /******************************************************************************* |
| * Copyright (c) 2010 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.jpt.core.context.orm.OrmJoinTable; |
| import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference; |
| import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy; |
| import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy; |
| import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping; |
| import org.eclipse.jpt.core.context.orm.OrmRelationshipReference; |
| import org.eclipse.jpt.core.internal.context.orm.AbstractOrmOneToOneRelationshipReference; |
| import org.eclipse.jpt.core.internal.context.orm.GenericOrmJoinTableJoiningStrategy; |
| import org.eclipse.jpt.core.resource.orm.XmlOneToOne; |
| |
| public class GenericOrmOneToOneRelationshipReference2_0 |
| extends AbstractOrmOneToOneRelationshipReference |
| { |
| |
| |
| public GenericOrmOneToOneRelationshipReference2_0( |
| OrmOneToOneMapping parent, XmlOneToOne resource) { |
| super(parent, resource); |
| } |
| |
| |
| @Override |
| protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() { |
| return new GenericOrmJoinTableJoiningStrategy(this, getResourceMapping()); |
| } |
| |
| @Override |
| public void initializeOn(OrmRelationshipReference newRelationshipReference) { |
| super.initializeOn(newRelationshipReference); |
| newRelationshipReference.initializeFromJoinTableEnabledRelationshipReference(this); |
| // no other primary key reference as of yet, so no initialization based on pk join columns |
| } |
| |
| @Override |
| public void initializeFromJoinTableEnabledRelationshipReference( |
| OrmJoinTableEnabledRelationshipReference oldRelationshipReference) { |
| super.initializeFromJoinTableEnabledRelationshipReference(oldRelationshipReference); |
| OrmJoinTable oldTable = |
| oldRelationshipReference.getJoinTableJoiningStrategy().getJoinTable(); |
| if (oldTable != null) { |
| this.joinTableJoiningStrategy.addJoinTable().initializeFrom(oldTable); |
| } |
| } |
| |
| @Override |
| protected OrmJoiningStrategy calculatePredominantJoiningStrategy() { |
| if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) { |
| return this.mappedByJoiningStrategy; |
| } |
| else if (this.primaryKeyJoinColumnJoiningStrategy.primaryKeyJoinColumnsSize() > 0) { |
| return this.primaryKeyJoinColumnJoiningStrategy; |
| } |
| else if (this.joinTableJoiningStrategy.getJoinTable() != null){ |
| return this.joinTableJoiningStrategy; |
| } |
| return this.joinColumnJoiningStrategy; |
| } |
| } |