JBoss Tools SVN: r33073 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal: context and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-07-20 08:28:40 -0400 (Wed, 20 Jul 2011)
New Revision: 33073
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToManyMappingDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaManyToOneMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaOneToOneMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKey.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaEntityDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaManyToManyMappingDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToOneMappingDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/ForeignKeyImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyMapping.java
Log:
https://issues.jboss.org/browse/JBIDE-9375
validate @ForeignKey inverseName for ManyToMany mapping
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -14,8 +14,10 @@
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
import org.eclipse.jpt.jpa.core.context.Table.Owner;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaColumn;
+import org.eclipse.jpt.jpa.core.context.java.JavaConverter;
import org.eclipse.jpt.jpa.core.context.java.JavaDiscriminatorColumn;
import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
@@ -25,6 +27,9 @@
import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy;
import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
@@ -47,8 +52,11 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaJoinColumnImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaJoinTableImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToManyMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToOneMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaNamedQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaOneToManyMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaOneToOneMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaParameter;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaQueryContainerImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaSecondaryTableImpl;
@@ -65,6 +73,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaIndex;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaParameter;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeConverterImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeDef;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeDefImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.TypeImpl;
@@ -135,11 +144,28 @@
public JavaColumn buildJavaColumn(JavaJpaContextNode parent, JavaColumn.Owner owner) {
return new HibernateJavaColumnImpl(parent, owner);
}
+
+ @Override
+ public JavaManyToOneMapping buildJavaManyToOneMapping(
+ JavaPersistentAttribute parent) {
+ return new HibernateJavaManyToOneMapping(parent);
+ }
@Override
+ public JavaOneToOneMapping buildJavaOneToOneMapping(
+ JavaPersistentAttribute parent) {
+ return new HibernateJavaOneToOneMapping(parent);
+ }
+
+ @Override
+ public JavaOneToManyMapping buildJavaOneToManyMapping(
+ JavaPersistentAttribute parent) {
+ return new HibernateJavaOneToManyMapping(parent);
+ }
+
+ @Override
public JavaManyToManyMapping buildJavaManyToManyMapping(
JavaPersistentAttribute parent) {
- //same for jpa2_0 and 1_0
return new HibernateJavaManyToManyMapping(parent);
}
@@ -204,4 +230,9 @@
return new TypeImpl(parent, annotation);
}
+ public JavaConverter buildJavaTypeConverter(JavaAttributeMapping parent,
+ TypeAnnotation converterAnnotation) {
+ return new JavaTypeConverterImpl(parent, converterAnnotation);
+ }
+
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -11,16 +11,9 @@
package org.jboss.tools.hibernate.jpt.core.internal;
import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.resource.java.EmbeddableAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEmbeddable;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToOneMapping;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaOneToManyMapping;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaOneToOneMapping;
/**
@@ -36,22 +29,4 @@
return new HibernateJavaEmbeddable(parent, embeddableAnnotation);
}
- @Override
- public JavaManyToOneMapping buildJavaManyToOneMapping(
- JavaPersistentAttribute parent) {
- return new HibernateJavaManyToOneMapping(parent);
- }
-
- @Override
- public JavaOneToOneMapping buildJavaOneToOneMapping(
- JavaPersistentAttribute parent) {
- return new HibernateJavaOneToOneMapping(parent);
- }
-
- @Override
- public JavaOneToManyMapping buildJavaOneToManyMapping(
- JavaPersistentAttribute parent) {
- return new HibernateJavaOneToManyMapping(parent);
- }
-
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKey.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKey.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKey.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -11,14 +11,14 @@
package org.jboss.tools.hibernate.jpt.core.internal.context;
-import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.ForeignKeyAnnotation;
/**
* @author Dmitry Geraskov
*
*/
-public interface ForeignKey extends JpaContextNode {
+public interface ForeignKey extends JavaJpaContextNode {
String getName();
void setName(String name);
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -38,4 +38,6 @@
String TYPE_CLASS_NOT_FOUND = "TYPE_CLASS_NOT_FOUND"; //$NON-NLS-1$
+ String NAME_CANT_BE_EMPTY = "NAME_CANT_BE_EMPTY";//$NON-NLS-1$
+
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties 2011-07-20 12:28:40 UTC (rev 33073)
@@ -8,4 +8,5 @@
CC_NOT_EXISTS= Console configuration \"{0}\" does not exist.
TYPE_CANT_BE_EMPTY=Type could not be empty.
USER_TYPE_INTERFACE = Type class \"{0}\" should implement interface \"org.hibernate.usertype.UserType\".
-TYPE_CLASS_NOT_FOUND = Type class \"{0}\" could not be found.
\ No newline at end of file
+TYPE_CLASS_NOT_FOUND = Type class \"{0}\" could not be found.
+NAME_CANT_BE_EMPTY = Name could not be empty.
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaEntityDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaEntityDefinition.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaEntityDefinition.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -117,7 +117,6 @@
Hibernate.NAMED_NATIVE_QUERY,
Hibernate.NAMED_NATIVE_QUERIES,
Hibernate.DISCRIMINATOR_FORMULA,
- Hibernate.FOREIGN_KEY,
};
protected static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaManyToManyMappingDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaManyToManyMappingDefinition.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaManyToManyMappingDefinition.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -17,10 +17,10 @@
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -48,11 +48,11 @@
}
public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
+ return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
}
public String getAnnotationName() {
- return ManyToOneAnnotation.ANNOTATION_NAME;
+ return ManyToManyAnnotation.ANNOTATION_NAME;
}
public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
@@ -70,13 +70,13 @@
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
JoinTableAnnotation.ANNOTATION_NAME,
- JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME
+ MapKeyAnnotation.ANNOTATION_NAME,
+ OrderByAnnotation.ANNOTATION_NAME
};
private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaManyToOneMapping(persistentAttribute);
+ return factory.buildJavaManyToManyMapping(persistentAttribute);
}
@Override
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToManyMappingDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToManyMappingDefinition.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToManyMappingDefinition.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.definition;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.JpaFactory;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov (geraskov(a)gmail.com)
+ *
+ */
+public class HibernateJavaOneToManyMappingDefinition implements JavaAttributeMappingDefinition
+{
+ // singleton
+ private static final HibernateJavaOneToManyMappingDefinition INSTANCE = new HibernateJavaOneToManyMappingDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static HibernateJavaOneToManyMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Enforce singleton usage
+ */
+ private HibernateJavaOneToManyMappingDefinition() {
+ super();
+ }
+
+ public String getKey() {
+ return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String getAnnotationName() {
+ return OneToOneAnnotation.ANNOTATION_NAME;
+ }
+
+ public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
+ return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
+ }
+
+ protected static final String[] HIBERNATE_ANNOTATION_NAMES_ARRAY = new String[] {
+ Hibernate.FOREIGN_KEY,
+ };
+
+ private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
+ JoinTableAnnotation.ANNOTATION_NAME,
+ JoinColumnAnnotation.ANNOTATION_NAME,
+ JoinColumnsAnnotation.ANNOTATION_NAME,
+ PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
+ PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return new CompositeIterable<String>(SUPPORTING_ANNOTATION_NAMES, new ArrayIterable<String>(HIBERNATE_ANNOTATION_NAMES_ARRAY));
+ }
+
+ public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
+ return factory.buildJavaOneToOneMapping(persistentAttribute);
+ }
+
+ @Override
+ public String toString() {
+ return this.getClass().getSimpleName();
+ }
+
+
+}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToOneMappingDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToOneMappingDefinition.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToOneMappingDefinition.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -20,9 +20,9 @@
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -49,11 +49,11 @@
}
public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
+ return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
}
public String getAnnotationName() {
- return OneToOneAnnotation.ANNOTATION_NAME;
+ return OneToManyAnnotation.ANNOTATION_NAME;
}
public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
@@ -66,10 +66,10 @@
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
JoinTableAnnotation.ANNOTATION_NAME,
+ MapKeyAnnotation.ANNOTATION_NAME,
+ OrderByAnnotation.ANNOTATION_NAME,
JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME
+ JoinColumnsAnnotation.ANNOTATION_NAME
};
private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
@@ -79,7 +79,7 @@
}
public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaOneToOneMapping(persistentAttribute);
+ return factory.buildJavaOneToManyMapping(persistentAttribute);
}
@Override
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaManyToOneMapping.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaManyToOneMapping.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaManyToOneMapping.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaManyToOneMapping;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
-import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
-import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
-import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
-
-/**
- *
- * @author Dmitry Geraskov (geraskov(a)gmail.com)
- *
- */
-public abstract class AbstractHibernateJavaManyToOneMapping extends
-AbstractJavaManyToOneMapping implements ForeignKeyHolder {
-
- protected ForeignKey foreignKey;
-
- public AbstractHibernateJavaManyToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- /*@Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(Hibernate.FOREIGN_KEY);
- }*/
-
- @Override
- protected HibernateAbstractJpaFactory getJpaFactory() {
- return (HibernateAbstractJpaFactory) super.getJpaFactory();
- }
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncForeignKey();
- }
-
- @Override
- public void update() {
- super.update();
- if (foreignKey != null){
- this.foreignKey.update();
- }
- }
-
- // ********************* foreignKey **************
-
- protected void syncForeignKey() {
- ForeignKeyAnnotation annotation = getForeignKeyAnnotation();
- if (annotation == null) {
- if (getForeignKey() != null) {
- setForeignKey(null);
- }
- }
- else {
- if (getForeignKey() == null) {
- setForeignKey(buildForeignKey(annotation));
- }
- else {
- if ((this.foreignKey != null) && (this.foreignKey.getForeignKeyAnnotation() == annotation)) {
- this.foreignKey.synchronizeWithResourceModel();
- } else {
- this.setForeignKey(this.buildForeignKey(annotation));
- }
- }
- }
- }
-
- @Override
- public ForeignKey addForeignKey() {
- if (getForeignKey() != null) {
- throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
- }
- ForeignKeyAnnotation annotation = (ForeignKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- ForeignKey foreignKey = buildForeignKey(annotation);
- setForeignKey(foreignKey);
- return this.foreignKey;
- }
-
- @Override
- public ForeignKey getForeignKey() {
- return this.foreignKey;
- }
-
- protected void setForeignKey(ForeignKey newForeignKey) {
- ForeignKey oldForeignKey = this.foreignKey;
- this.foreignKey = newForeignKey;
- firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, newForeignKey);
- }
-
- @Override
- public void removeForeignKey() {
- if (getForeignKey() == null) {
- throw new IllegalStateException("foreignKey does not exist, cannot be removed"); //$NON-NLS-1$
- }
- this.getResourcePersistentAttribute().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- setForeignKey(null);
- }
-
- protected ForeignKey buildForeignKey() {
- ForeignKeyAnnotation annotation = this.getForeignKeyAnnotation();
- return (annotation == null) ? null : this.buildForeignKey(annotation);
- }
-
- protected ForeignKey buildForeignKey(ForeignKeyAnnotation annotation) {
- return getJpaFactory().buildForeignKey(this, annotation);
- }
-
- protected ForeignKeyAnnotation getForeignKeyAnnotation() {
- return (ForeignKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- }
-
- public Table getForeignKeyDbTable() {
- return getTypeMapping().getPrimaryDbTable();
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter,
- CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateForeignKey(messages, astRoot);
- }
-
- protected void validateForeignKey(List<IMessage> messages,
- CompilationUnit astRoot) {
- Table table = getTypeMapping().getPrimaryDbTable();
- if (!validatesAgainstDatabase() || this.foreignKey == null
- || table == null) {
- return;
- }
- Iterator<org.eclipse.jpt.jpa.db.ForeignKey> fks = table.getForeignKeys()
- .iterator();
- while (fks.hasNext()) {
- org.eclipse.jpt.jpa.db.ForeignKey fk = fks
- .next();
- if (this.foreignKey.getName().equals(fk.getIdentifier())) {
- return;
- }
- }
- TextRange textRange = this.getForeignKeyAnnotation().getNameTextRange(
- astRoot);
- IMessage message = new LocalMessage(IMessage.HIGH_SEVERITY,
- Messages.UNRESOLVED_FOREIGN_KEY_NAME, new String[] {
- this.foreignKey.getName(),
- getTypeMapping().getPrimaryTableName() },
- this.foreignKey);
- message.setLineNo(textRange.getLineNumber());
- message.setOffset(textRange.getOffset());
- message.setLength(textRange.getLength());
- messages.add(message);
- }
-
-}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaOneToOneMapping.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaOneToOneMapping.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaOneToOneMapping.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaOneToOneMapping;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
-import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
-import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
-import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
-/**
- *
- * @author Dmitry Geraskov (geraskov(a)gmail.com)
- *
- */
-public abstract class AbstractHibernateJavaOneToOneMapping extends
- AbstractJavaOneToOneMapping implements ForeignKeyHolder {
-
- protected ForeignKey foreignKey;
-
- public AbstractHibernateJavaOneToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- /*@Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(Hibernate.FOREIGN_KEY);
- }*/
-
- @Override
- protected HibernateAbstractJpaFactory getJpaFactory() {
- return (HibernateAbstractJpaFactory) super.getJpaFactory();
- }
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncForeignKey();
- }
-
- @Override
- public void update() {
- super.update();
- if (foreignKey != null){
- this.foreignKey.update();
- }
- }
-
- // ********************* foreignKey **************
-
- protected void syncForeignKey() {
- ForeignKeyAnnotation annotation = getForeignKeyAnnotation();
- if (annotation == null) {
- if (getForeignKey() != null) {
- setForeignKey(null);
- }
- }
- else {
- if (getForeignKey() == null) {
- setForeignKey(buildForeignKey(annotation));
- }
- else {
- if ((this.foreignKey != null) && (this.foreignKey.getForeignKeyAnnotation() == annotation)) {
- this.foreignKey.synchronizeWithResourceModel();
- } else {
- this.setForeignKey(this.buildForeignKey(annotation));
- }
- }
- }
- }
-
- @Override
- public ForeignKey addForeignKey() {
- if (getForeignKey() != null) {
- throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
- }
- ForeignKeyAnnotation annotation = (ForeignKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- ForeignKey foreignKey = buildForeignKey(annotation);
- setForeignKey(foreignKey);
- return this.foreignKey;
- }
-
- @Override
- public ForeignKey getForeignKey() {
- return this.foreignKey;
- }
-
- protected void setForeignKey(ForeignKey newForeignKey) {
- ForeignKey oldForeignKey = this.foreignKey;
- this.foreignKey = newForeignKey;
- firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, newForeignKey);
- }
-
- @Override
- public void removeForeignKey() {
- if (getForeignKey() == null) {
- throw new IllegalStateException("foreignKey does not exist, cannot be removed"); //$NON-NLS-1$
- }
- this.getResourcePersistentAttribute().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- setForeignKey(null);
- }
-
- protected ForeignKey buildForeignKey() {
- ForeignKeyAnnotation annotation = this.getForeignKeyAnnotation();
- return (annotation == null) ? null : this.buildForeignKey(annotation);
- }
-
- protected ForeignKey buildForeignKey(ForeignKeyAnnotation annotation) {
- return getJpaFactory().buildForeignKey(this, annotation);
- }
-
- protected ForeignKeyAnnotation getForeignKeyAnnotation() {
- return (ForeignKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- }
-
- public Table getForeignKeyDbTable() {
- return getTypeMapping().getPrimaryDbTable();
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter,
- CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateForeignKey(messages, astRoot);
- }
-
- protected void validateForeignKey(List<IMessage> messages,
- CompilationUnit astRoot) {
- Table table = getTypeMapping().getPrimaryDbTable();
- if (!validatesAgainstDatabase() || this.foreignKey == null
- || table == null) {
- return;
- }
- Iterator<org.eclipse.jpt.jpa.db.ForeignKey> fks = table.getForeignKeys()
- .iterator();
- while (fks.hasNext()) {
- org.eclipse.jpt.jpa.db.ForeignKey fk = fks
- .next();
- if (this.foreignKey.getName().equals(fk.getIdentifier())) {
- return;
- }
- }
- TextRange textRange = this.getForeignKeyAnnotation().getNameTextRange(
- astRoot);
- IMessage message = new LocalMessage(IMessage.HIGH_SEVERITY,
- Messages.UNRESOLVED_FOREIGN_KEY_NAME, new String[] {
- this.foreignKey.getName(),
- getTypeMapping().getPrimaryTableName() },
- this.foreignKey);
- message.setLineNo(textRange.getLineNumber());
- message.setOffset(textRange.getOffset());
- message.setLength(textRange.getLength());
- messages.add(message);
- }
-}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/ForeignKeyImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/ForeignKeyImpl.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/ForeignKeyImpl.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -11,11 +11,21 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.jpa.db.Table;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
@@ -94,4 +104,66 @@
return annotation;
}
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter,
+ CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.validateName(messages, reporter, astRoot);
+ this.validateInverseName(messages, reporter, astRoot);
+ }
+
+ /**
+ * @param messages
+ * @param reporter
+ * @param astRoot
+ */
+ private void validateName(List<IMessage> messages, IReporter reporter,
+ CompilationUnit astRoot) {
+ validateForeignKeyName(messages, this.name, getResourceForeignKey().getNameTextRange(astRoot));
+ }
+
+ /**
+ * @param messages
+ * @param reporter
+ * @param astRoot
+ */
+ private void validateInverseName(List<IMessage> messages,
+ IReporter reporter, CompilationUnit astRoot) {
+ if (getParent() instanceof ManyToManyMapping
+ && ((ManyToManyMapping)getParent()).isRelationshipOwner()){
+ validateForeignKeyName(messages, this.inverseName, getResourceForeignKey().getInverseNameTextRange(astRoot));
+ } else {
+ //according to @ForeinKey javadoc inverseName ignored in other places
+ }
+ }
+
+ private void validateForeignKeyName(List<IMessage> messages, String name, TextRange range) {
+ if (name == null || name.trim().length() == 0) {
+ messages.add(creatErrorMessage(Messages.NAME_CANT_BE_EMPTY, range));
+ } else {
+ AttributeMapping mapping = (AttributeMapping) getParent();
+ Table table = mapping.getTypeMapping().getPrimaryDbTable();
+ if (!mapping.validatesAgainstDatabase() || table == null ){
+ return;
+ }
+ Iterator<org.eclipse.jpt.jpa.db.ForeignKey> fks = table.getForeignKeys().iterator();
+ while (fks.hasNext()) {
+ org.eclipse.jpt.jpa.db.ForeignKey fk = fks.next();
+ if (name.equals(fk.getIdentifier())){
+ return;
+ }
+ }
+ creatErrorMessage(Messages.UNRESOLVED_FOREIGN_KEY_NAME, range);
+ }
+ }
+
+ protected IMessage creatErrorMessage(String strmessage, TextRange range){
+ IMessage message = new LocalMessage(IMessage.HIGH_SEVERITY,
+ strmessage, new String[0], getResource());
+ message.setLineNo(range.getLineNumber());
+ message.setOffset(range.getOffset());
+ message.setLength(range.getLength());
+ return message;
+ }
+
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -16,7 +16,11 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.utility.Filter;
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaConverter;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.java.JavaConverter.Adapter;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaBasicMapping;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -34,6 +38,10 @@
public class HibernateJavaBasicMappingImpl extends AbstractJavaBasicMapping
implements HibernateJavaBasicMapping {
+ protected static final Iterable<JavaConverter.Adapter> HIBERNATE_CONVERTER_ADAPTERS =
+ new CompositeIterable<JavaConverter.Adapter>(JavaTypeConverter.Adapter.instance(),
+ new ArrayIterable<JavaConverter.Adapter>(CONVERTER_ADAPTER_ARRAY));
+
protected final HibernateJavaTypeDefContainer typeDefContainer;
protected GenerationTime specifiedGenerationTime;
@@ -49,19 +57,17 @@
this.type = this.buildType();
}
- /*@Override
- public void addSupportingAnnotationNamesTo(Vector<String> names) {
- names.add(Hibernate.GENERATED);
- names.add(Hibernate.INDEX);
- names.add(Hibernate.TYPE);
- }*/
-
@Override
protected HibernateAbstractJpaFactory getJpaFactory() {
return (HibernateAbstractJpaFactory) super.getJpaFactory();
}
@Override
+ protected Iterable<Adapter> getConverterAdapters() {
+ return HIBERNATE_CONVERTER_ADAPTERS;
+ }
+
+ @Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.typeDefContainer.initialize(this.getResourcePersistentAttribute());
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -19,7 +19,7 @@
*
*/
public interface HibernateJavaEntity extends JavaEntity,
-HibernateEntity, ForeignKeyHolder{
+HibernateEntity{
HibernateJavaGeneratorContainer getGeneratorContainer();
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -39,7 +39,6 @@
import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
-import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateTable;
import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
@@ -59,13 +58,10 @@
protected final JavaCacheable2_0 cacheable;
- protected ForeignKey foreignKey;
-
public HibernateJavaEntityImpl(JavaPersistentType parent, EntityAnnotation mappingAnnotation) {
super(parent, mappingAnnotation);
this.discriminatorFormula = this.buildDiscriminatorFormula();
this.typeDefContainer = getJpaFactory().buildJavaTypeDefContainer(parent);
- this.foreignKey = this.buildForeignKey();
this.cacheable = this.buildJavaCachable();
}
@@ -81,7 +77,6 @@
this.cacheable.synchronizeWithResourceModel();
this.typeDefContainer.initialize(this.getResourcePersistentType());
this.syncDiscriminatorFormula();
- this.syncForeignKey();
}
@Override
@@ -92,9 +87,6 @@
if (discriminatorFormula != null){
this.discriminatorFormula.update();
}
- if (foreignKey != null){
- this.foreignKey.update();
- }
}
@Override
@@ -112,31 +104,8 @@
return this.typeDefContainer;
}
-/* protected static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY2 = new String[] {
- Hibernate.GENERIC_GENERATOR,
- Hibernate.GENERIC_GENERATORS,
- Hibernate.TYPE_DEF,
- Hibernate.TYPE_DEFS,
- Hibernate.NAMED_QUERY,
- Hibernate.NAMED_QUERIES,
- Hibernate.NAMED_NATIVE_QUERY,
- Hibernate.NAMED_NATIVE_QUERIES,
- Hibernate.DISCRIMINATOR_FORMULA,
- Hibernate.FOREIGN_KEY,
- };
- protected static final Iterable<String> SUPPORTING_ANNOTATION_NAMES2 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY2);
-
-
- @SuppressWarnings("unchecked")
@Override
- public Iterable<String> getSupportingAnnotationNames() {
- return new CompositeIterable<String>(
- SUPPORTING_ANNOTATION_NAMES2,
- super.getSupportingAnnotationNames());
- }*/
-
- @Override
public HibernateJavaTable getTable() {
return (HibernateJavaTable) super.getTable();
}
@@ -207,79 +176,7 @@
firePropertyChanged(DISCRIMINATOR_FORMULA_PROPERTY, oldDiscriminatorFormula, newDiscriminatorFormula);
}
- // ********************* foreignKey **************
-
- protected void syncForeignKey() {
- ForeignKeyAnnotation annotation = getForeignKeyAnnotation();
- if (annotation == null) {
- if (getForeignKey() != null) {
- setForeignKey(null);
- }
- }
- else {
- if (getForeignKey() == null) {
- setForeignKey(buildForeignKey(annotation));
- }
- else {
- if ((this.foreignKey != null) && (this.foreignKey.getForeignKeyAnnotation() == annotation)) {
- this.foreignKey.synchronizeWithResourceModel();
- } else {
- this.setForeignKey(this.buildForeignKey(annotation));
- }
- }
- }
- }
-
@Override
- public ForeignKey addForeignKey() {
- if (getForeignKey() != null) {
- throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
- }
- ForeignKeyAnnotation annotation = (ForeignKeyAnnotation) this.getResourcePersistentType().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- ForeignKey foreignKey = buildForeignKey(annotation);
- setForeignKey(foreignKey);
- return this.foreignKey;
- }
-
- @Override
- public ForeignKey getForeignKey() {
- return this.foreignKey;
- }
-
- protected void setForeignKey(ForeignKey newForeignKey) {
- ForeignKey oldForeignKey = this.foreignKey;
- this.foreignKey = newForeignKey;
- firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, newForeignKey);
- }
-
- @Override
- public void removeForeignKey() {
- if (getForeignKey() == null) {
- throw new IllegalStateException("foreignKey does not exist, cannot be removed"); //$NON-NLS-1$
- }
- this.getResourcePersistentType().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- setForeignKey(null);
- }
-
- protected ForeignKey buildForeignKey() {
- ForeignKeyAnnotation annotation = this.getForeignKeyAnnotation();
- return (annotation == null) ? null : this.buildForeignKey(annotation);
- }
-
- protected ForeignKey buildForeignKey(ForeignKeyAnnotation annotation) {
- return getJpaFactory().buildForeignKey(this, annotation);
- }
-
- protected ForeignKeyAnnotation getForeignKeyAnnotation() {
- return (ForeignKeyAnnotation) this.getResourcePersistentType().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- public org.eclipse.jpt.jpa.db.Table getForeignKeyDbTable() {
- return getPrimaryDbTable();
- }
-
- @Override
public HibernateJavaGeneratorContainer getGeneratorContainer() {
return (HibernateJavaGeneratorContainer)super.getGeneratorContainer();
}
@@ -289,31 +186,8 @@
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
getTypeDefContainer().validate(messages, reporter, astRoot);
- this.validateForeignKey(messages, astRoot);
}
- protected void validateForeignKey(List<IMessage> messages, CompilationUnit astRoot) {
- org.eclipse.jpt.jpa.db.Table table = getForeignKeyDbTable();
- if (!validatesAgainstDatabase() || this.foreignKey == null || table == null ){
- return;
- }
- Iterator<org.eclipse.jpt.jpa.db.ForeignKey> fks = table.getForeignKeys().iterator();
- while (fks.hasNext()) {
- org.eclipse.jpt.jpa.db.ForeignKey fk = fks.next();
- if (this.foreignKey.getName().equals(fk.getIdentifier())){
- return;
- }
- }
- TextRange textRange = this.getForeignKeyAnnotation().getNameTextRange(astRoot);
- IMessage message = new LocalMessage(IMessage.HIGH_SEVERITY,
- Messages.UNRESOLVED_FOREIGN_KEY_NAME, new String[] {this.foreignKey.getName(), getPrimaryTableName()},
- this.foreignKey);
- message.setLineNo(textRange.getLineNumber());
- message.setOffset(textRange.getOffset());
- message.setLength(textRange.getLength());
- messages.add(message);
- }
-
@Override
protected PrimaryKeyJoinColumnOwner buildPrimaryKeyJoinColumnOwner() {
return new HibernatePrimaryKeyJoinColumnOwner();
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -11,11 +11,9 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.context.java.JavaMappingRelationship;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaManyToManyMapping;
@@ -25,8 +23,6 @@
import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
-import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
@@ -47,12 +43,6 @@
return new HibernateJavaManyToManyRelationship(this);
}
- /*@Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(Hibernate.FOREIGN_KEY);
- }*/
-
@Override
protected HibernateAbstractJpaFactory getJpaFactory() {
return (HibernateAbstractJpaFactory) super.getJpaFactory();
@@ -147,29 +137,13 @@
public void validate(List<IMessage> messages, IReporter reporter,
CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
- this.validateForeignKey(messages, astRoot);
+ this.validateForeignKey(messages, reporter, astRoot);
}
- protected void validateForeignKey(List<IMessage> messages, CompilationUnit astRoot) {
- Table table = getTypeMapping().getPrimaryDbTable();
- if (!validatesAgainstDatabase() || this.foreignKey == null || table == null ){
- return;
+ protected void validateForeignKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ if (foreignKey != null){
+ foreignKey.validate(messages, reporter, astRoot);
}
- Iterator<org.eclipse.jpt.jpa.db.ForeignKey> fks = table.getForeignKeys().iterator();
- while (fks.hasNext()) {
- org.eclipse.jpt.jpa.db.ForeignKey fk = fks.next();
- if (this.foreignKey.getName().equals(fk.getIdentifier())){
- return;
- }
- }
- TextRange textRange = this.getForeignKeyAnnotation().getNameTextRange(astRoot);
- IMessage message = new LocalMessage(IMessage.HIGH_SEVERITY,
- Messages.UNRESOLVED_FOREIGN_KEY_NAME, new String[] {this.foreignKey.getName(), getTypeMapping().getPrimaryTableName()},
- this.foreignKey);
- message.setLineNo(textRange.getLineNumber());
- message.setOffset(textRange.getOffset());
- message.setLength(textRange.getLength());
- messages.add(message);
}
}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.java.GenericJavaManyToOneRelationship;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneRelationship2_0;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateJavaManyToOneMapping extends AbstractHibernateJavaManyToOneMapping {
-
- public HibernateJavaManyToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- @Override
- protected JavaManyToOneRelationship2_0 buildRelationship() {
- return new GenericJavaManyToOneRelationship(this);
- }
-
-}
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java (from rev 33010, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaManyToOneMapping.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaManyToOneMapping;
+import org.eclipse.jpt.jpa.db.Table;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
+import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
+import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+
+/**
+ *
+ * @author Dmitry Geraskov (geraskov(a)gmail.com)
+ *
+ */
+public class HibernateJavaManyToOneMapping extends
+AbstractJavaManyToOneMapping implements ForeignKeyHolder {
+
+ protected ForeignKey foreignKey;
+
+ public HibernateJavaManyToOneMapping(JavaPersistentAttribute parent) {
+ super(parent);
+ }
+
+ @Override
+ protected HibernateAbstractJpaFactory getJpaFactory() {
+ return (HibernateAbstractJpaFactory) super.getJpaFactory();
+ }
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.syncForeignKey();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ if (foreignKey != null){
+ this.foreignKey.update();
+ }
+ }
+
+ // ********************* foreignKey **************
+
+ protected void syncForeignKey() {
+ ForeignKeyAnnotation annotation = getForeignKeyAnnotation();
+ if (annotation == null) {
+ if (getForeignKey() != null) {
+ setForeignKey(null);
+ }
+ }
+ else {
+ if (getForeignKey() == null) {
+ setForeignKey(buildForeignKey(annotation));
+ }
+ else {
+ if ((this.foreignKey != null) && (this.foreignKey.getForeignKeyAnnotation() == annotation)) {
+ this.foreignKey.synchronizeWithResourceModel();
+ } else {
+ this.setForeignKey(this.buildForeignKey(annotation));
+ }
+ }
+ }
+ }
+
+ @Override
+ public ForeignKey addForeignKey() {
+ if (getForeignKey() != null) {
+ throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
+ }
+ ForeignKeyAnnotation annotation = (ForeignKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ ForeignKey foreignKey = buildForeignKey(annotation);
+ setForeignKey(foreignKey);
+ return this.foreignKey;
+ }
+
+ @Override
+ public ForeignKey getForeignKey() {
+ return this.foreignKey;
+ }
+
+ protected void setForeignKey(ForeignKey newForeignKey) {
+ ForeignKey oldForeignKey = this.foreignKey;
+ this.foreignKey = newForeignKey;
+ firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, newForeignKey);
+ }
+
+ @Override
+ public void removeForeignKey() {
+ if (getForeignKey() == null) {
+ throw new IllegalStateException("foreignKey does not exist, cannot be removed"); //$NON-NLS-1$
+ }
+ this.getResourcePersistentAttribute().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ setForeignKey(null);
+ }
+
+ protected ForeignKey buildForeignKey() {
+ ForeignKeyAnnotation annotation = this.getForeignKeyAnnotation();
+ return (annotation == null) ? null : this.buildForeignKey(annotation);
+ }
+
+ protected ForeignKey buildForeignKey(ForeignKeyAnnotation annotation) {
+ return getJpaFactory().buildForeignKey(this, annotation);
+ }
+
+ protected ForeignKeyAnnotation getForeignKeyAnnotation() {
+ return (ForeignKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ }
+
+ public Table getForeignKeyDbTable() {
+ return getTypeMapping().getPrimaryDbTable();
+ }
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter,
+ CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.validateForeignKey(messages, reporter, astRoot);
+ }
+
+ protected void validateForeignKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ if (foreignKey != null){
+ foreignKey.validate(messages, reporter, astRoot);
+ }
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyMapping.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyMapping.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyMapping.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -10,16 +10,32 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.context.java.JavaMappingRelationship;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaOneToManyMapping;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaOneToManyMapping;
+import org.eclipse.jpt.jpa.db.Table;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
+import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
+import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateJavaOneToManyMapping extends GenericJavaOneToManyMapping {
+public class HibernateJavaOneToManyMapping extends AbstractJavaOneToManyMapping
+ implements ForeignKeyHolder{
+ protected ForeignKey foreignKey;
+
/**
* @param parent
*/
@@ -31,5 +47,108 @@
protected JavaMappingRelationship buildRelationship() {
return new HibernateJavaOneToManyRelationship(this, this.isJpa2_0Compatible());
}
+
+ @Override
+ protected HibernateAbstractJpaFactory getJpaFactory() {
+ return (HibernateAbstractJpaFactory) super.getJpaFactory();
+ }
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.syncForeignKey();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ if (foreignKey != null){
+ this.foreignKey.update();
+ }
+ }
+
+ // ********************* foreignKey **************
+
+ protected void syncForeignKey() {
+ ForeignKeyAnnotation annotation = getForeignKeyAnnotation();
+ if (annotation == null) {
+ if (getForeignKey() != null) {
+ setForeignKey(null);
+ }
+ }
+ else {
+ if (getForeignKey() == null) {
+ setForeignKey(buildForeignKey(annotation));
+ }
+ else {
+ if ((this.foreignKey != null) && (this.foreignKey.getForeignKeyAnnotation() == annotation)) {
+ this.foreignKey.synchronizeWithResourceModel();
+ } else {
+ this.setForeignKey(this.buildForeignKey(annotation));
+ }
+ }
+ }
+ }
+
+ @Override
+ public ForeignKey addForeignKey() {
+ if (getForeignKey() != null) {
+ throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
+ }
+ ForeignKeyAnnotation annotation = (ForeignKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ ForeignKey foreignKey = buildForeignKey(annotation);
+ setForeignKey(foreignKey);
+ return this.foreignKey;
+ }
+
+ @Override
+ public ForeignKey getForeignKey() {
+ return this.foreignKey;
+ }
+
+ protected void setForeignKey(ForeignKey newForeignKey) {
+ ForeignKey oldForeignKey = this.foreignKey;
+ this.foreignKey = newForeignKey;
+ firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, newForeignKey);
+ }
+
+ @Override
+ public void removeForeignKey() {
+ if (getForeignKey() == null) {
+ throw new IllegalStateException("foreignKey does not exist, cannot be removed"); //$NON-NLS-1$
+ }
+ this.getResourcePersistentAttribute().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ setForeignKey(null);
+ }
+
+ protected ForeignKey buildForeignKey() {
+ ForeignKeyAnnotation annotation = this.getForeignKeyAnnotation();
+ return (annotation == null) ? null : this.buildForeignKey(annotation);
+ }
+
+ protected ForeignKey buildForeignKey(ForeignKeyAnnotation annotation) {
+ return getJpaFactory().buildForeignKey(this, annotation);
+ }
+
+ protected ForeignKeyAnnotation getForeignKeyAnnotation() {
+ return (ForeignKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ }
+
+ public Table getForeignKeyDbTable() {
+ return getTypeMapping().getPrimaryDbTable();
+ }
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter,
+ CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.validateForeignKey(messages, reporter, astRoot);
+ }
+
+ protected void validateForeignKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ if (foreignKey != null){
+ foreignKey.validate(messages, reporter, astRoot);
+ }
+ }
+
}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java 2011-07-20 12:27:40 UTC (rev 33072)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.java.GenericJavaOneToOneRelationship;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneRelationship2_0;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateJavaOneToOneMapping extends AbstractHibernateJavaOneToOneMapping {
-
- public HibernateJavaOneToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- @Override
- protected JavaOneToOneRelationship2_0 buildRelationship() {
- return new GenericJavaOneToOneRelationship(this);
- }
-
-
-}
-
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java (from rev 33010, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/AbstractHibernateJavaOneToOneMapping.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java 2011-07-20 12:28:40 UTC (rev 33073)
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaOneToOneMapping;
+import org.eclipse.jpt.jpa.db.Table;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
+import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
+import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+/**
+ *
+ * @author Dmitry Geraskov (geraskov(a)gmail.com)
+ *
+ */
+public class HibernateJavaOneToOneMapping extends
+ AbstractJavaOneToOneMapping implements ForeignKeyHolder {
+
+ protected ForeignKey foreignKey;
+
+ public HibernateJavaOneToOneMapping(JavaPersistentAttribute parent) {
+ super(parent);
+ }
+
+ @Override
+ protected HibernateAbstractJpaFactory getJpaFactory() {
+ return (HibernateAbstractJpaFactory) super.getJpaFactory();
+ }
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.syncForeignKey();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ if (foreignKey != null){
+ this.foreignKey.update();
+ }
+ }
+
+ // ********************* foreignKey **************
+
+ protected void syncForeignKey() {
+ ForeignKeyAnnotation annotation = getForeignKeyAnnotation();
+ if (annotation == null) {
+ if (getForeignKey() != null) {
+ setForeignKey(null);
+ }
+ }
+ else {
+ if (getForeignKey() == null) {
+ setForeignKey(buildForeignKey(annotation));
+ }
+ else {
+ if ((this.foreignKey != null) && (this.foreignKey.getForeignKeyAnnotation() == annotation)) {
+ this.foreignKey.synchronizeWithResourceModel();
+ } else {
+ this.setForeignKey(this.buildForeignKey(annotation));
+ }
+ }
+ }
+ }
+
+ @Override
+ public ForeignKey addForeignKey() {
+ if (getForeignKey() != null) {
+ throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
+ }
+ ForeignKeyAnnotation annotation = (ForeignKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ ForeignKey foreignKey = buildForeignKey(annotation);
+ setForeignKey(foreignKey);
+ return this.foreignKey;
+ }
+
+ @Override
+ public ForeignKey getForeignKey() {
+ return this.foreignKey;
+ }
+
+ protected void setForeignKey(ForeignKey newForeignKey) {
+ ForeignKey oldForeignKey = this.foreignKey;
+ this.foreignKey = newForeignKey;
+ firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, newForeignKey);
+ }
+
+ @Override
+ public void removeForeignKey() {
+ if (getForeignKey() == null) {
+ throw new IllegalStateException("foreignKey does not exist, cannot be removed"); //$NON-NLS-1$
+ }
+ this.getResourcePersistentAttribute().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ setForeignKey(null);
+ }
+
+ protected ForeignKey buildForeignKey() {
+ ForeignKeyAnnotation annotation = this.getForeignKeyAnnotation();
+ return (annotation == null) ? null : this.buildForeignKey(annotation);
+ }
+
+ protected ForeignKey buildForeignKey(ForeignKeyAnnotation annotation) {
+ return getJpaFactory().buildForeignKey(this, annotation);
+ }
+
+ protected ForeignKeyAnnotation getForeignKeyAnnotation() {
+ return (ForeignKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ }
+
+ public Table getForeignKeyDbTable() {
+ return getTypeMapping().getPrimaryDbTable();
+ }
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter,
+ CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.validateForeignKey(messages, reporter, astRoot);
+ }
+
+ protected void validateForeignKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ if (foreignKey != null){
+ foreignKey.validate(messages, reporter, astRoot);
+ }
+ }
+}
14 years, 8 months
JBoss Tools SVN: r33072 - in trunk/hibernatetools/plugins: org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-07-20 08:27:40 -0400 (Wed, 20 Jul 2011)
New Revision: 33072
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/TypeConverter.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeConverter.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeConverterImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/jpa2/HibernateJavaElementCollectionMapping2_0.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/jpa2/details/HibernateElementCollectionMapping2_0Composite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/TypeComposite.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpaFactory2_0.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/java/Hibernate2_0JavaUiFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
Log:
https://issues.jboss.org/browse/JBIDE-9283
Add hibernate @Type composite to JPA Details view
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/TypeConverter.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/TypeConverter.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/TypeConverter.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -0,0 +1,13 @@
+package org.jboss.tools.hibernate.jpt.core.internal.context;
+
+import org.eclipse.jpt.jpa.core.context.Converter;
+
+
+public interface TypeConverter extends Converter {
+
+ String getHibernateType();
+ void setHibernateType(String type);
+ String TYPE_PROPERTY = "type"; //$NON-NLS-1$
+
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeConverter.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeConverter.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeConverter.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.jpa.core.JpaFactory;
+import org.eclipse.jpt.jpa.core.context.Converter;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaConverter;
+import org.eclipse.jpt.jpa.core.resource.java.Annotation;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
+import org.jboss.tools.hibernate.jpt.core.internal.context.TypeConverter;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.TypeAnnotation;
+
+/**
+ *
+ * @author Dmitry Geraskov
+ *
+ */
+public interface JavaTypeConverter extends TypeConverter, JavaConverter{
+ // ********** adapter **********
+
+ public static class Adapter
+ extends JavaConverter.AbstractAdapter
+ {
+ private static final Adapter INSTANCE = new Adapter();
+ public static Adapter instance() {
+ return INSTANCE;
+ }
+
+ private Adapter() {
+ super();
+ }
+
+ public Class<? extends Converter> getConverterType() {
+ return TypeConverter.class;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return TypeAnnotation.ANNOTATION_NAME;
+ }
+
+ public JavaConverter buildConverter(Annotation converterAnnotation, JavaAttributeMapping parent, JpaFactory factory) {
+ return ((HibernateAbstractJpaFactory)factory).buildJavaTypeConverter(parent, (TypeAnnotation) converterAnnotation);
+ }
+ }
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeConverterImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeConverterImpl.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaTypeConverterImpl.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jpa.core.context.Converter;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.AbstractJavaConverter;
+import org.jboss.tools.hibernate.jpt.core.internal.context.TypeConverter;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.TypeAnnotation;
+
+/**
+ *
+ * @author Dmitry Geraskov
+ *
+ */
+public class JavaTypeConverterImpl extends AbstractJavaConverter implements JavaTypeConverter {
+
+ protected final TypeAnnotation typeAnnotation;
+
+ protected String type;
+
+ public JavaTypeConverterImpl(JavaAttributeMapping parent, TypeAnnotation typeAnnotation) {
+ super(parent);
+ this.typeAnnotation = typeAnnotation;
+ type = buildHibernateType();
+ }
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setHibernateType_(this.buildHibernateType());
+ }
+
+ protected String buildHibernateType() {
+ return typeAnnotation.getType();
+ }
+
+ // ********** misc **********
+
+ public Class<? extends Converter> getType() {
+ return TypeConverter.class;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return TypeAnnotation.ANNOTATION_NAME;
+ }
+
+ // ********** type **********
+
+ @Override
+ protected TextRange getAnnotationTextRange(CompilationUnit astRoot) {
+ return this.typeAnnotation.getTextRange(astRoot);
+ }
+
+ @Override
+ public String getHibernateType() {
+ return type;
+ }
+
+ @Override
+ public void setHibernateType(String type) {
+ this.typeAnnotation.setType(type);
+ setHibernateType_(type);
+ }
+
+ public void setHibernateType_(String type) {
+ String old = this.type;
+ this.type = type;
+ this.firePropertyChanged(TYPE_PROPERTY, old, type);
+ }
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/jpa2/HibernateJavaElementCollectionMapping2_0.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/jpa2/HibernateJavaElementCollectionMapping2_0.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/jpa2/HibernateJavaElementCollectionMapping2_0.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java.jpa2;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaConverter;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.java.JavaConverter.Adapter;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.AbstractJavaElementCollectionMapping2_0;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeConverter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaElementCollectionMapping2_0 extends
+ AbstractJavaElementCollectionMapping2_0 {
+
+ protected static final Iterable<JavaConverter.Adapter> HIBERNATE_CONVERTER_ADAPTERS =
+ new CompositeIterable<JavaConverter.Adapter>(JavaTypeConverter.Adapter.instance(),
+ new ArrayIterable<JavaConverter.Adapter>(CONVERTER_ADAPTER_ARRAY));
+
+ public HibernateJavaElementCollectionMapping2_0(
+ JavaPersistentAttribute parent) {
+ super(parent);
+ }
+
+ @Override
+ protected Iterable<Adapter> getConverterAdapters() {
+ return HIBERNATE_CONVERTER_ADAPTERS;
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpaFactory2_0.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpaFactory2_0.java 2011-07-20 11:37:25 UTC (rev 33071)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpaFactory2_0.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -37,7 +37,6 @@
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaCacheable2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaCollectionTable2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaDerivedIdentity2_0;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaElementCollectionMapping2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaEmbeddable2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaNamedQuery2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaOrderColumn2_0;
@@ -72,6 +71,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToOneMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaOneToManyMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaOneToOneMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.jpa2.HibernateJavaElementCollectionMapping2_0;
@@ -82,23 +82,10 @@
public class HibernateJpaFactory2_0 extends HibernateAbstractJpaFactory implements JpaFactory2_0 {
// ********** Hibernate Specific **********
- @Override
- public JavaManyToOneMapping buildJavaManyToOneMapping(JavaPersistentAttribute parent) {
- return new HibernateJavaManyToOneMapping(parent);
+ public JavaElementCollectionMapping2_0 buildJavaElementCollectionMapping2_0(JavaPersistentAttribute parent) {
+ return new HibernateJavaElementCollectionMapping2_0(parent);
}
- @Override
- public JavaOneToOneMapping buildJavaOneToOneMapping(
- JavaPersistentAttribute parent) {
- return new HibernateJavaOneToOneMapping(parent);
- }
-
- @Override
- public JavaOneToManyMapping buildJavaOneToManyMapping(
- JavaPersistentAttribute parent) {
- return new HibernateJavaOneToManyMapping(parent);
- }
-
// ********** From GenericJpa2_0 Model **********
// ********** Core Model **********
@@ -150,10 +137,6 @@
return new GenericJavaDerivedIdentity2_0(parent);
}
- public JavaElementCollectionMapping2_0 buildJavaElementCollectionMapping2_0(JavaPersistentAttribute parent) {
- return new GenericJavaElementCollectionMapping2_0(parent);
- }
-
public JavaCacheable2_0 buildJavaCacheable(JavaCacheableHolder2_0 parent) {
return new GenericJavaCacheable2_0(parent);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeAnnotationImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeAnnotationImpl.java 2011-07-20 11:37:25 UTC (rev 33071)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeAnnotationImpl.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -83,6 +83,7 @@
return ANNOTATION_NAME;
}
+
AnnotationElementAdapter<String> buildTypeAdapter(DeclarationAnnotationElementAdapter<String> daea) {
return new ShortCircuitAnnotationElementAdapter<String>(this.annotatedElement, daea);
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/jpa2/details/HibernateElementCollectionMapping2_0Composite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/jpa2/details/HibernateElementCollectionMapping2_0Composite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/jpa2/details/HibernateElementCollectionMapping2_0Composite.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.jpa2.details;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.Converter;
+import org.eclipse.jpt.jpa.core.context.ConvertibleMapping;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.details.AbstractElementCollectionMapping2_0Composite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.Section;
+import org.jboss.tools.hibernate.jpt.core.internal.context.TypeConverter;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateUIMappingMessages;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.TypeComposite;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateElementCollectionMapping2_0Composite extends
+ AbstractElementCollectionMapping2_0Composite<ElementCollectionMapping2_0> {
+
+ /**
+ * @param subjectHolder
+ * @param parent
+ * @param widgetFactory
+ */
+ public HibernateElementCollectionMapping2_0Composite(
+ PropertyValueModel<? extends ElementCollectionMapping2_0> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeBasicValueSection(Composite container) {
+ List<Control> oldChildren = Arrays.asList(container.getChildren());
+ super.initializeBasicValueSection(container);
+ List<Control> newChildren = Arrays.asList(container.getChildren());
+ newChildren.removeAll(oldChildren);
+
+ //FIXME due to closed method we need to do the search
+ Composite converterSection = findTypeSection(((Composite)newChildren.get(0)).getChildren());
+
+ PropertyValueModel<Converter> converterHolder = buildConverterHolder();
+ // Temporal
+ addRadioButton(
+ converterSection,
+ HibernateUIMappingMessages.TypeComposite_type,
+ buildTypeBooleanHolder(),
+ null);
+ registerSubPane(new TypeComposite(buildTypeConverterHolder(converterHolder), converterSection, getWidgetFactory()));
+
+ }
+
+ private WritablePropertyValueModel<Boolean> buildTypeBooleanHolder() {
+ return new PropertyAspectAdapter<ElementCollectionMapping2_0, Boolean>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ Converter converter = this.subject.getConverter();
+ return Boolean.valueOf(converter.getType() == TypeConverter.class);
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value.booleanValue()) {
+ this.subject.setConverter(TypeConverter.class);
+ }
+ }
+ };
+ }
+
+ private PropertyValueModel<TypeConverter> buildTypeConverterHolder(PropertyValueModel<Converter> converterHolder) {
+ return new TransformationPropertyValueModel<Converter, TypeConverter>(converterHolder) {
+ @Override
+ protected TypeConverter transform_(Converter converter) {
+ return converter.getType() == TypeConverter.class ? (TypeConverter) converter : null;
+ }
+ };
+ }
+
+ protected PropertyValueModel<Converter> buildConverterHolder() {
+ return new PropertyAspectAdapter<ElementCollectionMapping2_0, Converter>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) {
+ @Override
+ protected Converter buildValue_() {
+ return this.subject.getConverter();
+ }
+ };
+ }
+
+ protected Composite findTypeSection(Control[] controls){
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] instanceof Section){
+ Section section = (Section) controls[i];
+ return (Composite) section.getClient();
+ }
+ }
+ return null;
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java 2011-07-20 11:37:25 UTC (rev 33071)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -12,8 +12,10 @@
import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.ui.internal.widgets.Pane;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.context.BasicMapping;
+import org.eclipse.jpt.jpa.core.context.Converter;
import org.eclipse.jpt.jpa.ui.details.JpaComposite;
import org.eclipse.jpt.jpa.ui.internal.details.AbstractBasicMappingComposite;
import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite;
@@ -26,6 +28,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.Generated;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateColumn;
import org.jboss.tools.hibernate.jpt.core.internal.context.IndexHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.TypeConverter;
/**
* Here the layout of this pane:
@@ -107,6 +110,50 @@
new OptionalComposite(this, addSubPane(container, 4));
}
+ @Override
+ protected void initializeTypeSection(Composite container) {
+ super.initializeTypeSection(container);
+
+ PropertyValueModel<Converter> converterHolder = buildConverterHolder();
+
+ addRadioButton(
+ container,
+ HibernateUIMappingMessages.TypeComposite_type,
+ buildConverterBooleanHolder(TypeConverter.class),
+ null);
+
+ registerSubPane(new TypeComposite(buildHibernateConverterHolder(converterHolder),
+ container, getWidgetFactory()));
+
+ }
+
+ protected PropertyValueModel<TypeConverter> buildHibernateConverterHolder(PropertyValueModel<Converter> converterHolder) {
+ return new TransformationPropertyValueModel<Converter, TypeConverter>(converterHolder) {
+ @Override
+ protected TypeConverter transform_(Converter converter) {
+ return converter.getType() == TypeConverter.class ? (TypeConverter) converter : null;
+ }
+ };
+ }
+
+ /*protected WritablePropertyValueModel<Boolean> buildHibernateTypeBooleanHolder() {
+ return new PropertyAspectAdapter<BasicMapping, Boolean>(getSubjectHolder(), TypeHolder.TYPE_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(((TypeHolder)subject).getType() != null);
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value.booleanValue() && (((TypeHolder)subject).getType() == null)) {
+ ((TypeHolder)subject).addType();
+ } else if (!value.booleanValue() && (((TypeHolder)subject).getType() != null)) {
+ ((TypeHolder)subject).removeType();
+ }
+ }
+ };
+ }*/
+
protected void initializeIndexCollapsibleSection(Composite container) {
if (getSubject() instanceof IndexHolder) {
container = addCollapsibleSection(
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2011-07-20 11:37:25 UTC (rev 33071)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -49,6 +49,7 @@
public static String Index_section_index;
public static String ParametersComposite_nameColumn;
public static String ParametersComposite_valueColumn;
+ public static String TypeComposite_type;
private HibernateUIMappingMessages() {}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/TypeComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/TypeComposite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/TypeComposite.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
+
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.widgets.Pane;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.TypeConverter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class TypeComposite extends Pane<TypeConverter> {
+
+ /**
+ * Creates a new <code>TypeComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public TypeComposite(PropertyValueModel<? extends TypeConverter> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ // Name widgets
+ addText(
+ container,
+ buildTypeTypeHolder(),
+ null,
+ buildBooleanHolder()
+ );
+ }
+
+ private WritablePropertyValueModel<String> buildTypeTypeHolder() {
+ return new PropertyAspectAdapter<TypeConverter, String>(getSubjectHolder(), TypeConverter.TYPE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getHibernateType();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ subject.setHibernateType(value);
+ }
+ };
+ }
+
+ protected PropertyValueModel<Boolean> buildBooleanHolder() {
+ return new TransformationPropertyValueModel<TypeConverter, Boolean>(getSubjectHolder()) {
+ @Override
+ protected Boolean transform(TypeConverter value) {
+ if (getSubject() != null && getSubject().getParent().getPersistentAttribute().isVirtual()) {
+ return Boolean.FALSE;
+ }
+ return Boolean.valueOf(value != null);
+ }
+ };
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/java/Hibernate2_0JavaUiFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/java/Hibernate2_0JavaUiFactory.java 2011-07-20 11:37:25 UTC (rev 33071)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/java/Hibernate2_0JavaUiFactory.java 2011-07-20 12:27:40 UTC (rev 33072)
@@ -16,13 +16,15 @@
import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping;
import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
+import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0;
import org.eclipse.jpt.jpa.ui.details.JpaComposite;
-import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.details.java.Generic2_0JavaUiFactory;
import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmEntity;
import org.jboss.tools.hibernate.jpt.ui.internal.java.details.HibernateJavaEntityComposite;
+import org.jboss.tools.hibernate.jpt.ui.internal.jpa2.details.HibernateElementCollectionMapping2_0Composite;
import org.jboss.tools.hibernate.jpt.ui.internal.jpa2.details.orm.Hibernate2_0OrmEntityComposite;
import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateBasicMappingComposite;
import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateIdMappingComposite;
@@ -31,7 +33,7 @@
* @author Dmitry Geraskov
*
*/
-public class Hibernate2_0JavaUiFactory extends BaseJavaUiFactory {
+public class Hibernate2_0JavaUiFactory extends Generic2_0JavaUiFactory {
@SuppressWarnings("unchecked")
@@ -65,6 +67,11 @@
return new HibernateBasicMappingComposite(subjectHolder, parent, widgetFactory);
}
-
+ public JpaComposite createJavaElementCollectionMapping2_0Composite(
+ PropertyValueModel<JavaElementCollectionMapping2_0> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+ return new HibernateElementCollectionMapping2_0Composite(subjectHolder, parent, widgetFactory);
+ }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2011-07-20 11:37:25 UTC (rev 33071)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2011-07-20 12:27:40 UTC (rev 33072)
@@ -26,4 +26,5 @@
IndexHolderComposite_name=Name:
Index_section_index=Index
ParametersComposite_nameColumn=Name
-ParametersComposite_valueColumn=Value
\ No newline at end of file
+ParametersComposite_valueColumn=Value
+TypeComposite_type=Type
\ No newline at end of file
14 years, 8 months
JBoss Tools SVN: r33071 - trunk/as/plugins/org.jboss.ide.eclipse.as.core.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-07-20 07:37:25 -0400 (Wed, 20 Jul 2011)
New Revision: 33071
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
Log:
Regression for tab groups specific to as7 with less verifications
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2011-07-20 10:32:42 UTC (rev 33070)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2011-07-20 11:37:25 UTC (rev 33071)
@@ -119,7 +119,7 @@
hasConfiguration="false"
id="org.jboss.ide.eclipse.as.70"
initialState="stopped"
- launchConfigId="org.jboss.ide.eclipse.as.core.server.startupConfiguration"
+ launchConfigId="org.jboss.ide.eclipse.as.core.server.JBoss7StartupConfiguration"
launchModes="run,debug,profile"
name="%jboss.version.70.name"
runtime="true"
@@ -630,6 +630,15 @@
sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"
sourcePathComputerId="org.eclipse.jst.server.generic.core.sourcePathComputer"/>
<launchConfigurationType
+ category="JBoss"
+ delegate="org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration"
+ id="org.jboss.ide.eclipse.as.core.server.JBoss7StartupConfiguration"
+ modes="run,debug,profile"
+ name="JBoss Application Server Startup Configuration"
+ public="true"
+ sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"
+ sourcePathComputerId="org.eclipse.jst.server.generic.core.sourcePathComputer"/>
+ <launchConfigurationType
delegate="org.jboss.ide.eclipse.as.core.server.internal.launch.TwiddleLaunchConfiguration"
id="org.jboss.ide.eclipse.as.core.server.twiddleConfiguration"
modes="run"
14 years, 8 months
JBoss Tools SVN: r33069 - in trunk/as: tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2 and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-07-20 05:16:55 -0400 (Wed, 20 Jul 2011)
New Revision: 33069
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/PathUtils.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java
Log:
[JBIDE-9374] fixed test to now assert removal of markers and war (was: asserted only removal of markers). Corrected test to not assert fixed file removal order
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java 2011-07-20 08:34:08 UTC (rev 33068)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DeploymentMarkerUtils.java 2011-07-20 09:16:55 UTC (rev 33069)
@@ -217,4 +217,16 @@
return Status.OK_STATUS;
}
+ public static String getDeployedMarker(String file) {
+ return file + DEPLOYED;
+ }
+
+ public static String getFailedMarkerName(String file) {
+ return file + FAILED_DEPLOY;
+ }
+
+ public static String getDoDeployMarkerName(String file) {
+ return file + DO_DEPLOY;
+ }
}
+
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java 2011-07-20 08:34:08 UTC (rev 33068)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java 2011-07-20 09:16:55 UTC (rev 33069)
@@ -11,10 +11,7 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -25,6 +22,7 @@
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerUtil;
import org.jboss.ide.eclipse.as.core.server.internal.v7.DeploymentMarkerUtils;
+import org.jboss.ide.eclipse.as.test.util.PathUtils;
import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
import org.jboss.ide.eclipse.as.test.util.wtp.JavaEEFacetConstants;
import org.jboss.ide.eclipse.as.test.util.wtp.OperationTestCase;
@@ -45,7 +43,7 @@
IModule mod = ServerUtil.getModule(project);
IModule[] module = new IModule[] { mod };
verifyJSTPublisher(module);
- IFile f = project.getFolder(CONTENT_DIR).getFolder("WEB-INF").getFile("web.xml");
+// IFile f = project.getFolder(CONTENT_DIR).getFolder("WEB-INF").getFile("web.xml");
server = ServerRuntimeUtils.addModule(server,mod);
ServerRuntimeUtils.publish(server);
@@ -80,15 +78,18 @@
server = ServerRuntimeUtils.createMockJBoss7Server();
server = ServerRuntimeUtils.useMockPublishMethod(server);
/*
- * removing module newModule.war will remove 2 markers:
+ * removing module newModule.war will remove 2 markers and the war:
* <ul>
+ * <li>newModule.war</li>
* <li>newModule.war.deployed</li>
* <li>newModule.war.failed</li>
* </ul>
*/
- testMockPublishMethod(8, "newModule.war",
- "newModule.war" + DeploymentMarkerUtils.FAILED_DEPLOY,
- "newModule.war" + DeploymentMarkerUtils.DEPLOYED);
+ String moduleName = "newModule.war";
+ testMockPublishMethod(8,
+ moduleName,
+ DeploymentMarkerUtils.getFailedMarkerName(moduleName),
+ DeploymentMarkerUtils.getDeployedMarker(moduleName));
}
private void testMockPublishMethod(int initial, String... filesToRemove) throws CoreException, IOException {
@@ -97,19 +98,16 @@
IModule mod = ServerUtil.getModule(project);
server = ServerRuntimeUtils.addModule(server,mod);
ServerRuntimeUtils.publish(server);
- IPath[] changed = MockPublishMethod.getChanged();
- assertEquals(initial, changed.length);
+ assertEquals(initial, MockPublishMethod.getChanged().length);
MockPublishMethod.reset();
// remove
server = ServerRuntimeUtils.removeModule(server, mod);
ServerRuntimeUtils.publish(server);
- IPath[] rem = MockPublishMethod.getRemoved();
- assertEquals(filesToRemove.length, rem.length);
+ assertEquals(filesToRemove.length, MockPublishMethod.getRemoved().length);
IPath[] removedFiles = MockPublishMethod.getRemoved();
- List<IPath> removedAsList = Arrays.asList(removedFiles);
for(int i = 0; i < removedFiles.length; i++) {
- assertTrue(removedAsList.contains(new Path(MockPublishMethod.MOCK_ROOT + "/" + filesToRemove[i])));
+ assertTrue(PathUtils.containsPath(MockPublishMethod.MOCK_ROOT + "/" + filesToRemove[i], removedFiles));
}
MockPublishMethod.reset();
}
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/PathUtils.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/PathUtils.java (rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/PathUtils.java 2011-07-20 09:16:55 UTC (rev 33069)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010 - 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.test.util;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @author André Dietisheim
+ */
+public class PathUtils {
+
+ /**
+ * Returns <code>true</code> if the given path (string) is contained in the
+ * given array of paths
+ *
+ * @param pathString
+ * the path (string) to check
+ * @param pathArray
+ * the array of paths to check
+ * @return true if the path was found in the array
+ */
+ public static boolean containsPath(String pathString, IPath[] pathArray) {
+ if (pathArray == null
+ || pathString == null) {
+ return false;
+ }
+ for (IPath path : pathArray) {
+ if (pathString.equals(path.toString())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Property changes on: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/PathUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
14 years, 8 months
JBoss Tools SVN: r33068 - trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-07-20 04:34:08 -0400 (Wed, 20 Jul 2011)
New Revision: 33068
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockJSTPublisherTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java
Log:
Broken AS build test suite. Regression from ensuring that for as7 the folder is removed in addition to the .deployed file.
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java 2011-07-20 04:43:15 UTC (rev 33067)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java 2011-07-20 08:34:08 UTC (rev 33068)
@@ -11,6 +11,8 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -84,7 +86,9 @@
* <li>newModule.war.failed</li>
* </ul>
*/
- testMockPublishMethod(8,"newModule.war" + DeploymentMarkerUtils.FAILED_DEPLOY,"newModule.war" + DeploymentMarkerUtils.DEPLOYED);
+ testMockPublishMethod(8, "newModule.war",
+ "newModule.war" + DeploymentMarkerUtils.FAILED_DEPLOY,
+ "newModule.war" + DeploymentMarkerUtils.DEPLOYED);
}
private void testMockPublishMethod(int initial, String... filesToRemove) throws CoreException, IOException {
@@ -93,16 +97,19 @@
IModule mod = ServerUtil.getModule(project);
server = ServerRuntimeUtils.addModule(server,mod);
ServerRuntimeUtils.publish(server);
- assertEquals(initial, MockPublishMethod.getChanged().length);
+ IPath[] changed = MockPublishMethod.getChanged();
+ assertEquals(initial, changed.length);
MockPublishMethod.reset();
// remove
server = ServerRuntimeUtils.removeModule(server, mod);
ServerRuntimeUtils.publish(server);
- assertEquals(filesToRemove.length, MockPublishMethod.getRemoved().length);
+ IPath[] rem = MockPublishMethod.getRemoved();
+ assertEquals(filesToRemove.length, rem.length);
IPath[] removedFiles = MockPublishMethod.getRemoved();
+ List<IPath> removedAsList = Arrays.asList(removedFiles);
for(int i = 0; i < removedFiles.length; i++) {
- assertEquals(MockPublishMethod.MOCK_ROOT + "/" + filesToRemove[i], removedFiles[i].toString());
+ assertTrue(removedAsList.contains(new Path(MockPublishMethod.MOCK_ROOT + "/" + filesToRemove[i])));
}
MockPublishMethod.reset();
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockJSTPublisherTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockJSTPublisherTest.java 2011-07-20 04:43:15 UTC (rev 33067)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockJSTPublisherTest.java 2011-07-20 08:34:08 UTC (rev 33068)
@@ -98,7 +98,7 @@
assertRemoved(
isAs7,
new String[] { "newModule.ear" },
- new String[] { "newModule.ear.deployed", "newModule.ear.failed" });
+ new String[] { "newModule.ear", "newModule.ear.deployed", "newModule.ear.failed" });
}
protected void assertRemoved(boolean isAs7, String[] nonAs7, String[] as7) {
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java 2011-07-20 04:43:15 UTC (rev 33067)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java 2011-07-20 08:34:08 UTC (rev 33068)
@@ -203,7 +203,7 @@
ServerRuntimeUtils.publish(server);
JobUtils.waitForIdle();
assertEquals(changed2.size(), 0);
- assertEquals(removed2.size(), 2); // [test.xml.failed, test.xml.deployed]
+ assertEquals(removed2.size(), 3); // [test.xml, test.xml.failed, test.xml.deployed]
MockPublishMethod.reset();
}
@@ -249,7 +249,7 @@
ServerRuntimeUtils.publish(server);
JobUtils.waitForIdle();
assertEquals(changed2.size(), 0);
- assertEquals(removed2.size(), 2); // [test.failed, test.deployed]
+ assertEquals(removed2.size(), 3); // [test.xml, test.failed, test.deployed]
MockPublishMethod.reset();
}
14 years, 8 months
JBoss Tools SVN: r33067 - trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-07-20 00:43:15 -0400 (Wed, 20 Jul 2011)
New Revision: 33067
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
Log:
JBIDE-9291 - quick fix to add the suggested jars
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2011-07-20 04:39:23 UTC (rev 33066)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2011-07-20 04:43:15 UTC (rev 33067)
@@ -207,6 +207,8 @@
addPaths(location.append(AS7_MODULES).append("org/hibernate/validator"),list, true);
addPaths(location.append(AS7_MODULES).append("org/resteasy"),list, true);
addPaths(location.append(AS7_MODULES).append("org/picketbox"),list, true);
+ addPaths(location.append(AS7_MODULES).append("org/jboss/as/controller-client/main/"),list, true);
+ addPaths(location.append(AS7_MODULES).append("org/jboss/dmr/main/"),list, true);
return list;
}
14 years, 8 months
JBoss Tools SVN: r33066 - trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-07-20 00:39:23 -0400 (Wed, 20 Jul 2011)
New Revision: 33066
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
Log:
JBIDE-9291 - quick fix to add the suggested jars
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2011-07-20 00:08:40 UTC (rev 33065)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2011-07-20 04:39:23 UTC (rev 33066)
@@ -204,6 +204,10 @@
Set<Entry> list = new HashSet<Entry>();
SimpleFileFilter filter = new SimpleFileFilter(new String[]{"jsf-api-1.2_13.jar", "jsf-impl-1.2_13.jar"}); // Problematic jar //$NON-NLS-1$
addPaths(location.append(AS7_MODULES).append(JAVAX), list, true, filter);
+ addPaths(location.append(AS7_MODULES).append("org/hibernate/validator"),list, true);
+ addPaths(location.append(AS7_MODULES).append("org/resteasy"),list, true);
+ addPaths(location.append(AS7_MODULES).append("org/picketbox"),list, true);
+
return list;
}
14 years, 8 months
JBoss Tools SVN: r33065 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-07-19 20:08:40 -0400 (Tue, 19 Jul 2011)
New Revision: 33065
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
Log:
https://issues.jboss.org/browse/JBIDE-7632, https://issues.jboss.org/browse/JBIDE-7633, https://issues.jboss.org/browse/JBIDE-7630
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-07-19 23:56:16 UTC (rev 33064)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-07-20 00:08:40 UTC (rev 33065)
@@ -61,6 +61,7 @@
public static final String IMPLEMENTS = "implements"; //$NON-NLS-1$
public static final String EXTENDS = "extends"; //$NON-NLS-1$
public static final String OPEN_BRACE = "{"; //$NON-NLS-1$
+ public static final String CLOSE_BRACE = "}"; //$NON-NLS-1$
static final HashSet<String> primitives = new HashSet<String>();
static{
@@ -355,10 +356,6 @@
String paramName = injectionParameter.getName();
IMethod method = injectionParameter.getBeanMethod().getMethod();
- ICompilationUnit compilationUnit = method.getCompilationUnit();
-
- IBuffer buffer = compilationUnit.getBuffer();
-
for(ILocalVariable parameter : method.getParameters()){
if(parameter.getElementName().equals(paramName)){
return new SourceRange(parameter.getSourceRange().getOffset(), parameter.getSourceRange().getLength());
14 years, 8 months
JBoss Tools SVN: r33064 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-07-19 19:56:16 -0400 (Tue, 19 Jul 2011)
New Revision: 33064
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeTargetAnnotationMarkerResolution.java
Log:
https://issues.jboss.org/browse/JBIDE-7632, https://issues.jboss.org/browse/JBIDE-7633, https://issues.jboss.org/browse/JBIDE-7630
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java 2011-07-19 23:54:59 UTC (rev 33063)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java 2011-07-19 23:56:16 UTC (rev 33064)
@@ -34,7 +34,7 @@
this.qualifiedNames = typeNames;
this.type = type;
shortNames = MarkerResolutionUtils.getShortNames(qualifiedNames);
- totalList = "{"+MarkerResolutionUtils.getTotalList(shortNames)+"}";
+ totalList = MarkerResolutionUtils.OPEN_BRACE+MarkerResolutionUtils.getTotalList(shortNames)+MarkerResolutionUtils.CLOSE_BRACE;
label = NLS.bind(CDIUIMessages.ADD_TARGET_MARKER_RESOLUTION_TITLE, totalList, type.getElementName());
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeTargetAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeTargetAnnotationMarkerResolution.java 2011-07-19 23:54:59 UTC (rev 33063)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeTargetAnnotationMarkerResolution.java 2011-07-19 23:56:16 UTC (rev 33064)
@@ -40,7 +40,7 @@
this.annotation = annotation;
this.qualifiedNames = typeNames;
shortNames = MarkerResolutionUtils.getShortNames(qualifiedNames);
- totalList = "{"+MarkerResolutionUtils.getTotalList(shortNames)+"}";
+ totalList = MarkerResolutionUtils.OPEN_BRACE+MarkerResolutionUtils.getTotalList(shortNames)+MarkerResolutionUtils.CLOSE_BRACE;
try {
label = NLS.bind(CDIUIMessages.CHANGE_TARGET_MARKER_RESOLUTION_TITLE, annotation.getSource(), totalList);
14 years, 8 months
JBoss Tools SVN: r33063 - in trunk/common/tests/org.jboss.tools.common.el.core.test: projects/JavaProject and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-07-19 19:54:59 -0400 (Tue, 19 Jul 2011)
New Revision: 33063
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.classpath
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.project
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/bin/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/src/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/src/test/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/src/test/TestList.java
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.classpath
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.project
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/bin/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/CollectionBean.java
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/Test.java
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java
Removed:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject/.settings/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject/bin/test/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
Log:
https://issues.jboss.org/browse/JBIDE-9373
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.classpath
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.classpath (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.classpath 2011-07-19 23:54:59 UTC (rev 33063)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.project
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.project (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.project 2011-07-19 23:54:59 UTC (rev 33063)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>JavaProject1</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/src/test/TestList.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/src/test/TestList.java (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/src/test/TestList.java 2011-07-19 23:54:59 UTC (rev 33063)
@@ -0,0 +1,8 @@
+package test;
+
+import java.util.ArrayList;
+
+public class TestList<E> extends ArrayList<E> {
+
+ private static final long serialVersionUID = -7718691817083841334L;
+}
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject1/src/test/TestList.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.classpath
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.classpath (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.classpath 2011-07-19 23:54:59 UTC (rev 33063)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/JavaProject1"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.project
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.project (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.project 2011-07-19 23:54:59 UTC (rev 33063)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>JavaProject2</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/CollectionBean.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/CollectionBean.java (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/CollectionBean.java 2011-07-19 23:54:59 UTC (rev 33063)
@@ -0,0 +1,6 @@
+package test;
+
+public class CollectionBean {
+
+ public TestList<Test> tests;
+}
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/CollectionBean.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/Test.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/Test.java (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/Test.java 2011-07-19 23:54:59 UTC (rev 33063)
@@ -0,0 +1,8 @@
+package test;
+
+public class Test {
+
+ public String foo() {
+ return "";
+ }
+}
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/Test.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2011-07-19 23:41:22 UTC (rev 33062)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2011-07-19 23:54:59 UTC (rev 33063)
@@ -10,13 +10,12 @@
******************************************************************************/
package org.jboss.tools.common.el.core.test;
-import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.jboss.tools.common.el.core.test.resolver.ELResolverFactoryManagerTest;
import org.jboss.tools.common.el.core.test.resolver.ElVarSearcherTest;
-import org.jboss.tools.test.util.ProjectImportTestSetup;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.jboss.tools.common.el.core.test.resolver.TypeInfoCollectorTest;
/**
* @author V.Kabanovich
*
@@ -32,6 +31,7 @@
suite.addTestSuite(RelevanceCheckTest.class);
suite.addTestSuite(ElVarSearcherTest.class);
suite.addTestSuite(ELResolverFactoryManagerTest.class);
+ suite.addTestSuite(TypeInfoCollectorTest.class);
return suite;
}
-}
+}
\ No newline at end of file
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java 2011-07-19 23:54:59 UTC (rev 33063)
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.test.resolver;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.MemberInfo;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class TypeInfoCollectorTest extends TestCase {
+
+ protected static String PLUGIN_ID = "org.jboss.tools.common.el.core.test";
+
+ IProject project1 = null;
+ IProject project2 = null;
+
+ @Override
+ protected void setUp() throws Exception {
+ project1 = ResourcesUtils.importProject(PLUGIN_ID, "/projects/JavaProject1");
+ project1.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ JobUtils.waitForIdle();
+
+ project2 = ResourcesUtils.importProject(PLUGIN_ID, "/projects/JavaProject2");
+ project2.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ JobUtils.waitForIdle();
+ }
+
+ /**
+ * See https://issues.jboss.org/browse/JBIDE-9373
+ * @throws CoreException
+ */
+ public void testTypeResolution() throws CoreException {
+ IJavaProject jp = JavaCore.create(project2);
+ IType bean = jp.findType("test.CollectionBean");
+ TypeInfoCollector.TypeInfo typeInfo = new TypeInfoCollector.TypeInfo(bean, null, false);
+
+ IField field = bean.getField("tests");
+ TypeInfoCollector.FieldInfo fieldInfo = new TypeInfoCollector.FieldInfo(field, null, typeInfo, false);
+
+ TypeInfoCollector collector = fieldInfo.getTypeCollector(false, false);
+ MemberInfo info = getMethod(collector, "iterator");
+ assertNotNull(info);
+ info = getMethod(info.getTypeCollector(false, false), "next");
+ assertNotNull(info);
+ info = getMethod(info.getTypeCollector(false, false), "foo");
+ assertNotNull(info);
+ assertNotNull(info.getMemberType());
+ }
+
+ private MemberInfo getMethod(TypeInfoCollector collector, String name) {
+ collector.collectInfo();
+ List<MemberInfo> mts = collector.getMethods();
+ for (MemberInfo info : mts) {
+ if(name.equals(info.getName())) {
+ return info;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
+ JobUtils.waitForIdle();
+ project1.delete(true, true, null);
+ project2.delete(true, true, null);
+ JobUtils.waitForIdle();
+ ResourcesUtils.setBuildAutomatically(saveAutoBuild);
+ }
+}
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
14 years, 8 months