diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java | 187 |
1 files changed, 0 insertions, 187 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java deleted file mode 100644 index 177b534ba7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.context.orm; - -import java.util.List; -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.RelationshipMapping; -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.OrmManyToManyMapping; -import org.eclipse.jpt.core.context.orm.OrmManyToManyRelationshipReference; -import org.eclipse.jpt.core.context.orm.OrmMappedByJoiningStrategy; -import org.eclipse.jpt.core.context.orm.OrmOwnableRelationshipReference; -import org.eclipse.jpt.core.context.orm.OrmRelationshipReference; -import org.eclipse.jpt.core.resource.orm.XmlManyToMany; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericOrmManyToManyRelationshipReference - extends AbstractOrmRelationshipReference - implements OrmManyToManyRelationshipReference -{ - protected OrmMappedByJoiningStrategy mappedByJoiningStrategy; - - protected OrmJoinTableJoiningStrategy joinTableJoiningStrategy; - - - public GenericOrmManyToManyRelationshipReference( - OrmManyToManyMapping parent, XmlManyToMany resource) { - super(parent, resource); - } - - - @Override - protected void initializeJoiningStrategies() { - this.mappedByJoiningStrategy = buildMappedByJoiningStrategy(); - - // initialize join table last, as the existence of a default join - // table is dependent on the other mechanisms (mappedBy) - // not being specified - this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy(); - } - - protected OrmMappedByJoiningStrategy buildMappedByJoiningStrategy() { - return new GenericOrmMappedByJoiningStrategy(this, getResourceMapping()); - } - - protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() { - return new GenericOrmJoinTableJoiningStrategy(this, getResourceMapping()); - } - - public void initializeOn(OrmRelationshipReference newRelationshipReference) { - newRelationshipReference.initializeFromOwnableRelationshipReference(this); - newRelationshipReference.initializeFromJoinTableEnabledRelationshipReference(this); - } - - @Override - public void initializeFromOwnableRelationshipReference( - OrmOwnableRelationshipReference oldRelationshipReference) { - super.initializeFromOwnableRelationshipReference(oldRelationshipReference); - this.mappedByJoiningStrategy.setMappedByAttribute( - oldRelationshipReference.getMappedByJoiningStrategy().getMappedByAttribute()); - } - - @Override - public void initializeFromJoinTableEnabledRelationshipReference( - OrmJoinTableEnabledRelationshipReference oldRelationshipReference) { - super.initializeFromJoinTableEnabledRelationshipReference(oldRelationshipReference); - OrmJoinTable oldTable = - oldRelationshipReference.getJoinTableJoiningStrategy().getJoinTable(); - if (oldTable != null) { - this.joinTableJoiningStrategy.addJoinTable().initializeFrom(oldTable); - } - } - - - @Override - public OrmManyToManyMapping getRelationshipMapping() { - return (OrmManyToManyMapping) super.getRelationshipMapping(); - } - - public XmlManyToMany getResourceMapping() { - return getRelationshipMapping().getResourceAttributeMapping(); - } - - public boolean isRelationshipOwner() { - return this.mappedByJoiningStrategy.getMappedByAttribute() == null; - } - - public boolean isOwnedBy(RelationshipMapping mapping) { - return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping); - } - - @Override - protected OrmJoiningStrategy calculatePredominantJoiningStrategy() { - if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) { - return this.mappedByJoiningStrategy; - } - return this.joinTableJoiningStrategy; - } - - - // **************** mapped by ********************************************** - - public OrmMappedByJoiningStrategy getMappedByJoiningStrategy() { - return this.mappedByJoiningStrategy; - } - - public boolean usesMappedByJoiningStrategy() { - return getPredominantJoiningStrategy() == this.mappedByJoiningStrategy; - } - - public void setMappedByJoiningStrategy() { - this.mappedByJoiningStrategy.addStrategy(); - this.joinTableJoiningStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public void unsetMappedByJoiningStrategy() { - this.mappedByJoiningStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public boolean mayBeMappedBy(AttributeMapping mappedByMapping) { - return mappedByMapping.getKey() == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY; - } - - - // **************** join table joining strategy *************************** - - public OrmJoinTableJoiningStrategy getJoinTableJoiningStrategy() { - return this.joinTableJoiningStrategy; - } - - public boolean usesJoinTableJoiningStrategy() { - return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy; - } - - public void setJoinTableJoiningStrategy() { - // join table is the default strategy, so no need to add to resource - this.mappedByJoiningStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public void unsetJoinTableJoiningStrategy() { - this.joinTableJoiningStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public boolean mayHaveDefaultJoinTable() { - return getMappedByJoiningStrategy().getMappedByAttribute() == null; - } - - - // **************** resource => context ************************************ - - @Override - protected void updateJoiningStrategies() { - this.mappedByJoiningStrategy.update(); - - // update join table last, as the existence of a default join - // table is dependent on the other mechanisms (mappedBy) - // not being specified - this.joinTableJoiningStrategy.update(); - } - - - // **************** Validation ********************************************* - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.mappedByJoiningStrategy.validate(messages, reporter); - this.joinTableJoiningStrategy.validate(messages, reporter); - } -} |