Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmDiscriminatorColumn.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmDiscriminatorColumn.java223
1 files changed, 0 insertions, 223 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmDiscriminatorColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmDiscriminatorColumn.java
deleted file mode 100644
index ab4649463a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmDiscriminatorColumn.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 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.jpa1.context.orm;
-
-import java.util.List;
-
-import org.eclipse.jpt.core.context.DiscriminatorColumn;
-import org.eclipse.jpt.core.context.DiscriminatorType;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.orm.OrmDiscriminatorColumn;
-import org.eclipse.jpt.core.internal.context.orm.AbstractOrmNamedColumn;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlDiscriminatorColumn;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmDiscriminatorColumn extends AbstractOrmNamedColumn<XmlDiscriminatorColumn>
- implements OrmDiscriminatorColumn
-{
-
- protected DiscriminatorType specifiedDiscriminatorType;
-
- protected DiscriminatorType defaultDiscriminatorType;
-
- protected Integer specifiedLength;
-
- protected int defaultLength;
-
- protected XmlEntity entity;
-
- public GenericOrmDiscriminatorColumn(XmlContextNode parent, OrmDiscriminatorColumn.Owner owner) {
- super(parent, owner);
- }
-
- @Override
- public OrmDiscriminatorColumn.Owner getOwner() {
- return (OrmDiscriminatorColumn.Owner) super.getOwner();
- }
-
- public DiscriminatorType getDiscriminatorType() {
- return (this.getSpecifiedDiscriminatorType() == null) ? this.getDefaultDiscriminatorType() : this.getSpecifiedDiscriminatorType();
- }
-
- public DiscriminatorType getDefaultDiscriminatorType() {
- return this.defaultDiscriminatorType;
- }
-
- protected void setDefaultDiscriminatorType(DiscriminatorType discriminatorType) {
- DiscriminatorType old = this.defaultDiscriminatorType;
- this.defaultDiscriminatorType = discriminatorType;
- firePropertyChanged(DEFAULT_DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType);
- }
-
- public DiscriminatorType getSpecifiedDiscriminatorType() {
- return this.specifiedDiscriminatorType;
- }
-
- public void setSpecifiedDiscriminatorType(DiscriminatorType newSpecifiedDiscriminatorType) {
- DiscriminatorType oldDiscriminatorType = this.specifiedDiscriminatorType;
- this.specifiedDiscriminatorType = newSpecifiedDiscriminatorType;
- if (oldDiscriminatorType != newSpecifiedDiscriminatorType) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setDiscriminatorType(DiscriminatorType.toOrmResourceModel(newSpecifiedDiscriminatorType));
- this.removeResourceColumnIfFeaturesUnset();
- }
- else if (newSpecifiedDiscriminatorType != null) {
- addResourceColumn();
- this.getResourceColumn().setDiscriminatorType(DiscriminatorType.toOrmResourceModel(newSpecifiedDiscriminatorType));
- }
- }
- firePropertyChanged(DiscriminatorColumn.SPECIFIED_DISCRIMINATOR_TYPE_PROPERTY, oldDiscriminatorType, newSpecifiedDiscriminatorType);
- }
-
- protected void setSpecifiedDiscriminatorType_(DiscriminatorType newSpecifiedDiscriminatorType) {
- DiscriminatorType oldDiscriminatorType = this.specifiedDiscriminatorType;
- this.specifiedDiscriminatorType = newSpecifiedDiscriminatorType;
- firePropertyChanged(DiscriminatorColumn.SPECIFIED_DISCRIMINATOR_TYPE_PROPERTY, oldDiscriminatorType, newSpecifiedDiscriminatorType);
- }
-
- public int getLength() {
- return (this.getSpecifiedLength() == null) ? this.getDefaultLength() : this.getSpecifiedLength().intValue();
- }
-
- public int getDefaultLength() {
- return this.defaultLength;
- }
-
- protected void setDefaultLength(int defaultLength) {
- int old = this.defaultLength;
- this.defaultLength = defaultLength;
- firePropertyChanged(DEFAULT_LENGTH_PROPERTY, old, defaultLength);
- }
-
- public Integer getSpecifiedLength() {
- return this.specifiedLength;
- }
-
- public void setSpecifiedLength(Integer newSpecifiedLength) {
- Integer oldSpecifiedLength = this.specifiedLength;
- this.specifiedLength = newSpecifiedLength;
- if (this.valuesAreDifferent(oldSpecifiedLength, newSpecifiedLength)) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setLength(newSpecifiedLength);
- this.removeResourceColumnIfFeaturesUnset();
- }
- else if (newSpecifiedLength != null) {
- addResourceColumn();
- getResourceColumn().setLength(newSpecifiedLength);
- }
- }
- firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, oldSpecifiedLength, newSpecifiedLength);
- }
-
- protected void setSpecifiedLength_(Integer newSpecifiedLength) {
- Integer oldSpecifiedLength = this.specifiedLength;
- this.specifiedLength = newSpecifiedLength;
- firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, oldSpecifiedLength, newSpecifiedLength);
- }
-
-
- @Override
- public XmlDiscriminatorColumn getResourceColumn() {
- return this.entity.getDiscriminatorColumn();
- }
-
- @Override
- protected void addResourceColumn() {
- this.entity.setDiscriminatorColumn(OrmFactory.eINSTANCE.createXmlDiscriminatorColumn());
- }
-
- @Override
- protected void removeResourceColumn() {
- this.entity.setDiscriminatorColumn(null);
- }
-
- public boolean isResourceSpecified() {
- return getResourceColumn() != null;
- }
-
- public void initialize(XmlEntity xmlEntity) {
- this.entity = xmlEntity;
- this.initialize(this.getResourceColumn());
- }
-
- public void update(XmlEntity xmlEntity) {
- this.entity = xmlEntity;
- this.update(this.getResourceColumn());
- }
-
-
- @Override
- protected void initialize(XmlDiscriminatorColumn column) {
- super.initialize(column);
- this.defaultDiscriminatorType = this.buildDefaultDiscriminatorType();
- this.defaultLength = this.buildDefaultLength();
- this.specifiedLength = this.getResourceLength(column);
- this.specifiedDiscriminatorType = this.getResourceDiscriminatorType(column);
- }
-
- @Override
- protected void update(XmlDiscriminatorColumn column) {
- //don't call super because postUpdate() handles updating the default column name
- this.setSpecifiedName_(this.getResourceColumnName(column));
- this.setColumnDefinition_(this.getResourceColumnDefinition(column));
- this.setSpecifiedLength_(this.getResourceLength(column));
- this.setSpecifiedDiscriminatorType_(this.getResourceDiscriminatorType(column));
- }
-
- @Override
- /**
- * Using postUpdate since these defaults are dependent on the entity hierarchy
- */
- public void postUpdate() {
- super.postUpdate();
- this.setDefaultName(this.buildDefaultName());
- this.setDefaultDiscriminatorType(this.buildDefaultDiscriminatorType());
- this.setDefaultLength(this.buildDefaultLength());
- }
-
- protected Integer getResourceLength(XmlDiscriminatorColumn column) {
- return column == null ? null : column.getLength();
- }
-
- protected DiscriminatorType getResourceDiscriminatorType(XmlDiscriminatorColumn column) {
- return column == null ? null : DiscriminatorType.fromOrmResourceModel(column.getDiscriminatorType());
- }
-
- protected int buildDefaultLength() {
- return this.getOwner().getDefaultLength();
- }
-
- protected DiscriminatorType buildDefaultDiscriminatorType() {
- return this.getOwner().getDefaultDiscriminatorType();
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- if (this.connectionProfileIsActive()) {
- if ( ! this.isResolved()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.DISCRIMINATOR_COLUMN_UNRESOLVED_NAME,
- new String[] {this.getName()},
- this,
- this.getNameTextRange()
- )
- );
- }
- }
- }
-}

Back to the top